File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
hadoop-common-project/hadoop-common/src
main/java/org/apache/hadoop/ipc
test/java/org/apache/hadoop/ipc Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -195,14 +195,18 @@ private RPC() {} // no public ctor
195195 private static final String ENGINE_PROP = "rpc.engine" ;
196196
197197 /**
198- * Set a protocol to use a non-default RpcEngine.
198+ * Set a protocol to use a non-default RpcEngine if one
199+ * is not specified in the configuration.
199200 * @param conf configuration to use
200201 * @param protocol the protocol interface
201202 * @param engine the RpcEngine impl
202203 */
203204 public static void setProtocolEngine (Configuration conf ,
204205 Class <?> protocol , Class <?> engine ) {
205- conf .setClass (ENGINE_PROP +"." +protocol .getName (), engine , RpcEngine .class );
206+ if (conf .get (ENGINE_PROP +"." +protocol .getName ()) == null ) {
207+ conf .setClass (ENGINE_PROP +"." +protocol .getName (), engine ,
208+ RpcEngine .class );
209+ }
206210 }
207211
208212 // return the RpcEngine configured to handle a protocol
Original file line number Diff line number Diff line change @@ -1554,6 +1554,18 @@ public RpcStatusProto getRpcStatusProto() {
15541554 }
15551555 }
15561556
1557+ @ Test
1558+ public void testSetProtocolEngine () {
1559+ Configuration conf = new Configuration ();
1560+ RPC .setProtocolEngine (conf , StoppedProtocol .class , StoppedRpcEngine .class );
1561+ RpcEngine rpcEngine = RPC .getProtocolEngine (StoppedProtocol .class , conf );
1562+ assertTrue (rpcEngine instanceof StoppedRpcEngine );
1563+
1564+ RPC .setProtocolEngine (conf , StoppedProtocol .class , ProtobufRpcEngine .class );
1565+ rpcEngine = RPC .getProtocolEngine (StoppedProtocol .class , conf );
1566+ assertTrue (rpcEngine instanceof StoppedRpcEngine );
1567+ }
1568+
15571569 public static void main (String [] args ) throws Exception {
15581570 new TestRPC ().testCallsInternal (conf );
15591571 }
You can’t perform that action at this time.
0 commit comments