Add some debug logging to keep track of timing

This commit is contained in:
Hugo Trippaers 2014-07-30 16:04:35 +02:00 committed by wilderrodrigues
parent 7b8050c056
commit 43fd212298
3 changed files with 28 additions and 0 deletions

View File

@ -72,4 +72,14 @@ public class FileConfigItem extends ConfigItem {
return sb.toString();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("FileConfigItem, copying ");
sb.append(fileContents.length());
sb.append(" characters to ");
sb.append(fileName);
return sb.toString();
}
}

View File

@ -56,4 +56,14 @@ public class ScriptConfigItem extends ConfigItem {
return sb.toString();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ScriptConfigItem, executing ");
sb.append(script);
sb.append(' ');
sb.append(args);
return sb.toString();
}
}

View File

@ -168,6 +168,8 @@ public class VirtualRoutingResource {
private Answer applyConfig(NetworkElementCommand cmd, List<ConfigItem> cfg) {
if (cfg.isEmpty()) {
return new Answer(cmd, true, "Nothing to do");
}
@ -176,7 +178,12 @@ public class VirtualRoutingResource {
List<String> details = new ArrayList<String>();
boolean finalResult = false;
for (ConfigItem configItem : cfg) {
long startTimestamp = System.currentTimeMillis();
ExecutionResult result = applyConfigToVR(cmd.getRouterAccessIp(), configItem);
if (s_logger.isDebugEnabled()) {
long elapsed = System.currentTimeMillis() - startTimestamp;
s_logger.debug("Processing " + configItem + " took " + elapsed + "ms");
}
if (result == null) {
result = new ExecutionResult(false, "null execution result");
}
@ -190,6 +197,7 @@ public class VirtualRoutingResource {
s_logger.warn("Expected " + cmd.getAnswersCount() + " answers while executing " + cmd.getClass().getSimpleName() + " but received " + results.size());
}
if (results.size() == 1) {
return new Answer(cmd, finalResult, results.get(0).getDetails());
} else {