use of com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse 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.context.NodeCheckerResponse in project dynomite-cluster-checker by diegopacheco.
the class ListPrinterTest method buildResultReport.
private ExecutionReport buildResultReport(List<DynomiteNodeInfo> nodes) {
ExecutionReport resultReport = new ExecutionReport();
resultReport.setOfflineNodes(nodes);
resultReport.setFailoverStatus("Issue");
List<NodeCheckerResponse> responses = new ArrayList<NodeCheckerResponse>();
responses.add(new NodeCheckerResponse("localhost1:6379:rack1:dc1:123|localhost2:6379:rack1:dc1:123|", "0", "0", false, "localhost1"));
responses.add(new NodeCheckerResponse("localhost1:6379:rack1:dc1:123|localhost2:6379:rack1:dc1:123|", "0", "0", false, "localhost2"));
resultReport.setNodesReport(responses);
return resultReport;
}
use of com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse 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.context.NodeCheckerResponse 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.context.NodeCheckerResponse 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);
}
Aggregations