|
@@ -21,11 +21,14 @@ import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
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.conf.ReconfigurableBase;
|
|
|
|
+import org.apache.hadoop.conf.ReconfigurationException;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.Trash;
|
|
import org.apache.hadoop.fs.Trash;
|
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
@@ -41,6 +44,7 @@ import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
|
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
|
+import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
|
@@ -93,6 +97,7 @@ import java.security.PrivilegedExceptionAction;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -141,6 +146,10 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SUPPORT_ALLOW_FO
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMESERVICE_ID;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMESERVICE_ID;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_SECONDARY_NAMENODE_KEYTAB_FILE_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_SECONDARY_NAMENODE_KEYTAB_FILE_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.HADOOP_USER_GROUP_METRICS_PERCENTILES_INTERVALS;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.HADOOP_USER_GROUP_METRICS_PERCENTILES_INTERVALS;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_DEFAULT;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_DEFAULT;
|
|
import static org.apache.hadoop.util.ExitUtil.terminate;
|
|
import static org.apache.hadoop.util.ExitUtil.terminate;
|
|
import static org.apache.hadoop.util.ToolRunner.confirmPrompt;
|
|
import static org.apache.hadoop.util.ToolRunner.confirmPrompt;
|
|
|
|
|
|
@@ -182,7 +191,8 @@ import static org.apache.hadoop.util.ToolRunner.confirmPrompt;
|
|
* NameNode state, for example partial blocksMap etc.
|
|
* NameNode state, for example partial blocksMap etc.
|
|
**********************************************************/
|
|
**********************************************************/
|
|
@InterfaceAudience.Private
|
|
@InterfaceAudience.Private
|
|
-public class NameNode implements NameNodeStatusMXBean {
|
|
|
|
|
|
+public class NameNode extends ReconfigurableBase implements
|
|
|
|
+ NameNodeStatusMXBean {
|
|
static{
|
|
static{
|
|
HdfsConfiguration.init();
|
|
HdfsConfiguration.init();
|
|
}
|
|
}
|
|
@@ -260,7 +270,12 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
public static final String[] NAMESERVICE_SPECIFIC_KEYS = {
|
|
public static final String[] NAMESERVICE_SPECIFIC_KEYS = {
|
|
DFS_HA_AUTO_FAILOVER_ENABLED_KEY
|
|
DFS_HA_AUTO_FAILOVER_ENABLED_KEY
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /** A list of property that are reconfigurable at runtime. */
|
|
|
|
+ static final List<String> RECONFIGURABLE_PROPERTIES = Collections
|
|
|
|
+ .unmodifiableList(Arrays.asList(DFS_HEARTBEAT_INTERVAL_KEY,
|
|
|
|
+ DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY));
|
|
|
|
+
|
|
private static final String USAGE = "Usage: hdfs namenode ["
|
|
private static final String USAGE = "Usage: hdfs namenode ["
|
|
+ StartupOption.BACKUP.getName() + "] | \n\t["
|
|
+ StartupOption.BACKUP.getName() + "] | \n\t["
|
|
+ StartupOption.CHECKPOINT.getName() + "] | \n\t["
|
|
+ StartupOption.CHECKPOINT.getName() + "] | \n\t["
|
|
@@ -329,7 +344,6 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
LogFactory.getLog("NameNodeMetricsLog");
|
|
LogFactory.getLog("NameNodeMetricsLog");
|
|
|
|
|
|
protected FSNamesystem namesystem;
|
|
protected FSNamesystem namesystem;
|
|
- protected final Configuration conf;
|
|
|
|
protected final NamenodeRole role;
|
|
protected final NamenodeRole role;
|
|
private volatile HAState state;
|
|
private volatile HAState state;
|
|
private final boolean haEnabled;
|
|
private final boolean haEnabled;
|
|
@@ -864,12 +878,12 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
|
|
|
|
protected NameNode(Configuration conf, NamenodeRole role)
|
|
protected NameNode(Configuration conf, NamenodeRole role)
|
|
throws IOException {
|
|
throws IOException {
|
|
|
|
+ super(conf);
|
|
this.tracer = new Tracer.Builder("NameNode").
|
|
this.tracer = new Tracer.Builder("NameNode").
|
|
conf(TraceUtils.wrapHadoopConf(NAMENODE_HTRACE_PREFIX, conf)).
|
|
conf(TraceUtils.wrapHadoopConf(NAMENODE_HTRACE_PREFIX, conf)).
|
|
build();
|
|
build();
|
|
this.tracerConfigurationManager =
|
|
this.tracerConfigurationManager =
|
|
new TracerConfigurationManager(NAMENODE_HTRACE_PREFIX, conf);
|
|
new TracerConfigurationManager(NAMENODE_HTRACE_PREFIX, conf);
|
|
- this.conf = conf;
|
|
|
|
this.role = role;
|
|
this.role = role;
|
|
setClientNamenodeAddress(conf);
|
|
setClientNamenodeAddress(conf);
|
|
String nsId = getNameServiceId(conf);
|
|
String nsId = getNameServiceId(conf);
|
|
@@ -880,7 +894,7 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
this.haContext = createHAContext();
|
|
this.haContext = createHAContext();
|
|
try {
|
|
try {
|
|
initializeGenericKeys(conf, nsId, namenodeId);
|
|
initializeGenericKeys(conf, nsId, namenodeId);
|
|
- initialize(conf);
|
|
|
|
|
|
+ initialize(getConf());
|
|
try {
|
|
try {
|
|
haContext.writeLock();
|
|
haContext.writeLock();
|
|
state.prepareToEnterState(haContext);
|
|
state.prepareToEnterState(haContext);
|
|
@@ -1804,7 +1818,7 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
public void startActiveServices() throws IOException {
|
|
public void startActiveServices() throws IOException {
|
|
try {
|
|
try {
|
|
namesystem.startActiveServices();
|
|
namesystem.startActiveServices();
|
|
- startTrashEmptier(conf);
|
|
|
|
|
|
+ startTrashEmptier(getConf());
|
|
} catch (Throwable t) {
|
|
} catch (Throwable t) {
|
|
doImmediateShutdown(t);
|
|
doImmediateShutdown(t);
|
|
}
|
|
}
|
|
@@ -1825,7 +1839,7 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
@Override
|
|
@Override
|
|
public void startStandbyServices() throws IOException {
|
|
public void startStandbyServices() throws IOException {
|
|
try {
|
|
try {
|
|
- namesystem.startStandbyServices(conf);
|
|
|
|
|
|
+ namesystem.startStandbyServices(getConf());
|
|
} catch (Throwable t) {
|
|
} catch (Throwable t) {
|
|
doImmediateShutdown(t);
|
|
doImmediateShutdown(t);
|
|
}
|
|
}
|
|
@@ -1902,8 +1916,8 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
*/
|
|
*/
|
|
void checkHaStateChange(StateChangeRequestInfo req)
|
|
void checkHaStateChange(StateChangeRequestInfo req)
|
|
throws AccessControlException {
|
|
throws AccessControlException {
|
|
- boolean autoHaEnabled = conf.getBoolean(DFS_HA_AUTO_FAILOVER_ENABLED_KEY,
|
|
|
|
- DFS_HA_AUTO_FAILOVER_ENABLED_DEFAULT);
|
|
|
|
|
|
+ boolean autoHaEnabled = getConf().getBoolean(
|
|
|
|
+ DFS_HA_AUTO_FAILOVER_ENABLED_KEY, DFS_HA_AUTO_FAILOVER_ENABLED_DEFAULT);
|
|
switch (req.getSource()) {
|
|
switch (req.getSource()) {
|
|
case REQUEST_BY_USER:
|
|
case REQUEST_BY_USER:
|
|
if (autoHaEnabled) {
|
|
if (autoHaEnabled) {
|
|
@@ -1930,4 +1944,75 @@ public class NameNode implements NameNodeStatusMXBean {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * {@inheritDoc}
|
|
|
|
+ * */
|
|
|
|
+ @Override // ReconfigurableBase
|
|
|
|
+ public Collection<String> getReconfigurableProperties() {
|
|
|
|
+ return RECONFIGURABLE_PROPERTIES;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * {@inheritDoc}
|
|
|
|
+ * */
|
|
|
|
+ @Override // ReconfigurableBase
|
|
|
|
+ protected String reconfigurePropertyImpl(String property, String newVal)
|
|
|
|
+ throws ReconfigurationException {
|
|
|
|
+ final DatanodeManager datanodeManager = namesystem.getBlockManager()
|
|
|
|
+ .getDatanodeManager();
|
|
|
|
+
|
|
|
|
+ switch (property) {
|
|
|
|
+ case DFS_HEARTBEAT_INTERVAL_KEY:
|
|
|
|
+ namesystem.writeLock();
|
|
|
|
+ try {
|
|
|
|
+ if (newVal == null) {
|
|
|
|
+ // set to default
|
|
|
|
+ datanodeManager.setHeartbeatInterval(DFS_HEARTBEAT_INTERVAL_DEFAULT);
|
|
|
|
+ return String.valueOf(DFS_HEARTBEAT_INTERVAL_DEFAULT);
|
|
|
|
+ } else {
|
|
|
|
+ datanodeManager.setHeartbeatInterval(Long.parseLong(newVal));
|
|
|
|
+ return String.valueOf(datanodeManager.getHeartbeatInterval());
|
|
|
|
+ }
|
|
|
|
+ } catch (NumberFormatException nfe) {
|
|
|
|
+ throw new ReconfigurationException(property, newVal, getConf().get(
|
|
|
|
+ property), nfe);
|
|
|
|
+ } finally {
|
|
|
|
+ namesystem.writeUnlock();
|
|
|
|
+ LOG.info("RECONFIGURE* changed heartbeatInterval to "
|
|
|
|
+ + datanodeManager.getHeartbeatInterval());
|
|
|
|
+ }
|
|
|
|
+ case DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY:
|
|
|
|
+ namesystem.writeLock();
|
|
|
|
+ try {
|
|
|
|
+ if (newVal == null) {
|
|
|
|
+ // set to default
|
|
|
|
+ datanodeManager
|
|
|
|
+ .setHeartbeatRecheckInterval(
|
|
|
|
+ DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_DEFAULT);
|
|
|
|
+ return String
|
|
|
|
+ .valueOf(DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_DEFAULT);
|
|
|
|
+ } else {
|
|
|
|
+ datanodeManager.setHeartbeatRecheckInterval(Integer.parseInt(newVal));
|
|
|
|
+ return String.valueOf(datanodeManager.getHeartbeatRecheckInterval());
|
|
|
|
+ }
|
|
|
|
+ } catch (NumberFormatException nfe) {
|
|
|
|
+ throw new ReconfigurationException(property, newVal, getConf().get(
|
|
|
|
+ property), nfe);
|
|
|
|
+ } finally {
|
|
|
|
+ namesystem.writeUnlock();
|
|
|
|
+ LOG.info("RECONFIGURE* changed heartbeatRecheckInterval to "
|
|
|
|
+ + datanodeManager.getHeartbeatRecheckInterval());
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ throw new ReconfigurationException(property, newVal, getConf()
|
|
|
|
+ .get(property));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override // ReconfigurableBase
|
|
|
|
+ protected Configuration getNewConf() {
|
|
|
|
+ return new HdfsConfiguration();
|
|
|
|
+ }
|
|
}
|
|
}
|