|
@@ -34,6 +34,8 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY;
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY;
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_DEFAULT;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_MAX_OBJECTS_DEFAULT;
|
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_MAX_OBJECTS_KEY;
|
|
@@ -271,6 +273,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
private static final long DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL =
|
|
|
TimeUnit.MILLISECONDS.convert(1, TimeUnit.HOURS);
|
|
|
private DelegationTokenSecretManager dtSecretManager;
|
|
|
+ private boolean alwaysUseDelegationTokensForTests;
|
|
|
|
|
|
//
|
|
|
// Stores the correct file name hierarchy
|
|
@@ -348,6 +351,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
this.datanodeStatistics = blockManager.getDatanodeManager().getDatanodeStatistics();
|
|
|
this.fsLock = new ReentrantReadWriteLock(true); // fair locking
|
|
|
setConfigurationParameters(conf);
|
|
|
+ // For testing purposes, allow the DT secret manager to be started regardless
|
|
|
+ // of whether security is enabled.
|
|
|
+ alwaysUseDelegationTokensForTests =
|
|
|
+ conf.getBoolean(DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY,
|
|
|
+ DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_DEFAULT);
|
|
|
dtSecretManager = createDelegationTokenSecretManager(conf);
|
|
|
this.registerMBean(); // register the MBean for the FSNamesystemState
|
|
|
if(fsImage == null) {
|
|
@@ -620,6 +628,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private boolean shouldUseDelegationTokens() {
|
|
|
+ return UserGroupInformation.isSecurityEnabled() ||
|
|
|
+ alwaysUseDelegationTokensForTests;
|
|
|
+ }
|
|
|
+
|
|
|
long getDefaultBlockSize() {
|
|
|
return serverDefaults.getBlockSize();
|
|
|
}
|
|
@@ -3430,21 +3443,21 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
void enterSafeMode(boolean resourcesLow) throws IOException {
|
|
|
writeLock();
|
|
|
try {
|
|
|
- // Ensure that any concurrent operations have been fully synced
|
|
|
- // before entering safe mode. This ensures that the FSImage
|
|
|
- // is entirely stable on disk as soon as we're in safe mode.
|
|
|
- getEditLog().logSyncAll();
|
|
|
- if (!isInSafeMode()) {
|
|
|
- safeMode = new SafeModeInfo(resourcesLow);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (resourcesLow) {
|
|
|
- safeMode.setResourcesLow();
|
|
|
- }
|
|
|
- safeMode.setManual();
|
|
|
- getEditLog().logSyncAll();
|
|
|
- NameNode.stateChangeLog.info("STATE* Safe mode is ON. "
|
|
|
- + safeMode.getTurnOffTip());
|
|
|
+ // Ensure that any concurrent operations have been fully synced
|
|
|
+ // before entering safe mode. This ensures that the FSImage
|
|
|
+ // is entirely stable on disk as soon as we're in safe mode.
|
|
|
+ getEditLog().logSyncAll();
|
|
|
+ if (!isInSafeMode()) {
|
|
|
+ safeMode = new SafeModeInfo(resourcesLow);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (resourcesLow) {
|
|
|
+ safeMode.setResourcesLow();
|
|
|
+ }
|
|
|
+ safeMode.setManual();
|
|
|
+ getEditLog().logSyncAll();
|
|
|
+ NameNode.stateChangeLog.info("STATE* Safe mode is ON. "
|
|
|
+ + safeMode.getTurnOffTip());
|
|
|
} finally {
|
|
|
writeUnlock();
|
|
|
}
|
|
@@ -4197,16 +4210,13 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
* @param key new delegation key.
|
|
|
*/
|
|
|
public void logUpdateMasterKey(DelegationKey key) throws IOException {
|
|
|
- writeLock();
|
|
|
- try {
|
|
|
- if (isInSafeMode()) {
|
|
|
- throw new SafeModeException(
|
|
|
- "Cannot log master key update in safe mode", safeMode);
|
|
|
- }
|
|
|
- getEditLog().logUpdateMasterKey(key);
|
|
|
- } finally {
|
|
|
- writeUnlock();
|
|
|
- }
|
|
|
+ assert !isInSafeMode() :
|
|
|
+ "this should never be called while in safemode, since we stop " +
|
|
|
+ "the DT manager before entering safemode!";
|
|
|
+ // No need to hold FSN lock since we don't access any internal
|
|
|
+ // structures, and this is stopped before the FSN shuts itself
|
|
|
+ // down, etc.
|
|
|
+ getEditLog().logUpdateMasterKey(key);
|
|
|
getEditLog().logSync();
|
|
|
}
|
|
|
|