public static RaftServerProxy newRaftServer(
RaftPeerId id, RaftGroup group, StateMachine.Registry stateMachineRegistry,
RaftProperties properties, Parameters parameters) throws IOException {
final RaftServerProxy proxy;
try {
proxy = JavaUtils.attempt(
() -> new RaftServerProxy(id, stateMachineRegistry, group, properties, parameters),
5, 500L, "new RaftServerProxy", RaftServerProxy.LOG);
} catch (InterruptedException e) {
throw IOUtils.toInterruptedIOException(
"Interrupted when creating RaftServer " + id + ", " + group, e);
} catch (IOException e) {
throw new IOException("Failed to create RaftServer " + id + ", " + group, e);
}
if (!group.getPeers().isEmpty()) {
proxy.getServerRpc().addPeers(group.getPeers());
}
return proxy;
}