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

The following examples show how to use com.alipay.remoting.rpc.RpcClient#registerUserProcessor() . 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: 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 3
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 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: 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 6
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 7
Source File: ClientConnectionTest.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 8
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 9
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 10
Source File: ServerInvokeExceptionTest.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 11
Source File: BasicUsage_AsyncProcessor_Null_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 12
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 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: RaftServer.java    From sofa-registry with Apache License 2.0 5 votes vote down vote up
/**
 * start raft server
 * @param raftServerConfig
 * @throws IOException
 */
public void start(RaftServerConfig raftServerConfig) throws IOException {

    FileUtils.forceMkdir(new File(dataPath));

    serverHandlers.add(new RaftServerHandler(this));
    serverHandlers.add(new RaftServerConnectionHandler());

    boltServer = new BoltServer(new URL(NetUtil.getLocalAddress().getHostAddress(),
        serverId.getPort()), serverHandlers);

    boltServer.initServer();

    RpcServer rpcServer = boltServer.getRpcServer();

    RaftRpcServerFactory.addRaftRequestProcessors(rpcServer);

    this.fsm = ServiceStateMachine.getInstance();
    this.fsm.setLeaderProcessListener(leaderProcessListener);
    this.fsm.setFollowerProcessListener(followerProcessListener);

    NodeOptions nodeOptions = initNodeOptions(raftServerConfig);

    this.raftGroupService = new RaftGroupService(groupId, serverId, nodeOptions, rpcServer);
    //start
    this.node = this.raftGroupService.start();

    if (raftServerConfig.isEnableMetrics()) {
        ReporterUtils.startSlf4jReporter(raftServerConfig.getEnableMetricsReporterPeriod(),
            node.getNodeMetrics().getMetricRegistry(), raftServerConfig.getMetricsLogger());
    }

    RpcClient raftClient = ((AbstractBoltClientService) (((NodeImpl) node).getRpcService()))
        .getRpcClient();

    NotifyLeaderChangeHandler notifyLeaderChangeHandler = new NotifyLeaderChangeHandler(
        groupId, null);
    raftClient.registerUserProcessor(new SyncUserProcessorAdapter(notifyLeaderChangeHandler));
}
 
Example 15
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 16
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 17
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 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: 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 20
Source File: BasicUsage_InvokeContext_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();
}