Exemple #1
0
        private void TestPbServerFactory()
        {
            IPEndPoint                addr     = new IPEndPoint(0);
            Configuration             conf     = new Configuration();
            ApplicationMasterProtocol instance = new TestRPCFactories.AMRMProtocolTestImpl(this
                                                                                           );
            Server server = null;

            try
            {
                server = RpcServerFactoryPBImpl.Get().GetServer(typeof(ApplicationMasterProtocol)
                                                                , instance, addr, conf, null, 1);
                server.Start();
            }
            catch (YarnRuntimeException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                NUnit.Framework.Assert.Fail("Failed to create server");
            }
            finally
            {
                if (server != null)
                {
                    server.Stop();
                }
            }
        }
Exemple #2
0
        private void TestPbClientFactory()
        {
            IPEndPoint addr = new IPEndPoint(0);

            System.Console.Error.WriteLine(addr.GetHostName() + addr.Port);
            Configuration             conf     = new Configuration();
            ApplicationMasterProtocol instance = new TestRPCFactories.AMRMProtocolTestImpl(this
                                                                                           );
            Server server = null;

            try
            {
                server = RpcServerFactoryPBImpl.Get().GetServer(typeof(ApplicationMasterProtocol)
                                                                , instance, addr, conf, null, 1);
                server.Start();
                System.Console.Error.WriteLine(server.GetListenerAddress());
                System.Console.Error.WriteLine(NetUtils.GetConnectAddress(server));
                ApplicationMasterProtocol amrmClient = null;
                try
                {
                    amrmClient = (ApplicationMasterProtocol)RpcClientFactoryPBImpl.Get().GetClient(typeof(
                                                                                                       ApplicationMasterProtocol), 1, NetUtils.GetConnectAddress(server), conf);
                }
                catch (YarnRuntimeException e)
                {
                    Sharpen.Runtime.PrintStackTrace(e);
                    NUnit.Framework.Assert.Fail("Failed to create client");
                }
            }
            catch (YarnRuntimeException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                NUnit.Framework.Assert.Fail("Failed to create server");
            }
            finally
            {
                if (server != null)
                {
                    server.Stop();
                }
            }
        }