jython script to modify min and max connection pool in given datasource at cluster level

WAS
WAS used Ask the Experts™
on
Please provide a jython script to modify min and max connection pool in given datasource at cluster level

cell name : ABC
Cluster:  EFG

Datasource            Current Max            New Max
Eclipse                                32                  42
Tata                                 32                  42
papa                           32                  42
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
HonorGodSoftware Engineer

Commented:
Something like this perhaps?

Invoke without parameters to display the usage information:

Command: poolMod

Purpose: WebSphere (wsadmin) script used to modify the min/max connection
         pool setting for a specified datasource.

  Usage: poolMod [options]

Required switches:
  -L | --cluster    <name> = Name of specific cluster
  -d | --dataSource <name> = Name of DataSource to be viewed / modified

Optional switches:
  -m | --minConn    #      = Minimum # of connections
  -x | --maxConn    #      = Maximum # of connections

Notes:
- Long form option values may be separated/delimited from their associated
  value using either a space, or an equal sign ('=').

- Short form option values may be sepearated from their associated value using
  an optional space.

- Description text containing blanks should be enclosed in double quotes.

Examples:
  wsadmin -lang jython -f poolMod.py --cluster=C1 --dataSource myDS

  wsadmin -lang jython -f poolMod.py -LC1 -d myDS

Open in new window


If you only specify a cluster and datasource names, the current connection pool settings are displayed
poolMod.py
WASIT Analyst

Author

Commented:
HonorGod,

can you hardcode the clustername and cell name into the script, i don't want to pass the values, also this script looks way too complicated and too big, is it possible for you to write small and easy to understand and maintain like if i want to change anything in the future .

Below is an example for creating workmanager in a cluster, where the  clustername and cellname are hardcoded in the script and very small and easy to understand and easy to modify. I used this as a template to create timermanger in WAS6.1 :)

print 'begin script'

cell_name = "was_cell"
cluster_name = "kaka"

cell = '/Cell:' + cell_name
#node = cell + '/Node:' + node_name
ServerCluster = cell + '/ServerCluster:' + cluster_name

import java
# WorkManager info begin

def add_wm():
  wm_provider=AdminConfig.getid(ServerCluster + '/WorkManagerProvider:WorkManagerProvider')
  AdminConfig.create('WorkManagerInfo', wm_provider, [['name', 'kakaWorkManager'], ['jndiName', 'wm/kakaWorkManager'], ['numAlarmThreads', '5'], ['minThreads', '1'], ['maxThreads', '20'], ['threadPriority', '5'], ['isGrowable', 'off']])
  AdminConfig.save()

add_wm();

print 'Done setting up WM'

print 'Saving changes..'

AdminConfig.save()

print 'SUCCESS'
Software Engineer
Commented:
Q: can you hardcode the clustername and cell name into the script?
A: Sure

- this script looks way too complicated and too big
  Sorry, I was trying to provide a more useful script.

How's this for "quick and dirty"? ;-)

clusterName = 'myCluster'
dsName      = 'myDS'
newMin      = '2'
newMax      = '200'

#-------------------------------------------------------------------------------
# Use list comprehension to build the list of all configured clusters
#-------------------------------------------------------------------------------
clusters    = [ x for x in AdminConfig.list( 'ServerCluster' ).splitlines() ]

#-------------------------------------------------------------------------------
# Build the list of cluster names
#-------------------------------------------------------------------------------
names   = [ AdminConfig.showAttribute( x, 'name' ) for x in clusters ]

#-------------------------------------------------------------------------------
# Does the specified cluster exist?
#-------------------------------------------------------------------------------
if clusterName in names :
    clustId  = clusters[ names.index( clusterName ) ]
    dSources = [ x for x in AdminConfig.list( 'DataSource', clustId ).splitlines() ]
    names    = [ AdminConfig.showAttribute( x, 'name' ) for x in dSources ]
    if dsName in names :
        dsId = dSources[ names.index( dsName ) ]
        cp   = AdminConfig.showAttribute( dsId, 'connectionPool' )
        oldMin = AdminConfig.showAttribute( cp, 'minConnections' )
        oldMax = AdminConfig.showAttribute( cp, 'maxConnections' )
        AdminConfig.modify( cp, [ [ 'minConnections', newMin ], [ 'maxConnections', newMax ] ] )
        print 'Changes: DataSource = "%s" prev min = %s max = %s  new min = %s max %s' % ( dsName, oldMin, oldMax, newMin, newMax )
        print 'Saving configuration changes'
        AdminConfig.save()
    else :
        print 'Specified DataSource not found:', dsName
else :
    print 'Specified cluster not found:', clusterName

Open in new window

WASIT Analyst

Author

Commented:
Thank you honorgod
HonorGodSoftware Engineer

Commented:
You are very welcome.

Thanks for the grade & points.

Good luck & have a great day.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial