0
votes

I want to restart an AppCluster in WebSphere 8.5 using Jython.

  cluster = AdminControl.completeObjectName('name=ICXTCluster,*')
  AdminControl.invoke(cluster, 'restart')

This is not working:

Operation restart not in ModelMBeanInfo

So I tried to manually implement restart by stopping and then starting the cluster:

  cluster = AdminControl.completeObjectName('name=ICXTCluster,*')
  AdminControl.invoke(cluster, 'stop')
  AdminControl.invoke(cluster, 'start')

It throws another error:

com.ibm.websphere.wlm.exception.ClusterException: Start operation failed because another administrative operation: Stop is already in progress.

The stop seems to work, ISC shows me the AppCluster as stopped. But it's not started again. I assume that those invoke operation is asynchron, so AdminControl.invoke(cluster, 'start') got executed before the previous stop was finished.

How can I stop the Cluster synchron? Or is there another way to restart it?

1
you could also start the appcluster with as systemd, the you could easily restart it from console / ansible - umeli
Have you looked at the AdminClusterManagement helper script? - Haxiel

1 Answers

0
votes

Since it seems not possible by build-in Jython commands, I wrote a script that polls the cluster state every 5 seconds and check if its equal to the desired state. So we can use the async functions and make them sync by waiting for the server to be stopped and started:

import time
def set_state_sync(invoke_state, target_state):
    print 'Check state for ' + cluster_name
    cluster = AdminControl.completeObjectName('name=' + cluster_name + ',*')
    state = AdminControl.getAttribute(cluster, 'state')
    print 'Initial state: ' + state
    if state == target_state:
        print 'State is already ' + target_state
        return

    print '[Changed]: Invoke state ' + invoke_state
    AdminControl.invoke(cluster, invoke_state)

    max_wait = 300
    interval = 5
    waited = 0
    while state != target_state:
        time.sleep(interval)
        state = AdminControl.getAttribute(cluster, 'state')
        print 'State poll: ' + state
        waited += interval
        if waited > max_wait:
            print 'Error: Timed out after ' + max_wait + ' seconds!'
            exit()
    return

cluster_name = '{{ cluster_name }}'
set_state_sync('stop', 'websphere.cluster.stopped')
set_state_sync('start', 'websphere.cluster.running')
print 'Finished Restarting'