Tagit bort PDB koden. Kommer byta till ny approuch. TNS stödet kvar.
PDB som ska cachas får alltid gå via CDB Connection String och istället får man skicka med en flagga med PDB namnet som man vill ha ut. Blir mycket enklare.
Showing
2 changed files
with
4 additions
and
53 deletions
1 | package se.lil.om; | 1 | package se.lil.om; |
2 | 2 | ||
3 | import java.sql.*; | 3 | import java.sql.*; |
4 | import java.util.HashMap; | ||
5 | import java.util.Hashtable; | ||
6 | import java.util.Properties; | 4 | import java.util.Properties; |
7 | import java.util.concurrent.locks.Lock; | 5 | import java.util.concurrent.locks.Lock; |
8 | import java.util.concurrent.locks.ReentrantLock; | 6 | import java.util.concurrent.locks.ReentrantLock; |
... | @@ -22,8 +20,6 @@ public class OraMon { | ... | @@ -22,8 +20,6 @@ public class OraMon { |
22 | Boolean hasContainers = null; | 20 | Boolean hasContainers = null; |
23 | OraMon containerDB = null; | 21 | OraMon containerDB = null; |
24 | 22 | ||
25 | private Hashtable<String, OraMon> myPDBs = null; | ||
26 | |||
27 | public static final int SYSSTAT = 1; | 23 | public static final int SYSSTAT = 1; |
28 | public static final int OSSTAT = 2; | 24 | public static final int OSSTAT = 2; |
29 | 25 | ||
... | @@ -276,37 +272,6 @@ public class OraMon { | ... | @@ -276,37 +272,6 @@ public class OraMon { |
276 | rset.close(); | 272 | rset.close(); |
277 | } | 273 | } |
278 | 274 | ||
279 | // Check if we can have containers | ||
280 | if(hasContainers == null) { | ||
281 | // We don't know, check if the CONTAINERS view exists in the database | ||
282 | rset = stmt.executeQuery("select count(*) from SYS.ALL_VIEWS where VIEW_NAME = 'V_$CONTAINERS'"); | ||
283 | if(rset.next()) { | ||
284 | if(rset.getInt(1) == 1) { | ||
285 | // We found the containers view. Enable container handling | ||
286 | hasContainers = true; | ||
287 | String serviceName = getServiceName(); | ||
288 | if(serviceName != null) { | ||
289 | if(serviceName.equals(this.dbName)) isCDB = true; | ||
290 | else isPDB = true; | ||
291 | } else { | ||
292 | // Servicename is null, treat as CDB | ||
293 | isCDB = true; | ||
294 | isPDB = false; | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | if(hasContainers == null) { | ||
299 | hasContainers = false; | ||
300 | isCDB = true; | ||
301 | isPDB = false; | ||
302 | } | ||
303 | } | ||
304 | |||
305 | // If we have containers, but we are not the CDB, then we are a PDB. | ||
306 | // We should ask the CDB object for our data | ||
307 | if(isPDB) { | ||
308 | getDataFromCDB(ageTs); | ||
309 | } else { | ||
310 | // All other cases (CDB or an instance without containers) get the data from the database | 275 | // All other cases (CDB or an instance without containers) get the data from the database |
311 | 276 | ||
312 | //Get the entire V_$OSSTAT table from DB | 277 | //Get the entire V_$OSSTAT table from DB |
... | @@ -329,7 +294,6 @@ public class OraMon { | ... | @@ -329,7 +294,6 @@ public class OraMon { |
329 | 294 | ||
330 | //Get the entire V_$SYSSTAT table from DB | 295 | //Get the entire V_$SYSSTAT table from DB |
331 | colSysStat.update(stmt.executeQuery("select systimestamp, name, value from V$SYSSTAT")); | 296 | colSysStat.update(stmt.executeQuery("select systimestamp, name, value from V$SYSSTAT")); |
332 | } | ||
333 | 297 | ||
334 | stmt.close(); | 298 | stmt.close(); |
335 | getDataSucess++; | 299 | getDataSucess++; |
... | @@ -355,21 +319,6 @@ public class OraMon { | ... | @@ -355,21 +319,6 @@ public class OraMon { |
355 | // End thread safe | 319 | // End thread safe |
356 | } | 320 | } |
357 | 321 | ||
358 | public void getDataFromCDB(long ageTs) throws Throwable { | ||
359 | //Generate a con string for the CDB using the PDB con string and replace the service name | ||
360 | String cdbConString = getConString().replaceAll(getServiceName(), getDBName()); | ||
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 | } | ||
371 | } | ||
372 | |||
373 | public Throwable getLastEx() { | 322 | public Throwable getLastEx() { |
374 | return lastEx; | 323 | return lastEx; |
375 | } | 324 | } | ... | ... |
... | @@ -24,7 +24,8 @@ public class TestRunner { | ... | @@ -24,7 +24,8 @@ public class TestRunner { |
24 | } | 24 | } |
25 | 25 | ||
26 | public static void testTns() throws Throwable { | 26 | public static void testTns() throws Throwable { |
27 | OraMon mon = new OraMon("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=u00153.kap.rsv.se)(Port=1526))(ADDRESS=(PROTOCOL=TCP)(Host=u00154.kap.rsv.se)(Port=1526)))(CONNECT_DATA=(SERVICE_NAME=PB1K001)))","dbsnmp","dbsnmp"); // PDB using TNS | 27 | //OraMon mon = new OraMon("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=u00153.kap.rsv.se)(Port=1526))(ADDRESS=(PROTOCOL=TCP)(Host=u00154.kap.rsv.se)(Port=1526)))(CONNECT_DATA=(SERVICE_NAME=PB1K001)))","dbsnmp","dbsnmp"); // PDB using TNS |
28 | OraMon mon = new OraMon("jdbc:oracle:thin:@//u00153.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp"); | ||
28 | System.out.println("getData returned: " + mon.getData()); | 29 | System.out.println("getData returned: " + mon.getData()); |
29 | System.out.println("getDatabaseName: " + mon.getDBName()); | 30 | System.out.println("getDatabaseName: " + mon.getDBName()); |
30 | System.out.println("getServiceName: " + mon.getServiceName()); | 31 | System.out.println("getServiceName: " + mon.getServiceName()); |
... | @@ -41,7 +42,8 @@ public class TestRunner { | ... | @@ -41,7 +42,8 @@ public class TestRunner { |
41 | 42 | ||
42 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@uvp3dbkappkg:1550:VP1K03","dbsnmp","dbsnmp"); // SID eller Service Name format | 43 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@uvp3dbkappkg:1550:VP1K03","dbsnmp","dbsnmp"); // SID eller Service Name format |
43 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u00154.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp"); | 44 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u00154.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp"); |
44 | OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); | 45 | OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); // PDB, CDB är DB1K12 |
46 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K002","dbsnmp","dbsnmp"); // Andra PDB på CDB DB1K12 | ||
45 | //OraMon mon2 = new OraMon("jdbc:oracle:thin:@host:port:sid","user","pass"); // SID format | 47 | //OraMon mon2 = new OraMon("jdbc:oracle:thin:@host:port:sid","user","pass"); // SID format |
46 | mon1.open(); | 48 | mon1.open(); |
47 | //mon2.open(); | 49 | //mon2.open(); | ... | ... |
-
Please register or sign in to post a comment