private Set<SocketAddress> getLocalSocketAddresses(final Set<HazelcastInstance> hazelcastInstanceSet) { final Set<SocketAddress> localSocketAddressesSet = new HashSet<>(); for (HazelcastInstance hazelcastInstance : hazelcastInstanceSet) { localSocketAddressesSet.add(hazelcastInstance.getLocalEndpoint().getSocketAddress()); } return localSocketAddressesSet; }
private static InetSocketAddress getInetSocketAddress(HazelcastInstance hazelcastInstance) { try { return (InetSocketAddress) hazelcastInstance.getLocalEndpoint().getSocketAddress(); } catch (NoSuchMethodError ignored) { try { return hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress(); } catch (Exception e) { return null; } } }
private void syncConfigurationMultiMap(HazelcastInstance hazelcastInstance) { Lock lock = hazelcastInstance.getLock(SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK); lock.lock(); try { MultiMap<SocketAddress, SocketAddress> multiMap = hazelcastInstance .getMultiMap(SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP); for (HazelcastInstance localInstance : Hazelcast.getAllHazelcastInstances()) { SocketAddress localInstanceSocketAddress = localInstance.getLocalEndpoint().getSocketAddress(); if (multiMap.size() == 0) { multiMap.put(localInstanceSocketAddress, localInstanceSocketAddress); } else { multiMap.put(multiMap.keySet().iterator().next(), localInstanceSocketAddress); } } } finally { lock.unlock(); } }