diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecRegistry.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecRegistry.java index daf91e22ec..0f99aa3f7a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecRegistry.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecRegistry.java @@ -179,4 +179,13 @@ public RawErasureCoderFactory getCoderByName( public Map getCodec2CoderCompactMap() { return coderNameCompactMap; } + + /** + * Get all codec names and their corresponding coder list. + * @return a map of all codec names, and their corresponding code list + * separated by ','. + */ + public HashMap getCodec2CoderCompactMap() { + return coderNameCompactMap; + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java index d68669f2b0..84bac2d83f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/ClientNamenodeProtocolServerSideTranslatorPB.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -1761,6 +1762,25 @@ public GetErasureCodingCodecsResponseProto getErasureCodingCodecs( } } + @Override + public GetErasureCodingCodecsResponseProto getErasureCodingCodecs( + RpcController controller, GetErasureCodingCodecsRequestProto request) + throws ServiceException { + try { + HashMap codecs = server.getErasureCodingCodecs(); + GetErasureCodingCodecsResponseProto.Builder resBuilder = + GetErasureCodingCodecsResponseProto.newBuilder(); + for (Map.Entry codec : codecs.entrySet()) { + resBuilder.addCodec( + PBHelperClient.convertErasureCodingCodec( + codec.getKey(), codec.getValue())); + } + return resBuilder.build(); + } catch (IOException e) { + throw new ServiceException(e); + } + } + @Override public AddErasureCodingPoliciesResponseProto addErasureCodingPolicies( RpcController controller, AddErasureCodingPoliciesRequestProto request) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 752c830f95..d5bf29ed12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -7655,6 +7655,20 @@ Map getErasureCodingCodecs() throws IOException { } } + /** + * Get available erasure coding codecs and corresponding coders. + */ + HashMap getErasureCodingCodecs() throws IOException { + checkOperation(OperationCategory.READ); + readLock(); + try { + checkOperation(OperationCategory.READ); + return FSDirErasureCodingOp.getErasureCodingCodecs(this); + } finally { + readUnlock("getErasureCodingCodecs"); + } + } + void setXAttr(String src, XAttr xAttr, EnumSet flag, boolean logRetryCache) throws IOException {