use of com.hazelcast.core.Member in project neo4j by neo4j.
the class HazelcastClusterTopology method getCoreTopology.
static CoreTopology getCoreTopology(HazelcastInstance hazelcastInstance, Config config, Log log) {
Map<MemberId, CoreServerInfo> coreMembers = emptyMap();
boolean canBeBootstrapped = false;
ClusterId clusterId = null;
if (hazelcastInstance != null) {
Set<Member> hzMembers = hazelcastInstance.getCluster().getMembers();
canBeBootstrapped = canBeBootstrapped(hazelcastInstance, config);
coreMembers = toCoreMemberMap(hzMembers, log, hazelcastInstance);
clusterId = getClusterId(hazelcastInstance);
} else {
log.info("Cannot currently bind to distributed discovery service.");
}
return new CoreTopology(clusterId, canBeBootstrapped, coreMembers);
}
use of com.hazelcast.core.Member in project neo4j by neo4j.
the class HazelcastClusterTopology method toCoreMemberMap.
static Map<MemberId, CoreServerInfo> toCoreMemberMap(Set<Member> members, Log log, HazelcastInstance hazelcastInstance) {
Map<MemberId, CoreServerInfo> coreMembers = new HashMap<>();
MultiMap<String, String> serverGroupsMMap = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP_NAME);
for (Member member : members) {
try {
MemberId memberId = new MemberId(UUID.fromString(member.getStringAttribute(MEMBER_UUID)));
CoreServerInfo coreServerInfo = new CoreServerInfo(socketAddress(member.getStringAttribute(RAFT_SERVER), AdvertisedSocketAddress::new), socketAddress(member.getStringAttribute(TRANSACTION_SERVER), AdvertisedSocketAddress::new), ClientConnectorAddresses.fromString(member.getStringAttribute(CLIENT_CONNECTOR_ADDRESSES)), asSet(serverGroupsMMap.get(memberId.getUuid().toString())));
coreMembers.put(memberId, coreServerInfo);
} catch (IllegalArgumentException e) {
log.warn("Incomplete member attributes supplied from Hazelcast", e);
}
}
return coreMembers;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientCacheProxy method updateCacheListenerConfigOnOtherNodes.
protected void updateCacheListenerConfigOnOtherNodes(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean isRegister) {
final Collection<Member> members = clientContext.getClusterService().getMemberList();
final HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) clientContext.getHazelcastInstance();
for (Member member : members) {
try {
final Address address = member.getAddress();
Data configData = toData(cacheEntryListenerConfiguration);
final ClientMessage request = CacheListenerRegistrationCodec.encodeRequest(nameWithPrefix, configData, isRegister, address);
final ClientInvocation invocation = new ClientInvocation(client, request, address);
invocation.invoke();
} catch (Exception e) {
ExceptionUtil.sneakyThrow(e);
}
}
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientConsoleApp method handlePartitions.
protected void handlePartitions(String[] args) {
Set<Partition> partitions = hazelcast.getPartitionService().getPartitions();
Map<Member, Integer> partitionCounts = new HashMap<Member, Integer>();
for (Partition partition : partitions) {
Member owner = partition.getOwner();
if (owner != null) {
Integer count = partitionCounts.get(owner);
int newCount = 1;
if (count != null) {
newCount = count + 1;
}
partitionCounts.put(owner, newCount);
}
println(partition);
}
Set<Entry<Member, Integer>> entries = partitionCounts.entrySet();
for (Entry<Member, Integer> entry : entries) {
println(entry.getKey() + ":" + entry.getValue());
}
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class ClientConsoleApp method executeOnMembers.
private void executeOnMembers(String[] args) {
// executeOnMembers <echo-string>
try {
IExecutorService executorService = hazelcast.getExecutorService("default");
Echo task = new Echo(args[1]);
Map<Member, Future<String>> results = executorService.submitToAllMembers(task);
for (Future f : results.values()) {
println(f.get());
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
Aggregations