HDFS-7340. Make rollingUpgrade start/finalize idempotent. Contributed by Jing Zhao.
This commit is contained in:
parent
ff361e7c31
commit
f354b0fe88
|
@ -714,6 +714,8 @@ Release 2.6.0 - UNRELEASED
|
||||||
HDFS-7147. Update archival storage user documentation.
|
HDFS-7147. Update archival storage user documentation.
|
||||||
(Tsz Wo Nicholas Sze via wheat9)
|
(Tsz Wo Nicholas Sze via wheat9)
|
||||||
|
|
||||||
|
HDFS-7340. Make rollingUpgrade start/finalize idempotent. (jing9)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HDFS-6387. HDFS CLI admin tool for creating & deleting an
|
HDFS-6387. HDFS CLI admin tool for creating & deleting an
|
||||||
|
|
|
@ -8282,6 +8282,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
if (isRollingUpgrade()) {
|
||||||
|
return rollingUpgradeInfo;
|
||||||
|
}
|
||||||
long startTime = now();
|
long startTime = now();
|
||||||
if (!haEnabled) { // for non-HA, we require NN to be in safemode
|
if (!haEnabled) { // for non-HA, we require NN to be in safemode
|
||||||
startRollingUpgradeInternalForNonHA(startTime);
|
startRollingUpgradeInternalForNonHA(startTime);
|
||||||
|
@ -8390,13 +8393,16 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RollingUpgradeInfo finalizeRollingUpgrade() throws IOException {
|
void finalizeRollingUpgrade() throws IOException {
|
||||||
checkSuperuserPrivilege();
|
checkSuperuserPrivilege();
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
writeLock();
|
writeLock();
|
||||||
final RollingUpgradeInfo returnInfo;
|
final RollingUpgradeInfo returnInfo;
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
|
if (!isRollingUpgrade()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
checkNameNodeSafeMode("Failed to finalize rolling upgrade");
|
checkNameNodeSafeMode("Failed to finalize rolling upgrade");
|
||||||
|
|
||||||
returnInfo = finalizeRollingUpgradeInternal(now());
|
returnInfo = finalizeRollingUpgradeInternal(now());
|
||||||
|
@ -8420,16 +8426,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
|
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
|
||||||
logAuditEvent(true, "finalizeRollingUpgrade", null, null, null);
|
logAuditEvent(true, "finalizeRollingUpgrade", null, null, null);
|
||||||
}
|
}
|
||||||
return returnInfo;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RollingUpgradeInfo finalizeRollingUpgradeInternal(long finalizeTime)
|
RollingUpgradeInfo finalizeRollingUpgradeInternal(long finalizeTime)
|
||||||
throws RollingUpgradeException {
|
throws RollingUpgradeException {
|
||||||
if (!isRollingUpgrade()) {
|
|
||||||
throw new RollingUpgradeException(
|
|
||||||
"Failed to finalize rolling upgrade since there is no rolling upgrade in progress.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final long startTime = rollingUpgradeInfo.getStartTime();
|
final long startTime = rollingUpgradeInfo.getStartTime();
|
||||||
rollingUpgradeInfo = null;
|
rollingUpgradeInfo = null;
|
||||||
return new RollingUpgradeInfo(blockPoolId, false, startTime, finalizeTime);
|
return new RollingUpgradeInfo(blockPoolId, false, startTime, finalizeTime);
|
||||||
|
|
|
@ -954,7 +954,8 @@ class NameNodeRpcServer implements NamenodeProtocols {
|
||||||
case PREPARE:
|
case PREPARE:
|
||||||
return namesystem.startRollingUpgrade();
|
return namesystem.startRollingUpgrade();
|
||||||
case FINALIZE:
|
case FINALIZE:
|
||||||
return namesystem.finalizeRollingUpgrade();
|
namesystem.finalizeRollingUpgrade();
|
||||||
|
return null;
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedActionException(action + " is not yet supported.");
|
throw new UnsupportedActionException(action + " is not yet supported.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,8 @@ public class DFSAdmin extends FsShell {
|
||||||
out.println(info);
|
out.println(info);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out.println("There is no rolling upgrade in progress.");
|
out.println("There is no rolling upgrade in progress or rolling " +
|
||||||
|
"upgrade has already been finalized.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +354,7 @@ public class DFSAdmin extends FsShell {
|
||||||
Preconditions.checkState(info.isStarted());
|
Preconditions.checkState(info.isStarted());
|
||||||
break;
|
break;
|
||||||
case FINALIZE:
|
case FINALIZE:
|
||||||
Preconditions.checkState(info.isFinalized());
|
Preconditions.checkState(info == null || info.isFinalized());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printMessage(info, System.out);
|
printMessage(info, System.out);
|
||||||
|
|
|
@ -239,9 +239,9 @@ public class TestRollingUpgrade {
|
||||||
Assert.assertTrue(dfs2.exists(baz));
|
Assert.assertTrue(dfs2.exists(baz));
|
||||||
|
|
||||||
//finalize rolling upgrade
|
//finalize rolling upgrade
|
||||||
final RollingUpgradeInfo finalize = dfs2.rollingUpgrade(RollingUpgradeAction.FINALIZE);
|
final RollingUpgradeInfo finalize = dfs2.rollingUpgrade(
|
||||||
LOG.info("FINALIZE: " + finalize);
|
RollingUpgradeAction.FINALIZE);
|
||||||
Assert.assertEquals(info1.getStartTime(), finalize.getStartTime());
|
Assert.assertNull(finalize);
|
||||||
|
|
||||||
LOG.info("RESTART cluster 2 with regular startup option");
|
LOG.info("RESTART cluster 2 with regular startup option");
|
||||||
cluster2.getNameNodeInfos()[0].setStartOpt(StartupOption.REGULAR);
|
cluster2.getNameNodeInfos()[0].setStartOpt(StartupOption.REGULAR);
|
||||||
|
@ -385,7 +385,7 @@ public class TestRollingUpgrade {
|
||||||
Assert.assertTrue(fsimage.hasRollbackFSImage());
|
Assert.assertTrue(fsimage.hasRollbackFSImage());
|
||||||
|
|
||||||
info = dfs.rollingUpgrade(RollingUpgradeAction.FINALIZE);
|
info = dfs.rollingUpgrade(RollingUpgradeAction.FINALIZE);
|
||||||
Assert.assertTrue(info.isFinalized());
|
Assert.assertNull(info);
|
||||||
Assert.assertTrue(dfs.exists(foo));
|
Assert.assertTrue(dfs.exists(foo));
|
||||||
|
|
||||||
// Once finalized, there should be no more fsimage for rollbacks.
|
// Once finalized, there should be no more fsimage for rollbacks.
|
||||||
|
|
Loading…
Reference in New Issue