Search in sources :

Example 1 with NodeCheckerResponse

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);
}
Also used : Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)

Example 2 with NodeCheckerResponse

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;
}
Also used : ExecutionReport(com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionReport) ArrayList(java.util.ArrayList) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)

Example 3 with NodeCheckerResponse

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());
    }
}
Also used : Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)

Example 4 with NodeCheckerResponse

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);
}
Also used : Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 5 with NodeCheckerResponse

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);
}
Also used : ExecutionContext(com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext) Logger(org.apache.log4j.Logger) List(java.util.List) RedisClientCache(com.github.diegopacheco.dynomite.cluster.checker.cluster.cache.RedisClientCache) Jedis(redis.clients.jedis.Jedis) Collectors(java.util.stream.Collectors) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo) Jedis(redis.clients.jedis.Jedis) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Aggregations

NodeCheckerResponse (com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)6 Chronometer (com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer)3 DynomiteNodeInfo (com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)2 RedisClientCache (com.github.diegopacheco.dynomite.cluster.checker.cluster.cache.RedisClientCache)1 ExecutionContext (com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext)1 ExecutionReport (com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionReport)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 Test (org.junit.Test)1 Jedis (redis.clients.jedis.Jedis)1