From a6675d5f5d4e6adc0b6c0a3d0762fb21a0af7047 Mon Sep 17 00:00:00 2001 From: eclark Date: Mon, 13 Jan 2014 21:51:07 +0000 Subject: [PATCH] HBASE-10315 Canary shouldn't exit with 3 if there is no master running. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1557864 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/tool/Canary.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 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 2a3b229d6c8..72a88764eb7 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 @@ -243,14 +243,22 @@ public final class Canary implements Tool { // exit if any error occurs if (this.failOnError && monitor.hasError()) { monitorThread.interrupt(); - System.exit(monitor.errorCode); + if (monitor.initialized) { + System.exit(monitor.errorCode); + } else { + System.exit(INIT_ERROR_EXIT_CODE); + } } currentTimeLength = System.currentTimeMillis() - startTime; if (currentTimeLength > this.timeout) { LOG.error("The monitor is running too long (" + currentTimeLength + ") after timeout limit:" + this.timeout + " will be killed itself !!"); - monitor.errorCode = TIMEOUT_ERROR_EXIT_CODE; + if (monitor.initialized) { + System.exit(TIMEOUT_ERROR_EXIT_CODE); + } else { + System.exit(INIT_ERROR_EXIT_CODE); + } break; } } @@ -320,6 +328,7 @@ public final class Canary implements Tool { protected HBaseAdmin admin; protected String[] targets; protected boolean useRegExp; + protected boolean initialized = false; protected boolean done = false; protected int errorCode = 0; @@ -376,6 +385,7 @@ public final class Canary implements Tool { try { if (this.targets != null && this.targets.length > 0) { String[] tables = generateMonitorTables(this.targets); + this.initialized = true; for (String table : tables) { Canary.sniff(admin, sink, table); } @@ -556,6 +566,7 @@ public final class Canary implements Tool { public void run() { if (this.initAdmin() && this.checkNoTableNames()) { Map> rsAndRMap = this.filterRegionServerByName(); + this.initialized = true; this.monitorRegionServers(rsAndRMap); } this.done = true;