|
@@ -19,11 +19,11 @@ package org.apache.hadoop.hdfs.server.namenode;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
|
+import org.apache.hadoop.HadoopIllegalArgumentException;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
|
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicyState;
|
|
|
-import org.apache.hadoop.hdfs.protocol.IllegalECPolicyException;
|
|
|
import org.apache.hadoop.hdfs.protocol.SystemErasureCodingPolicies;
|
|
|
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
@@ -144,7 +144,7 @@ public final class ErasureCodingPolicyManager {
|
|
|
policyName,
|
|
|
DFSConfigKeys.DFS_NAMENODE_EC_POLICIES_ENABLED_KEY,
|
|
|
names);
|
|
|
- throw new IllegalArgumentException(msg);
|
|
|
+ throw new HadoopIllegalArgumentException(msg);
|
|
|
}
|
|
|
enabledPoliciesByName.put(ecPolicy.getName(), ecPolicy);
|
|
|
}
|
|
@@ -230,33 +230,34 @@ public final class ErasureCodingPolicyManager {
|
|
|
* Add an erasure coding policy.
|
|
|
* @return the added policy
|
|
|
*/
|
|
|
- public synchronized ErasureCodingPolicy addPolicy(ErasureCodingPolicy policy)
|
|
|
- throws IllegalECPolicyException {
|
|
|
+ public synchronized ErasureCodingPolicy addPolicy(
|
|
|
+ ErasureCodingPolicy policy) {
|
|
|
// Set policy state into DISABLED when adding into Hadoop.
|
|
|
policy.setState(ErasureCodingPolicyState.DISABLED);
|
|
|
|
|
|
if (!CodecUtil.hasCodec(policy.getCodecName())) {
|
|
|
- throw new IllegalECPolicyException("Codec name "
|
|
|
+ throw new HadoopIllegalArgumentException("Codec name "
|
|
|
+ policy.getCodecName() + " is not supported");
|
|
|
}
|
|
|
|
|
|
if (policy.getCellSize() > maxCellSize) {
|
|
|
- throw new IllegalECPolicyException("Cell size " + policy.getCellSize()
|
|
|
- + " should not exceed maximum " + maxCellSize + " byte");
|
|
|
+ throw new HadoopIllegalArgumentException("Cell size " +
|
|
|
+ policy.getCellSize() + " should not exceed maximum " +
|
|
|
+ maxCellSize + " bytes");
|
|
|
}
|
|
|
|
|
|
String assignedNewName = ErasureCodingPolicy.composePolicyName(
|
|
|
policy.getSchema(), policy.getCellSize());
|
|
|
for (ErasureCodingPolicy p : getPolicies()) {
|
|
|
if (p.getName().equals(assignedNewName)) {
|
|
|
- throw new IllegalECPolicyException("The policy name " + assignedNewName
|
|
|
- + " already exists");
|
|
|
+ throw new HadoopIllegalArgumentException("The policy name " +
|
|
|
+ assignedNewName + " already exists");
|
|
|
}
|
|
|
if (p.getSchema().equals(policy.getSchema()) &&
|
|
|
p.getCellSize() == policy.getCellSize()) {
|
|
|
- throw new IllegalECPolicyException("A policy with same schema "
|
|
|
+ throw new HadoopIllegalArgumentException("A policy with same schema "
|
|
|
+ policy.getSchema().toString() + " and cell size "
|
|
|
- + p.getCellSize() + " is already exists");
|
|
|
+ + p.getCellSize() + " already exists");
|
|
|
}
|
|
|
}
|
|
|
policy.setName(assignedNewName);
|
|
@@ -281,12 +282,12 @@ public final class ErasureCodingPolicyManager {
|
|
|
public synchronized void removePolicy(String name) {
|
|
|
ErasureCodingPolicy ecPolicy = policiesByName.get(name);
|
|
|
if (ecPolicy == null) {
|
|
|
- throw new IllegalArgumentException("The policy name " +
|
|
|
- name + " does not exists");
|
|
|
+ throw new HadoopIllegalArgumentException("The policy name " +
|
|
|
+ name + " does not exist");
|
|
|
}
|
|
|
|
|
|
if (ecPolicy.isSystemPolicy()) {
|
|
|
- throw new IllegalArgumentException("System erasure coding policy " +
|
|
|
+ throw new HadoopIllegalArgumentException("System erasure coding policy " +
|
|
|
name + " cannot be removed");
|
|
|
}
|
|
|
|
|
@@ -317,8 +318,8 @@ public final class ErasureCodingPolicyManager {
|
|
|
public synchronized void disablePolicy(String name) {
|
|
|
ErasureCodingPolicy ecPolicy = policiesByName.get(name);
|
|
|
if (ecPolicy == null) {
|
|
|
- throw new IllegalArgumentException("The policy name " +
|
|
|
- name + " does not exists");
|
|
|
+ throw new HadoopIllegalArgumentException("The policy name " +
|
|
|
+ name + " does not exist");
|
|
|
}
|
|
|
|
|
|
if (enabledPoliciesByName.containsKey(name)) {
|
|
@@ -336,8 +337,8 @@ public final class ErasureCodingPolicyManager {
|
|
|
public synchronized void enablePolicy(String name) {
|
|
|
ErasureCodingPolicy ecPolicy = policiesByName.get(name);
|
|
|
if (ecPolicy == null) {
|
|
|
- throw new IllegalArgumentException("The policy name " +
|
|
|
- name + " does not exists");
|
|
|
+ throw new HadoopIllegalArgumentException("The policy name " +
|
|
|
+ name + " does not exist");
|
|
|
}
|
|
|
|
|
|
enabledPoliciesByName.put(name, ecPolicy);
|
|
@@ -346,4 +347,4 @@ public final class ErasureCodingPolicyManager {
|
|
|
enabledPoliciesByName.values().toArray(new ErasureCodingPolicy[0]);
|
|
|
LOG.info("Enable the erasure coding policy " + name);
|
|
|
}
|
|
|
-}
|
|
|
+}
|