From 006fc4764aed7cde1c8c500503f1321cabad561c Mon Sep 17 00:00:00 2001 From: Elliott Neil Clark Date: Sun, 27 Oct 2013 13:23:51 -0700 Subject: [PATCH] HBASE-9848 Make regionserver Canary exit with different exit codes --- .../src/main/java/org/apache/hadoop/hbase/tool/Canary.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java index ed98a75..ebea8b5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java @@ -109,6 +109,9 @@ public final class Canary implements Tool { } } + private static final int USAGE_EXIT_CODE = 1; + private static final int INIT_ERROR_EXIT_CODE = 2; + private static final int ERROR_EXIT_CODE = 3; private static final long DEFAULT_INTERVAL = 6000; @@ -230,6 +233,9 @@ public final class Canary implements Tool { monitor = this.newMonitor(index, args); monitorThread = new Thread(monitor); startTime = System.currentTimeMillis(); + if (this.failOnError && monitor.hasError()) { + System.exit(INIT_ERROR_EXIT_CODE); + } monitorThread.start(); while (!monitor.isDone()) { // wait for 1 sec @@ -237,7 +243,7 @@ public final class Canary implements Tool { // exit if any error occurs if (this.failOnError && monitor.hasError()) { monitorThread.interrupt(); - System.exit(1); + System.exit(ERROR_EXIT_CODE); } currentTimeLength = System.currentTimeMillis() - startTime; if (currentTimeLength > this.timeout) { @@ -252,13 +258,13 @@ public final class Canary implements Tool { if (this.failOnError && monitor.hasError()) { monitorThread.interrupt(); - System.exit(1); + System.exit(ERROR_EXIT_CODE); } Thread.sleep(interval); } while (interval > 0); - return(monitor.hasError()? 1: 0); + return(monitor.hasError()? ERROR_EXIT_CODE: 0); } private void printUsageAndExit() { @@ -276,7 +282,7 @@ public final class Canary implements Tool { System.err.println(" -f stop whole program if first error occurs," + " default is true"); System.err.println(" -t timeout for a check, default is 600000 (milisecs)"); - System.exit(1); + System.exit(USAGE_EXIT_CODE); } /** -- 1.8.3.4 (Apple Git-47)