HDFS-15623. Respect configured values of rpc.engine (#2403) Contributed by Hector Chaverri.
This commit is contained in:
parent
4b312810ae
commit
6eacaffeea
@ -195,14 +195,18 @@ private RPC() {} // no public ctor
|
|||||||
private static final String ENGINE_PROP = "rpc.engine";
|
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 conf configuration to use
|
||||||
* @param protocol the protocol interface
|
* @param protocol the protocol interface
|
||||||
* @param engine the RpcEngine impl
|
* @param engine the RpcEngine impl
|
||||||
*/
|
*/
|
||||||
public static void setProtocolEngine(Configuration conf,
|
public static void setProtocolEngine(Configuration conf,
|
||||||
Class<?> protocol, Class<?> engine) {
|
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
|
// return the RpcEngine configured to handle a protocol
|
||||||
|
@ -1554,6 +1554,18 @@ public RpcStatusProto getRpcStatusProto() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 {
|
public static void main(String[] args) throws Exception {
|
||||||
new TestRPC().testCallsInternal(conf);
|
new TestRPC().testCallsInternal(conf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user