HDFS-2671. NN should throw StandbyException in response to RPCs in STANDBY state. Contributed by Todd Lipcon.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1214117 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5a658e7a4
commit
7e8accd68e
@ -49,3 +49,5 @@ HDFS-2625. TestDfsOverAvroRpc failing after introduction of HeartbeatResponse ty
|
||||
HDFS-2627. Determine DN's view of which NN is active based on heartbeat responses (todd)
|
||||
|
||||
HDFS-2634. Standby needs to ingest latest edit logs before transitioning to active (todd)
|
||||
|
||||
HDFS-2671. NN should throw StandbyException in response to RPCs in STANDBY state (todd)
|
||||
|
@ -43,6 +43,7 @@
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||
import org.apache.hadoop.ipc.RPC;
|
||||
import org.apache.hadoop.ipc.StandbyException;
|
||||
import org.apache.hadoop.net.NetUtils;
|
||||
|
||||
import com.google.protobuf.BlockingService;
|
||||
@ -397,11 +398,11 @@ String getClusterId() {
|
||||
|
||||
@Override // NameNode
|
||||
protected void checkOperation(OperationCategory op)
|
||||
throws UnsupportedActionException {
|
||||
throws StandbyException {
|
||||
if (OperationCategory.JOURNAL != op) {
|
||||
String msg = "Operation category " + op
|
||||
+ " is not supported at the BackupNode";
|
||||
throw new UnsupportedActionException(msg);
|
||||
throw new StandbyException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration;
|
||||
import org.apache.hadoop.ipc.StandbyException;
|
||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||
import org.apache.hadoop.net.NetUtils;
|
||||
import org.apache.hadoop.security.RefreshUserMappingsProtocol;
|
||||
@ -910,7 +911,7 @@ synchronized void transitionToStandby() throws ServiceFailedException {
|
||||
|
||||
/** Check if an operation of given category is allowed */
|
||||
protected synchronized void checkOperation(final OperationCategory op)
|
||||
throws UnsupportedActionException {
|
||||
throws StandbyException {
|
||||
state.checkOperation(haContext, op);
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,7 @@ public ActiveState() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkOperation(HAContext context, OperationCategory op)
|
||||
throws UnsupportedActionException {
|
||||
public void checkOperation(HAContext context, OperationCategory op) {
|
||||
return; // Other than journal all operations are allowed in active state
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
import org.apache.hadoop.ha.ServiceFailedException;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||
import org.apache.hadoop.hdfs.server.namenode.UnsupportedActionException;
|
||||
import org.apache.hadoop.ipc.StandbyException;
|
||||
|
||||
/**
|
||||
* Namenode base state to implement state machine pattern.
|
||||
@ -89,12 +90,8 @@ public void setState(HAContext context, HAState s) throws ServiceFailedException
|
||||
* @throws UnsupportedActionException if a given type of operation is not
|
||||
* supported in this state.
|
||||
*/
|
||||
public void checkOperation(final HAContext context, final OperationCategory op)
|
||||
throws UnsupportedActionException {
|
||||
String msg = "Operation category " + op + " is not supported in state "
|
||||
+ context.getState();
|
||||
throw new UnsupportedActionException(msg);
|
||||
}
|
||||
public abstract void checkOperation(final HAContext context, final OperationCategory op)
|
||||
throws StandbyException;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -22,6 +22,8 @@
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.ha.ServiceFailedException;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||
import org.apache.hadoop.ipc.StandbyException;
|
||||
|
||||
/**
|
||||
* Namenode standby state. In this state the namenode acts as warm standby and
|
||||
@ -66,5 +68,13 @@ public void exitState(HAContext context) throws ServiceFailedException {
|
||||
throw new ServiceFailedException("Failed to stop standby services", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkOperation(HAContext context, OperationCategory op)
|
||||
throws StandbyException {
|
||||
String msg = "Operation category " + op + " is not supported in state "
|
||||
+ context.getState();
|
||||
throw new StandbyException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user