Kommit lite längre, ny getFriendlyName som returnerar antingen DB name
eller service name, samt lyckats generera CDB databasens con string för att nu ladda den i registryt.
Showing
4 changed files
with
22 additions
and
8 deletions
... | @@ -127,14 +127,14 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -127,14 +127,14 @@ public class OraMonRESTgetData extends HttpServlet { |
127 | if(monitor != null) { | 127 | if(monitor != null) { |
128 | // Call getData() | 128 | // Call getData() |
129 | boolean didUpdate = monitor.getData(age); | 129 | boolean didUpdate = monitor.getData(age); |
130 | String dbName = monitor.getDBName(); | 130 | String dbName = monitor.getFriendlyName(); |
131 | if(didUpdate) { | 131 | if(didUpdate) { |
132 | sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on instance '" + dbName + "'\""); | 132 | sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on '" + dbName + "'\""); |
133 | sb.append(",\"ms\":"+monitor.getLastRTms()+"}"); | 133 | sb.append(",\"ms\":"+monitor.getLastRTms()+"}"); |
134 | } else { | 134 | } else { |
135 | response.setStatus(HttpServletResponse.SC_ACCEPTED); | 135 | response.setStatus(HttpServletResponse.SC_ACCEPTED); |
136 | sb.append("{\"error\":false"); | 136 | sb.append("{\"error\":false"); |
137 | sb.append(",\"msg\":\"Data does not need to be updated on instance '" + dbName + "' either because another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\""); | 137 | sb.append(",\"msg\":\"Data does not need to be updated on '" + dbName + "' either because another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\""); |
138 | sb.append(",\"age\":"+monitor.getAgeTs()+"}"); | 138 | sb.append(",\"age\":"+monitor.getAgeTs()+"}"); |
139 | } | 139 | } |
140 | } else { | 140 | } else { | ... | ... |
... | @@ -123,7 +123,7 @@ public class OraMonRESTgetMetrics extends HttpServlet { | ... | @@ -123,7 +123,7 @@ public class OraMonRESTgetMetrics extends HttpServlet { |
123 | // Loop over all monitors and output a Json array with the default set of metrics | 123 | // Loop over all monitors and output a Json array with the default set of metrics |
124 | 124 | ||
125 | for (OraMon item : list) { | 125 | for (OraMon item : list) { |
126 | sb.append("{\"name\":\"" + item.getDBName() + "\",\"error\":false,\"nvarray\":"); | 126 | sb.append("{\"name\":\"" + item.getFriendlyName() + "\",\"error\":false,\"nvarray\":"); |
127 | sb.append("["); | 127 | sb.append("["); |
128 | 128 | ||
129 | 129 | ... | ... |
... | @@ -134,7 +134,13 @@ public class OraMon { | ... | @@ -134,7 +134,13 @@ public class OraMon { |
134 | 134 | ||
135 | public String getDBName() { | 135 | public String getDBName() { |
136 | // Returns the instance name unless we are a PDB, in that case the service name from the con string is returned instead. | 136 | // Returns the instance name unless we are a PDB, in that case the service name from the con string is returned instead. |
137 | if(isPDB) return getServiceName(); | 137 | return this.dbName; |
138 | } | ||
139 | |||
140 | public String getFriendlyName() { | ||
141 | // Returns a friendly name of the database, either the service name from con string or the database name from the instance | ||
142 | getServiceName(); | ||
143 | if(this.serviceName != null) return this.serviceName; | ||
138 | else return this.dbName; | 144 | else return this.dbName; |
139 | } | 145 | } |
140 | 146 | ||
... | @@ -288,11 +294,16 @@ public class OraMon { | ... | @@ -288,11 +294,16 @@ public class OraMon { |
288 | } | 294 | } |
289 | } | 295 | } |
290 | } | 296 | } |
297 | if(hasContainers == null) { | ||
298 | hasContainers = false; | ||
299 | isCDB = true; | ||
300 | isPDB = false; | ||
301 | } | ||
291 | } | 302 | } |
292 | 303 | ||
293 | // If we have containers, but we are not the CDB, then we are a PDB. | 304 | // If we have containers, but we are not the CDB, then we are a PDB. |
294 | // We should ask the CDB object for our data | 305 | // We should ask the CDB object for our data |
295 | if(isPDB && false) { | 306 | if(isPDB) { |
296 | getDataFromCDB(); | 307 | getDataFromCDB(); |
297 | } else { | 308 | } else { |
298 | // All other cases (CDB or an instance without containers) get the data from the database | 309 | // All other cases (CDB or an instance without containers) get the data from the database |
... | @@ -337,7 +348,9 @@ public class OraMon { | ... | @@ -337,7 +348,9 @@ public class OraMon { |
337 | } | 348 | } |
338 | 349 | ||
339 | public void getDataFromCDB() { | 350 | public void getDataFromCDB() { |
340 | // TODO | 351 | //Generate a con string for the CDB using the PDB con string and replace the service name |
352 | String cdbConString = getConString().replaceAll(getServiceName(), getDBName()); | ||
353 | System.out.println("CDB seems to be: " + cdbConString); | ||
341 | } | 354 | } |
342 | 355 | ||
343 | public Throwable getLastEx() { | 356 | public Throwable getLastEx() { | ... | ... |
... | @@ -28,7 +28,8 @@ public class TestRunner { | ... | @@ -28,7 +28,8 @@ public class TestRunner { |
28 | System.out.println("getData returned: " + mon.getData()); | 28 | System.out.println("getData returned: " + mon.getData()); |
29 | System.out.println("getDatabaseName: " + mon.getDBName()); | 29 | System.out.println("getDatabaseName: " + mon.getDBName()); |
30 | System.out.println("getServiceName: " + mon.getServiceName()); | 30 | System.out.println("getServiceName: " + mon.getServiceName()); |
31 | System.out.println("getServiceName: " + mon.getConString()); | 31 | System.out.println("getFriendlyName: " + mon.getFriendlyName()); |
32 | System.out.println("getConString: " + mon.getConString()); | ||
32 | System.out.println("getNumberOfCPUs: " + mon.getNumberOfCPUs()); | 33 | System.out.println("getNumberOfCPUs: " + mon.getNumberOfCPUs()); |
33 | } | 34 | } |
34 | 35 | ... | ... |
-
Please register or sign in to post a comment