Search in sources :

Example 1 with ExecutionContext

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);
}
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)

Example 2 with ExecutionContext

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();
}
Also used : GetJsonReportResultTask(com.github.diegopacheco.dynomite.cluster.checker.tasks.GetJsonReportResultTask) Task(com.github.diegopacheco.dynomite.cluster.checker.tasks.Task) ExecutionContext(com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext) Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) List(java.util.List) GetJsonReportResultTask(com.github.diegopacheco.dynomite.cluster.checker.tasks.GetJsonReportResultTask)

Aggregations

ExecutionContext (com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext)2 List (java.util.List)2 RedisClientCache (com.github.diegopacheco.dynomite.cluster.checker.cluster.cache.RedisClientCache)1 NodeCheckerResponse (com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)1 DynomiteNodeInfo (com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)1 GetJsonReportResultTask (com.github.diegopacheco.dynomite.cluster.checker.tasks.GetJsonReportResultTask)1 Task (com.github.diegopacheco.dynomite.cluster.checker.tasks.Task)1 Chronometer (com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 Jedis (redis.clients.jedis.Jedis)1