com.alipay.remoting.rpc.RpcClient Java Examples

The following examples show how to use com.alipay.remoting.rpc.RpcClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AloneBoltClientConnectionManager.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
/**
 * 通过配置获取长连接
 *
 * @param rpcClient       bolt客户端
 * @param transportConfig 传输层配置
 * @param url             传输层地址
 * @return 长连接
 */
public Connection getConnection(RpcClient rpcClient, ClientTransportConfig transportConfig, Url url) {
    if (rpcClient == null || transportConfig == null || url == null) {
        return null;
    }
    Connection connection;
    try {
        connection = rpcClient.getConnection(url, url.getConnectTimeout());
    } catch (InterruptedException | RemotingException e) {
        throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_GET_CONNECTION),e);
    }
    if (connection == null) {
        return null;
    }

    return connection;
}
 
Example #2
Source File: BasicUsage_ExecutorSelector_Test.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    server = new BoltServer(port, true);
    server.start();
    server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
    server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
    serverUserProcessor.setExecutorSelector(this.selector0);
    server.registerUserProcessor(serverUserProcessor);

    client = new RpcClient();
    client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
    client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
    clientUserProcessor.setExecutorSelector(this.selector1);
    client.registerUserProcessor(clientUserProcessor);
    client.init();
}
 
Example #3
Source File: ReconnectManagerTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
private void doInit(boolean enableSystem, boolean enableUser) {
    if (enableSystem) {
        System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
    } else {
        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.init();
}
 
Example #4
Source File: ScheduledDisconnectStrategyTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
private void doInit(boolean enableSystem, boolean enableUser) {
    if (enableSystem) {
        System.setProperty(Configs.CONN_MONITOR_SWITCH, "true");
        System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
    } else {
        System.setProperty(Configs.CONN_MONITOR_SWITCH, "false");
        System.setProperty(Configs.CONN_RECONNECT_SWITCH, "false");
    }
    server = new BoltServer(port, false, true);
    server.start();
    server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
    server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
    server.registerUserProcessor(serverUserProcessor);

    client = new RpcClient();
    if (enableUser) {
        client.enableReconnectSwitch();
        client.enableConnectionMonitorSwitch();
    }
    client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
    client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
    client.registerUserProcessor(clientUserProcessor);
    client.init();
}
 
Example #5
Source File: BasicUsageTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public 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.init();
}
 
Example #6
Source File: ServerTimeoutSwitchTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    server = new BoltServer(port);
    server.start();
    server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
    server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);

    serverUserProcessor.setTimeoutDiscard(false);
    server.registerUserProcessor(serverUserProcessor);

    client = new RpcClient();
    client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
    client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
    clientUserProcessor.setTimeoutDiscard(false);
    client.registerUserProcessor(clientUserProcessor);
    client.init();
}
 
Example #7
Source File: GlobalSwitchTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Test
public void testUserSettings_takesEffect_before_SystemSettingsFalse() {
    System.setProperty(Configs.CONN_RECONNECT_SWITCH, "false");
    System.setProperty(Configs.CONN_MONITOR_SWITCH, "false");
    client1 = new RpcClient();
    client2 = new RpcClient();

    client1.enableConnectionMonitorSwitch();
    client1.enableReconnectSwitch();
    Assert.assertTrue(client1.isConnectionMonitorSwitchOn());
    Assert.assertTrue(client1.isReconnectSwitchOn());
    Assert.assertFalse(client2.isConnectionMonitorSwitchOn());
    Assert.assertFalse(client2.isReconnectSwitchOn());

    client1.disableConnectionMonitorSwitch();
    client1.disableReconnectSwith();
    client2.enableConnectionMonitorSwitch();
    client2.enableReconnectSwitch();
    Assert.assertFalse(client1.isConnectionMonitorSwitchOn());
    Assert.assertFalse(client1.isReconnectSwitchOn());
    Assert.assertTrue(client2.isReconnectSwitchOn());
    Assert.assertTrue(client2.isConnectionMonitorSwitchOn());
}
 
