hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
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 GMT
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;



Mime
View raw message