Search in sources :

Example 6 with DiscoveryNode

use of com.hazelcast.spi.discovery.DiscoveryNode in project hazelcast by hazelcast.

the class DiscoveryJoinerTest method init.

@Before
public void init() throws Exception {
    discoveryNodes = new ArrayList<DiscoveryNode>(2);
    Address publicAddress = new Address("127.0.0.1", 50001);
    Address privateAddress = new Address("127.0.0.2", 50001);
    discoveryNodes.add(new SimpleDiscoveryNode(privateAddress, publicAddress));
    publicAddress = new Address("127.0.0.1", 50002);
    privateAddress = new Address("127.0.0.2", 50002);
    discoveryNodes.add(new SimpleDiscoveryNode(privateAddress, publicAddress));
    factory = new TestHazelcastInstanceFactory(1);
    hz = factory.newHazelcastInstance();
}
Also used : SimpleDiscoveryNode(com.hazelcast.spi.discovery.SimpleDiscoveryNode) DiscoveryNode(com.hazelcast.spi.discovery.DiscoveryNode) Address(com.hazelcast.nio.Address) SimpleDiscoveryNode(com.hazelcast.spi.discovery.SimpleDiscoveryNode) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Before(org.junit.Before)

Example 7 with DiscoveryNode

use of com.hazelcast.spi.discovery.DiscoveryNode in project hazelcast by hazelcast.

the class DiscoveryAddressTranslator method refresh.

@Override
public void refresh() {
    Iterable<DiscoveryNode> discoveredNodes = checkNotNull(discoveryService.discoverNodes(), "Discovered nodes cannot be null!");
    Map<Address, Address> privateToPublic = new HashMap<Address, Address>();
    for (DiscoveryNode discoveryNode : discoveredNodes) {
        privateToPublic.put(discoveryNode.getPrivateAddress(), discoveryNode.getPublicAddress());
    }
    this.privateToPublic = privateToPublic;
}
Also used : DiscoveryNode(com.hazelcast.spi.discovery.DiscoveryNode) Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap)

Example 8 with DiscoveryNode

use of com.hazelcast.spi.discovery.DiscoveryNode in project hazelcast by hazelcast.

the class DiscoveryJoiner method getPossibleAddresses.

@Override
protected Collection<Address> getPossibleAddresses() {
    Iterable<DiscoveryNode> discoveredNodes = checkNotNull(discoveryService.discoverNodes(), "Discovered nodes cannot be null!");
    MemberImpl localMember = node.nodeEngine.getLocalMember();
    Address localAddress = localMember.getAddress();
    Collection<Address> possibleMembers = new ArrayList<Address>();
    for (DiscoveryNode discoveryNode : discoveredNodes) {
        Address discoveredAddress = usePublicAddress ? discoveryNode.getPublicAddress() : discoveryNode.getPrivateAddress();
        if (localAddress.equals(discoveredAddress)) {
            continue;
        }
        possibleMembers.add(discoveredAddress);
    }
    return possibleMembers;
}
Also used : DiscoveryNode(com.hazelcast.spi.discovery.DiscoveryNode) Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) ArrayList(java.util.ArrayList)

Aggregations

DiscoveryNode (com.hazelcast.spi.discovery.DiscoveryNode)8 Address (com.hazelcast.nio.Address)6 SimpleDiscoveryNode (com.hazelcast.spi.discovery.SimpleDiscoveryNode)5 ArrayList (java.util.ArrayList)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)2 AwsConfig (com.hazelcast.config.AwsConfig)2 Config (com.hazelcast.config.Config)2 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)2 InterfacesConfig (com.hazelcast.config.InterfacesConfig)2 JoinConfig (com.hazelcast.config.JoinConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 DiscoveryStrategyFactory (com.hazelcast.spi.discovery.DiscoveryStrategyFactory)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 UnknownHostException (java.net.UnknownHostException)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Test (org.junit.Test)2