Commit 0d1c6605 0d1c66055d1cf3604d8fb7b61fb7b435229b2fcb by Christian Gerdes

getDataFromCDB() now successfully creates a CDB object in the Registry

- Calls getData with the PDB age limit on the CDB object
- Verifies that the CDB objects name matches the databasename from the
PDB object
1 parent b18f52d6
...@@ -248,6 +248,7 @@ public class OraMon { ...@@ -248,6 +248,7 @@ public class OraMon {
248 return false; 248 return false;
249 } 249 }
250 // We do have the lock. Do the rest in a try catch everything and if we catch anything, re throw the catch but always release the lock. 250 // We do have the lock. Do the rest in a try catch everything and if we catch anything, re throw the catch but always release the lock.
251 Statement stmt = null;
251 try { 252 try {
252 long startTSns = System.nanoTime(); 253 long startTSns = System.nanoTime();
253 getDataCalls++; 254 getDataCalls++;
...@@ -264,7 +265,7 @@ public class OraMon { ...@@ -264,7 +265,7 @@ public class OraMon {
264 if(stale) { 265 if(stale) {
265 open(); 266 open();
266 } 267 }
267 Statement stmt = conn.createStatement(); 268 stmt = conn.createStatement();
268 ResultSet rset = null; 269 ResultSet rset = null;
269 270
270 //Get the database name once // Currently always gets the CDB name 271 //Get the database name once // Currently always gets the CDB name
...@@ -304,7 +305,7 @@ public class OraMon { ...@@ -304,7 +305,7 @@ public class OraMon {
304 // If we have containers, but we are not the CDB, then we are a PDB. 305 // If we have containers, but we are not the CDB, then we are a PDB.
305 // We should ask the CDB object for our data 306 // We should ask the CDB object for our data
306 if(isPDB) { 307 if(isPDB) {
307 getDataFromCDB(); 308 getDataFromCDB(ageTs);
308 } else { 309 } else {
309 // All other cases (CDB or an instance without containers) get the data from the database 310 // All other cases (CDB or an instance without containers) get the data from the database
310 311
...@@ -340,6 +341,13 @@ public class OraMon { ...@@ -340,6 +341,13 @@ public class OraMon {
340 Throwable thisCause = e; 341 Throwable thisCause = e;
341 while(lastCause != null) { thisCause = lastCause; lastCause = thisCause.getCause(); } 342 while(lastCause != null) { thisCause = lastCause; lastCause = thisCause.getCause(); }
342 lastEx = thisCause; 343 lastEx = thisCause;
344 // Close the connection and statement to prevent memory leaks
345 try {
346 stmt.close();
347 conn.close();
348 } catch (Exception e2) {
349 // Dont care
350 }
343 throw (e); 351 throw (e);
344 } finally { 352 } finally {
345 lock.unlock(); 353 lock.unlock();
...@@ -347,10 +355,19 @@ public class OraMon { ...@@ -347,10 +355,19 @@ public class OraMon {
347 // End thread safe 355 // End thread safe
348 } 356 }
349 357
350 public void getDataFromCDB() { 358 public void getDataFromCDB(long ageTs) throws Throwable {
351 //Generate a con string for the CDB using the PDB con string and replace the service name 359 //Generate a con string for the CDB using the PDB con string and replace the service name
352 String cdbConString = getConString().replaceAll(getServiceName(), getDBName()); 360 String cdbConString = getConString().replaceAll(getServiceName(), getDBName());
353 System.out.println("CDB seems to be: " + cdbConString); 361 System.out.println("CDB seems to be: " + cdbConString);
362 //Find the CDB in the registry
363 OraMon myCDB = Registry.findOrCreate(cdbConString, conUser, conPass);
364 myCDB.getData(ageTs);
365 // Verify the CDB
366 if (getDBName().equals(myCDB.getDBName())) {
367 System.out.println("myCDB name equals DBName");
368 } else {
369 System.out.println("myCDB name does not equal DBName");
370 }
354 } 371 }
355 372
356 public Throwable getLastEx() { 373 public Throwable getLastEx() {
......