Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 143B0E54A for ; Wed, 27 Feb 2013 20:15:23 +0000 (UTC) Received: (qmail 44016 invoked by uid 500); 27 Feb 2013 20:15:23 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 43928 invoked by uid 500); 27 Feb 2013 20:15:22 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 43921 invoked by uid 99); 27 Feb 2013 20:15:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 20:15:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 20:15:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 722CF2388980; Wed, 27 Feb 2013 20:15:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1450947 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/HealthChecker.java main/java/org/apache/hadoop/hbase/HealthReport.java test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java Date: Wed, 27 Feb 2013 20:15:02 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130227201502.722CF2388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stack Date: Wed Feb 27 20:15:01 2013 New Revision: 1450947 URL: http://svn.apache.org/r1450947 Log: HBASE-7951 TestNodeHealthCheckChore.testHealthChecker failed 0.95 build #3 Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthChecker.java hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthReport.java hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthChecker.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthChecker.java?rev=1450947&r1=1450946&r2=1450947&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthChecker.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthChecker.java Wed Feb 27 20:15:01 2013 @@ -65,12 +65,13 @@ class HealthChecker { execScript.add(healthCheckScript); this.shexec = new ShellCommandExecutor(execScript.toArray(new String[execScript.size()]), null, null, scriptTimeout); - LOG.info("HealthChecker initialized."); + LOG.info("HealthChecker initialized with script at " + this.healthCheckScript); } public HealthReport checkHealth() { HealthCheckerExitStatus status = HealthCheckerExitStatus.SUCCESS; try { + // Calling this execute leaves around running executor threads. shexec.execute(); } catch (ExitCodeException e) { // ignore the exit code of the script Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthReport.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthReport.java?rev=1450947&r1=1450946&r2=1450947&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthReport.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HealthReport.java Wed Feb 27 20:15:01 2013 @@ -42,6 +42,11 @@ class HealthReport { return status; } + @Override + public String toString() { + return this.status + " " + this.healthReport; + } + /** * Gets the health report of the region server. * @@ -84,5 +89,4 @@ class HealthReport { } return true; } - -} +} \ No newline at end of file Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java?rev=1450947&r1=1450946&r2=1450947&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNodeHealthCheckChore.java Wed Feb 27 20:15:01 2013 @@ -54,7 +54,7 @@ public class TestNodeHealthCheckChore { Path testDir = UTIL.getDataTestDir(); FileSystem fs = UTIL.getTestFileSystem(); fs.delete(testDir, true); - fs.mkdirs(testDir); + if (!fs.mkdirs(testDir)) throw new IOException("Failed mkdir " + testDir); } @Test @@ -62,30 +62,30 @@ public class TestNodeHealthCheckChore { Configuration config = getConfForNodeHealthScript(); config.addResource(healthScriptFile.getName()); String location = healthScriptFile.getAbsolutePath(); - long timeout = config.getLong(HConstants.HEALTH_SCRIPT_TIMEOUT, 200); - + long timeout = config.getLong(HConstants.HEALTH_SCRIPT_TIMEOUT, 2000); HealthChecker checker = new HealthChecker(); checker.init(location, timeout); String normalScript = "echo \"I am all fine\""; createScript(normalScript, true); HealthReport report = checker.checkHealth(); + + LOG.info("Health Status:" + report.getHealthReport()); assertEquals(HealthCheckerExitStatus.SUCCESS, report.getStatus()); - LOG.info("Health Status:" + checker); String errorScript = "echo ERROR\n echo \"Server not healthy\""; createScript(errorScript, true); report = checker.checkHealth(); - assertEquals(HealthCheckerExitStatus.FAILED, report.getStatus()); LOG.info("Health Status:" + report.getHealthReport()); + assertEquals(HealthCheckerExitStatus.FAILED, report.getStatus()); String timeOutScript = "sleep 4\n echo\"I am fine\""; createScript(timeOutScript, true); report = checker.checkHealth(); - assertEquals(HealthCheckerExitStatus.TIMED_OUT, report.getStatus()); LOG.info("Health Status:" + report.getHealthReport()); + assertEquals(HealthCheckerExitStatus.TIMED_OUT, report.getStatus()); - healthScriptFile.delete(); + this.healthScriptFile.delete(); } @Test @@ -95,31 +95,46 @@ public class TestNodeHealthCheckChore { String errorScript = "echo ERROR\n echo \"Server not healthy\""; createScript(errorScript, true); HealthCheckChore rsChore = new HealthCheckChore(100, stop, conf); - //Default threshold is three. - rsChore.chore(); - rsChore.chore(); - assertFalse("Stoppable must not be stopped.", stop.isStopped()); - rsChore.chore(); - assertTrue("Stoppable must have been stopped.", stop.isStopped()); + try { + //Default threshold is three. + rsChore.chore(); + rsChore.chore(); + assertFalse("Stoppable must not be stopped.", stop.isStopped()); + rsChore.chore(); + assertTrue("Stoppable must have been stopped.", stop.isStopped()); + } finally { + stop.stop("Finished w/ test"); + } } private void createScript(String scriptStr, boolean setExecutable) throws Exception { - healthScriptFile.createNewFile(); + if (!this.healthScriptFile.exists()) { + if (!healthScriptFile.createNewFile()) { + throw new IOException("Failed create of " + this.healthScriptFile); + } + } PrintWriter pw = new PrintWriter(new FileOutputStream(healthScriptFile)); - pw.println(scriptStr); - pw.flush(); - pw.close(); + try { + pw.println(scriptStr); + pw.flush(); + } finally { + pw.close(); + } healthScriptFile.setExecutable(setExecutable); + LOG.info("Created " + this.healthScriptFile + ", executable=" + setExecutable); } - private Configuration getConfForNodeHealthScript() { + private Configuration getConfForNodeHealthScript() throws IOException { Configuration conf = UTIL.getConfiguration(); File tempDir = new File(UTIL.getDataTestDir().toString()); - tempDir.mkdirs(); + if (!tempDir.exists()) { + if (!tempDir.mkdirs()) { + throw new IOException("Failed mkdirs " + tempDir); + } + } healthScriptFile = new File(tempDir.getAbsolutePath(), "HealthScript.sh"); - conf.set(HConstants.HEALTH_SCRIPT_LOC, - healthScriptFile.getAbsolutePath()); + conf.set(HConstants.HEALTH_SCRIPT_LOC, healthScriptFile.getAbsolutePath()); conf.setLong(HConstants.HEALTH_FAILURE_THRESHOLD, 3); conf.setLong(HConstants.HEALTH_SCRIPT_TIMEOUT, 200); return conf;