Commit b18f52d6 b18f52d690151cd0ed37dd6303db9ae887882ad8 by Christian Gerdes

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.
1 parent 146c1f6e
......@@ -127,14 +127,14 @@ public class OraMonRESTgetData extends HttpServlet {
if(monitor != null) {
// Call getData()
boolean didUpdate = monitor.getData(age);
String dbName = monitor.getDBName();
String dbName = monitor.getFriendlyName();
if(didUpdate) {
sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on instance '" + dbName + "'\"");
sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on '" + dbName + "'\"");
sb.append(",\"ms\":"+monitor.getLastRTms()+"}");
} else {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
sb.append("{\"error\":false");
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.\"");
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.\"");
sb.append(",\"age\":"+monitor.getAgeTs()+"}");
}
} else {
......
......@@ -123,7 +123,7 @@ public class OraMonRESTgetMetrics extends HttpServlet {
// Loop over all monitors and output a Json array with the default set of metrics
for (OraMon item : list) {
sb.append("{\"name\":\"" + item.getDBName() + "\",\"error\":false,\"nvarray\":");
sb.append("{\"name\":\"" + item.getFriendlyName() + "\",\"error\":false,\"nvarray\":");
sb.append("[");
......
......@@ -134,7 +134,13 @@ public class OraMon {
public String getDBName() {
// Returns the instance name unless we are a PDB, in that case the service name from the con string is returned instead.
if(isPDB) return getServiceName();
return this.dbName;
}
public String getFriendlyName() {
// Returns a friendly name of the database, either the service name from con string or the database name from the instance
getServiceName();
if(this.serviceName != null) return this.serviceName;
else return this.dbName;
}
......@@ -288,11 +294,16 @@ public class OraMon {
}
}
}
if(hasContainers == null) {
hasContainers = false;
isCDB = true;
isPDB = false;
}
}
// If we have containers, but we are not the CDB, then we are a PDB.
// We should ask the CDB object for our data
if(isPDB && false) {
if(isPDB) {
getDataFromCDB();
} else {
// All other cases (CDB or an instance without containers) get the data from the database
......@@ -337,7 +348,9 @@ public class OraMon {
}
public void getDataFromCDB() {
// TODO
//Generate a con string for the CDB using the PDB con string and replace the service name
String cdbConString = getConString().replaceAll(getServiceName(), getDBName());
System.out.println("CDB seems to be: " + cdbConString);
}
public Throwable getLastEx() {
......
......@@ -28,7 +28,8 @@ public class TestRunner {
System.out.println("getData returned: " + mon.getData());
System.out.println("getDatabaseName: " + mon.getDBName());
System.out.println("getServiceName: " + mon.getServiceName());
System.out.println("getServiceName: " + mon.getConString());
System.out.println("getFriendlyName: " + mon.getFriendlyName());
System.out.println("getConString: " + mon.getConString());
System.out.println("getNumberOfCPUs: " + mon.getNumberOfCPUs());
}
......