WLST Tip!

Recently, I had a question about using offline WLST to create a Capacity Constraint in a WebLogic Server configuration. The tricky part is that Constraint MBeans (and resulting configuration) are children of the SelfTuning MBean at the domain level, but the SelfTuning MBean is not listed in the configuration file by default. This behavior is the result of an optimization in WebLogic Server where the configuration file only explicitly lists objects and attributes that are defined. It does not list objects or attributes that completely governed by defaults. Take a look at the documentation at http://docs.oracle.com/cd/E23943_01/web.1111/e13715/using_wlst.htm#i1091409, which says:

"As a performance optimization, WebLogic Server does not store most of its default values in the WebLogic domain's configuration files. In some cases, this optimization prevents management objects from being displayed by WLST offline (because WebLogic Server has never written the corresponding XML elements to the domain's configuration files). For example, if you never modify the default logging severity level for a WebLogic domain while the domain is active, WLST offline will not display the domain's Log management object.

If you want to change the default value of attributes whose management object is not displayed by WLST offline, you must first use the create command to create the management object. Then you can cd to the management object and change the attribute value."

To create a Constraint object, you must first create the SelfTuning object. Here's an example that creates a new domain and then adds a Capacity Constraint to it:

C:\Oracle10.3.6\Middleware\user_projects>java weblogic.WLST

wls:/offline> createDomain('C:/Oracle10.3.6/Middleware/wlserver_10.3/common/templates/
domains/wls.jar','C:/Oracle10.3.6/Middleware/user_projects/wkmgr_domain3',
'weblogic','welcome1')

wls:/offline> readDomain('wkmgr_domain3')

wls:/offline/wkmgr_domain3>create('st','SelfTuning')

Proxy for st: Name=st, Type=SelfTuning

wls:/offline/wkmgr_domain3>cd('SelfTuning/st')

wls:/offline/wkmgr_domain3/SelfTuning/st>create('myCapacityConstraint',
'Capacity')

Proxy for myCapacityConstraint: Name=myCapacityConstraint, Type=SelfTuning!
Capacity

wls:/offline/wkmgr_domain3/SelfTuning/st>updateDomain()

wls:/offline/wkmgr_domain3/SelfTuning/st>cd('Capacity')

wls:/offline/wkmgr_domain3/SelfTuning/st/Capacity>ls()

drw-   myCapacityConstraint

wls:/offline/wkmgr_domain3/SelfTuning/st/Capacity>cd('myCapacityConstraint')

wls:/offline/wkmgr_domain3/SelfTuning/st/Capacity/myCapacityConstraint>ls()

-rw-   DeploymentOrder                               1000

-rw-   Name                                          myCapacityConstraint

-rw-   Notes                                         null

-rw-   Target                                        null

wls:/offline/wkmgr_domain3/SelfTuning/st/Capacity/myCapacityConstraint>
set('Count',50)

wls:/offline/wkmgr_domain3/SelfTuning/st/Capacity/myCapacityConstraint>
updateDomain()

That's it!

Happy scripting!


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The official blog for Oracle WebLogic Server fans and followers!

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today