use of com.hazelcast.instance.EndpointQualifier.CLIENT in project hazelcast by hazelcast.
the class ClusterViewListenerService method getPartitions.
/**
* If any partition does not have an owner, this method returns empty collection
*
* @param partitionTableView will be converted to address->partitions mapping
* @return address->partitions mapping, where address is the client address of the member
*/
public Map<UUID, List<Integer>> getPartitions(PartitionTableView partitionTableView) {
Map<UUID, List<Integer>> partitionsMap = new HashMap<>();
int partitionCount = partitionTableView.length();
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
PartitionReplica owner = partitionTableView.getReplica(partitionId, 0);
if (owner == null || owner.uuid() == null) {
partitionsMap.clear();
return partitionsMap;
}
partitionsMap.computeIfAbsent(owner.uuid(), k -> new LinkedList<>()).add(partitionId);
}
return partitionsMap;
}
use of com.hazelcast.instance.EndpointQualifier.CLIENT in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleCluster.
/**
* Sets the HTTP response to a string containing basic cluster information:
* <ul>
* <li>Member list</li>
* <li>Client connection count</li>
* <li>Connection count</li>
* </ul>
*
* @param command the HTTP request
*/
private void handleCluster(HttpGetCommand command) {
Node node = textCommandService.getNode();
Server server = node.getServer();
ClusterServiceImpl clusterService = node.getClusterService();
JsonArray membersArray = new JsonArray();
clusterService.getMembers().stream().map(m -> new JsonObject().add("address", m.getAddress().toString()).add("liteMember", m.isLiteMember()).add("localMember", m.localMember()).add("uuid", m.getUuid().toString()).add("memberVersion", m.getVersion().toString())).forEach(membersArray::add);
ServerConnectionManager cm = server.getConnectionManager(CLIENT);
int clientCount = cm == null ? 0 : cm.connectionCount(ServerConnection::isClient);
JsonObject response = new JsonObject().add("members", membersArray).add("connectionCount", clientCount).add("allConnectionCount", server.connectionCount());
prepareResponse(command, response);
}
Aggregations