HDFS-2679. Add interface to query current state to HAServiceProtocol. Contributed by Eli Collins.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1220612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45e81ae415
commit
329717264f
|
@ -63,3 +63,5 @@ HDFS-2602. NN should log newly-allocated blocks without losing BlockInfo (atm)
|
||||||
HDFS-2667. Fix transition from active to standby (todd)
|
HDFS-2667. Fix transition from active to standby (todd)
|
||||||
|
|
||||||
HDFS-2684. Fix up some failing unit tests on HA branch (todd)
|
HDFS-2684. Fix up some failing unit tests on HA branch (todd)
|
||||||
|
|
||||||
|
HDFS-2679. Add interface to query current state to HAServiceProtocol (eli via todd)
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.HadoopIllegalArgumentException;
|
import org.apache.hadoop.HadoopIllegalArgumentException;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
||||||
import org.apache.hadoop.ha.HealthCheckFailedException;
|
import org.apache.hadoop.ha.HealthCheckFailedException;
|
||||||
import org.apache.hadoop.ha.ServiceFailedException;
|
import org.apache.hadoop.ha.ServiceFailedException;
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
||||||
|
@ -909,6 +910,10 @@ public class NameNode {
|
||||||
state.setState(haContext, STANDBY_STATE);
|
state.setState(haContext, STANDBY_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized HAServiceState getServiceState() {
|
||||||
|
return state.getServiceState();
|
||||||
|
}
|
||||||
|
|
||||||
/** Check if an operation of given category is allowed */
|
/** Check if an operation of given category is allowed */
|
||||||
protected synchronized void checkOperation(final OperationCategory op)
|
protected synchronized void checkOperation(final OperationCategory op)
|
||||||
throws StandbyException {
|
throws StandbyException {
|
||||||
|
|
|
@ -1062,6 +1062,11 @@ class NameNodeRpcServer implements NamenodeProtocols {
|
||||||
nn.transitionToStandby();
|
nn.transitionToStandby();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // HAServiceProtocol
|
||||||
|
public synchronized HAServiceState getServiceState() {
|
||||||
|
return nn.getServiceState();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify version.
|
* Verify version.
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,10 +20,10 @@ package org.apache.hadoop.hdfs.server.namenode.ha;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
||||||
import org.apache.hadoop.ha.ServiceFailedException;
|
import org.apache.hadoop.ha.ServiceFailedException;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.UnsupportedActionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active state of the namenode. In this state, namenode provides the namenode
|
* Active state of the namenode. In this state, namenode provides the namenode
|
||||||
|
@ -33,7 +33,7 @@ import org.apache.hadoop.hdfs.server.namenode.UnsupportedActionException;
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class ActiveState extends HAState {
|
public class ActiveState extends HAState {
|
||||||
public ActiveState() {
|
public ActiveState() {
|
||||||
super("active");
|
super(HAServiceState.ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.hadoop.hdfs.server.namenode.ha;
|
package org.apache.hadoop.hdfs.server.namenode.ha;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
||||||
import org.apache.hadoop.ha.ServiceFailedException;
|
import org.apache.hadoop.ha.ServiceFailedException;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.UnsupportedActionException;
|
import org.apache.hadoop.hdfs.server.namenode.UnsupportedActionException;
|
||||||
|
@ -28,14 +29,21 @@ import org.apache.hadoop.ipc.StandbyException;
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
abstract public class HAState {
|
abstract public class HAState {
|
||||||
protected final String name;
|
protected final HAServiceState state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param name Name of the state.
|
* @param name Name of the state.
|
||||||
*/
|
*/
|
||||||
public HAState(String name) {
|
public HAState(HAServiceState state) {
|
||||||
this.name = name;
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the generic service state
|
||||||
|
*/
|
||||||
|
public HAServiceState getServiceState() {
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,8 +101,10 @@ abstract public class HAState {
|
||||||
public abstract void checkOperation(final HAContext context, final OperationCategory op)
|
public abstract void checkOperation(final HAContext context, final OperationCategory op)
|
||||||
throws StandbyException;
|
throws StandbyException;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @return String representation of the service state.
|
||||||
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString();
|
return state.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.ha.ServiceFailedException;
|
import org.apache.hadoop.ha.ServiceFailedException;
|
||||||
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
|
||||||
import org.apache.hadoop.ipc.StandbyException;
|
import org.apache.hadoop.ipc.StandbyException;
|
||||||
|
@ -39,7 +40,7 @@ import org.apache.hadoop.ipc.StandbyException;
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class StandbyState extends HAState {
|
public class StandbyState extends HAState {
|
||||||
public StandbyState() {
|
public StandbyState() {
|
||||||
super("standby");
|
super(HAServiceState.STANDBY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue