Search This Blog

Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Saturday, June 15, 2013

SOA & ADF Bounce script


We were working on SOA doamin for automation with WLST. After woring on the retiring and activation  of  the composites of SOA_Infra we are ready for shutdown the managed servers. Now the task is simple we have break-down the task into two simple functions.

  1. stop the cluster
  2. start the cluster
  3. Main program
Here the main program uses the logic of fetching the cluster list from the admin server. The functions are made in such a way that each cluster control operation can be tracked with state command, that will tell about all the managed servers in the cluster state. Once we did a trial found that there could be some time required for shutdown the managed servers. Double checked the state with Console as well. Re-run the same script with the menu option to start the Cluster.

Here NodeManager is independently running on each machines where the cluster spread across the  managed servers are running. So, this script only controls the clustered managed servers.

You can extend the same script to turn down the Admin server as well. after cluster down you can have that action. The command is shutdown('AdminServer', 'Server')



If you want more stories on the automation go thru the recommended book!
  
#====================================
# 
# Description: This script objective is to provide the choices to perform operation
#    1 is for stop the cluster
#    2 is for start the cluster
#    other is for exit from this script
#  this uses two functions startClstr and stopClstr which takes parameter as 'cluster name'.
#
#====================================
# Stop all instances of a Cluster 
#====================================
def stopClstr(clstrName):
 try:
  shutdown(clstrName,"Cluster")
  java.lang.Thread.sleep(25000)
  state(clstrName,"Cluster")
 except Exception, e:
  print 'Error while shutting down cluster ',e
 
#====================================
# Startp all instances of a Cluster 
#====================================
def startClstr(clstrName):
 try:
  start(clstrName,"Cluster")
  state(clstrName,"Cluster")
 except Exception, e:
  print 'Error while shutting down cluster ',e
 

if __name__== "main":
 connect('weblogic','welcome1','t3://localhost:7001')
 print "1.To Stop Instances"
 print "2.To Start Instances"
 print "3.Exit from Menu"
 ch=input('Enter Your Choice: ')
 cd("Clusters")
 clstrList=ls(returnMap='true')
 if ch== 1 :
  for clstr in clstrList:
   stopClstr(clstr)
 elif ch == 2 :
  for clstr in clstrList:
   startClstr(clstr)
 else:
  exit()

SOA Retire Activate Composites


Why we need retire and activate composites?

Before you go for bouncing the SOA Suite Domain which contains SOA, ADF Clusters with multiple managed servers, where each Weblogic server hosted all the sessions which are in execution state on them must be persisted to a restore further when Servers back to RUNNING state. To make this possible we need to use the retire composites and then after RUNNING servers bring them back to activate state for service.

Here is a sample trail script where the SOA application composites management. Here you need to navigate to the wlst.sh or cmd path. To access SCA function you must start WLST from /common/bin. When trying to run the SOA WLST command from regular 'java weblogic.WLST' cannot execute the SCA functions. When you try to execute the sca_retireComposite() it could throw the 'NameError'. So the cause is started WLST from the wrong location, to avoid that our PATH is to change and run the script from the following path: $SOA_ORACLE_HOME/common/bin/wlst.sh will work on Unix/Linux environments. Similarly you choose for Windows environment instead of using executing the shell script you need to use 'call' in the batch script.

Here the major task we have proceeding with the following two functions.

  1. Retire is to retire the composites .
  2. Activate is to activate the composites.
loadProperties('/user/test/scripts/composites.properties')
def retireComposites(Soahost,port, username,password,scacompositename, ver):
        sca_retireComposite(Soahost, port, username, password, scacompositename, revision=ver, partition='default') 
def activateComposites(Soahost,port, username,password,scacompositename, ver):
        sca_activateComposite(Soahost, port, username, password, scacompositename, revision=ver, partition='default')
if __name__== "main":
        print "1.To retire composites"
        print "2.To activate composites"
        print "3.Exit from Menu"
        ch=input('Enter Your Choice: ')
        f=open('/user/test/scripts/composites.txt','r')
        if ch== 1 :
                for c in f:
                        c=c.rstrip('\n')
                        retireComposites(Soahost,port, username,password,c, ver)
        elif ch == 2 :
                for c in f:
                        c=c.rstrip('\n')
                        activateComposites(Soahost,port, username,password,c, ver)
        else:
                exit()
        f.close()

Here is the composite.txt sample, where you can specify your composites configured in the SOA partition. Which are usually visible on enterprise manager(em) console. Oracle must given a easy module for displaying the deployed SCA composites list. Anyway we have stored in a separate file as shown below. You have flexibility of changing the order when you use this composite.txt file.

B2B_BPEL_TEST_Sub_reccive
B2B_BPEL_TIBCO_PUB_invoke

The actual trouble started when we tried to use a separate composite.txt file. each line can be read and the value always having at the end an EOL ( \n ). To supress that escape sequance we have used python scring function rtrip function.

The regular properties file which is loaded on the fist line can be created as follows:


Soahost=localhost
port=8001
username=weblogic
password=welcome1
ver=1.0



Please share this with your friends and collegues, comment if you already tried or successfully implemented on your SOA environment.

Video References:

Iris Li demonstrates how to deploy a SOA composite application using the Oracle Enterprise Manager 11g

SOA Composites references :

Popular Posts