From c150f02537baf81282877b483b5f4c59477ac74b Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sun, 29 Mar 2009 13:10:49 +0000 Subject: [PATCH] HBASE-1150 HMsg carries safemode flag; remove git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@759676 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/java/org/apache/hadoop/hbase/HMsg.java | 49 ++++--------------- .../hadoop/hbase/master/RegionManager.java | 8 +-- .../hadoop/hbase/master/ServerManager.java | 6 +-- .../hbase/regionserver/HRegionServer.java | 2 +- 5 files changed, 17 insertions(+), 49 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 2456349ee30..d182181e9a2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -65,6 +65,7 @@ Release 0.20.0 - Unreleased Rawson via Andrew Purtell) HBASE-1293 hfile doesn't recycle decompressors (Ryan Rawson via Andrew Purtell) + HBASE-1150 HMsg carries safemode flag; remove (Nitay Joffe via Stack) IMPROVEMENTS HBASE-1089 Add count of regions on filesystem to master UI; add percentage diff --git a/src/java/org/apache/hadoop/hbase/HMsg.java b/src/java/org/apache/hadoop/hbase/HMsg.java index a35309b71f4..ec14665e35c 100644 --- a/src/java/org/apache/hadoop/hbase/HMsg.java +++ b/src/java/org/apache/hadoop/hbase/HMsg.java @@ -19,7 +19,6 @@ */ package org.apache.hadoop.hbase; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -114,7 +113,6 @@ public class HMsg implements Writable { private Type type = null; private HRegionInfo info = null; private byte[] message = null; - private boolean safeMode = false; /** Default constructor. Used during deserialization */ public HMsg() { @@ -126,7 +124,7 @@ public class HMsg implements Writable { * @param type Message type */ public HMsg(final HMsg.Type type) { - this(type, new HRegionInfo(), null, false); + this(type, new HRegionInfo(), null); } /** @@ -135,22 +133,9 @@ public class HMsg implements Writable { * @param hri Region to which message type applies */ public HMsg(final HMsg.Type type, final HRegionInfo hri) { - this(type, hri, null, false); + this(type, hri, null); } - - /** - * Constructor used by master to inform region servers if we are still in - * safe mode. - * - * @param type - * @param hri - * @param safeMode - */ - public HMsg(final HMsg.Type type, final HRegionInfo hri, - final boolean safeMode) { - this(type, hri, null, safeMode); - } - + /** * Construct a message with the specified message and HRegionInfo * @@ -160,19 +145,6 @@ public class HMsg implements Writable { * @param msg Optional message (Stringified exception, etc.) */ public HMsg(final HMsg.Type type, final HRegionInfo hri, final byte[] msg) { - this(type, hri, msg, false); - } - - /** - * Used by the master to inform region servers if we are still in safe mode - * - * @param type - * @param hri - * @param msg - * @param safemode - */ - public HMsg(final HMsg.Type type, final HRegionInfo hri, final byte[] msg, - final boolean safemode) { if (type == null) { throw new NullPointerException("Message type cannot be null"); } @@ -182,7 +154,6 @@ public class HMsg implements Writable { } this.info = hri; this.message = msg; - this.safeMode = safemode; } /** @@ -209,11 +180,6 @@ public class HMsg implements Writable { public byte[] getMessage() { return this.message; } - - /** @return safe mode */ - public boolean isInSafeMode() { - return this.safeMode; - } /** * @see java.lang.Object#toString() @@ -230,7 +196,6 @@ public class HMsg implements Writable { if (this.message != null && this.message.length > 0) { sb.append(": " + Bytes.toString(this.message)); } - sb.append(": safeMode=" + safeMode); return sb.toString(); } @@ -270,6 +235,9 @@ public class HMsg implements Writable { // Writable ////////////////////////////////////////////////////////////////////////////// + /** + * @see org.apache.hadoop.io.Writable#write(java.io.DataOutput) + */ public void write(DataOutput out) throws IOException { out.writeInt(this.type.ordinal()); this.info.write(out); @@ -279,9 +247,11 @@ public class HMsg implements Writable { out.writeBoolean(true); Bytes.writeByteArray(out, this.message); } - out.writeBoolean(this.safeMode); } + /** + * @see org.apache.hadoop.io.Writable#readFields(java.io.DataInput) + */ public void readFields(DataInput in) throws IOException { int ordinal = in.readInt(); this.type = HMsg.Type.values()[ordinal]; @@ -290,6 +260,5 @@ public class HMsg implements Writable { if (hasMessage) { this.message = Bytes.readByteArray(in); } - this.safeMode = in.readBoolean(); } } diff --git a/src/java/org/apache/hadoop/hbase/master/RegionManager.java b/src/java/org/apache/hadoop/hbase/master/RegionManager.java index 5cb5fd99dbe..11cc8c9b8c6 100644 --- a/src/java/org/apache/hadoop/hbase/master/RegionManager.java +++ b/src/java/org/apache/hadoop/hbase/master/RegionManager.java @@ -287,7 +287,7 @@ class RegionManager implements HConstants { this.historian.addRegionAssignment(s.getRegionInfo(), info.getServerName()); returnMsgs.add( - new HMsg(HMsg.Type.MSG_REGION_OPEN, s.getRegionInfo(), inSafeMode())); + new HMsg(HMsg.Type.MSG_REGION_OPEN, s.getRegionInfo())); if (--nregions <= 0) { break; } @@ -415,7 +415,7 @@ class RegionManager implements HConstants { s.setPendingOpen(info.getServerName()); this.historian.addRegionAssignment(s.getRegionInfo(), info.getServerName()); returnMsgs.add( - new HMsg(HMsg.Type.MSG_REGION_OPEN, s.getRegionInfo(), inSafeMode())); + new HMsg(HMsg.Type.MSG_REGION_OPEN, s.getRegionInfo())); } } @@ -455,7 +455,7 @@ class RegionManager implements HConstants { } // make a message to close the region returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE, currentRegion, - OVERLOADED, inSafeMode())); + OVERLOADED)); // mark the region as closing setClosing(info.getServerName(), currentRegion, false); setPendingClose(regionName); @@ -1129,7 +1129,7 @@ class RegionManager implements HConstants { if (LOG.isDebugEnabled()) { LOG.debug("Sending " + msg + " " + pair.getFirst() + " to " + addr); } - returnMsgs.add(new HMsg(msg, pair.getFirst(), inSafeMode())); + returnMsgs.add(new HMsg(msg, pair.getFirst())); i.remove(); } } diff --git a/src/java/org/apache/hadoop/hbase/master/ServerManager.java b/src/java/org/apache/hadoop/hbase/master/ServerManager.java index 398cedb2a62..890d09d67fb 100644 --- a/src/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/src/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -410,8 +410,7 @@ class ServerManager implements HConstants { // Tell the region server to close regions that we have marked for closing. for (HRegionInfo i: master.regionManager.getMarkedToClose(serverInfo.getServerName())) { - returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE, i, - master.regionManager.inSafeMode())); + returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE, i)); // Transition the region from toClose to closing state master.regionManager.setPendingClose(i.getRegionNameAsString()); } @@ -505,8 +504,7 @@ class ServerManager implements HConstants { // Otherwise the HMaster will think the Region was closed on purpose, // and then try to reopen it elsewhere; that's not what we want. returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE_WITHOUT_REPORT, - region, "Duplicate assignment".getBytes(), - master.regionManager.inSafeMode())); + region, "Duplicate assignment".getBytes())); } else { if (region.isRootRegion()) { // it was assigned, and it's not a duplicate assignment, so take it out diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index b09bf6211d6..1ecc523063a 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -380,7 +380,7 @@ public class HRegionServer implements HConstants, HRegionInterface, HBaseRPCErro i++) { LOG.info(msgs[i].toString()); if (safeMode.get()) { - if (!msgs[i].isInSafeMode()) { + if (zooKeeperWrapper.checkOutOfSafeMode()) { this.connection.unsetRootRegionLocation(); synchronized (safeMode) { safeMode.set(false);