Friday, 19 February 2016

Create / replace datasource with WLST online mode

The following tutorial has been checked to work Webogic 12c version 12.1.3 and 12.2,1.

There are 3 steps involved:

1. Define a jython script to create a datasource
2. Define instance specific parameters
3. Execute the script


1. Create your jython script createDS.py:

####################################
def connectAdmin() :
 try:
  connect(adminServerUser,adminServerPassword, adminServer)
  print('Successfully connected')
 except:
   print 'Unable to find admin server...'
   exit()

def deleteDS() :
 try:
  cd('/SystemResources/' + dsName)
  set('Targets',jarray.array([], ObjectName))
 except:
  print 'Datasource not created yet'
 
 try:
  cd('/JDBCSystemResources')
  datasources = cmo.getJDBCSystemResources()
  for datasource in datasources :
   currentDSName = datasource.getName()
   if dsName == currentDSName :
    try:
     datasource.forceShutDown()
    except:
     print 'Could not shutdown datasource'
    try:
     cmo.destroyJDBCSystemResource(datasource)
    except:
     print 'Could not destroy data source'
 except:
  print 'could not delete datasource'

def retrieveTargets() :
 targetsNames = targets.split(" ")
 targetsArray = jarray.zeros(len(targetsNames),ObjectName)
 index = 0
 for targetName in targetsNames :
  targetsArray[index] = ObjectName('com.bea:Name='+targetName+',Type=Server')
  index = index + 1
 return targetsArray
 
if __name__== "main":

 print('This will enable you to create or update a Datasource')
 connectAdmin()

 print('Starting a edit session')
 edit()
 startEdit()
 deleteDS()

 print 'Creating data source'
# Create a new Mbean ( a JDBC resource)
 cd('/')
 cmo.createJDBCSystemResource(dsName)

 #Naming the datasource under JDBCSystemResources
 cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
 cmo.setName(dsName)

 print 'Assigning JNDI name'

#Setting JNDI name
 cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDataSourceParams/'+dsName)
 set('JNDINames',jarray.array([String(jndiName)], String))

 cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName )
 cmo.setUrl(driverUrl)
 cmo.setDriverName( driverName )
 cmo.setPassword(driverPassword)


 cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName+'/Properties/'+dsName)
 cmo.createProperty('user')
 cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName+'/Properties/'+dsName+'/Properties/user')
 cmo.setValue(driverUser)

 print 'Assigning target'

 cd('/SystemResources/' + dsName)

 targetsArray = retrieveTargets()
 set('Targets',targetsArray)

 #Writing the chages to the server
 save()
 activate()

 disconnect()

####################################


2. Create a properties file for your instance, instance.properties:

adminServer = t3://localhost:7001
adminServerUser = weblogic
adminServerPassword = password
items = 1
dsName =  MyDS
jndiName = jdbc/MyDS
targets = AdminServer
driverName = oracle.jdbc.xa.client.OracleXADataSource
driverUrl = jdbc:oracle:thin:@pippo.pallino.int:1597:SERVICE
driverUser = MyUser

driverPassword = myPass


3. Run the following command:

WL_HOME\server\bin\setWLSEnv.cmd
java weblogic.WLST -loadProperties instance.properties createDS.py

Wednesday, 17 February 2016

Move data between two Google App Engine applications

Use Google Cloud Storage as an intermediary mean to copy data  to both GAE instances

Create a bucket in your cloud.

Open the datastore_admin of GAE

Select an entity to backup  and push the button "Backup entities" (figure 1)

Figure 1


On the following screen, the data store admin will ask you for the bucket name (figure 2).

Confirm by pressing on "Backup entities"


Figure 2

You can follow the status of the back. Once completed check that the tree structure of the backup
shows up in your bucket.

Very important : make sure to share publicly all files within the backup, otherwise the other application will not be able to connect and import the data. You have to go individually on every resource and check it

On data store client go the backups section where your recent backup shows up, check it,
and push on the info button. A screen showing information on your backup will show up (figure 3).



Figure 3

Make sure you retrieve the handle to this backup (figure 4).


Figure 4

The handle looks something like:

/gs/buck_name/agxzfnNpeHFvcy1ocmRyQQsSHF9BRV9EYXRhc3RvcmVBZG1pbl9PcGVyYXRpb24YgtX1FQwLEhZfQUVfQmFja3VwX0luZm9ybWF0aW9uGAEM.backup_info

Logon now to the other GAE instance datastore admin where you intend to import your data.

In the backups sectoin, in the input next to "import "back-up information"  button, enter the handle retrieved previously and click on the button (figure 5).




Figure 5


The transfer of the data should take place.

About Me

My Photo