diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationService.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationService.java index e7ceaf7d398..26cd0d82a99 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationService.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/GrpcReplicationService.java @@ -58,37 +58,24 @@ public class GrpcReplicationService extends private final ContainerReplicationSource source; private final ContainerImporter importer; - private final boolean zeroCopyEnabled; - private final ZeroCopyMessageMarshaller sendContainerZeroCopyMessageMarshaller; private final ZeroCopyMessageMarshaller copyContainerZeroCopyMessageMarshaller; - public GrpcReplicationService(ContainerReplicationSource source, - ContainerImporter importer, boolean zeroCopyEnabled) { + public GrpcReplicationService(ContainerReplicationSource source, ContainerImporter importer) { this.source = source; this.importer = importer; - this.zeroCopyEnabled = zeroCopyEnabled; - - if (zeroCopyEnabled) { - sendContainerZeroCopyMessageMarshaller = new ZeroCopyMessageMarshaller<>( - SendContainerRequest.getDefaultInstance()); - copyContainerZeroCopyMessageMarshaller = new ZeroCopyMessageMarshaller<>( - CopyContainerRequestProto.getDefaultInstance()); - } else { - sendContainerZeroCopyMessageMarshaller = null; - copyContainerZeroCopyMessageMarshaller = null; - } + + sendContainerZeroCopyMessageMarshaller = new ZeroCopyMessageMarshaller<>( + SendContainerRequest.getDefaultInstance()); + copyContainerZeroCopyMessageMarshaller = new ZeroCopyMessageMarshaller<>( + CopyContainerRequestProto.getDefaultInstance()); } public ServerServiceDefinition bindServiceWithZeroCopy() { ServerServiceDefinition orig = super.bindService(); - if (!zeroCopyEnabled) { - LOG.info("Zerocopy is not enabled."); - return orig; - } Set methodNames = new HashSet<>(); ServerServiceDefinition.Builder builder = @@ -154,10 +141,7 @@ public void download(CopyContainerRequestProto request, } finally { // output may have already been closed, ignore such errors IOUtils.cleanupWithLogger(LOG, outputStream); - - if (copyContainerZeroCopyMessageMarshaller != null) { - copyContainerZeroCopyMessageMarshaller.release(request); - } + copyContainerZeroCopyMessageMarshaller.release(request); } } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java index b4e92a4a60a..6ca474bdd8a 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationServer.java @@ -99,13 +99,12 @@ public ReplicationServer(ContainerController controller, new LinkedBlockingQueue<>(replicationQueueLimit), threadFactory); - init(replicationConfig.isZeroCopyEnable()); + init(); } - public void init(boolean enableZeroCopy) { + public void init() { GrpcReplicationService grpcReplicationService = new GrpcReplicationService( - new OnDemandContainerReplicationSource(controller), importer, - enableZeroCopy); + new OnDemandContainerReplicationSource(controller), importer); NettyServerBuilder nettyServerBuilder = NettyServerBuilder.forPort(port) .maxInboundMessageSize(OzoneConsts.OZONE_SCM_CHUNK_MAX_SIZE) .addService(ServerInterceptors.intercept( @@ -203,11 +202,6 @@ public static final class ReplicationConfig { static final String REPLICATION_OUTOFSERVICE_FACTOR_KEY = PREFIX + "." + OUTOFSERVICE_FACTOR_KEY; - public static final String ZEROCOPY_ENABLE_KEY = "zerocopy.enabled"; - private static final boolean ZEROCOPY_ENABLE_DEFAULT = true; - private static final String ZEROCOPY_ENABLE_DEFAULT_VALUE = - "true"; - /** * The maximum number of replication commands a single datanode can execute * simultaneously. @@ -249,15 +243,6 @@ public static final class ReplicationConfig { ) private double outOfServiceFactor = OUTOFSERVICE_FACTOR_DEFAULT; - @Config(key = ZEROCOPY_ENABLE_KEY, - type = ConfigType.BOOLEAN, - defaultValue = ZEROCOPY_ENABLE_DEFAULT_VALUE, - tags = {DATANODE, SCM}, - description = "Specify if zero-copy should be enabled for " + - "replication protocol." - ) - private boolean zeroCopyEnable = ZEROCOPY_ENABLE_DEFAULT; - public double getOutOfServiceFactor() { return outOfServiceFactor; } @@ -291,14 +276,6 @@ public void setReplicationQueueLimit(int limit) { this.replicationQueueLimit = limit; } - public boolean isZeroCopyEnable() { - return zeroCopyEnable; - } - - public void setZeroCopyEnable(boolean zeroCopyEnable) { - this.zeroCopyEnable = zeroCopyEnable; - } - @PostConstruct public void validate() { if (replicationMaxStreams < 1) { diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationService.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationService.java index 03901b99be3..bca98d1e7dc 100644 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationService.java +++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationService.java @@ -83,17 +83,15 @@ class TestGrpcReplicationService { @BeforeEach public void setUp() throws Exception { - init(false); + init(); } - public void init(boolean isZeroCopy) throws Exception { + public void init() throws Exception { conf = new OzoneConfiguration(); ReplicationServer.ReplicationConfig replicationConfig = conf.getObject(ReplicationServer.ReplicationConfig.class); - replicationConfig.setZeroCopyEnable(isZeroCopy); - SecurityConfig secConf = new SecurityConfig(conf); ContainerSet containerSet = new ContainerSet(1000); @@ -230,7 +228,7 @@ public void copyData(long containerId, OutputStream destination, }; ContainerImporter importer = mock(ContainerImporter.class); GrpcReplicationService subject = - new GrpcReplicationService(source, importer, false); + new GrpcReplicationService(source, importer); CopyContainerRequestProto request = CopyContainerRequestProto.newBuilder() .setContainerID(1) diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationServiceWithZeroCopy.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationServiceWithZeroCopy.java deleted file mode 100644 index 00891cf3e24..00000000000 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestGrpcReplicationServiceWithZeroCopy.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.ozone.container.replication; - -import org.junit.jupiter.api.BeforeEach; - -/** - * Tests {@link GrpcReplicationService}. - */ -class TestGrpcReplicationServiceWithZeroCopy - extends TestGrpcReplicationService { - @BeforeEach - public void setUp() throws Exception { - init(true); - } -} diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStreamWithZeroCopy.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStream.java similarity index 99% rename from hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStreamWithZeroCopy.java rename to hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStream.java index 25e3f957104..5743866f2d2 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStreamWithZeroCopy.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestECKeyOutputStream.java @@ -14,6 +14,7 @@ * License for the specific language governing permissions and limitations under * the License. */ + package org.apache.hadoop.ozone.client.rpc; import org.apache.commons.lang3.NotImplementedException; @@ -74,7 +75,7 @@ /** * Tests key output stream. */ -class TestECKeyOutputStreamWithZeroCopy { +public class TestECKeyOutputStream { private static MiniOzoneCluster cluster; private static OzoneConfiguration conf = new OzoneConfiguration(); private static OzoneClient client;