use of com.baidu.hugegraph.backend.store.raft.RaftGroupManager in project incubator-hugegraph by apache.
the class RaftAPI method removePeer.
@POST
@Timed
@Status(Status.OK)
@Path("remove_peer")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin" })
public Map<String, String> removePeer(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("group") @DefaultValue("default") String group, @QueryParam("endpoint") String endpoint) {
LOG.debug("Graph [{}] prepare to remove peer: {}", graph, endpoint);
HugeGraph g = graph(manager, graph);
RaftGroupManager raftManager = raftGroupManager(g, group, "remove_peer");
String peerId = raftManager.removePeer(endpoint);
return ImmutableMap.of(raftManager.group(), peerId);
}
use of com.baidu.hugegraph.backend.store.raft.RaftGroupManager in project incubator-hugegraph by apache.
the class RaftAPI method setLeader.
@POST
@Timed
@Status(Status.OK)
@Path("set_leader")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin" })
public Map<String, String> setLeader(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("group") @DefaultValue("default") String group, @QueryParam("endpoint") String endpoint) {
LOG.debug("Graph [{}] prepare to set leader to: {}", graph, endpoint);
HugeGraph g = graph(manager, graph);
RaftGroupManager raftManager = raftGroupManager(g, group, "set_leader");
String leaderId = raftManager.setLeader(endpoint);
return ImmutableMap.of(raftManager.group(), leaderId);
}
use of com.baidu.hugegraph.backend.store.raft.RaftGroupManager in project incubator-hugegraph by apache.
the class ListPeersProcessor method processRequest.
@Override
public Message processRequest(ListPeersRequest request, RpcRequestClosure done) {
LOG.debug("Processing ListPeersRequest {}", request.getClass());
RaftGroupManager nodeManager = this.context.raftNodeManager(RaftSharedContext.DEFAULT_GROUP);
try {
CommonResponse common = CommonResponse.newBuilder().setStatus(true).build();
return ListPeersResponse.newBuilder().setCommon(common).addAllEndpoints(nodeManager.listPeers()).build();
} catch (Throwable e) {
CommonResponse common = CommonResponse.newBuilder().setStatus(false).setMessage(e.toString()).build();
return ListPeersResponse.newBuilder().setCommon(common).addAllEndpoints(ImmutableList.of()).build();
}
}
Aggregations