HDFS-6597. Merging change r1611723 from trunk to branch-2.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1611724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a61f91286f
commit
fcca9666a8
|
@ -46,6 +46,9 @@ Release 2.6.0 - UNRELEASED
|
||||||
HDFS-4120. Add a new "-skipSharedEditsCheck" option for BootstrapStandby
|
HDFS-4120. Add a new "-skipSharedEditsCheck" option for BootstrapStandby
|
||||||
(Liang Xie and Rakesh R via vinayakumarb)
|
(Liang Xie and Rakesh R via vinayakumarb)
|
||||||
|
|
||||||
|
HDFS-6597. Add a new option to NN upgrade to terminate the process after
|
||||||
|
upgrade on NN is completed. (Danilo Vunjak via cnauroth)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-6690. Deduplicate xattr names in memory. (wang)
|
HDFS-6690. Deduplicate xattr names in memory. (wang)
|
||||||
|
|
|
@ -93,7 +93,8 @@ public final class HdfsServerConstants {
|
||||||
FORCE("-force"),
|
FORCE("-force"),
|
||||||
NONINTERACTIVE("-nonInteractive"),
|
NONINTERACTIVE("-nonInteractive"),
|
||||||
RENAMERESERVED("-renameReserved"),
|
RENAMERESERVED("-renameReserved"),
|
||||||
METADATAVERSION("-metadataVersion");
|
METADATAVERSION("-metadataVersion"),
|
||||||
|
UPGRADEONLY("-upgradeOnly");
|
||||||
|
|
||||||
private static final Pattern ENUM_WITH_ROLLING_UPGRADE_OPTION = Pattern.compile(
|
private static final Pattern ENUM_WITH_ROLLING_UPGRADE_OPTION = Pattern.compile(
|
||||||
"(\\w+)\\((\\w+)\\)");
|
"(\\w+)\\((\\w+)\\)");
|
||||||
|
|
|
@ -225,6 +225,7 @@ public class FSImage implements Closeable {
|
||||||
NNStorage.checkVersionUpgradable(storage.getLayoutVersion());
|
NNStorage.checkVersionUpgradable(storage.getLayoutVersion());
|
||||||
}
|
}
|
||||||
if (startOpt != StartupOption.UPGRADE
|
if (startOpt != StartupOption.UPGRADE
|
||||||
|
&& startOpt != StartupOption.UPGRADEONLY
|
||||||
&& !RollingUpgradeStartupOption.STARTED.matches(startOpt)
|
&& !RollingUpgradeStartupOption.STARTED.matches(startOpt)
|
||||||
&& layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSION
|
&& layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSION
|
||||||
&& layoutVersion != HdfsConstants.NAMENODE_LAYOUT_VERSION) {
|
&& layoutVersion != HdfsConstants.NAMENODE_LAYOUT_VERSION) {
|
||||||
|
@ -263,6 +264,7 @@ public class FSImage implements Closeable {
|
||||||
// 3. Do transitions
|
// 3. Do transitions
|
||||||
switch(startOpt) {
|
switch(startOpt) {
|
||||||
case UPGRADE:
|
case UPGRADE:
|
||||||
|
case UPGRADEONLY:
|
||||||
doUpgrade(target);
|
doUpgrade(target);
|
||||||
return false; // upgrade saved image already
|
return false; // upgrade saved image already
|
||||||
case IMPORT:
|
case IMPORT:
|
||||||
|
@ -748,11 +750,13 @@ public class FSImage implements Closeable {
|
||||||
editLog.recoverUnclosedStreams();
|
editLog.recoverUnclosedStreams();
|
||||||
} else if (HAUtil.isHAEnabled(conf, nameserviceId)
|
} else if (HAUtil.isHAEnabled(conf, nameserviceId)
|
||||||
&& (startOpt == StartupOption.UPGRADE
|
&& (startOpt == StartupOption.UPGRADE
|
||||||
|
|| startOpt == StartupOption.UPGRADEONLY
|
||||||
|| RollingUpgradeStartupOption.ROLLBACK.matches(startOpt))) {
|
|| RollingUpgradeStartupOption.ROLLBACK.matches(startOpt))) {
|
||||||
// This NN is HA, but we're doing an upgrade or a rollback of rolling
|
// This NN is HA, but we're doing an upgrade or a rollback of rolling
|
||||||
// upgrade so init the edit log for write.
|
// upgrade so init the edit log for write.
|
||||||
editLog.initJournalsForWrite();
|
editLog.initJournalsForWrite();
|
||||||
if (startOpt == StartupOption.UPGRADE) {
|
if (startOpt == StartupOption.UPGRADE
|
||||||
|
|| startOpt == StartupOption.UPGRADEONLY) {
|
||||||
long sharedLogCTime = editLog.getSharedLogCTime();
|
long sharedLogCTime = editLog.getSharedLogCTime();
|
||||||
if (this.storage.getCTime() < sharedLogCTime) {
|
if (this.storage.getCTime() < sharedLogCTime) {
|
||||||
throw new IOException("It looks like the shared log is already " +
|
throw new IOException("It looks like the shared log is already " +
|
||||||
|
|
|
@ -971,7 +971,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
}
|
}
|
||||||
// This will start a new log segment and write to the seen_txid file, so
|
// This will start a new log segment and write to the seen_txid file, so
|
||||||
// we shouldn't do it when coming up in standby state
|
// we shouldn't do it when coming up in standby state
|
||||||
if (!haEnabled || (haEnabled && startOpt == StartupOption.UPGRADE)) {
|
if (!haEnabled || (haEnabled && startOpt == StartupOption.UPGRADE)
|
||||||
|
|| (haEnabled && startOpt == StartupOption.UPGRADEONLY)) {
|
||||||
fsImage.openEditLogForWrite();
|
fsImage.openEditLogForWrite();
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
|
|
|
@ -836,7 +836,7 @@ public class NNStorage extends Storage implements Closeable,
|
||||||
*/
|
*/
|
||||||
void processStartupOptionsForUpgrade(StartupOption startOpt, int layoutVersion)
|
void processStartupOptionsForUpgrade(StartupOption startOpt, int layoutVersion)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (startOpt == StartupOption.UPGRADE) {
|
if (startOpt == StartupOption.UPGRADE || startOpt == StartupOption.UPGRADEONLY) {
|
||||||
// If upgrade from a release that does not support federation,
|
// If upgrade from a release that does not support federation,
|
||||||
// if clusterId is provided in the startupOptions use it.
|
// if clusterId is provided in the startupOptions use it.
|
||||||
// Else generate a new cluster ID
|
// Else generate a new cluster ID
|
||||||
|
|
|
@ -209,6 +209,9 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
+ StartupOption.UPGRADE.getName() +
|
+ StartupOption.UPGRADE.getName() +
|
||||||
" [" + StartupOption.CLUSTERID.getName() + " cid]" +
|
" [" + StartupOption.CLUSTERID.getName() + " cid]" +
|
||||||
" [" + StartupOption.RENAMERESERVED.getName() + "<k-v pairs>] ] | \n\t["
|
" [" + StartupOption.RENAMERESERVED.getName() + "<k-v pairs>] ] | \n\t["
|
||||||
|
+ StartupOption.UPGRADEONLY.getName() +
|
||||||
|
" [" + StartupOption.CLUSTERID.getName() + " cid]" +
|
||||||
|
" [" + StartupOption.RENAMERESERVED.getName() + "<k-v pairs>] ] | \n\t["
|
||||||
+ StartupOption.ROLLBACK.getName() + "] | \n\t["
|
+ StartupOption.ROLLBACK.getName() + "] | \n\t["
|
||||||
+ StartupOption.ROLLINGUPGRADE.getName() + " <"
|
+ StartupOption.ROLLINGUPGRADE.getName() + " <"
|
||||||
+ RollingUpgradeStartupOption.DOWNGRADE.name().toLowerCase() + "|"
|
+ RollingUpgradeStartupOption.DOWNGRADE.name().toLowerCase() + "|"
|
||||||
|
@ -712,6 +715,7 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
* <li>{@link StartupOption#BACKUP BACKUP} - start backup node</li>
|
* <li>{@link StartupOption#BACKUP BACKUP} - start backup node</li>
|
||||||
* <li>{@link StartupOption#CHECKPOINT CHECKPOINT} - start checkpoint node</li>
|
* <li>{@link StartupOption#CHECKPOINT CHECKPOINT} - start checkpoint node</li>
|
||||||
* <li>{@link StartupOption#UPGRADE UPGRADE} - start the cluster
|
* <li>{@link StartupOption#UPGRADE UPGRADE} - start the cluster
|
||||||
|
* <li>{@link StartupOption#UPGRADEONLY UPGRADEONLY} - upgrade the cluster
|
||||||
* upgrade and create a snapshot of the current file system state</li>
|
* upgrade and create a snapshot of the current file system state</li>
|
||||||
* <li>{@link StartupOption#RECOVER RECOVERY} - recover name node
|
* <li>{@link StartupOption#RECOVER RECOVERY} - recover name node
|
||||||
* metadata</li>
|
* metadata</li>
|
||||||
|
@ -766,7 +770,8 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HAState createHAState(StartupOption startOpt) {
|
protected HAState createHAState(StartupOption startOpt) {
|
||||||
if (!haEnabled || startOpt == StartupOption.UPGRADE) {
|
if (!haEnabled || startOpt == StartupOption.UPGRADE
|
||||||
|
|| startOpt == StartupOption.UPGRADEONLY) {
|
||||||
return ACTIVE_STATE;
|
return ACTIVE_STATE;
|
||||||
} else {
|
} else {
|
||||||
return STANDBY_STATE;
|
return STANDBY_STATE;
|
||||||
|
@ -1197,8 +1202,10 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
startOpt = StartupOption.BACKUP;
|
startOpt = StartupOption.BACKUP;
|
||||||
} else if (StartupOption.CHECKPOINT.getName().equalsIgnoreCase(cmd)) {
|
} else if (StartupOption.CHECKPOINT.getName().equalsIgnoreCase(cmd)) {
|
||||||
startOpt = StartupOption.CHECKPOINT;
|
startOpt = StartupOption.CHECKPOINT;
|
||||||
} else if (StartupOption.UPGRADE.getName().equalsIgnoreCase(cmd)) {
|
} else if (StartupOption.UPGRADE.getName().equalsIgnoreCase(cmd)
|
||||||
startOpt = StartupOption.UPGRADE;
|
|| StartupOption.UPGRADEONLY.getName().equalsIgnoreCase(cmd)) {
|
||||||
|
startOpt = StartupOption.UPGRADE.getName().equalsIgnoreCase(cmd) ?
|
||||||
|
StartupOption.UPGRADE : StartupOption.UPGRADEONLY;
|
||||||
/* Can be followed by CLUSTERID with a required parameter or
|
/* Can be followed by CLUSTERID with a required parameter or
|
||||||
* RENAMERESERVED with an optional parameter
|
* RENAMERESERVED with an optional parameter
|
||||||
*/
|
*/
|
||||||
|
@ -1402,6 +1409,12 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
terminate(0);
|
terminate(0);
|
||||||
return null; // avoid javac warning
|
return null; // avoid javac warning
|
||||||
}
|
}
|
||||||
|
case UPGRADEONLY: {
|
||||||
|
DefaultMetricsSystem.initialize("NameNode");
|
||||||
|
new NameNode(conf);
|
||||||
|
terminate(0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
DefaultMetricsSystem.initialize("NameNode");
|
DefaultMetricsSystem.initialize("NameNode");
|
||||||
return new NameNode(conf);
|
return new NameNode(conf);
|
||||||
|
|
|
@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
@ -30,11 +32,15 @@ import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class tests various upgrade cases from earlier versions to current
|
* This class tests various upgrade cases from earlier versions to current
|
||||||
* version with and without clusterid.
|
* version with and without clusterid.
|
||||||
*/
|
*/
|
||||||
|
@RunWith(value = Parameterized.class)
|
||||||
public class TestStartupOptionUpgrade {
|
public class TestStartupOptionUpgrade {
|
||||||
|
|
||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
|
@ -42,10 +48,21 @@ public class TestStartupOptionUpgrade {
|
||||||
private int layoutVersion;
|
private int layoutVersion;
|
||||||
NNStorage storage;
|
NNStorage storage;
|
||||||
|
|
||||||
|
@Parameters
|
||||||
|
public static Collection<Object[]> startOption() {
|
||||||
|
Object[][] params = new Object[][] { { StartupOption.UPGRADE },
|
||||||
|
{ StartupOption.UPGRADEONLY } };
|
||||||
|
return Arrays.asList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestStartupOptionUpgrade(StartupOption startOption) {
|
||||||
|
super();
|
||||||
|
this.startOpt = startOption;
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
conf = new HdfsConfiguration();
|
conf = new HdfsConfiguration();
|
||||||
startOpt = StartupOption.UPGRADE;
|
|
||||||
startOpt.setClusterId(null);
|
startOpt.setClusterId(null);
|
||||||
storage = new NNStorage(conf,
|
storage = new NNStorage(conf,
|
||||||
Collections.<URI>emptyList(),
|
Collections.<URI>emptyList(),
|
||||||
|
|
Loading…
Reference in New Issue