diff --git a/src/main/java/org/apache/hadoop/hbase/HMsg.java b/src/main/java/org/apache/hadoop/hbase/HMsg.java
index c53460f..a141e4b 100644
--- a/src/main/java/org/apache/hadoop/hbase/HMsg.java
+++ b/src/main/java/org/apache/hadoop/hbase/HMsg.java
@@ -38,15 +38,9 @@ import org.apache.hadoop.io.Writable;
* design, these are to go via zk from here on out.
*/
public class HMsg implements Writable {
- public static final HMsg [] STOP_REGIONSERVER_ARRAY =
- new HMsg [] {new HMsg(Type.STOP_REGIONSERVER)};
public static final HMsg [] EMPTY_HMSG_ARRAY = new HMsg[0];
public static enum Type {
- /** Master tells region server to stop.
- */
- STOP_REGIONSERVER,
-
/**
* Region server split the region associated with this message.
*/
diff --git a/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java b/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
index 2e601e1..9502b1d 100644
--- a/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
+++ b/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
@@ -504,7 +504,9 @@ public class HRegionInfo extends VersionedWritable implements WritableComparable
return this.tableDesc.isRootRegion();
}
- /** @return true if this is the meta table */
+ /** @return true if this region is from a table that is a meta table,
+ * either .META. or -ROOT-
+ */
public boolean isMetaTable() {
return this.tableDesc.isMetaTable();
}
diff --git a/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
index 2d27a98..5c8c2ff 100644
--- a/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
+++ b/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
@@ -249,7 +249,9 @@ public class HTableDescriptor implements WritableComparable {
values.put(IS_META_KEY, isMeta? TRUE: FALSE);
}
- /** @return true if table is the meta table */
+ /** @return true if table is a meta table, either .META. or
+ * -ROOT-
+ */
public boolean isMetaTable() {
return isMetaRegion() && !isRootRegion();
}
diff --git a/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index f14a0ed..c999541 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -1832,6 +1832,19 @@ public class AssignmentManager extends ZooKeeperListener {
}
/**
+ * @return True if only catalog tables online.
+ */
+ boolean isCatalogOnly() {
+ synchronized (this.regions) {
+ LOG.info("REGIONS REMOVE " + this.regions.keySet());
+ for (Map.Entry e: this.regions.entrySet()) {
+ if (!e.getKey().isMetaTable()) return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* State of a Region while undergoing transitions.
*/
public static class RegionState implements Writable {
diff --git a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
index 4d921da..e737294 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
@@ -269,11 +269,6 @@ public class ServerManager {
"ready next on next report");
}
- // Check startcodes
- if (raceThatShouldNotHappenAnymore(storedInfo, info)) {
- return HMsg.STOP_REGIONSERVER_ARRAY;
- }
-
for (HMsg msg: msgs) {
LOG.info("Received " + msg + " from " + serverInfo.getServerName());
switch (msg.getType()) {
@@ -288,40 +283,26 @@ public class ServerManager {
}
HMsg [] reply = null;
- int numservers = countOfRegionServers();
if (this.clusterShutdown) {
- if (numservers <= 2) {
+ if (this.services.getAssignmentManager().isCatalogOnly()) {
+ LOG.info("Only catalog regions remaining; running their shutdown now");
+ // The only remaining regions are catalog regions.
// Shutdown needs to be staggered; the meta regions need to close last
- // in case they need to be updated during the close melee. If <= 2
- // servers left, then these are the two that were carrying root and meta
- // most likely (TODO: This presumes unsplittable meta -- FIX). Tell
- // these servers can shutdown now too.
- reply = HMsg.STOP_REGIONSERVER_ARRAY;
+ // in case they need to be updated during the close melee. If only
+ // catalog reigons remaining, tell them they can go down now too. On
+ // close of region, the regionservers should then shut themselves down.
+ Map> assignments =
+ this.services.getAssignmentManager().getAssignments();
+ for (Map.Entry> e: assignments.entrySet()) {
+ for (HRegionInfo hri: e.getValue()) {
+ this.services.getAssignmentManager().unassign(hri);
+ }
+ }
}
}
return processRegionServerAllsWell(info, mostLoadedRegions, reply);
}
- private boolean raceThatShouldNotHappenAnymore(final HServerInfo storedInfo,
- final HServerInfo reportedInfo) {
- if (storedInfo.getStartCode() != reportedInfo.getStartCode()) {
- // TODO: I don't think this possible any more. We check startcodes when
- // server comes in on regionServerStartup -- St.Ack
- // This state is reachable if:
- // 1) RegionServer A started
- // 2) RegionServer B started on the same machine, then clobbered A in regionServerStartup.
- // 3) RegionServer A returns, expecting to work as usual.
- // The answer is to ask A to shut down for good.
- LOG.warn("Race condition detected: " + reportedInfo.getServerName());
- synchronized (this.onlineServers) {
- removeServerInfo(reportedInfo.getServerName());
- notifyOnlineServers();
- }
- return true;
- }
- return false;
- }
-
/**
* RegionServer is checking in, no exceptional circumstances
* @param serverInfo
diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 22c9b3c..e27decc 100644
--- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -741,16 +741,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
}
updateOutboundMsgs(outboundMessages);
outboundMessages.clear();
-
- for (int i = 0; !this.stopped && msgs != null && i < msgs.length; i++) {
- LOG.info(msgs[i].toString());
- // Intercept stop regionserver messages
- if (msgs[i].getType().equals(HMsg.Type.STOP_REGIONSERVER)) {
- stop("Received " + msgs[i]);
- continue;
- }
- LOG.warn("NOT PROCESSING " + msgs[i] + " -- WHY IS MASTER SENDING IT TO US?");
- }
return outboundMessages;
}
diff --git a/src/test/java/org/apache/hadoop/hbase/TestHMsg.java b/src/test/java/org/apache/hadoop/hbase/TestHMsg.java
deleted file mode 100644
index b55956f..0000000
--- a/src/test/java/org/apache/hadoop/hbase/TestHMsg.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright 2009 The Apache Software Foundation
- *
- * 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;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.Writables;
-
-public class TestHMsg extends TestCase {
- public void testList() {
- List msgs = new ArrayList();
- HMsg hmsg = null;
- final int size = 10;
- for (int i = 0; i < size; i++) {
- byte [] b = Bytes.toBytes(i);
- hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
- msgs.add(hmsg);
- }
- assertEquals(size, msgs.size());
- int index = msgs.indexOf(hmsg);
- assertNotSame(-1, index);
- msgs.remove(index);
- assertEquals(size - 1, msgs.size());
- byte [] other = Bytes.toBytes("other");
- hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), other, other));
- assertEquals(-1, msgs.indexOf(hmsg));
- // Assert that two HMsgs are same if same content.
- byte [] b = Bytes.toBytes(1);
- hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
- assertNotSame(-1, msgs.indexOf(hmsg));
- }
-
- public void testSerialization() throws IOException {
- // Check out new HMsg that carries two daughter split regions.
- byte [] abytes = Bytes.toBytes("a");
- byte [] bbytes = Bytes.toBytes("b");
- byte [] parentbytes = Bytes.toBytes("parent");
- HRegionInfo parent =
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("parent")),
- parentbytes, parentbytes);
- // Assert simple HMsg serializes
- HMsg hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER, parent);
- byte [] bytes = Writables.getBytes(hmsg);
- HMsg close = (HMsg)Writables.getWritable(bytes, new HMsg());
- assertTrue(close.equals(hmsg));
- // Assert split serializes
- HRegionInfo daughtera =
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("a")), abytes, abytes);
- HRegionInfo daughterb =
- new HRegionInfo(new HTableDescriptor(Bytes.toBytes("b")), bbytes, bbytes);
- HMsg splithmsg = new HMsg(HMsg.Type.REGION_SPLIT,
- parent, daughtera, daughterb, Bytes.toBytes("REGION_SPLIT"));
- bytes = Writables.getBytes(splithmsg);
- hmsg = (HMsg)Writables.getWritable(bytes, new HMsg());
- assertTrue(splithmsg.equals(hmsg));
- }
-}
diff --git a/src/test/java/org/apache/hadoop/hbase/TestSerialization.java b/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
index befcdaf..da1d5a7 100644
--- a/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
+++ b/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
@@ -84,21 +84,6 @@ public class TestSerialization {
assertTrue(Bytes.equals("value".getBytes(), hmw.get("key".getBytes())));
}
- @Test public void testHMsg() throws Exception {
- final String name = "testHMsg";
- HMsg m = new HMsg(HMsg.Type.STOP_REGIONSERVER);
- byte [] mb = Writables.getBytes(m);
- HMsg deserializedHMsg = (HMsg)Writables.getWritable(mb, new HMsg());
- assertTrue(m.equals(deserializedHMsg));
- m = new HMsg(HMsg.Type.STOP_REGIONSERVER,
- new HRegionInfo(new HTableDescriptor(name),
- HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY),
- "Some message".getBytes());
- mb = Writables.getBytes(m);
- deserializedHMsg = (HMsg)Writables.getWritable(mb, new HMsg());
- assertTrue(m.equals(deserializedHMsg));
- }
-
@Test public void testTableDescriptor() throws Exception {
final String name = "testTableDescriptor";
HTableDescriptor htd = createTableDescriptor(name);