use of com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext in project dynomite-cluster-checker by diegopacheco.
the class RedisReplicationTask method execute.
@Override
public void execute(ExecutionContext ec) {
int replicationCount = 0;
List<DynomiteNodeInfo> nodes = ec.getOnlineNodes();
for (DynomiteNodeInfo node : nodes) {
Jedis redisCliet = RedisClientCache.get(node.toSeedRedis());
if (redisCliet != null) {
String result = "";
try {
result = redisCliet.get(ec.getReplicationKey());
} catch (Exception e) {
logger.error("Error to read " + ec.getReplicationKey() + " from Redis - EX: " + e);
}
if (result != null && (!"".equals(result)) && ec.getReplicationValue().equals(result)) {
replicationCount++;
List<NodeCheckerResponse> onlineDynNodes = ec.getExecutionReport().getNodesReport();
List<NodeCheckerResponse> resultFilter = onlineDynNodes.stream().filter(n -> node.toSeedRedis().equals(n.getSeeds())).collect(Collectors.toList());
if (resultFilter != null && resultFilter.size() == 1) {
resultFilter.get(0).setConsistencyRedis(true);
}
}
}
}
ec.getExecutionReport().setRedisReplicationCount(replicationCount);
}
use of com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext 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