Search in sources :

Example 1 with Chronometer

use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer 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 Chronometer

use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer in project dynomite-cluster-checker by diegopacheco.

the class DynomiteClusterCheckerMain method main.

public static void main(String[] args) {
    Chronometer stopWatch = new Chronometer();
    try {
        stopWatch.start();
        Boolean isTelemetryMode = isTelemtryModeSet(args) ? true : false;
        DCCTaskExecutionEngine dcc = new DCCTaskExecutionEngine();
        String jsonResult = dcc.run(extractArg(0, args), isTelemetryMode);
        logger.info(jsonResult);
    } catch (Exception e) {
        logger.error("Error: " + e);
    } finally {
        stopWatch.stop();
        logger.info("--");
        logger.info(stopWatch.getDiffAsSecondsString());
        System.exit(0);
    }
}
Also used : Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) DCCTaskExecutionEngine(com.github.diegopacheco.dynomite.cluster.checker.tasks.engine.DCCTaskExecutionEngine)

Example 3 with Chronometer

use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer 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 Chronometer

use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer 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 Chronometer

use of com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer 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

Chronometer (com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer)5 NodeCheckerResponse (com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)3 ExecutionContext (com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext)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 DCCTaskExecutionEngine (com.github.diegopacheco.dynomite.cluster.checker.tasks.engine.DCCTaskExecutionEngine)1 List (java.util.List)1