HDFS-2922. HA: close out operation categories. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1292620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-02-23 02:08:54 +00:00
parent 90a14f89e1
commit 8db31c5972
5 changed files with 27 additions and 20 deletions

View File

@ -226,3 +226,5 @@ HDFS-2929. Stress test and fixes for block synchronization (todd)
HDFS-2972. Small optimization building incremental block report (todd) HDFS-2972. Small optimization building incremental block report (todd)
HDFS-2973. Re-enable NO_ACK optimization for block deletion. (todd) HDFS-2973. Re-enable NO_ACK optimization for block deletion. (todd)
HDFS-2922. HA: close out operation categories (eli)

View File

@ -407,6 +407,9 @@ public class BackupNode extends NameNode {
@Override // NameNode @Override // NameNode
public void checkOperation(OperationCategory op) public void checkOperation(OperationCategory op)
throws StandbyException { throws StandbyException {
if (op == OperationCategory.UNCHECKED) {
return;
}
if (OperationCategory.JOURNAL != op && if (OperationCategory.JOURNAL != op &&
!(OperationCategory.READ == op && allowStaleStandbyReads)) { !(OperationCategory.READ == op && allowStaleStandbyReads)) {
String msg = "Operation category " + op String msg = "Operation category " + op

View File

@ -114,6 +114,8 @@ public class NameNode {
* Categories of operations supported by the namenode. * Categories of operations supported by the namenode.
*/ */
public static enum OperationCategory { public static enum OperationCategory {
/** Operations that are state agnostic */
UNCHECKED,
/** Read operation that does not change the namespace state */ /** Read operation that does not change the namespace state */
READ, READ,
/** Write operation that changes the namespace state */ /** Write operation that changes the namespace state */

View File

@ -353,9 +353,7 @@ class NameNodeRpcServer implements NamenodeProtocols {
public void errorReport(NamenodeRegistration registration, public void errorReport(NamenodeRegistration registration,
int errorCode, int errorCode,
String msg) throws IOException { String msg) throws IOException {
// nn.checkOperation(OperationCategory.WRITE); namesystem.checkOperation(OperationCategory.UNCHECKED);
// TODO: I dont think this should be checked - it's just for logging
// and dropping backups
verifyRequest(registration); verifyRequest(registration);
LOG.info("Error report from " + registration + ": " + msg); LOG.info("Error report from " + registration + ": " + msg);
if(errorCode == FATAL) if(errorCode == FATAL)
@ -707,8 +705,8 @@ class NameNodeRpcServer implements NamenodeProtocols {
@Override // ClientProtocol @Override // ClientProtocol
public DatanodeInfo[] getDatanodeReport(DatanodeReportType type) public DatanodeInfo[] getDatanodeReport(DatanodeReportType type)
throws IOException { throws IOException {
// TODO(HA): decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
DatanodeInfo results[] = namesystem.datanodeReport(type); DatanodeInfo results[] = namesystem.datanodeReport(type);
if (results == null ) { if (results == null ) {
throw new IOException("Cannot find datanode report"); throw new IOException("Cannot find datanode report");
@ -718,32 +716,32 @@ class NameNodeRpcServer implements NamenodeProtocols {
@Override // ClientProtocol @Override // ClientProtocol
public boolean setSafeMode(SafeModeAction action) throws IOException { public boolean setSafeMode(SafeModeAction action) throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
return namesystem.setSafeMode(action); return namesystem.setSafeMode(action);
} }
@Override // ClientProtocol @Override // ClientProtocol
public boolean restoreFailedStorage(String arg) public boolean restoreFailedStorage(String arg) throws IOException {
throws AccessControlException { namesystem.checkOperation(OperationCategory.UNCHECKED);
// TODO:HA decide on OperationCategory for this
return namesystem.restoreFailedStorage(arg); return namesystem.restoreFailedStorage(arg);
} }
@Override // ClientProtocol @Override // ClientProtocol
public void saveNamespace() throws IOException { public void saveNamespace() throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.saveNamespace(); namesystem.saveNamespace();
} }
@Override // ClientProtocol @Override // ClientProtocol
public void refreshNodes() throws IOException { public void refreshNodes() throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.getBlockManager().getDatanodeManager().refreshNodes( namesystem.getBlockManager().getDatanodeManager().refreshNodes(
new HdfsConfiguration()); new HdfsConfiguration());
} }
@Override // NamenodeProtocol @Override // NamenodeProtocol
public long getTransactionID() { public long getTransactionID() throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.CHECKPOINT);
return namesystem.getEditLog().getSyncTxId(); return namesystem.getEditLog().getSyncTxId();
} }
@ -755,28 +753,29 @@ class NameNodeRpcServer implements NamenodeProtocols {
@Override // NamenodeProtocol @Override // NamenodeProtocol
public RemoteEditLogManifest getEditLogManifest(long sinceTxId) public RemoteEditLogManifest getEditLogManifest(long sinceTxId)
throws IOException { throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.READ);
return namesystem.getEditLog().getEditLogManifest(sinceTxId); return namesystem.getEditLog().getEditLogManifest(sinceTxId);
} }
@Override // ClientProtocol @Override // ClientProtocol
public void finalizeUpgrade() throws IOException { public void finalizeUpgrade() throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.WRITE);
namesystem.finalizeUpgrade(); namesystem.finalizeUpgrade();
} }
@Override // ClientProtocol @Override // ClientProtocol
public UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action) public UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action)
throws IOException { throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.READ);
return namesystem.distributedUpgradeProgress(action); return namesystem.distributedUpgradeProgress(action);
} }
@Override // ClientProtocol @Override // ClientProtocol
public void metaSave(String filename) throws IOException { public void metaSave(String filename) throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.metaSave(filename); namesystem.metaSave(filename);
} }
@Override // ClientProtocol @Override // ClientProtocol
public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie)
throws IOException { throws IOException {
@ -795,12 +794,12 @@ class NameNodeRpcServer implements NamenodeProtocols {
/** /**
* Tell all datanodes to use a new, non-persistent bandwidth value for * Tell all datanodes to use a new, non-persistent bandwidth value for
* dfs.datanode.balance.bandwidthPerSec. * dfs.datanode.balance.bandwidthPerSec.
* @param bandwidth Blanacer bandwidth in bytes per second for all datanodes. * @param bandwidth Balancer bandwidth in bytes per second for all datanodes.
* @throws IOException * @throws IOException
*/ */
@Override // ClientProtocol @Override // ClientProtocol
public void setBalancerBandwidth(long bandwidth) throws IOException { public void setBalancerBandwidth(long bandwidth) throws IOException {
// TODO:HA decide on OperationCategory for this namesystem.checkOperation(OperationCategory.UNCHECKED);
namesystem.getBlockManager().getDatanodeManager().setBalancerBandwidth(bandwidth); namesystem.getBlockManager().getDatanodeManager().setBalancerBandwidth(bandwidth);
} }

View File

@ -78,7 +78,8 @@ public class StandbyState extends HAState {
@Override @Override
public void checkOperation(HAContext context, OperationCategory op) public void checkOperation(HAContext context, OperationCategory op)
throws StandbyException { throws StandbyException {
if (op == OperationCategory.READ && context.allowStaleReads()) { if (op == OperationCategory.UNCHECKED ||
(op == OperationCategory.READ && context.allowStaleReads())) {
return; return;
} }
String msg = "Operation category " + op + " is not supported in state " String msg = "Operation category " + op + " is not supported in state "