Wednesday, April 23, 2014

Creating the Gridlink data source through WLST script

Creating the Gridlink data source through WLST script

The below WLST script will help as to create a GridLink datasource in weblogic server.

GridLinkDataSource.properties

dbURL=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=SERVICENAME)))
connectionpool.test.query=SQL SELECT * FROM DUAL
connectionpool.driver.class=oracle.jdbc.OracleDriver
connectionpool.username=SOA_EAIOWNER
connectionpool.password=orasoa11g
connectionpool.initCapacity=10
connectionpool.maxCapacity=60
datasource.name=EAISOAMetadataSource
datasource.jndi.name=eai/ds/EAISOAMetadataSource
datasource.target=Servers/AdminServer

domain.AdminIP=localhost
domain.AdminPort=7201

domain.AdminPasswd=Albin123!

GridLinkDatasourceCreation.py

from java.io import FileInputStream

def createGridLinkJDBCResources(configProps):
   edit()
   startEdit()
       
   server='AdminServer'
   cd("Servers/"+server)
   target=cmo
   cd("../..")
   print '========================================='
   print 'Creating GridLink DataSource....'
   print '========================================='
   dsTestQuery=configProps.get("connectionpool.test.query")
   dsDriverName=configProps.get("connectionpool.driver.class")
 
           
   cd('/')
   dbURL= configProps.get("dbURL")         
   dsUserName = configProps.get("connectionpool.username")
   dsPassword = configProps.get("connectionpool.password")
   initCapacity = configProps.get("connectionpool.initCapacity")
   maxCapacity = configProps.get("connectionpool.maxCapacity")
   dsName = configProps.get("datasource.name")
   jndiname = configProps.get("datasource.jndi.name")
   datasourceTargets = configProps.get("datasource.target").split(",")

   print 'dsUserName',dsUserName
   print 'dsPassword',dsPassword
   print 'initCapacity',initCapacity
   print 'maxCapacity',maxCapacity
   print 'dsName',dsName
   print 'jndiname',jndiname
   print 'datasourceTargets',datasourceTargets

   print 'Creating DataSource: ',dsName,' ....'
 
   myResourceName = dsName 
   jdbcSystemResource = create(myResourceName,"JDBCSystemResource")   
   myFile = jdbcSystemResource.getDescriptorFileName()   
   jdbcResource = jdbcSystemResource.getJDBCResource()   
   jdbcResource.setName(myResourceName) 
 
 

   # Create the DataSource Params   
   dpBean = jdbcResource.getJDBCDataSourceParams()   
   myName=jndiname
   dpBean.setJNDINames([myName])
   dpBean.setGlobalTransactionsProtocol('TwoPhaseCommit')
   
   # Create the Driver Params   
   drBean = jdbcResource.getJDBCDriverParams()   
   drBean.setPassword(dsPassword)   
   drBean.setUrl(dbURL)   
   drBean.setDriverName(dsDriverName)

   #Create the Oracle params
   orapr=jdbcResource.getJDBCOracleParams()
   orapr.setFanEnabled(true)
   orapr.setOnsNodeList('node1:6200,node2:6200')
   propBean = drBean.getProperties()
   driverProps = Properties()   
   driverProps.setProperty("user",dsUserName)
   e = driverProps.propertyNames()
   while e.hasMoreElements() :           
propName = e.nextElement()           
myBean = propBean.createProperty(propName)         
myBean.setValue(driverProps.getProperty(propName)) 
 
# Create the ConnectionPool Params   
ppBean = jdbcResource.getJDBCConnectionPoolParams()   
ppBean.setInitialCapacity(int(initCapacity))   
ppBean.setMaxCapacity(int(maxCapacity))   
ppBean.setTestConnectionsOnReserve(true)   
ppBean.setTestTableName('SQL SELECT 1 FROM DUAL')

xaParams = jdbcResource.getJDBCXAParams()   
xaParams.setKeepXaConnTillTxComplete(1) 

   # Add Target
   for datasourceTarget in datasourceTargets:
print 'DataSourceTargets',datasourceTargets
print 'DataSourceTarget',datasourceTarget
if datasourceTarget=='':
print ''
else:
jdbcSystemResource.addTarget(getMBean(datasourceTarget))   
 

   print 'DataSource: ',dsName,', has been created Successfully !!!'
   print '=========================================' 
       
 
   save()
   activate() 


 
def main():
    propInputStream1 = FileInputStream("GridLinkDataSource.properties")
    configProps = util.Properties()
    configProps.load(propInputStream1)
 
    adminURL='t3://'+configProps.get('domain.AdminIP')+':'+configProps.get('domain.AdminPort')
    adminUserName='weblogic'
    adminPassword=configProps.get("domain.AdminPasswd")
    connect(adminUserName, adminPassword, adminURL)
 
    createGridLinkJDBCResources(configProps);
 
    print 'Successfully created JDBC resources for SOACoreDomain'

    disconnect()

     
main()



Friday, April 18, 2014

Configuring the DefaultFileStore for TLOGS in weblogic server through WLST script

Configuring the DefaultFileStore for TLOGS in weblogic server through WLST script

Script to set the shared location to the tlogs

The below script will help us to set the shared location to the tlogs for the weblogic servers in a domain.

import sys

print "@@@ Starting the script ..."

from java.util import *
from javax.management import *
from java.io import FileInputStream

print "@@@ Starting the script ..."
global props
 
#The directory of the domain configuration
#/app/oracle/products/11g/admin/domains
wlsDomain=os.environ["WLSDOMAIN"]
print "WLSDOMAIN="+wlsDomain


adminURL='t3://'+domainProps.get('domain1.AdminIP')+':'+domainProps.get('domain1.AdminPort')
adminUserName='weblogic'
adminPassword=domainProps.get("domain1.AdminPasswd")
connect(adminUserName, adminPassword, adminURL)

edit()
startEdit()

adminserverDir = File(wlsDomain+'/SOACoreDomain/soa_cluster/tlogs')
bool = adminserverDir.mkdirs()

cd('/Servers/SOA1/DefaultFileStore/SOA1')
cmo.setDirectory(wlsDomain+'/SOACoreDomain/soa_cluster/tlogs')

cd('/Servers/SOA2/DefaultFileStore/SOA2')
cmo.setDirectory(wlsDomain+'/SOACoreDomain/soa_cluster/tlogs')

cd('/Servers/SOA3/DefaultFileStore/SOA3')
cmo.setDirectory(wlsDomain+'/SOACoreDomain/soa_cluster/tlogs')

save()
activate()

Execute the script:
cd %WLS_HOME%\common\bin
wlst.sh DomainLogConfigurtionChange.py




Thursday, April 17, 2014

Migrating the JMS file store to DB store through WLST script in weblogic server- Oracle SOA Suite

Migrating the JMS file store to DB store through WLST script  in weblogic server- Oracle SOA Suite

The below script will help us to migrate the JMS file store to DB store through WLST script  in weblogic server- Oracle SOA Suite. Before executing this script the required data source here EAIJMSDataSource should be created pointing to the database schema created for JMS.
For clustered environment the same should be executed for all the servers in the cluster with unique JDBC store name(e.g WseeJaxwsJDBCStore1 for server 1 and WseeJaxwsJDBCStore2 for server 2).

Script to migrate JMS file store to DB store

import sys

print "@@@ Starting the script ..."

from java.util import *
from javax.management import *

#The directory of the domain configuration
#/app/oracle/products/11g/admin/domains
wlsDomain=os.environ["WLSDOMAIN"]
print "WLSDOMAIN="+wlsDomain


adminURL='t3://'+domainProps.get('domain1.AdminIP')+':'+domainProps.get('domain1.AdminPort')
adminUserName='weblogic'
adminPassword=domainProps.get("domain1.AdminPasswd")
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
############# JDBC stores for STANDALONE ADMINSERVER
cd('/')

