Thursday, 18 June 2015

WebSphere Application Server - Jython, continuing to learn learn learn


I had a particular requirement today. I needed to update a bunch of JDBC data sources, and change the Connection Pool properties, specifically the Aged Timeout value.

This was at the behest of our DBA, as we were looking at the way that connections are created/persisted between WAS and DB2.

Therefore, he ( let's call him John ) wanted to test to see whether changing the Aged Timeout value from the default of 0 to 1200 seconds.

On the journey, I acquired a few more scars ^H^H^H^H^H skills, as per the following examples: -

Getting Cluster Status

clusterName='AppCluster'
clusterID=AdminConfig.getid('/ServerCluster:'+clusterName+'/')
clusterObj=AdminControl.completeObjectName('type=Cluster,name='+clusterName+',*')
clusterStatus=AdminControl.getAttribute(clusterObj,'state')
print clusterStatus


Getting JNDI Names, Max Connections, Purge Policy and Aged Timeout

The trick is to get a "handle" on the Connection Pool, and then retrieve the Attributes from there. This works for ALL data sources.

for dataSource in AdminConfig.list('DataSource').splitlines():
 jndi=AdminConfig.showAttribute(dataSource,'jndiName')
 connPool=AdminConfig.showAttribute(dataSource,'connectionPool')
 maxConn=AdminConfig.showAttribute(connPool,'maxConnections')
 purgePolicy=AdminConfig.showAttribute(connPool,'purgePolicy')
 agedTimeout=AdminConfig.showAttribute(connPool,'agedTimeout')


( Note the indent during the loop )

Reviewing and Changing Aged Timeout

for dataSource in AdminConfig.list('DataSource').splitlines():
 jndi=AdminConfig.showAttribute(dataSource,'jndiName')
 connPool=AdminConfig.showAttribute(dataSource,'connectionPool')
 print "Old"
 print AdminConfig.showAttribute(connPool,'agedTimeout')
 AdminConfig.modify(connPool, '[[agedTimeout "1200"]]')
 print "New"
 print AdminConfig.showAttribute(connPool,'agedTimeout')
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()


( Note the indent during the loop )

which reports

...
Old
0
''
New
1200
Old
0
''
New
1200

...

Ironically, I then used almost the same script to revert out the change, setting the agedTimeout attribute from 1200 back to 0.

No comments:

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...