use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo in project dynomite-cluster-checker by diegopacheco.
the class CheckNodesConnectivityTask method checkNodeConnectivity.
private List<DynomiteNodeInfo> checkNodeConnectivity(ExecutionContext ec) {
List<DynomiteNodeInfo> onlineNodes = new ArrayList<>();
for (DynomiteNodeInfo node : ec.getOriginalNodes()) {
try {
DynoJedisClient client = DynoClientCache.get(node.toSeed());
if (client == null) {
client = DCCConnectionManager.createSingleNodeCluster(DynomiteConfig.CLUSTER_NAME, node);
DynoClientCache.put(node.toSeed(), client);
}
try {
Jedis redisClient = RedisClientCache.get(node.toSeedRedis());
if (redisClient == null) {
redisClient = RedisNodeConnectionManager.createNodeConnection(node);
RedisClientCache.put(node.toSeedRedis(), redisClient);
}
} catch (Exception e) {
logger.error("Could not Connet on Redis Node: " + node + " EX: " + e);
}
String prefix = "awesomeSbrubles";
client.get(prefix);
node.setNodeClient(client);
onlineNodes.add(node);
} catch (Throwable t) {
logger.error("Could not Connet on Node: " + node + " EX: " + t);
} finally {
}
}
ec.setOnlineNodes(onlineNodes);
return onlineNodes;
}
use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo 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.parser.DynomiteNodeInfo 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.parser.DynomiteNodeInfo in project dynomite-cluster-checker by diegopacheco.
the class SimpleConnectionTest method testConnection.
@Ignore
@Test
public /**
* Should have the same result(connectivity-like) as:
* ./gradlew execute -Dexec.args="127.0.0.1:8102:rack1:local-dc:100"
*/
void testConnection() {
String clusterName = "local-cluster";
DynomiteNodeInfo node = new DynomiteNodeInfo("127.0.0.1", "8102", "rack1", "local-dc", "100");
DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(DynomiteConfig.CLIENT_NAME).withDynomiteClusterName(clusterName).withCPConfig(new ArchaiusConnectionPoolConfiguration(DynomiteConfig.CLIENT_NAME).withTokenSupplier(toTokenMapSupplier(Arrays.asList(node))).setMaxConnsPerHost(1).setConnectTimeout(2000).setPoolShutdownDelay(0).setFailOnStartupIfNoHosts(true).setFailOnStartupIfNoHostsSeconds(2).setMaxTimeoutWhenExhausted(2000).setSocketTimeout(2000).setRetryPolicyFactory(new RetryNTimes.RetryFactory(1))).withHostSupplier(toHostSupplier(Arrays.asList(node))).build();
dynoClient.set("Z", "200");
System.out.println("Z: " + dynoClient.get("Z"));
}
Aggregations