public virtual void SetUp() { // Setup server for both protocols conf = new Configuration(); conf.SetInt(CommonConfigurationKeys.IpcMaximumDataLength, 1024); // Set RPC engine to protobuf RPC engine RPC.SetProtocolEngine(conf, typeof(TestProtoBufRpc.TestRpcService), typeof(ProtobufRpcEngine )); // Create server side implementation TestProtoBufRpc.PBServerImpl serverImpl = new TestProtoBufRpc.PBServerImpl(); BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.NewReflectiveBlockingService (serverImpl); // Get RPC server for server side implementation server = new RPC.Builder(conf).SetProtocol(typeof(TestProtoBufRpc.TestRpcService) ).SetInstance(service).SetBindAddress(Address).SetPort(Port).Build(); addr = NetUtils.GetConnectAddress(server); // now the second protocol TestProtoBufRpc.PBServer2Impl server2Impl = new TestProtoBufRpc.PBServer2Impl(); BlockingService service2 = TestRpcServiceProtos.TestProtobufRpc2Proto.NewReflectiveBlockingService (server2Impl); server.AddProtocol(RPC.RpcKind.RpcProtocolBuffer, typeof(TestProtoBufRpc.TestRpcService2 ), service2); server.Start(); }
public virtual void SetUp() { // create a server with two handlers server = new RPC.Builder(conf).SetProtocol(typeof(TestMultipleProtocolServer.Foo0 )).SetInstance(new TestMultipleProtocolServer.Foo0Impl(this)).SetBindAddress(Address ).SetPort(0).SetNumHandlers(2).SetVerbose(false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Foo1 ), new TestMultipleProtocolServer.Foo1Impl(this)); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Bar ), new TestMultipleProtocolServer.BarImpl(this)); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Mixin ), new TestMultipleProtocolServer.BarImpl(this)); // Add Protobuf server // Create server side implementation TestProtoBufRpc.PBServerImpl pbServerImpl = new TestProtoBufRpc.PBServerImpl(); BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.NewReflectiveBlockingService (pbServerImpl); server.AddProtocol(RPC.RpcKind.RpcProtocolBuffer, typeof(TestProtoBufRpc.TestRpcService ), service); server.Start(); addr = NetUtils.GetConnectAddress(server); }
/// <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); }