コード例 #1
0
            private void InitProtocolMetaInfo(Configuration conf)
            {
                RPC.SetProtocolEngine(conf, typeof(ProtocolMetaInfoPB), typeof(ProtobufRpcEngine)
                                      );
                ProtocolMetaInfoServerSideTranslatorPB xlator = new ProtocolMetaInfoServerSideTranslatorPB
                                                                    (this);
                BlockingService protocolInfoBlockingService = ProtocolInfoProtos.ProtocolInfoService
                                                              .NewReflectiveBlockingService(xlator);

                AddProtocol(RPC.RpcKind.RpcProtocolBuffer, typeof(ProtocolMetaInfoPB), protocolInfoBlockingService
                            );
            }
コード例 #2
0
        public virtual void TestProtocolMetaInfoSSTranslatorPB()
        {
            TestRPCCompatibility.TestImpl1 impl = new TestRPCCompatibility.TestImpl1();
            server = new RPC.Builder(conf).SetProtocol(typeof(TestRPCCompatibility.TestProtocol1
                                                              )).SetInstance(impl).SetBindAddress(Address).SetPort(0).SetNumHandlers(2).SetVerbose
                         (false).Build();
            server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestRPCCompatibility.TestProtocol0
                                                               ), impl);
            server.Start();
            ProtocolMetaInfoServerSideTranslatorPB xlator = new ProtocolMetaInfoServerSideTranslatorPB
                                                                (server);

            ProtocolInfoProtos.GetProtocolSignatureResponseProto resp = xlator.GetProtocolSignature
                                                                            (null, CreateGetProtocolSigRequestProto(typeof(TestRPCCompatibility.TestProtocol1
                                                                                                                           ), RPC.RpcKind.RpcProtocolBuffer));
            //No signatures should be found
            Assert.Equal(0, resp.GetProtocolSignatureCount());
            resp = xlator.GetProtocolSignature(null, CreateGetProtocolSigRequestProto(typeof(
                                                                                          TestRPCCompatibility.TestProtocol1), RPC.RpcKind.RpcWritable));
            Assert.Equal(1, resp.GetProtocolSignatureCount());
            ProtocolInfoProtos.ProtocolSignatureProto sig = resp.GetProtocolSignatureList()[0
                                                            ];
            Assert.Equal(TestRPCCompatibility.TestProtocol1.versionID, sig
                         .GetVersion());
            bool found    = false;
            int  expected = ProtocolSignature.GetFingerprint(typeof(TestRPCCompatibility.TestProtocol1
                                                                    ).GetMethod("echo", typeof(string)));

            foreach (int m in sig.GetMethodsList())
            {
                if (expected == m)
                {
                    found = true;
                    break;
                }
            }
            Assert.True(found);
        }