Index: src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHStoreFile.java =================================================================== --- src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHStoreFile.java (revision 582017) +++ src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestHStoreFile.java (working copy) @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.dfs.MiniDFSCluster; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; @@ -39,9 +40,10 @@ */ public class TestHStoreFile extends TestCase { static final Log LOG = LogFactory.getLog(TestHStoreFile.class); - private static String DIR = System.getProperty("test.build.data", "."); + private static String DIR = "/"; private static final char FIRST_CHAR = 'a'; private static final char LAST_CHAR = 'z'; + private MiniDFSCluster cluster; private FileSystem fs; private Configuration conf; private Path dir = null; @@ -51,15 +53,17 @@ public void setUp() throws Exception { super.setUp(); this.conf = new HBaseConfiguration(); - this.fs = FileSystem.getLocal(this.conf); + this.cluster = null; + this.cluster = new MiniDFSCluster(this.conf, 2, true, (String[])null); + this.fs = cluster.getFileSystem(); this.dir = new Path(DIR, getName()); } /** {@inheritDoc} */ @Override public void tearDown() throws Exception { - if (this.fs.exists(this.dir)) { - this.fs.delete(this.dir); + if (this.cluster != null) { + this.cluster.shutdown(); } super.tearDown(); } Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java (revision 582017) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java (working copy) @@ -96,7 +96,7 @@ protected final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final Vector outboundMsgs = new Vector(); - int numRetries; + final int numRetries; protected final int threadWakeFrequency; private final int msgInterval; private final int serverLeaseTimeout; @@ -314,7 +314,7 @@ } } } - + // HLog and HLog roller. log is protected rather than private to avoid // eclipse warning when accessed by inner classes protected HLog log; @@ -472,19 +472,27 @@ // get it when the master is panicing because for instance // the HDFS has been yanked out from under it. Be wary of // this message. - try { - if (checkFileSystem()) { - closeAllRegions(); - restart = true; + if (checkFileSystem()) { + closeAllRegions(); + synchronized (logRollerLock) { + try { + log.closeAndDelete(); + serverInfo.setStartCode(rand.nextLong()); + log = setupHLog(); + } catch (IOException e) { + this.abortRequested = true; + this.stopRequested.set(true); + e = RemoteExceptionHandler.checkIOException(e); + LOG.fatal("error restarting server", e); + break; + } } - } catch (Exception e) { + reportForDuty(); + restart = true; + } else { LOG.fatal("file system available check failed. " + - "Shutting down server.", e); - this.stopRequested.set(true); - this.fsOk = false; - this.abortRequested = true; + "Shutting down server."); } - break; case HMsg.MSG_REGIONSERVER_STOP: @@ -604,7 +612,7 @@ * Run init. Sets up hlog and starts up all server threads. * @param c Extra configuration. */ - private void init(final MapWritable c) { + private void init(final MapWritable c) throws IOException { try { for (Map.Entry e: c.entrySet()) { String key = e.getKey().toString(); @@ -618,18 +626,22 @@ startServiceThreads(); } catch (IOException e) { this.stopRequested.set(true); - LOG.fatal("Failed init", - RemoteExceptionHandler.checkIOException(e)); + e = RemoteExceptionHandler.checkIOException(e); + LOG.fatal("Failed init", e); + IOException ex = new IOException("region server startup failed"); + ex.initCause(e); + throw ex; } } - private HLog setupHLog() - throws RegionServerRunningException, IOException { + private HLog setupHLog() throws RegionServerRunningException, + IOException { + String rootDir = this.conf.get(HConstants.HBASE_DIR); LOG.info("Root dir: " + rootDir); - Path logdir = new Path(new Path(rootDir), - "log" + "_" + getThisIP() + "_" + - this.serverInfo.getServerAddress().getPort()); + Path logdir = new Path(new Path(rootDir), "log" + "_" + getThisIP() + "_" + + this.serverInfo.getStartCode() + "_" + + this.serverInfo.getServerAddress().getPort()); if (LOG.isDebugEnabled()) { LOG.debug("Log dir " + logdir); } @@ -762,6 +774,7 @@ } break; } catch(IOException e) { + LOG.warn("error telling master we are up", e); this.sleeper.sleep(lastMsg); continue; } @@ -1429,4 +1442,4 @@ public static void main(String [] args) { doMain(args, HRegionServer.class); } -} \ No newline at end of file +}