cmo.createJDBCStore('WseeJaxwsJDBCStore')
cd('/JDBCStores/WseeJaxwsJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('WseeJaxws')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCStore('UMSJMSJDBCStore')
cd('/JDBCStores/UMSJMSJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('UMSJMS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCStore('SOAJMSJDBCStore')
cd('/JDBCStores/SOAJMSJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('SOAJMS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCStore('JDBCStore')
cd('/JDBCStores/JDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('rmjdbcstore')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCStore('WseeJDBCStore')
cd('/JDBCStores/WseeJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('Wsee')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCStore('BPMJMSJDBCStore')
cd('/JDBCStores/BPMJMSJDBCStore')
cmo.setDataSource(getMBean('/SystemResources/EAIJMSDataSource'))
cmo.setPrefixName('BPMJMS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

#### end of creating jdbc stores

############Set Persistent Stores for all the JMS Servers

cd('/Deployments/WseeJaxwsJmsServer')
cmo.setPersistentStore(getMBean('/JDBCStores/WseeJaxwsJDBCStore'))


cd('/Deployments/UMSJMSServer')
cmo.setPersistentStore(getMBean('/JDBCStores/UMSJMSJDBCStore'))


cd('/Deployments/BPMJMSServer')
cmo.setPersistentStore(getMBean('/JDBCStores/JDBCStore-0'))


cd('/Deployments/SOAJMSServer')
cmo.setPersistentStore(getMBean('/JDBCStores/SOAJMSJDBCStore'))


cd('/Deployments/wlsbJMSServer')
cmo.setPersistentStore(getMBean('/JDBCStores/JDBCStore'))


cd('/Deployments/WseeJmsServer')
cmo.setPersistentStore(getMBean('/JDBCStores/WseeJDBCStore'))

##### Set the persistent stores for all SAF agents
cd('/SAFAgents/ReliableWseeJaxwsSAFAgent')
cmo.setStore(getMBean('/JDBCStores/WseeJaxwsJDBCStore'))

cd('/SAFAgents/ReliableWseeSAFAgent')
cmo.setStore(getMBean('/JDBCStores/WseeJDBCStore'))

#################DESTROY ALL THE FILE STORES

cd('/')
cmo.destroyFileStore(getMBean('/FileStores/WseeJaxwsFileStore'))
cmo.destroyFileStore(getMBean('/FileStores/UMSJMSFileStore'))
cmo.destroyFileStore(getMBean('/FileStores/SOAJMSFileStore'))
cmo.destroyFileStore(getMBean('/FileStores/BPMJMSFileStore'))
cmo.destroyFileStore(getMBean('/FileStores/WseeFileStore'))
cmo.destroyFileStore(getMBean('/FileStores/FileStore'))

save()
activate()

Execute the script:
cd %WLS_HOME%\common\bin
wlst.sh MigrateJMSFiletoJDBCStore.py

Restart the servers, the required tables({PrefixName}WLStore) will be created if the tables are not created already.



Updating the Graceful Shutdown parameters in weblogic server through WLST script.

Updating the Graceful Shutdown parameters in weblogic server through WLST script.

The script will help us to update the Graceful Shutdown parameter for the servers in the weblogic domain.

UpdateGracefulShutdownParameters.py

def conn():

    try:              
            adminURL='t3://'+domainProps.get('domain1.AdminIP')+':'+domainProps.get('domain1.AdminPort')
            adminUserName='weblogic'
            adminPassword=domainProps.get("domain1.AdminPasswd")
            connect(adminUserName, adminPassword, adminURL)
    except ConnectionException,e:
        print 'Unable to find admin server...'
        exit()

   
def updateGraceFulShutdownTimings():
    edit()
    startEdit()
    print
    print '##############'
    print '# Update Graceful Shutdown to 300 Seconds and ignore session true#'
    print '##############'
    print
    for name in serverNames:
        try:
            print 'Updating Server==>'+ name.getName()
            cd("/Servers/" + name.getName())
            cmo.setGracefulShutdownTimeout(300)
            cmo.setIgnoreSessionsDuringShutdown(true)
        except WLSTException,e:
            # this typically means the server is not active, just ignore
            print 'Exception While Update the attribute'
    print '========================================='
    save()
    activate()  

def quit():
        disconnect()
        exit()

if __name__== "main":
    conn()
    serverNames = cmo.getServers()
    updateGraceFulShutdownTimings()
    quit()

Execute the script:
cd %WLS_HOME%\common\bin
wlst.sh UpdateGracefulShutdownParameters.py





Monday, April 14, 2014

Backing up the MDS Repository Artifacts - Oracle SOA Suite 11g

Backing up the MDS Repository Artifacts - Oracle SOA Suite

In Oracle SOA Suite 11g and Oracle SOA Suite 12c , all the common artifacts , the deployed composites and the common configurations are stored in the MDS database schema. Sometimes there is a possibility of MDS schema getting corrupted (the best example is the composites getting corrupted frequently)those scenario we will not be able to bring up the soa-infra and also we may loose all the deployments.

Backing up the MDS artifacts is the the solution for these kind of issues.

In this post i will be explaining some of the different options to back up the MDS artifacts.

The best approach is do a full back up of MDS repository schema using database backup utilities(dbexp).The backup can be restored if there is any issue with the MDS schema.

EM console - MDS configuration Page :

Right click on soa-infra and click on Administration and MDS Configuration.
Click Export on MDS Configuration page.


This will export the MDS artifacts to local machine as zip file.