|
@@ -175,8 +175,10 @@ import org.apache.hadoop.hdfs.DFSUtil;
|
|
import org.apache.hadoop.hdfs.HAUtil;
|
|
import org.apache.hadoop.hdfs.HAUtil;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.UnknownCryptoProtocolVersionException;
|
|
import org.apache.hadoop.hdfs.UnknownCryptoProtocolVersionException;
|
|
|
|
+import org.apache.hadoop.hdfs.protocol.AddingECPolicyResponse;
|
|
import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
|
|
import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
|
|
+import org.apache.hadoop.hdfs.protocol.BlockType;
|
|
import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
|
|
import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
|
|
import org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry;
|
|
import org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry;
|
|
import org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo;
|
|
import org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo;
|
|
@@ -193,6 +195,7 @@ import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
|
|
+import org.apache.hadoop.hdfs.protocol.IllegalECPolicyException;
|
|
import org.apache.hadoop.hdfs.protocol.LastBlockWithStatus;
|
|
import org.apache.hadoop.hdfs.protocol.LastBlockWithStatus;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
@@ -211,7 +214,6 @@ import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretMan
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
|
|
-import org.apache.hadoop.hdfs.protocol.BlockType;
|
|
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockUnderConstructionFeature;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.BlockUnderConstructionFeature;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
|
|
@@ -429,7 +431,6 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
private final BlockManager blockManager;
|
|
private final BlockManager blockManager;
|
|
private final SnapshotManager snapshotManager;
|
|
private final SnapshotManager snapshotManager;
|
|
private final CacheManager cacheManager;
|
|
private final CacheManager cacheManager;
|
|
- private final ErasureCodingPolicyManager ecPolicyManager;
|
|
|
|
private final DatanodeStatistics datanodeStatistics;
|
|
private final DatanodeStatistics datanodeStatistics;
|
|
|
|
|
|
private String nameserviceId;
|
|
private String nameserviceId;
|
|
@@ -593,9 +594,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
leaseManager.removeAllLeases();
|
|
leaseManager.removeAllLeases();
|
|
snapshotManager.clearSnapshottableDirs();
|
|
snapshotManager.clearSnapshottableDirs();
|
|
cacheManager.clear();
|
|
cacheManager.clear();
|
|
- ecPolicyManager.clear();
|
|
|
|
setImageLoaded(false);
|
|
setImageLoaded(false);
|
|
blockManager.clear();
|
|
blockManager.clear();
|
|
|
|
+ ErasureCodingPolicyManager.getInstance().clear();
|
|
}
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
@@ -846,7 +847,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
this.dir = new FSDirectory(this, conf);
|
|
this.dir = new FSDirectory(this, conf);
|
|
this.snapshotManager = new SnapshotManager(conf, dir);
|
|
this.snapshotManager = new SnapshotManager(conf, dir);
|
|
this.cacheManager = new CacheManager(this, conf, blockManager);
|
|
this.cacheManager = new CacheManager(this, conf, blockManager);
|
|
- this.ecPolicyManager = new ErasureCodingPolicyManager(conf);
|
|
|
|
|
|
+ // Init ErasureCodingPolicyManager instance.
|
|
|
|
+ ErasureCodingPolicyManager.getInstance().init(conf);
|
|
this.topConf = new TopConf(conf);
|
|
this.topConf = new TopConf(conf);
|
|
this.auditLoggers = initAuditLoggers(conf);
|
|
this.auditLoggers = initAuditLoggers(conf);
|
|
this.isDefaultAuditLogger = auditLoggers.size() == 1 &&
|
|
this.isDefaultAuditLogger = auditLoggers.size() == 1 &&
|
|
@@ -4831,7 +4833,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
NameNode.stateChangeLog.info("*DIR* reportBadBlocks for block: {} on"
|
|
NameNode.stateChangeLog.info("*DIR* reportBadBlocks for block: {} on"
|
|
+ " datanode: {}", blk, nodes[j].getXferAddr());
|
|
+ " datanode: {}", blk, nodes[j].getXferAddr());
|
|
blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j],
|
|
blockManager.findAndMarkBlockAsCorrupt(blk, nodes[j],
|
|
- storageIDs == null ? null: storageIDs[j],
|
|
|
|
|
|
+ storageIDs == null ? null: storageIDs[j],
|
|
"client machine reported it");
|
|
"client machine reported it");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5753,7 +5755,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
/** @return the ErasureCodingPolicyManager. */
|
|
/** @return the ErasureCodingPolicyManager. */
|
|
public ErasureCodingPolicyManager getErasureCodingPolicyManager() {
|
|
public ErasureCodingPolicyManager getErasureCodingPolicyManager() {
|
|
- return ecPolicyManager;
|
|
|
|
|
|
+ return ErasureCodingPolicyManager.getInstance();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -6823,6 +6825,28 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
resultingStat);
|
|
resultingStat);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Add multiple erasure coding policies to the ErasureCodingPolicyManager.
|
|
|
|
+ * @param policies The policies to add.
|
|
|
|
+ * @return The according result of add operation.
|
|
|
|
+ */
|
|
|
|
+ AddingECPolicyResponse[] addECPolicies(ErasureCodingPolicy[] policies)
|
|
|
|
+ throws IOException {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ List<AddingECPolicyResponse> responses = new ArrayList<>();
|
|
|
|
+ writeLock();
|
|
|
|
+ for (ErasureCodingPolicy policy : policies) {
|
|
|
|
+ try {
|
|
|
|
+ FSDirErasureCodingOp.addErasureCodePolicy(this, policy);
|
|
|
|
+ responses.add(new AddingECPolicyResponse(policy));
|
|
|
|
+ } catch (IllegalECPolicyException e) {
|
|
|
|
+ responses.add(new AddingECPolicyResponse(policy, e));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ writeUnlock("addECPolicies");
|
|
|
|
+ return responses.toArray(new AddingECPolicyResponse[0]);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Unset an erasure coding policy from the given path.
|
|
* Unset an erasure coding policy from the given path.
|
|
* @param srcArg The path of the target directory.
|
|
* @param srcArg The path of the target directory.
|