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));
}
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);
}
}
Aggregations