Search in sources :

Example 1 with PingRequestProcessor

use of com.alipay.sofa.jraft.rpc.impl.PingRequestProcessor in project sofa-jraft by sofastack.

the class RaftRpcServerFactory method addRaftRequestProcessors.

/**
 * Adds RAFT and CLI service request processors.
 *
 * @param rpcServer    rpc server instance
 * @param raftExecutor executor to handle RAFT requests.
 * @param cliExecutor  executor to handle CLI service requests.
 */
public static void addRaftRequestProcessors(final RpcServer rpcServer, final Executor raftExecutor, final Executor cliExecutor) {
    // raft core processors
    final AppendEntriesRequestProcessor appendEntriesRequestProcessor = new AppendEntriesRequestProcessor(raftExecutor);
    rpcServer.registerConnectionClosedEventListener(appendEntriesRequestProcessor);
    rpcServer.registerProcessor(appendEntriesRequestProcessor);
    rpcServer.registerProcessor(new GetFileRequestProcessor(raftExecutor));
    rpcServer.registerProcessor(new InstallSnapshotRequestProcessor(raftExecutor));
    rpcServer.registerProcessor(new RequestVoteRequestProcessor(raftExecutor));
    rpcServer.registerProcessor(new PingRequestProcessor());
    rpcServer.registerProcessor(new TimeoutNowRequestProcessor(raftExecutor));
    rpcServer.registerProcessor(new ReadIndexRequestProcessor(raftExecutor));
    // raft cli service
    rpcServer.registerProcessor(new AddPeerRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new RemovePeerRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new ResetPeerRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new ChangePeersRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new GetLeaderRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new SnapshotRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new TransferLeaderRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new GetPeersRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new AddLearnersRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new RemoveLearnersRequestProcessor(cliExecutor));
    rpcServer.registerProcessor(new ResetLearnersRequestProcessor(cliExecutor));
}
Also used : ReadIndexRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.ReadIndexRequestProcessor) RemoveLearnersRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.RemoveLearnersRequestProcessor) TransferLeaderRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.TransferLeaderRequestProcessor) GetPeersRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.GetPeersRequestProcessor) ResetLearnersRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.ResetLearnersRequestProcessor) AppendEntriesRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.AppendEntriesRequestProcessor) RemovePeerRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.RemovePeerRequestProcessor) AddLearnersRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.AddLearnersRequestProcessor) TimeoutNowRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.TimeoutNowRequestProcessor) PingRequestProcessor(com.alipay.sofa.jraft.rpc.impl.PingRequestProcessor) InstallSnapshotRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.InstallSnapshotRequestProcessor) SnapshotRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.SnapshotRequestProcessor) GetFileRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.GetFileRequestProcessor) AddPeerRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.AddPeerRequestProcessor) ChangePeersRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.ChangePeersRequestProcessor) RequestVoteRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.RequestVoteRequestProcessor) GetLeaderRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.GetLeaderRequestProcessor) InstallSnapshotRequestProcessor(com.alipay.sofa.jraft.rpc.impl.core.InstallSnapshotRequestProcessor) ResetPeerRequestProcessor(com.alipay.sofa.jraft.rpc.impl.cli.ResetPeerRequestProcessor)

Example 2 with PingRequestProcessor

use of com.alipay.sofa.jraft.rpc.impl.PingRequestProcessor in project sofa-jraft by sofastack.

the class ConnectionRefreshTest method simulation.

@Ignore
@Test
public void simulation() throws InterruptedException {
    ProtobufMsgFactory.load();
    final RpcServer server = RpcFactoryHelper.rpcFactory().createRpcServer(new Endpoint("127.0.0.1", 19991));
    server.registerProcessor(new PingRequestProcessor());
    server.init(null);
    final Endpoint target = new Endpoint("my.test.host1.com", 19991);
    final RpcClient client = RpcFactoryHelper.rpcFactory().createRpcClient();
    client.init(null);
    final RpcRequests.PingRequest req = // 
    RpcRequests.PingRequest.newBuilder().setSendTimestamp(// 
    System.currentTimeMillis()).build();
    for (int i = 0; i < 1000; i++) {
        try {
            final Object resp = client.invokeSync(target, req, 3000);
            System.out.println(resp);
        } catch (final Exception e) {
            e.printStackTrace();
        }
        Thread.sleep(1000);
    }
}
Also used : Endpoint(com.alipay.sofa.jraft.util.Endpoint) PingRequestProcessor(com.alipay.sofa.jraft.rpc.impl.PingRequestProcessor) Endpoint(com.alipay.sofa.jraft.util.Endpoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

PingRequestProcessor (com.alipay.sofa.jraft.rpc.impl.PingRequestProcessor)2 AddLearnersRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.AddLearnersRequestProcessor)1 AddPeerRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.AddPeerRequestProcessor)1 ChangePeersRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.ChangePeersRequestProcessor)1 GetLeaderRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.GetLeaderRequestProcessor)1 GetPeersRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.GetPeersRequestProcessor)1 RemoveLearnersRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.RemoveLearnersRequestProcessor)1 RemovePeerRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.RemovePeerRequestProcessor)1 ResetLearnersRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.ResetLearnersRequestProcessor)1 ResetPeerRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.ResetPeerRequestProcessor)1 SnapshotRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.SnapshotRequestProcessor)1 TransferLeaderRequestProcessor (com.alipay.sofa.jraft.rpc.impl.cli.TransferLeaderRequestProcessor)1 AppendEntriesRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.AppendEntriesRequestProcessor)1 GetFileRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.GetFileRequestProcessor)1 InstallSnapshotRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.InstallSnapshotRequestProcessor)1 ReadIndexRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.ReadIndexRequestProcessor)1 RequestVoteRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.RequestVoteRequestProcessor)1 TimeoutNowRequestProcessor (com.alipay.sofa.jraft.rpc.impl.core.TimeoutNowRequestProcessor)1 Endpoint (com.alipay.sofa.jraft.util.Endpoint)1 Ignore (org.junit.Ignore)1