hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1530499 - in /hbase/branches/0.96/hbase-server/src: main/java/org/apache/hadoop/hbase/ZNodeClearer.java test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java
Date Wed, 09 Oct 2013 05:53:33 GMT
Author: stack
Date: Wed Oct  9 05:53:33 2013
New Revision: 1530499

URL: http://svn.apache.org/r1530499
Log:
HBASE-9563 Autorestart doesn't work if zkcleaner fails

Added:
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java
Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java?rev=1530499&r1=1530498&r2=1530499&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java
Wed Oct  9 05:53:33 2013
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.zookeeper
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -90,7 +91,7 @@ public class ZNodeClearer {
   public static String readMyEphemeralNodeOnDisk() throws IOException {
     String fileName = getMyEphemeralNodeFileName();
     if (fileName == null){
-      throw new IOException("No filename");
+      throw new FileNotFoundException("No filename; set environment variable HBASE_ZNODE_FILE");
     }
     FileReader znodeFile = new FileReader(fileName);
     BufferedReader br = new BufferedReader(znodeFile);
@@ -141,9 +142,15 @@ public class ZNodeClearer {
     String znodeFileContent;
     try {
       znodeFileContent = ZNodeClearer.readMyEphemeralNodeOnDisk();
+    } catch (FileNotFoundException fnfe) {
+      // If no file, just keep going -- return success.
+      LOG.warn("Can't find the znode file; presume non-fatal", fnfe);
+      return true;
     } catch (IOException e) {
       LOG.warn("Can't read the content of the znode file", e);
       return false;
+    } finally {
+      zkw.close();
     }
 
     return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);

Added: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java?rev=1530499&view=auto
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java
(added)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterCommandLine.java
Wed Oct  9 05:53:33 2013
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.master;
+
+import static org.junit.Assert.*;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.junit.Test;
+
+public class TestHMasterCommandLine {
+  private static final HBaseTestingUtility TESTING_UTIL = new HBaseTestingUtility();
+  @Test
+  public void testRun() throws Exception {
+    HMasterCommandLine masterCommandLine = new HMasterCommandLine(HMaster.class);
+    masterCommandLine.setConf(TESTING_UTIL.getConfiguration());
+    assertEquals(0, masterCommandLine.run(new String [] {"clear"}));
+  }
+}
\ No newline at end of file



Mime
View raw message