private void doInit(bool enableSystem, bool enableUser)
        {
            if (enableSystem)
            {
                java.lang.System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
            }
            else
            {
                java.lang.System.setProperty(Configs.CONN_RECONNECT_SWITCH, "false");
            }
            server = new BoltServer(port);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            if (enableUser)
            {
                client.enableReconnectSwitch();
            }
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();
        }
Esempio n. 2
0
        public virtual void testLowBiggerThanHigh()
        {
            java.lang.System.setProperty(Configs.NETTY_BUFFER_HIGH_WATERMARK, Convert.ToString(1));
            java.lang.System.setProperty(Configs.NETTY_BUFFER_LOW_WATERMARK, Convert.ToString(2));
            try
            {
                server = new BoltServer(port, true);
                server.start();
                Assert.Null("should not reach here");
            }
            catch (InvalidOperationException)
            {
                // expect IllegalStateException
            }

            try
            {
                client = new RpcClient();
                client.startup();
                Assert.Null("should not reach here");
            }
            catch (ArgumentException)
            {
                // expect IllegalStateException
            }
        }
Esempio n. 3
0
 public ShareSameServerTestFixture()
 {
     server = new BoltServer(port);
     server.start();
     server.registerUserProcessor(serverUserProcessor);
     server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
 }
 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @Before private void init()
 private void init()
 {
     server = new BoltServer(port);
     server.start();
     server.addConnectionEventProcessor(ConnectionEventType.CONNECT, new CONNECTEventProcessor());
     client = new RpcClient();
     client.startup();
 }
Esempio n. 5
0
 private void init()
 {
     cm = new DefaultClientConnectionManager(connectionSelectStrategy, connectionFactory, connectionEventHandler, connectionEventListener);
     cm.AddressParser = addressParser;
     cm.startup();
     server = new BoltServer(port);
     server.start();
     server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
 }
        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Before private void init() throws ThreadInterruptedException
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        private void init()
        {
            concurrent = maxThread + workQueue;
            //        java.lang.System.setProperty(RpcConfigs.TP_MIN_SIZE, "1");
            //        java.lang.System.setProperty(RpcConfigs.TP_QUEUE_SIZE, "4");
            //        java.lang.System.setProperty(RpcConfigs.TP_MAX_SIZE, "3");

            server = new BoltServer(port);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();

            for (int i = 0; i < concurrent; i++)
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final com.alipay.remoting.rpc.common.RequestBody bd = new com.alipay.remoting.rpc.common.RequestBody(i + 1, "Hello world!");
                RequestBody bd = new RequestBody(i + 1, "Hello world!");
                Thread      t  = new Thread(() =>
                {
                    object obj = null;
                    try
                    {
                        logger.LogInformation("client fire! =========" + bd.Id);
                        obj = client.invokeSync(addr, bd, 2000);
                    }
                    catch (InvokeTimeoutException)
                    {
                        Assert.Null(obj);
                    }
                    catch (RemotingException e)
                    {
                        logger.LogError("Other RemotingException but InvokeTimeoutException occurred in sync", e);
                        Assert.Null("Should not reach here!");
                    }
                    catch (ThreadInterruptedException e)
                    {
                        logger.LogError("ThreadInterruptedException in sync", e);
                        Assert.Null("Should not reach here!");
                    }
                });
                t.Start();
                Thread.Sleep(100);
            }
            Thread.Sleep(100);
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before private void init()
        private void init()
        {
            server = new BoltServer(port, true);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before private void init() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        private void init()
        {
            server = new BoltServer(port);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);             // no use here

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);             // no use here
            client.startup();
            Thread.Sleep(100);
        }
Esempio n. 9
0
        private void init()
        {
            java.lang.System.setProperty(Configs.TCP_IDLE, "100");
            java.lang.System.setProperty(Configs.TCP_IDLE_SWITCH, Convert.ToString(true));
            server = new BoltServer(port);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();
        }
        private void init()
        {
            ProtocolManager.unRegisterProtocol(RpcProtocolV2.PROTOCOL_CODE);

            server = new BoltServer(port, true);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before private void init()
        private void init()
        {
            java.lang.System.setProperty(Configs.NETTY_BUFFER_HIGH_WATERMARK, Convert.ToString(2));
            java.lang.System.setProperty(Configs.NETTY_BUFFER_LOW_WATERMARK, Convert.ToString(1));

            server = new BoltServer(port, true);
            server.start();
            server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
            server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
            server.registerUserProcessor(serverUserProcessor);

            client = new RpcClient();
            client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
            client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
            client.registerUserProcessor(clientUserProcessor);
            client.startup();
        }
Esempio n. 12
0
 public Program()
 {
     // 1. create a Rpc server with port assigned
     server = new BoltServer(port);
     // 2. add processor for connect and close event if you need
     server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
     server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
     // 3. register user processor for client request
     server.registerUserProcessor(serverUserProcessor);
     // 4. server start
     if (server.start())
     {
         Console.WriteLine("server start ok!");
     }
     else
     {
         Console.WriteLine("server start failed!");
     }
     //server.RpcServer.shutdown();
     Console.ReadLine();
 }
Esempio n. 13
0
        //ORIGINAL LINE: @Test public void testHighSmallerThanDefaultLow() throws ThreadInterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testHighSmallerThanDefaultLow()
        {
            java.lang.System.setProperty(Configs.NETTY_BUFFER_HIGH_WATERMARK, Convert.ToString(3 * 1024));
            java.lang.System.setProperty(Configs.NETTY_BUFFER_LOW_WATERMARK, Convert.ToString(2 * 1024));
            server = new BoltServer(port, true);
            Assert.True(server.start());

            try
            {
                client = new RpcClient();
                client.startup();
                client.getConnection(addr, 3000);
            }
            catch (ArgumentException)
            {
                Assert.Null("should not reach here");
            }
            catch (RemotingException)
            {
                // not connected, but ok, here only test args init
            }
        }
Esempio n. 14
0
 private void StartBoltServer(CancellationToken cancellationToken)
 {
     this.boltServer = new BoltServer();
     this.boltServer.Start(cancellationToken);
 }