예제 #1
0
        /// <summary>Create a client proxy for the specified engine.</summary>
        /// <exception cref="System.IO.IOException"/>
        private RPCCallBenchmark.RpcServiceWrapper CreateRpcClient(RPCCallBenchmark.MyOptions
                                                                   opts)
        {
            IPEndPoint addr = NetUtils.CreateSocketAddr(opts.host, opts.GetPort());

            if (opts.rpcEngine == typeof(ProtobufRpcEngine))
            {
                TestProtoBufRpc.TestRpcService proxy = RPC.GetProxy <TestProtoBufRpc.TestRpcService
                                                                     >(0, addr, conf);
                return(new _RpcServiceWrapper_394(proxy));
            }
            else
            {
                if (opts.rpcEngine == typeof(WritableRpcEngine))
                {
                    TestRPC.TestProtocol proxy = RPC.GetProxy <TestRPC.TestProtocol>(TestRPC.TestProtocol
                                                                                     .versionID, addr, conf);
                    return(new _RpcServiceWrapper_407(proxy));
                }
                else
                {
                    throw new RuntimeException("unsupported engine: " + opts.rpcEngine);
                }
            }
        }
예제 #2
0
 /// <exception cref="System.IO.IOException"/>
 private RPC.Server StartServer(RPCCallBenchmark.MyOptions opts)
 {
     if (opts.serverThreads <= 0)
     {
         return(null);
     }
     conf.SetInt(CommonConfigurationKeys.IpcServerRpcReadThreadsKey, opts.serverReaderThreads
                 );
     RPC.Server server;
     // Get RPC server for server side implementation
     if (opts.rpcEngine == typeof(ProtobufRpcEngine))
     {
         // Create server side implementation
         TestProtoBufRpc.PBServerImpl serverImpl = new TestProtoBufRpc.PBServerImpl();
         BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.NewReflectiveBlockingService
                                       (serverImpl);
         server = new RPC.Builder(conf).SetProtocol(typeof(TestProtoBufRpc.TestRpcService)
                                                    ).SetInstance(service).SetBindAddress(opts.host).SetPort(opts.GetPort()).SetNumHandlers
                      (opts.serverThreads).SetVerbose(false).Build();
     }
     else
     {
         if (opts.rpcEngine == typeof(WritableRpcEngine))
         {
             server = new RPC.Builder(conf).SetProtocol(typeof(TestRPC.TestProtocol)).SetInstance
                          (new TestRPC.TestImpl()).SetBindAddress(opts.host).SetPort(opts.GetPort()).SetNumHandlers
                          (opts.serverThreads).SetVerbose(false).Build();
         }
         else
         {
             throw new RuntimeException("Bad engine: " + opts.rpcEngine);
         }
     }
     server.Start();
     return(server);
 }