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

The following examples show how to use com.alipay.remoting.rpc.RpcClient#addConnectionEventProcessor() . 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: 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 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: 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 4
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 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: 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 7
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 8
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 9
Source File: InvokeCallbackTest.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 10
Source File: PrehandleTest.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 11
Source File: ServerTimeoutTest.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 12
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 13
Source File: AddressArgs_CONNECTIONNUM_Test.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 14
Source File: ServerUnsupportedOperationExceptionTest.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    server = new BoltServer(port, false);
    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: 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();
}
 
Example 16
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 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: BasicUsage_InvokeContext_resuable_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 19
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 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();
}