use of org.apache.ratis.protocol.SetConfigurationRequest in project incubator-ratis by apache.
the class GrpcAdminProtocolService method setConfiguration.
@Override
public void setConfiguration(SetConfigurationRequestProto proto, StreamObserver<RaftClientReplyProto> responseObserver) {
final SetConfigurationRequest request = ClientProtoUtils.toSetConfigurationRequest(proto);
GrpcUtil.asyncCall(responseObserver, () -> protocol.setConfigurationAsync(request), ClientProtoUtils::toRaftClientReplyProto);
}
use of org.apache.ratis.protocol.SetConfigurationRequest in project incubator-ratis by apache.
the class AdminImpl method setConfiguration.
@Override
public RaftClientReply setConfiguration(List<RaftPeer> peersInNewConf, List<RaftPeer> listenersInNewConf) throws IOException {
Objects.requireNonNull(peersInNewConf, "peersInNewConf == null");
final long callId = CallId.getAndIncrement();
// also refresh the rpc proxies for these peers
client.getClientRpc().addRaftPeers(peersInNewConf);
return client.io().sendRequestWithRetry(() -> new SetConfigurationRequest(client.getId(), client.getLeaderId(), client.getGroupId(), callId, peersInNewConf, listenersInNewConf));
}
use of org.apache.ratis.protocol.SetConfigurationRequest in project incubator-ratis by apache.
the class RaftReconfigurationBaseTest method runTestReconfTimeout.
void runTestReconfTimeout(CLUSTER cluster) throws Exception {
final RaftPeerId leaderId = RaftTestUtil.waitForLeader(cluster).getId();
try (final RaftClient client = cluster.createClient(leaderId)) {
PeerChanges c1 = cluster.addNewPeers(2, false);
LOG.info("Start changing the configuration: {}", asList(c1.allPeersInNewConf));
Assert.assertFalse(((RaftConfigurationImpl) cluster.getLeader().getRaftConf()).isTransitional());
final RaftClientRpc sender = client.getClientRpc();
final SetConfigurationRequest request = cluster.newSetConfigurationRequest(client.getId(), leaderId, c1.allPeersInNewConf);
try {
sender.sendRequest(request);
Assert.fail("did not get expected exception");
} catch (IOException e) {
Assert.assertTrue("Got exception " + e, e instanceof ReconfigurationTimeoutException);
}
// the two new peers have not started yet, the bootstrapping must timeout
LOG.info(cluster.printServers());
// state so that we still get timeout instead of in-progress exception
try {
sender.sendRequest(request);
Assert.fail("did not get expected exception");
} catch (IOException e) {
Assert.assertTrue("Got exception " + e, e instanceof ReconfigurationTimeoutException);
}
// start the two new peers
LOG.info("Start new peers");
for (RaftPeer np : c1.newPeers) {
cluster.restartServer(np.getId(), false);
}
Assert.assertTrue(client.admin().setConfiguration(c1.allPeersInNewConf).isSuccess());
}
}
use of org.apache.ratis.protocol.SetConfigurationRequest in project alluxio by Alluxio.
the class RaftJournalSystem method addQuorumServer.
/**
* Adds a server to the quorum.
*
* @param serverNetAddress the address of the server
* @throws IOException if error occurred while performing the operation
*/
public synchronized void addQuorumServer(NetAddress serverNetAddress) throws IOException {
InetSocketAddress serverAddress = InetSocketAddress.createUnresolved(serverNetAddress.getHost(), serverNetAddress.getRpcPort());
RaftPeerId peerId = RaftJournalUtils.getPeerId(serverAddress);
Collection<RaftPeer> peers = mServer.getGroups().iterator().next().getPeers();
if (peers.stream().anyMatch((peer) -> peer.getId().equals(peerId))) {
return;
}
RaftPeer newPeer = RaftPeer.newBuilder().setId(peerId).setAddress(serverAddress).build();
List<RaftPeer> newPeers = new ArrayList<>(peers);
newPeers.add(newPeer);
RaftClientReply reply = mServer.setConfiguration(new SetConfigurationRequest(mRawClientId, mPeerId, RAFT_GROUP_ID, nextCallId(), newPeers));
if (reply.getException() != null) {
throw reply.getException();
}
}
Aggregations