-ROOT- and
+ * return that.
+ * @return {@link ServerName} for server hosting .META. or if null,
+ * we'll read the location that is up in -ROOT- table (which
+ * could be null or just plain stale).
+ * @throws IOException
+ */
+ public HServerAddress getMetaLocationOrReadLocationFromRoot() throws IOException {
+ HServerAddress sn = getMetaLocation();
+ return sn != null? sn: MetaReader.getMetaRegionLocation(this);
+ }
+
/**
* Waits indefinitely for availability of -ROOT-. Used during
* cluster startup.
Index: src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (revision 1230405)
+++ src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (working copy)
@@ -276,6 +276,19 @@
}
/**
+ * Gets the location of .META. region by reading content of
+ * -ROOT-.
+ * @param ct
+ * @return location of .META. region as a {@link ServerName} or
+ * null if not found
+ * @throws IOException
+ */
+ static HServerAddress getMetaRegionLocation(final CatalogTracker ct)
+ throws IOException {
+ return MetaReader.readMetaLocation(ct.waitForRootServerConnectionDefault());
+ }
+
+ /**
* Reads the location of META from ROOT.
* @param metaServer connection to server hosting ROOT
* @return location of META in ROOT, null if not available
Index: src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (revision 1230405)
+++ src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (working copy)
@@ -193,11 +193,13 @@
/**
* Handle failover. Restore state from META and ZK. Handle any regions in
* transition. Presumes .META. and -ROOT- deployed.
+ * @param onlineServers onlined servers when master start
* @throws KeeperException
* @throws IOException
* @throws InterruptedException
*/
- void processFailover() throws KeeperException, IOException, InterruptedException {
+ void processFailover(final Set
* Returns a map of servers that are not found to be online and the regions
* they were hosting.
+ * @param onlineServers if one region's location belongs to onlineServers, it
+ * doesn't need to be assigned
* @return map of servers not online to their assigned regions, as stored
* in META
* @throws IOException
* @throws KeeperException
*/
- private Map-ROOT- and .META. are assigned. If not,
* assign them.
@@ -418,14 +434,19 @@
throws InterruptedException, IOException, KeeperException {
int assigned = 0;
long timeout = this.conf.getLong("hbase.catalog.verification.timeout", 1000);
-
+
// Work on ROOT region. Is it in zk in transition?
- boolean rit = this.assignmentManager.
- processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.ROOT_REGIONINFO);
+ boolean rit = this.assignmentManager
+ .processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.ROOT_REGIONINFO);
if (!catalogTracker.verifyRootRegionLocation(timeout)) {
- this.assignmentManager.assignRoot();
- this.catalogTracker.waitForRoot();
- //This guarantees that the transition has completed
+
+ HServerAddress address = catalogTracker.getRootLocation();
+ if (address == null || !isProcessingServer(address)) {
+ this.assignmentManager.assignRoot();
+ this.catalogTracker.waitForRoot();
+ }
+
+ // This guarantees that the transition has completed
this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO);
assigned++;
}
@@ -433,14 +454,21 @@
", location=" + catalogTracker.getRootLocation());
// Work on meta region
- rit = this.assignmentManager.
- processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO);
+ rit = this.assignmentManager
+ .processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO);
if (!this.catalogTracker.verifyMetaRegionLocation(timeout)) {
- this.assignmentManager.assignMeta();
- this.catalogTracker.waitForMeta();
+
+ HServerAddress address = catalogTracker
+ .getMetaLocationOrReadLocationFromRoot();
+ if (address == null || !isProcessingServer(address)) {
+ this.assignmentManager.assignMeta();
+ this.catalogTracker.waitForMeta();
+ }
+
// Above check waits for general meta availability but this does not
// guarantee that the transition has completed
- this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
+ this.assignmentManager
+ .waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
assigned++;
}
LOG.info(".META. assigned=" + assigned + ", rit=" + rit +
Index: src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (revision 1230405)
+++ src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (working copy)
@@ -20,7 +20,7 @@
package org.apache.hadoop.hbase.master;
import java.io.IOException;
-import java.util.Map;
+import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -155,7 +155,7 @@
* @param onlineServers Map of online servers keyed by
* {@link HServerInfo#getServerName()}
*/
- void splitLogAfterStartup(final Map