HDFS-6034. Use DataNodeLayoutVersion for DN registration check and do not verify layout version if there is a rolling upgrade in progress.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1573119 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2014-03-01 01:14:02 +00:00
parent ee663fad14
commit c69cc31adc
3 changed files with 27 additions and 7 deletions

View File

@ -127,3 +127,6 @@ HDFS-5535 subtasks:
HDFS-6031. Add back the "-rollingUpgrade started" namenode startup option;
otherwise, namenode cannot start when the layout version is changed.
(szetszwo)
HDFS-6034. Use DataNodeLayoutVersion for DN registration check and do not
verify layout version if there is a rolling upgrade in progress. (szetszwo)

View File

@ -1020,7 +1020,6 @@ public abstract class Storage extends StorageInfo {
public static String getRegistrationID(StorageInfo storage) {
return "NS-" + Integer.toString(storage.getNamespaceID())
+ "-" + storage.getClusterID()
+ "-" + Integer.toString(storage.getLayoutVersion())
+ "-" + Long.toString(storage.getCTime());
}

View File

@ -104,6 +104,7 @@ import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifie
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole;
import org.apache.hadoop.hdfs.server.common.IncorrectVersionException;
import org.apache.hadoop.hdfs.server.datanode.DataNodeLayoutVersion;
import org.apache.hadoop.hdfs.server.namenode.NameNode.OperationCategory;
import org.apache.hadoop.hdfs.server.namenode.metrics.NameNodeMetrics;
import org.apache.hadoop.hdfs.server.namenode.web.resources.NamenodeWebHdfsMethods;
@ -1076,13 +1077,30 @@ class NameNodeRpcServer implements NamenodeProtocols {
* @param nodeReg node registration
* @throws UnregisteredNodeException if the registration is invalid
*/
void verifyRequest(NodeRegistration nodeReg) throws IOException {
if (!namesystem.getRegistrationID().equals(nodeReg.getRegistrationID())) {
LOG.warn("Invalid registrationID - expected: "
+ namesystem.getRegistrationID() + " received: "
+ nodeReg.getRegistrationID());
private void verifyRequest(NodeRegistration nodeReg) throws IOException {
// verify registration ID
final String id = nodeReg.getRegistrationID();
final String expectedID = namesystem.getRegistrationID();
if (!expectedID.equals(id)) {
LOG.warn("Registration IDs mismatched: the "
+ nodeReg.getClass().getSimpleName() + " ID is " + id
+ " but the expected ID is " + expectedID);
throw new UnregisteredNodeException(nodeReg);
}
// verify layout version if there is no rolling upgrade.
if (!namesystem.isRollingUpgrade()) {
final int lv = nodeReg.getVersion();
final int expectedLV = nodeReg instanceof NamenodeRegistration?
NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION
: DataNodeLayoutVersion.CURRENT_LAYOUT_VERSION;
if (expectedLV != nodeReg.getVersion()) {
LOG.warn("Layout versions mismatched: the "
+ nodeReg.getClass().getSimpleName() + " LV is " + lv
+ " but the expected LV is " + expectedLV);
throw new UnregisteredNodeException(nodeReg);
}
}
}
@Override // RefreshAuthorizationPolicyProtocol