From a89da4dd00e460492d4ca0da3df436646de197c7 Mon Sep 17 00:00:00 2001 From: cyberjso Date: Tue, 3 Jan 2017 14:33:26 -0200 Subject: [PATCH 1/3] Letting telemetry mode be asked when running though the console --- .../checker/DynomiteClusterCheckerMain.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java index a9a5344..d430071 100644 --- a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java +++ b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java @@ -29,18 +29,22 @@ public class DynomiteClusterCheckerMain { public static void main(String[] args){ Long init = System.currentTimeMillis(); try{ + String telemetryParam = args[1]; + String seeds = args[0]; + Boolean isTelemetryMode = isTelemtryModeSet(telemetryParam) ? new Boolean(telemetryParam) : false; DynomiteClusterCheckerMain dcc = new DynomiteClusterCheckerMain(); - //dcc.run(args[0],false); - //dcc.run("200.56.0.1:8101:rack1:local-dc:437425602",true); - dcc.run("227.0.0.1:8101:rack1:local-dc:437425602|127.0.0.1:8101:rack1:local-dc:437425602",false); - //dcc.run("jack.cats.com:8101:rack1:local-dc:437425602",false); - }finally { + dcc.run(seeds, isTelemetryMode); + } finally { Long end = System.currentTimeMillis(); System.out.println("--"); System.out.println( "TIME TO RUN: " + TimeUnit.MILLISECONDS.toSeconds((end-init)) + " seconds"); } } - + + private static boolean isTelemtryModeSet(String parameter) { + return (parameter.equalsIgnoreCase("false") || parameter.equalsIgnoreCase("true")); + } + public String run(String seeds,boolean telemetryMode){ Long init = System.currentTimeMillis(); From 09dfd2c453eaa1363cd0991e2ee9e25e345c28cc Mon Sep 17 00:00:00 2001 From: cyberjso Date: Tue, 3 Jan 2017 15:04:47 -0200 Subject: [PATCH 2/3] Protecting against NPE --- .../dynomite/cluster/checker/CheckerResponse.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/CheckerResponse.java b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/CheckerResponse.java index b67ea9b..dc17528 100644 --- a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/CheckerResponse.java +++ b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/CheckerResponse.java @@ -124,13 +124,17 @@ public String toPrettyTelemetryJson(){ pritIfNotNull(" \"server\":\"" + server + "\",\r\n",server) + pritIfNotNull(" \"seeds\":\"" + seeds + "\",\r\n",seeds) + pritIfNotNull(" \"insertTime\":\"" + getInsertTime(insertTime) + "\",\r\n",insertTime) + - pritIfNotNull(" \"getTime\":\"" + new Double(getTime.replace("ms", "").trim()).intValue() + "\",\r\n",getTime) + + pritIfNotNull(" \"getTime\":\"" + new Double(getTime().replace("ms", "").trim()).intValue() + "\",\r\n",getTime) + pritIfNotNull(" \"insertError\":\"" + resolveErrorTelemetry(insertError) + "\",\r\n",resolveErrorTelemetry(insertError)) + pritIfNotNull(" \"getError\":\"" + resolveErrorTelemetry(getError) + "\",\r\n",resolveErrorTelemetry(getError)) + " \"consistency\":\"" + resolveBoolean(consistency) + "\"\r\n" + " }"; } + private String getTime() { + return getTime == null ? "0" : getTime; + } + private int getInsertTime(String insertTime) { return (insertTime == null) ? 0 : new Double(insertTime.replace("ms", "").trim()).intValue(); } From 478360001bde59a6728fcc770854aea4ea3fcd9c Mon Sep 17 00:00:00 2001 From: cyberjso Date: Wed, 11 Jan 2017 08:31:52 -0200 Subject: [PATCH 3/3] Setting default values for telemetry mode when running trhough the console In case telemetry mode isn't set, It should is false. --- .../cluster/checker/DynomiteClusterCheckerMain.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java index d430071..3751bd1 100644 --- a/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java +++ b/dynomite-cluster-checker/src/main/java/com/github/diegopacheco/dynomite/cluster/checker/DynomiteClusterCheckerMain.java @@ -29,9 +29,8 @@ public class DynomiteClusterCheckerMain { public static void main(String[] args){ Long init = System.currentTimeMillis(); try{ - String telemetryParam = args[1]; String seeds = args[0]; - Boolean isTelemetryMode = isTelemtryModeSet(telemetryParam) ? new Boolean(telemetryParam) : false; + Boolean isTelemetryMode = isTelemtryModeSet(args) ? true : false; DynomiteClusterCheckerMain dcc = new DynomiteClusterCheckerMain(); dcc.run(seeds, isTelemetryMode); } finally { @@ -41,7 +40,10 @@ public static void main(String[] args){ } } - private static boolean isTelemtryModeSet(String parameter) { + private static boolean isTelemtryModeSet(String[] args) { + if (args.length < 2) return false; + + String parameter = args[1]; return (parameter.equalsIgnoreCase("false") || parameter.equalsIgnoreCase("true")); }