Search in sources :

Example 1 with LearnersOpResponse

use of com.alipay.sofa.jraft.rpc.CliRequests.LearnersOpResponse in project sofa-jraft by sofastack.

the class CliServiceImpl method processLearnersOpResponse.

private Status processLearnersOpResponse(final String groupId, final Message result, final String fmt, final Object... formatArgs) {
    if (result instanceof LearnersOpResponse) {
        final LearnersOpResponse resp = (LearnersOpResponse) result;
        final Configuration oldConf = new Configuration();
        for (final String peerIdStr : resp.getOldLearnersList()) {
            final PeerId oldPeer = new PeerId();
            oldPeer.parse(peerIdStr);
            oldConf.addLearner(oldPeer);
        }
        final Configuration newConf = new Configuration();
        for (final String peerIdStr : resp.getNewLearnersList()) {
            final PeerId newPeer = new PeerId();
            newPeer.parse(peerIdStr);
            newConf.addLearner(newPeer);
        }
        LOG.info("Learners of replication group {} changed from {} to {} after {}.", groupId, oldConf, newConf, String.format(fmt, formatArgs));
        return Status.OK();
    } else {
        return statusFromResponse(result);
    }
}
Also used : LearnersOpResponse(com.alipay.sofa.jraft.rpc.CliRequests.LearnersOpResponse) Configuration(com.alipay.sofa.jraft.conf.Configuration) PeerId(com.alipay.sofa.jraft.entity.PeerId)

Aggregations

Configuration (com.alipay.sofa.jraft.conf.Configuration)1 PeerId (com.alipay.sofa.jraft.entity.PeerId)1 LearnersOpResponse (com.alipay.sofa.jraft.rpc.CliRequests.LearnersOpResponse)1