You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2020/11/06 23:35:07 UTC
[hadoop] branch branch-3.1 updated: HDFS-15623. Respect configured
values of rpc.engine (#2403) Contributed by Hector Chaverri.
This is an automated email from the ASF dual-hosted git repository.
shv pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 3443d7594 HDFS-15623. Respect configured values of rpc.engine (#2403) Contributed by Hector Chaverri.
3443d7594 is described below
commit 3443d759468e7f0c7450a713e360238289a6378b
Author: hchaverr <hc...@linkedin.com>
AuthorDate: Thu Oct 22 10:32:28 2020 -0700
HDFS-15623. Respect configured values of rpc.engine (#2403) Contributed by Hector Chaverri.
(cherry picked from commit 6eacaffeea21e7e9286497ee17f89fd939d2eead)
---
.../src/main/java/org/apache/hadoop/ipc/RPC.java | 8 ++++++--
.../src/test/java/org/apache/hadoop/ipc/TestRPC.java | 12 ++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
index 9287b5a..9f87864 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java
@@ -193,14 +193,18 @@ public class RPC {
private static final String ENGINE_PROP = "rpc.engine";
/**
- * Set a protocol to use a non-default RpcEngine.
+ * Set a protocol to use a non-default RpcEngine if one
+ * is not specified in the configuration.
* @param conf configuration to use
* @param protocol the protocol interface
* @param engine the RpcEngine impl
*/
public static void setProtocolEngine(Configuration conf,
Class<?> protocol, Class<?> engine) {
- conf.setClass(ENGINE_PROP+"."+protocol.getName(), engine, RpcEngine.class);
+ if (conf.get(ENGINE_PROP+"."+protocol.getName()) == null) {
+ conf.setClass(ENGINE_PROP+"."+protocol.getName(), engine,
+ RpcEngine.class);
+ }
}
// return the RpcEngine configured to handle a protocol
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java
index 3d723c9..2d50902 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java
@@ -1501,6 +1501,18 @@ public class TestRPC extends TestRpcBase {
}
}
+ @Test
+ public void testSetProtocolEngine() {
+ Configuration conf = new Configuration();
+ RPC.setProtocolEngine(conf, StoppedProtocol.class, StoppedRpcEngine.class);
+ RpcEngine rpcEngine = RPC.getProtocolEngine(StoppedProtocol.class, conf);
+ assertTrue(rpcEngine instanceof StoppedRpcEngine);
+
+ RPC.setProtocolEngine(conf, StoppedProtocol.class, ProtobufRpcEngine.class);
+ rpcEngine = RPC.getProtocolEngine(StoppedProtocol.class, conf);
+ assertTrue(rpcEngine instanceof StoppedRpcEngine);
+ }
+
public static void main(String[] args) throws Exception {
new TestRPC().testCallsInternal(conf);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org