Example #8
Source File: GlobalSwitchTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Test
public void testUserSettings_takesEffect_before_SystemSettingsTrue() {
    System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
    System.setProperty(Configs.CONN_MONITOR_SWITCH, "true");
    client1 = new RpcClient();
    client2 = new RpcClient();

    client1.enableConnectionMonitorSwitch();
    client1.enableReconnectSwitch();

    Assert.assertTrue(client1.isConnectionMonitorSwitchOn());
    Assert.assertTrue(client1.isReconnectSwitchOn());
    Assert.assertTrue(client2.isConnectionMonitorSwitchOn());
    Assert.assertTrue(client2.isReconnectSwitchOn());

    client1.disableConnectionMonitorSwitch();
    client1.disableReconnectSwith();
    client2.disableReconnectSwith();
    client2.disableConnectionMonitorSwitch();
    Assert.assertFalse(client1.isConnectionMonitorSwitchOn());
    Assert.assertFalse(client1.isReconnectSwitchOn());
    Assert.assertFalse(client2.isReconnectSwitchOn());
    Assert.assertFalse(client2.isConnectionMonitorSwitchOn());
}
 
Example #9
Source File: WaterMark_SystemProperty_ExceptionTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.NETTY_BUFFER_HIGH_WATERMARK, Integer.toString(2));
    System.setProperty(Configs.NETTY_BUFFER_LOW_WATERMARK, Integer.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.init();
}
 
Example #10
Source File: WaterMarkTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.NETTY_BUFFER_HIGH_WATERMARK, Integer.toString(128 * 1024));
    System.setProperty(Configs.NETTY_BUFFER_LOW_WATERMARK, Integer.toString(32 * 1024));

    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.init();
}
 
Example #11
Source File: ServerHeartBeatTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.TCP_IDLE, "1000");
    System.setProperty(Configs.TCP_SERVER_IDLE, "100");
    System.setProperty(Configs.TCP_IDLE_SWITCH, Boolean.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.init();
}
 
Example #12
Source File: ClientHeartBeatTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.TCP_IDLE, "100");
    System.setProperty(Configs.TCP_IDLE_SWITCH, Boolean.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.init();
}
 
Example #13
Source File: WaterMark_UserProperty_ExceptionTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    server = new BoltServer(port, true);
    server.getRpcServer().initWriteBufferWaterMark(1, 2);
    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.initWriteBufferWaterMark(1, 2);
    client.init();
}
 
Example #14
Source File: RuntimeClientHeartBeatTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.TCP_IDLE, "100");
    System.setProperty(Configs.TCP_IDLE_SWITCH, Boolean.toString(true));
    System.setProperty(Configs.TCP_IDLE_MAXTIMES, "1000");
    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.init();
}
 
Example #15
Source File: HeartBeatDisableTest.java    From sofa-bolt with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    System.setProperty(Configs.TCP_IDLE, "100");
    System.setProperty(Configs.TCP_SERVER_IDLE, "50");
    System.setProperty(Configs.TCP_IDLE_SWITCH, Boolean.toString(false));
    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.init();
}
 
Example #16
Source File: BoltClient.java    From sofa-registry with Apache License 2.0 6 votes vote down vote up
protected Connection getBoltConnection(RpcClient rpcClient, URL url) throws RemotingException {
    Url boltUrl = createBoltUrl(url);
    try {
        Connection connection = rpcClient.getConnection(boltUrl, connectTimeout);
        if (connection == null || !connection.isFine()) {
            if (connection != null) {
                connection.close();
            }
            throw new RemotingException("Get bolt connection failed for boltUrl: " + boltUrl);
        }
        return connection;
    } catch (InterruptedException e) {
        throw new RuntimeException(
            "BoltClient rpcClient.getConnection InterruptedException! target boltUrl:"
                    + boltUrl, e);
    }
}
 
Example #17
Source File: CodecTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    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.init();
}
 
