diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java index 9094f98aa753..5a1415268c6d 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java @@ -35,20 +35,7 @@ @ConfigGroup(prefix = "ozone.client") public class OzoneClientConfig { - private static final Logger LOG = - LoggerFactory.getLogger(OzoneClientConfig.class); - - /** - * Enum for indicating what mode to use when combining chunk and block - * checksums to define an aggregate FileChecksum. This should be considered - * a client-side runtime option rather than a persistent property of any - * stored metadata, which is why this is not part of ChecksumOpt, which - * deals with properties of files at rest. - */ - public enum ChecksumCombineMode { - MD5MD5CRC, // MD5 of block checksums, which are MD5 over chunk CRCs - COMPOSITE_CRC // Block/chunk-independent composite CRC - } + private static final Logger LOG = LoggerFactory.getLogger(OzoneClientConfig.class); @Config(key = "stream.buffer.flush.size", defaultValue = "16MB", @@ -559,4 +546,16 @@ public void setMaxConcurrentWritePerKey(int maxConcurrentWritePerKey) { public int getMaxConcurrentWritePerKey() { return this.maxConcurrentWritePerKey; } + + /** + * Enum for indicating what mode to use when combining chunk and block + * checksums to define an aggregate FileChecksum. This should be considered + * a client-side runtime option rather than a persistent property of any + * stored metadata, which is why this is not part of ChecksumOpt, which + * deals with properties of files at rest. + */ + public enum ChecksumCombineMode { + MD5MD5CRC, // MD5 of block checksums, which are MD5 over chunk CRCs + COMPOSITE_CRC // Block/chunk-independent composite CRC + } } diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientCreator.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientCreator.java index 150efd2cb259..49ca3a09e11e 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientCreator.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientCreator.java @@ -32,10 +32,6 @@ public class XceiverClientCreator implements XceiverClientFactory { private static ErrorInjector errorInjector; - public static void enableErrorInjection(ErrorInjector injector) { - errorInjector = injector; - } - private final ConfigurationSource conf; private final boolean topologyAwareRead; private final ClientTrustManager trustManager; @@ -57,6 +53,10 @@ public XceiverClientCreator(ConfigurationSource conf, ClientTrustManager trustMa } } + public static void enableErrorInjection(ErrorInjector injector) { + errorInjector = injector; + } + public boolean isSecurityEnabled() { return securityEnabled; } diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java index a400363fd283..03289e8cacd7 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientRatis.java @@ -70,28 +70,7 @@ * The underlying RPC mechanism can be chosen via the constructor. */ public final class XceiverClientRatis extends XceiverClientSpi { - public static final Logger LOG = - LoggerFactory.getLogger(XceiverClientRatis.class); - - public static XceiverClientRatis newXceiverClientRatis( - org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline, - ConfigurationSource ozoneConf) { - return newXceiverClientRatis(pipeline, ozoneConf, null, null); - } - - public static XceiverClientRatis newXceiverClientRatis( - org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline, - ConfigurationSource ozoneConf, ClientTrustManager trustManager, ErrorInjector errorInjector) { - final String rpcType = ozoneConf - .get(ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_KEY, - ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_DEFAULT); - final RetryPolicy retryPolicy = RatisHelper.createRetryPolicy(ozoneConf); - final GrpcTlsConfig tlsConfig = RatisHelper.createTlsClientConfig(new - SecurityConfig(ozoneConf), trustManager); - return new XceiverClientRatis(pipeline, - SupportedRpcType.valueOfIgnoreCase(rpcType), - retryPolicy, tlsConfig, ozoneConf, errorInjector); - } + public static final Logger LOG = LoggerFactory.getLogger(XceiverClientRatis.class); private final Pipeline pipeline; private final RpcType rpcType; @@ -143,6 +122,26 @@ private XceiverClientRatis(Pipeline pipeline, RpcType rpcType, this.errorInjector = errorInjector; } + public static XceiverClientRatis newXceiverClientRatis( + org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline, + ConfigurationSource ozoneConf) { + return newXceiverClientRatis(pipeline, ozoneConf, null, null); + } + + public static XceiverClientRatis newXceiverClientRatis( + org.apache.hadoop.hdds.scm.pipeline.Pipeline pipeline, + ConfigurationSource ozoneConf, ClientTrustManager trustManager, ErrorInjector errorInjector) { + final String rpcType = ozoneConf + .get(ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_KEY, + ScmConfigKeys.HDDS_CONTAINER_RATIS_RPC_TYPE_DEFAULT); + final RetryPolicy retryPolicy = RatisHelper.createRetryPolicy(ozoneConf); + final GrpcTlsConfig tlsConfig = RatisHelper.createTlsClientConfig(new + SecurityConfig(ozoneConf), trustManager); + return new XceiverClientRatis(pipeline, + SupportedRpcType.valueOfIgnoreCase(rpcType), + retryPolicy, tlsConfig, ozoneConf, errorInjector); + } + private long updateCommitInfosMap(RaftClientReply reply, RaftProtos.ReplicationLevel level) { return Optional.ofNullable(reply) .filter(RaftClientReply::isSuccess) diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java index 49e11abb293a..ac2503339794 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java @@ -48,10 +48,6 @@ @InterfaceAudience.Public @InterfaceStability.Unstable public final class HddsClientUtils { - - private HddsClientUtils() { - } - private static final List> EXCEPTION_LIST = ImmutableList.>builder() .add(TimeoutException.class) @@ -64,6 +60,9 @@ private HddsClientUtils() { .add(NotReplicatedException.class) .build(); + private HddsClientUtils() { + } + private static void doNameChecks(String resName, String resType) { if (resName == null) { throw new IllegalArgumentException(resType + " name is null"); diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java index 4867a2aa69a7..4c357f339a9a 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java @@ -62,8 +62,10 @@ */ public class BlockInputStream extends BlockExtendedInputStream { - public static final Logger LOG = - LoggerFactory.getLogger(BlockInputStream.class); + public static final Logger LOG = LoggerFactory.getLogger(BlockInputStream.class); + + private static final List VALIDATORS = + ContainerProtocolCalls.toValidatorList((request, response) -> validate(response)); private final BlockID blockID; private long length; @@ -300,10 +302,6 @@ private void setPipeline(Pipeline pipeline) throws IOException { pipelineRef.set(readPipeline); } - private static final List VALIDATORS - = ContainerProtocolCalls.toValidatorList( - (request, response) -> validate(response)); - private static void validate(ContainerCommandResponseProto response) throws IOException { if (!response.hasGetBlock()) {