Search in sources :

Example 6 with RaftGroupManager

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);
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Path(jakarta.ws.rs.Path) RolesAllowed(jakarta.annotation.security.RolesAllowed) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 7 with RaftGroupManager

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);
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) HugeGraph(com.baidu.hugegraph.HugeGraph) Status(com.baidu.hugegraph.api.filter.StatusFilter.Status) Path(jakarta.ws.rs.Path) RolesAllowed(jakarta.annotation.security.RolesAllowed) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed)

Example 8 with RaftGroupManager

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();
    }
}
Also used : RaftGroupManager(com.baidu.hugegraph.backend.store.raft.RaftGroupManager) CommonResponse(com.baidu.hugegraph.backend.store.raft.rpc.RaftRequests.CommonResponse)

Aggregations

RaftGroupManager (com.baidu.hugegraph.backend.store.raft.RaftGroupManager)8 HugeGraph (com.baidu.hugegraph.HugeGraph)6 Timed (com.codahale.metrics.annotation.Timed)6 RolesAllowed (jakarta.annotation.security.RolesAllowed)6 Consumes (jakarta.ws.rs.Consumes)6 Path (jakarta.ws.rs.Path)6 Produces (jakarta.ws.rs.Produces)6 Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)4 POST (jakarta.ws.rs.POST)4 CommonResponse (com.baidu.hugegraph.backend.store.raft.rpc.RaftRequests.CommonResponse)2 GET (jakarta.ws.rs.GET)2