Example #18
Source File: CreateConnLockTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    whetherConnectTimeoutConsumedTooLong.set(false);
    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.init();
}
 
Example #19
Source File: BoltClient.java    From sofa-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new Bolt client.
 */
public BoltClient(int connNum) {
    rpcClient = new RpcClient();
    rpcClient.init();

    this.connNum = connNum;
}
 
Example #20
Source File: BasicUsage_MultiInterestUserProcessorTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public 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.init();
}
 
Example #21
Source File: BasicUsage_ProcessInIoThread_Test.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public 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.init();
}
 
Example #22
Source File: ServerClientStopTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    server = new BoltServer(port, true, 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.init();
}
 
Example #23
Source File: ReuseBoltClientConnectionManager.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
/**
 * 关闭长连接
 *
 * @param rpcClient       bolt客户端
 * @param transportConfig 传输层配置
 * @param url             传输层地址
 */
@Override
public void closeConnection(RpcClient rpcClient, ClientTransportConfig transportConfig, Url url) {
    if (rpcClient == null || transportConfig == null || url == null) {
        return;
    }
    // 先删除
    Connection connection = urlConnectionMap.remove(transportConfig);
    if (connection == null) {
        return;
    }
    // 再判断是否需要关闭
    boolean needDestroy;
    AtomicInteger integer = connectionRefCounter.get(connection);
    if (integer == null) {
        needDestroy = true;
    } else {
        // 当前连接引用数
        int currentCount = integer.decrementAndGet();
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Client transport {} of {} , current ref count is: {}", url.toString(),
                NetUtils.channelToString(connection.getLocalAddress(), connection.getRemoteAddress()),
                currentCount);
        }
        if (currentCount <= 0) {
            // 此长连接无任何引用,可以销毁
            connectionRefCounter.remove(connection);
            needDestroy = true;
        } else {
            needDestroy = false;
        }
    }
    if (needDestroy) {
        rpcClient.closeStandaloneConnection(connection);
    }
}
 
Example #24
Source File: BasicUsageDemoByJunit.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public 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.init();
}
 
Example #25
Source File: RpcClientDemoByMain.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
public RpcClientDemoByMain() {
    // 1. create a rpc client
    client = new RpcClient();
    // 2. add processor for connect and close event if you need
    client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
    client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
    // 3. do init
    client.init();
}
 
Example #26
Source File: ConnectionTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws Exception {
    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.init();
    Thread.sleep(100);
}
 
Example #27
Source File: RemotingUtilTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    server = new Server();
    try {
        server.startServer();
        Thread.sleep(100);
    } catch (InterruptedException e) {
        logger.error("Start server failed!", e);
    }
    client = new RpcClient();
    client.init();
}
 
Example #28
Source File: GlobalSwitchTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultvalue() {
    System.clearProperty(Configs.CONN_RECONNECT_SWITCH);
    System.clearProperty(Configs.CONN_MONITOR_SWITCH);
    client1 = new RpcClient();
    client2 = new RpcClient();

    Assert.assertFalse(client1.isConnectionMonitorSwitchOn());
    Assert.assertFalse(client1.isReconnectSwitchOn());
    Assert.assertFalse(client2.isConnectionMonitorSwitchOn());
    Assert.assertFalse(client2.isReconnectSwitchOn());
}
 
Example #29
Source File: GlobalSwitchTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Test
public void testSystemSettings_takesEffect_before_defaultvalue() {
    System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
    System.setProperty(Configs.CONN_MONITOR_SWITCH, "true");
    client1 = new RpcClient();
    client2 = new RpcClient();

    Assert.assertTrue(client1.isConnectionMonitorSwitchOn());
    Assert.assertTrue(client1.isReconnectSwitchOn());
    Assert.assertTrue(client2.isConnectionMonitorSwitchOn());
    Assert.assertTrue(client2.isReconnectSwitchOn());
}
 
Example #30
Source File: ClassCustomSerializerTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    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.init();
}