This is an automated email from the ASF dual-hosted git repository.
duong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new d4e0620317 HDDS-8777. Ratis Echo Freon Command (#4844)
d4e0620317 is described below
commit d4e0620317bf3cd7d51ec69092739510897fc6d4
Author: tanvipenumudy <[email protected]>
AuthorDate: Wed Sep 6 04:46:11 2023 +0530
HDDS-8777. Ratis Echo Freon Command (#4844)
---
.../main/java/org/apache/hadoop/ozone/OmUtils.java | 3 +-
.../ozone/om/protocol/OzoneManagerProtocol.java | 6 +-
...OzoneManagerProtocolClientSideTranslatorPB.java | 6 +-
.../src/main/smoketest/freon/echoRPCLoad.robot | 22 ++++++--
.../src/main/proto/OmClientProtocol.proto | 1 +
.../apache/hadoop/ozone/common/PayloadUtils.java | 44 +++++++++++++++
.../apache/hadoop/ozone/common/package-info.java | 22 ++++++++
.../org/apache/hadoop/ozone/om/OzoneManager.java | 4 +-
.../om/ratis/utils/OzoneManagerRatisUtils.java | 3 +
.../om/request/util/OMEchoRPCWriteRequest.java | 64 ++++++++++++++++++++++
.../om/response/util/OMEchoRPCWriteResponse.java | 48 ++++++++++++++++
.../ozone/om/response/util/package-info.java | 22 ++++++++
.../protocolPB/OzoneManagerRequestHandler.java | 17 ++----
.../ozone/om/response/TestCleanupTableInfo.java | 3 +
.../hadoop/ozone/freon/OmRPCLoadGenerator.java | 8 ++-
15 files changed, 246 insertions(+), 27 deletions(-)
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
index 711db38bcb..5a293d3256 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
@@ -257,7 +257,6 @@ public final class OmUtils {
case TenantGetUserInfo:
case TenantListUser:
case ListSnapshot:
- case EchoRPC:
case RefetchSecretKey:
case RangerBGSync:
// RangerBGSync is a read operation in the sense that it doesn't directly
@@ -323,6 +322,8 @@ public final class OmUtils {
case SetTimes:
case UnknownCommand:
return false;
+ case EchoRPC:
+ return omRequest.getEchoRPCRequest().getReadOnly();
default:
LOG.error("CmdType {} is not categorized as readOnly or not.", cmdType);
return false;
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java
index 0a712c9387..eddba4f96f 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OzoneManagerProtocol.java
@@ -1039,12 +1039,12 @@ public interface OzoneManagerProtocol
* to benchmark RPC communication performance.
* @param payloadReq payload in request.
* @param payloadSizeResp payload size of response.
+ * @param writeToRatis write to Ratis log if flag is set to true.
* @throws IOException if there is error in the RPC communication.
* @return EchoRPCResponse.
*/
- EchoRPCResponse echoRPCReq(byte[] payloadReq,
- int payloadSizeResp)
- throws IOException;
+ EchoRPCResponse echoRPCReq(byte[] payloadReq, int payloadSizeResp,
+ boolean writeToRatis) throws IOException;
/**
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java
index 813b22e5a3..c53ea15617 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java
@@ -2309,13 +2309,13 @@ public final class
OzoneManagerProtocolClientSideTranslatorPB
}
@Override
- public EchoRPCResponse echoRPCReq(byte[] payloadReq,
- int payloadSizeResp)
- throws IOException {
+ public EchoRPCResponse echoRPCReq(byte[] payloadReq, int payloadSizeResp,
+ boolean writeToRatis) throws IOException {
EchoRPCRequest echoRPCRequest =
EchoRPCRequest.newBuilder()
.setPayloadReq(ByteString.copyFrom(payloadReq))
.setPayloadSizeResp(payloadSizeResp)
+ .setReadOnly(!writeToRatis)
.build();
OMRequest omRequest = createOMRequest(Type.EchoRPC)
diff --git a/hadoop-ozone/dist/src/main/smoketest/freon/echoRPCLoad.robot
b/hadoop-ozone/dist/src/main/smoketest/freon/echoRPCLoad.robot
index f253f535af..32456af488 100644
--- a/hadoop-ozone/dist/src/main/smoketest/freon/echoRPCLoad.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/freon/echoRPCLoad.robot
@@ -23,20 +23,34 @@ ${PREFIX} ${EMPTY}
${n} 1
*** Test Cases ***
-Ozone Echo RPC Load Generator with request payload and response payload
+[Read] Ozone Echo RPC Load Generator with request payload and response payload
${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-req=1 --payload-resp=1
Should contain ${result} Successful executions: ${n}
-Ozone Echo RPC Load Generator with request payload and empty response payload
+[Read] Ozone Echo RPC Load Generator with request payload and empty response
payload
${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-req=1
Should contain ${result} Successful executions: ${n}
-Ozone Echo RPC Load Generator with empty request payload and response payload
+[Read] Ozone Echo RPC Load Generator with empty request payload and response
payload
${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-resp=1
Should contain ${result} Successful executions: ${n}
-Ozone Echo RPC Load Generator with empty request payload and empty response
payload
+[Read] Ozone Echo RPC Load Generator with empty request payload and empty
response payload
${result} = Execute ozone freon ome -t=1 -n=${n}
Should contain ${result} Successful executions: ${n}
+[Write] Ozone Echo RPC Load Generator with request payload and response payload
+ ${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-req=1 --payload-resp=1 --ratis
+ Should contain ${result} Successful executions: ${n}
+
+[Write] Ozone Echo RPC Load Generator with request payload and empty response
payload
+ ${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-req=1 --ratis
+ Should contain ${result} Successful executions: ${n}
+[Write] Ozone Echo RPC Load Generator with empty request payload and response
payload
+ ${result} = Execute ozone freon ome -t=1 -n=${n}
--payload-resp=1 --ratis
+ Should contain ${result} Successful executions: ${n}
+
+[Write] Ozone Echo RPC Load Generator with empty request payload and empty
response payload
+ ${result} = Execute ozone freon ome -t=1 -n=${n} --ratis
+ Should contain ${result} Successful executions: ${n}
diff --git
a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
index ace7028128..fc4844302b 100644
--- a/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
+++ b/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto
@@ -1609,6 +1609,7 @@ message PartInfo {
message EchoRPCRequest {
optional bytes payloadReq = 1;
optional int32 payloadSizeResp = 2;
+ optional bool readOnly = 3 [default = true];
}
/**
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/PayloadUtils.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/PayloadUtils.java
new file mode 100644
index 0000000000..d198bfcbfc
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/PayloadUtils.java
@@ -0,0 +1,44 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.common;
+
+import org.apache.commons.lang3.RandomUtils;
+
+/**
+ * Utility class for payload operations.
+ */
+public final class PayloadUtils {
+
+ private static final int RPC_PAYLOAD_MULTIPLICATION_FACTOR = 1024;
+ private static final int MAX_SIZE_KB = 2097151;
+
+ private PayloadUtils() {
+ }
+
+ public static byte[] generatePayloadBytes(int payloadSize) {
+
+ byte[] payloadBytes = new byte[0];
+ int payloadRespSize =
+ Math.min(payloadSize * RPC_PAYLOAD_MULTIPLICATION_FACTOR, MAX_SIZE_KB);
+ if (payloadRespSize > 0) {
+ payloadBytes = RandomUtils.nextBytes(payloadRespSize);
+ }
+
+ return payloadBytes;
+ }
+}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/package-info.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/package-info.java
new file mode 100644
index 0000000000..c7e177f2d4
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/common/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * 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.common;
+
+/**
+ * Utility classes for common operations in the OM.
+ */
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
index f421a3e6d8..b30ff26de3 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
@@ -4458,8 +4458,8 @@ public final class OzoneManager extends
ServiceRuntimeInfoImpl
}
@Override
- public EchoRPCResponse echoRPCReq(byte[] payloadReq,
- int payloadSizeResp) {
+ public EchoRPCResponse echoRPCReq(byte[] payloadReq, int payloadSizeResp,
+ boolean writeToRatis) {
return null;
}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
index 399b2cecc7..c07969e6fc 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/utils/OzoneManagerRatisUtils.java
@@ -80,6 +80,7 @@ import
org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotPurgeRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMCancelPrepareRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMFinalizeUpgradeRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMPrepareRequest;
+import org.apache.hadoop.ozone.om.request.util.OMEchoRPCWriteRequest;
import org.apache.hadoop.ozone.om.request.volume.OMVolumeCreateRequest;
import org.apache.hadoop.ozone.om.request.volume.OMVolumeDeleteRequest;
import org.apache.hadoop.ozone.om.request.volume.OMVolumeSetOwnerRequest;
@@ -319,6 +320,8 @@ public final class OzoneManagerRatisUtils {
volumeName = keyArgs.getVolumeName();
bucketName = keyArgs.getBucketName();
break;
+ case EchoRPC:
+ return new OMEchoRPCWriteRequest(omRequest);
default:
throw new OMException("Unrecognized write command type request "
+ cmdType, OMException.ResultCodes.INVALID_REQUEST);
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/util/OMEchoRPCWriteRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/util/OMEchoRPCWriteRequest.java
new file mode 100644
index 0000000000..0cc8282cc4
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/util/OMEchoRPCWriteRequest.java
@@ -0,0 +1,64 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.om.request.util;
+
+import com.google.protobuf.ByteString;
+import org.apache.hadoop.ozone.common.PayloadUtils;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
+import org.apache.hadoop.ozone.om.request.OMClientRequest;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import org.apache.hadoop.ozone.om.response.util.OMEchoRPCWriteResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.EchoRPCRequest;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.EchoRPCResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+
+/**
+ * Handles EchoRPC request (write).
+ */
+public class OMEchoRPCWriteRequest extends OMClientRequest {
+
+ public OMEchoRPCWriteRequest(OMRequest omRequest) {
+ super(omRequest);
+ }
+
+ @Override
+ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
+ long trxnLogIndex, OzoneManagerDoubleBufferHelper omDoubleBufferHelper) {
+
+ EchoRPCRequest echoRPCRequest = getOmRequest().getEchoRPCRequest();
+
+ byte[] payloadBytes =
+ PayloadUtils.generatePayloadBytes(echoRPCRequest.getPayloadSizeResp());
+
+ EchoRPCResponse echoRPCResponse = EchoRPCResponse.newBuilder()
+ .setPayload(ByteString.copyFrom(payloadBytes))
+ .build();
+
+ OMResponse.Builder omResponse =
+ OmResponseUtil.getOMResponseBuilder(getOmRequest());
+ OMClientResponse omClientResponse = new OMEchoRPCWriteResponse(
+ omResponse.setEchoRPCResponse(echoRPCResponse).build());
+ addResponseToDoubleBuffer(trxnLogIndex, omClientResponse,
+ omDoubleBufferHelper);
+
+ return omClientResponse;
+ }
+}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/OMEchoRPCWriteResponse.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/OMEchoRPCWriteResponse.java
new file mode 100644
index 0000000000..bf1fe3bdac
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/OMEchoRPCWriteResponse.java
@@ -0,0 +1,48 @@
+/*
+ * 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.om.response.util;
+
+import org.apache.hadoop.hdds.utils.db.BatchOperation;
+import org.apache.hadoop.ozone.om.OMMetadataManager;
+import org.apache.hadoop.ozone.om.response.CleanupTableInfo;
+import org.apache.hadoop.ozone.om.response.OMClientResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+
+import java.io.IOException;
+
+/**
+ * Response for EchoRPC request (write).
+ */
+@CleanupTableInfo
+public class OMEchoRPCWriteResponse extends OMClientResponse {
+
+ public OMEchoRPCWriteResponse(OMResponse omResponse) {
+ super(omResponse);
+ }
+
+ @Override
+ protected void addToDBBatch(OMMetadataManager omMetadataManager,
+ BatchOperation batchOperation)
+ throws IOException {
+ // Overrides the addToDBBatch method to prevent a db/cache update.
+ // The purpose of this override is to facilitate isolated benchmarking of
+ // Ratis without extensive backend modifications.
+ return;
+ }
+}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/package-info.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/package-info.java
new file mode 100644
index 0000000000..2c27968934
--- /dev/null
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/util/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 contains helper/utility classes for responses.
+ */
+package org.apache.hadoop.ozone.om.response.util;
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java
index b196e21735..08ba705495 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java
@@ -26,7 +26,6 @@ import java.util.stream.Collectors;
import com.google.protobuf.ByteString;
import com.google.protobuf.ServiceException;
-import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -38,6 +37,7 @@ import
org.apache.hadoop.hdds.protocol.proto.HddsProtos.TransferLeadershipRespon
import
org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.common.PayloadUtils;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.OzoneManagerPrepareState;
import org.apache.hadoop.ozone.om.exceptions.OMException;
@@ -162,8 +162,6 @@ public class OzoneManagerRequestHandler implements
RequestHandler {
LoggerFactory.getLogger(OzoneManagerRequestHandler.class);
private final OzoneManager impl;
private OzoneManagerDoubleBuffer ozoneManagerDoubleBuffer;
- private static final int RPC_PAYLOAD_MULTIPLICATION_FACTOR = 1024;
- private static final int MAX_SIZE_KB = 2097151;
public OzoneManagerRequestHandler(OzoneManager om,
OzoneManagerDoubleBuffer ozoneManagerDoubleBuffer) {
@@ -1348,16 +1346,9 @@ public class OzoneManagerRequestHandler implements
RequestHandler {
}
private EchoRPCResponse echoRPC(EchoRPCRequest req) {
- EchoRPCResponse.Builder builder =
- EchoRPCResponse.newBuilder();
-
- byte[] payloadBytes = new byte[0];
- int payloadRespSize = Math.min(
- req.getPayloadSizeResp()
- * RPC_PAYLOAD_MULTIPLICATION_FACTOR, MAX_SIZE_KB);
- if (payloadRespSize > 0) {
- payloadBytes = RandomUtils.nextBytes(payloadRespSize);
- }
+ EchoRPCResponse.Builder builder = EchoRPCResponse.newBuilder();
+ byte[] payloadBytes =
+ PayloadUtils.generatePayloadBytes(req.getPayloadSizeResp());
builder.setPayload(ByteString.copyFrom(payloadBytes));
return builder.build();
}
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/TestCleanupTableInfo.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/TestCleanupTableInfo.java
index f498372544..2aa96a1e73 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/TestCleanupTableInfo.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/response/TestCleanupTableInfo.java
@@ -45,6 +45,7 @@ import
org.apache.hadoop.ozone.om.request.key.OMKeyCreateRequest;
import org.apache.hadoop.ozone.om.response.file.OMFileCreateResponse;
import org.apache.hadoop.ozone.om.response.key.OMKeyCreateResponse;
import org.apache.hadoop.ozone.om.response.key.OmKeyResponse;
+import org.apache.hadoop.ozone.om.response.util.OMEchoRPCWriteResponse;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateFileRequest;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs;
@@ -150,6 +151,8 @@ public class TestCleanupTableInfo {
Set<Class<? extends OMClientResponse>> subTypes = responseClasses();
// OmKeyResponse is an abstract class that does not need CleanupTable.
subTypes.remove(OmKeyResponse.class);
+ // OMEchoRPCWriteResponse does not need CleanupTable.
+ subTypes.remove(OMEchoRPCWriteResponse.class);
subTypes.forEach(aClass -> {
Assert.assertTrue(aClass + " does not have annotation of" +
" CleanupTableInfo",
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmRPCLoadGenerator.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmRPCLoadGenerator.java
index c2f4caa94f..958df4c11a 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmRPCLoadGenerator.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/OmRPCLoadGenerator.java
@@ -68,6 +68,12 @@ public class OmRPCLoadGenerator extends BaseFreonGenerator
"Max size is 2097151 KB",
defaultValue = "0")
private int payloadRespSizeKB = 0;
+
+ @Option(names = {"--ratis"},
+ description = "Write to Ratis log, skip flag for read-only EchoRPC " +
+ "request")
+ private boolean writeToRatis = false;
+
@Override
public Void call() throws Exception {
Preconditions.checkArgument(payloadReqSizeKB >= 0,
@@ -111,7 +117,7 @@ public class OmRPCLoadGenerator extends BaseFreonGenerator
private void sendRPCReq(long l) throws Exception {
timer.time(() -> {
clients[(int) (l % clientsCount)].echoRPCReq(payloadReqBytes,
- payloadRespSize);
+ payloadRespSize, writeToRatis);
return null;
});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]