use of com.alipay.sofa.jraft.test.atomic.command.SlotsResponseCommand in project sofa-jraft by sofastack.
the class AtomicClient method start.
public void start() throws InterruptedException, TimeoutException {
cliOptions = new CliOptions();
this.cliClientService.init(cliOptions);
this.rpcClient = this.cliClientService.getRpcClient();
if (conf != null) {
final Set<PeerId> peers = conf.getPeerSet();
for (final PeerId peer : peers) {
try {
final BooleanCommand cmd = (BooleanCommand) this.rpcClient.invokeSync(peer.getEndpoint(), new GetSlotsCommand(), cliOptions.getRpcDefaultTimeout());
if (cmd instanceof SlotsResponseCommand) {
groups = ((SlotsResponseCommand) cmd).getMap();
break;
} else {
LOG.warn("Fail to get slots from peer {}, error: {}", peer, cmd.getErrorMsg());
}
} catch (final Throwable t) {
LOG.warn("Fail to get slots from peer {}, error: {}", peer, t.getMessage());
// continue;
}
}
if (groups == null || groups.isEmpty()) {
throw new IllegalArgumentException("Can't get slots from any peers");
} else {
LOG.info("All groups is {}", groups);
}
for (final String groupId : groups.values()) {
RouteTable.getInstance().updateConfiguration(groupId, conf);
refreshLeader(groupId);
refreshConf(groupId);
}
}
}
use of com.alipay.sofa.jraft.test.atomic.command.SlotsResponseCommand in project sofa-jraft by sofastack.
the class GetSlotsCommandProcessor method handleRequest.
@Override
public void handleRequest(final RpcContext rpcCtx, final GetSlotsCommand request) {
final SlotsResponseCommand response = new SlotsResponseCommand();
response.setMap(this.server.getGroups());
rpcCtx.sendResponse(response);
}
Aggregations