use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.
the class CheckDataReplicationTask method insertKey.
private void insertKey(ExecutionContext ec) {
Chronometer stopWatch = new Chronometer();
stopWatch.start();
NodeCheckerResponse nodeReport = new NodeCheckerResponse();
try {
nodeReport.setSeeds(ec.getRawSeeds());
nodeReport.setServer(ec.getOnlineNodes().toString());
String replicationKey = KeyValueGnerator.generateKey();
String replicationValue = KeyValueGnerator.generateValue();
ec.getWholeClusterClient().set(replicationKey, replicationValue);
nodeReport.setConsistency(true);
nodeReport.setConsistencyRedis(true);
ec.setReplicationKey(replicationKey);
ec.setReplicationValue(replicationValue);
} catch (Throwable t) {
logger.error("Cloud not insert data into the cluster. EX: " + t);
nodeReport.setConsistency(false);
nodeReport.setInsertError(t.getMessage());
}
stopWatch.stop();
nodeReport.setInsertTime(stopWatch.getDiffAsString());
ec.getExecutionReport().getNodesReport().add(nodeReport);
}
use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.
the class DynomiteClusterCheckerMain method main.
public static void main(String[] args) {
Chronometer stopWatch = new Chronometer();
try {
stopWatch.start();
Boolean isTelemetryMode = isTelemtryModeSet(args) ? true : false;
DCCTaskExecutionEngine dcc = new DCCTaskExecutionEngine();
String jsonResult = dcc.run(extractArg(0, args), isTelemetryMode);
logger.info(jsonResult);
} catch (Exception e) {
logger.error("Error: " + e);
} finally {
stopWatch.stop();
logger.info("--");
logger.info(stopWatch.getDiffAsSecondsString());
System.exit(0);
}
}
use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.
the class CheckClusterFailoverTask method execute.
@Override
public void execute(ExecutionContext ec) {
Chronometer stopWatch = new Chronometer();
stopWatch.start();
NodeCheckerResponse nodeReport = new NodeCheckerResponse();
try {
nodeReport.setSeeds(ec.getRawSeeds());
nodeReport.setServer(ec.getOnlineNodes().toString());
try {
String failOverKey = KeyValueGnerator.generateKey();
String failOverValue = KeyValueGnerator.generateValue();
ec.setFailOverKey(failOverKey);
ec.setFailOverValue(failOverValue);
ec.getWholeClusterClient().set(failOverKey, failOverValue);
} catch (Throwable t) {
nodeReport.setInsertError(t.getMessage());
}
String result = ec.getWholeClusterClient().get(ec.getFailOverKey());
stopWatch.stop();
nodeReport.setGetTime(stopWatch.getDiffAsString());
if (result != null && (!"".equals(result)) && ec.getFailOverValue().equals(result)) {
nodeReport.setConsistency(true);
ec.getExecutionReport().setFailoverStatus("OK");
} else {
nodeReport.setConsistency(false);
ec.getExecutionReport().setFailoverStatus("Inconsistent. Expected: " + ec.getFailOverValue() + ", Got: " + result + " - info: " + nodeReport.toString());
}
} catch (Throwable t) {
logger.error("Cloud not insert data into the cluster. EX: " + t);
nodeReport.setConsistency(false);
nodeReport.setGetError(t.getMessage());
ec.getExecutionReport().setFailoverStatus("Error! EX: " + t.getMessage() + " - info: " + nodeReport.toString());
}
}
use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.
the class CheckDataReplicationTask method getKeys.
private void getKeys(ExecutionContext ec) {
Chronometer stopWatch = new Chronometer();
stopWatch.start();
NodeCheckerResponse nodeReport = new NodeCheckerResponse();
int count = 0;
for (DynomiteNodeInfo node : ec.getOnlineNodes()) {
try {
nodeReport.setSeeds(node.toString());
nodeReport.setServer(node.getServer());
String result = node.getNodeClient().get(ec.getReplicationKey());
if (result != null && (!"".equals(result))) {
count++;
nodeReport.setConsistency(true);
} else {
nodeReport.setConsistency(false);
}
} catch (Throwable t) {
logger.error("Could not get KEY on node : " + node + " - EX: " + t);
nodeReport.setGetError(t.getMessage());
} finally {
stopWatch.stop();
nodeReport.setGetTime(stopWatch.getDiffAsString());
ec.getExecutionReport().getNodesReport().add(nodeReport);
nodeReport = new NodeCheckerResponse();
}
}
ec.getExecutionReport().setReplicationCount(count);
}
use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.
the class DCCTaskExecutionEngine method run.
@SuppressWarnings("unchecked")
public String run(String seeds, boolean telemetryMode) {
ExecutionContext ec = injector.getInstance(ExecutionContext.class);
Chronometer stopWatch = injector.getInstance(Chronometer.class);
stopWatch.start();
ec.setRawSeeds(seeds);
ec.setIsTelemetryMode(telemetryMode);
List<Task> tasks = injector.getInstance(Key.get(List.class, Names.named("tasks")));
for (Task t : tasks) {
t.execute(ec);
}
stopWatch.stop();
ec.getExecutionReport().setTimeToRun(stopWatch.getDiffAsString());
GetJsonReportResultTask jsonFinalReportTask = injector.getInstance(GetJsonReportResultTask.class);
jsonFinalReportTask.execute(ec);
return ec.getExecutionReport().getJsonResult();
}
Aggregations