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
This commit is contained in:
Michael Stack 2009-03-29 13:10:49 +00:00
parent a232c6e8f6
commit c150f02537
5 changed files with 17 additions and 49 deletions

View File

@ -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

View File

@ -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 <code>type</code> 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();
}
}

View File

@ -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();
}
}

View File

@ -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

View File

@ -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);