use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class NodeEngineRaftIntegration method send.
private boolean send(AsyncRaftOp operation, RaftEndpoint target) {
CPMember targetMember = getCPMember(target);
if (targetMember == null || localAddress.equals(targetMember.getAddress())) {
if (localCPMember.getUuid().equals(target.getUuid())) {
throw new IllegalStateException("Cannot send " + operation + " to " + target + " because it's same with the local CP member!");
}
return false;
}
operation.setTargetEndpoint(target).setPartitionId(partitionId);
return operationService.send(operation, targetMember.getAddress());
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class RaftInvocationManager method triggerRaftNodeCreation.
void triggerRaftNodeCreation(CPGroupSummary group) {
for (CPMember groupMember : group.members()) {
if (groupMember.equals(raftService.getLocalCPMember())) {
ExecutionService executionService = nodeEngine.getExecutionService();
executionService.execute(CP_SUBSYSTEM_EXECUTOR, () -> raftService.createRaftNode(group.id(), group.initialMembers()));
} else {
Operation op = new CreateRaftNodeOp(group.id(), group.initialMembers());
OperationService operationService = nodeEngine.getOperationService();
operationService.send(op, groupMember.getAddress());
}
}
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class RaftNodeImpl method printMemberState.
public void printMemberState() {
CPGroupId groupId = state.groupId();
StringBuilder sb = new StringBuilder("\n\nCP Group Members {").append("groupId: ").append(groupId.getName()).append("(").append(groupId.getId()).append(")").append(", size:").append(state.memberCount()).append(", term:").append(state.term()).append(", logIndex:").append(state.membersLogIndex()).append("} [");
for (RaftEndpoint member : state.members()) {
CPMember cpMember = raftIntegration.getCPMember(member);
sb.append("\n\t").append(cpMember != null ? cpMember : member);
if (state.localEndpoint().equals(member)) {
sb.append(" - ").append(state.role()).append(" this");
} else if (member.equals(state.leader())) {
sb.append(" - ").append(LEADER);
}
}
sb.append("\n]\n");
logger.info(sb.toString());
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleGetCPGroupByName.
private void handleGetCPGroupByName(final HttpGetCommand command) {
String prefix = URI_CP_GROUPS_URL + "/";
String groupName = command.getURI().substring(prefix.length()).trim();
CompletionStage<CPGroup> f = getCpSubsystemManagementService().getCPGroup(groupName);
f.whenCompleteAsync((group, t) -> {
if (t == null) {
if (group != null) {
JsonObject json = new JsonObject();
json.add("id", toJson(group.id())).add("status", group.status().name());
JsonArray membersArr = new JsonArray();
for (CPMember member : group.members()) {
membersArr.add(toJson(member));
}
json.add("members", membersArr);
prepareResponse(command, json);
} else {
command.send404();
}
textCommandService.sendResponse(command);
} else {
command.send500();
textCommandService.sendResponse(command);
}
});
}
use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleGetCPMembers.
private void handleGetCPMembers(final HttpGetCommand command) {
CompletionStage<Collection<CPMember>> f = getCpSubsystemManagementService().getCPMembers();
f.whenCompleteAsync((cpMembers, t) -> {
if (t == null) {
JsonArray arr = new JsonArray();
for (CPMember cpMember : cpMembers) {
arr.add(toJson(cpMember));
}
prepareResponse(command, arr);
textCommandService.sendResponse(command);
} else {
command.send500();
textCommandService.sendResponse(command);
}
});
}
Aggregations