Java Code Examples for com.alipay.remoting.rpc.RpcClient#enableReconnectSwitch()

The following examples show how to use com.alipay.remoting.rpc.RpcClient#enableReconnectSwitch() . 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: 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 2
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 3
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 4
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());
}