Search in sources :

Example 96 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl 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();
    Set<Address> localAddresses = node.getLocalAddressRegistry().getLocalAddresses();
    Collection<Address> possibleMembers = new ArrayList<>();
    for (DiscoveryNode discoveryNode : discoveredNodes) {
        Address discoveredAddress = usePublicAddress ? discoveryNode.getPublicAddress() : discoveryNode.getPrivateAddress();
        if (localAddresses.contains(discoveredAddress)) {
            if (!usePublicAddress && discoveryNode.getPublicAddress() != null) {
                // enrich member with client public address
                localMember.getAddressMap().put(EndpointQualifier.resolve(ProtocolType.CLIENT, "public"), publicAddress(localMember, discoveryNode));
            }
            continue;
        }
        possibleMembers.add(discoveredAddress);
    }
    return possibleMembers;
}
Also used : DiscoveryNode(com.hazelcast.spi.discovery.DiscoveryNode) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList)

Example 97 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class HostAwareMemberGroupFactory method createInternalMemberGroups.

@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
    Map<String, MemberGroup> groups = createHashMap(allMembers.size());
    for (Member member : allMembers) {
        Address address = ((MemberImpl) member).getAddress();
        MemberGroup group = groups.get(address.getHost());
        if (group == null) {
            group = new DefaultMemberGroup();
            groups.put(address.getHost(), group);
        }
        group.addMember(member);
    }
    return new HashSet<MemberGroup>(groups.values());
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) HashSet(java.util.HashSet)

Example 98 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method createMembersWithPlacementAwareMetadata.

private Collection<Member> createMembersWithPlacementAwareMetadata() {
    Collection<Member> members = new HashSet<>();
    MemberImpl member1 = new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, true);
    member1.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_PLACEMENT, "us-east-1a-placement-1");
    MemberImpl member2 = new MemberImpl(new Address("192.192.0.2", fakeAddress, 5701), VERSION, true);
    member2.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_PLACEMENT, "us-east-1a-placement-2");
    MemberImpl member3 = new MemberImpl(new Address("192.192.0.3", fakeAddress, 5701), VERSION, true);
    member3.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_PLACEMENT, "us-east-1a-placement-3");
    members.add(member1);
    members.add(member2);
    members.add(member3);
    return members;
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) HashSet(java.util.HashSet)

Example 99 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method createMembersWithZoneAwareMetadata.

private Collection<Member> createMembersWithZoneAwareMetadata() {
    Collection<Member> members = new HashSet<Member>();
    MemberImpl member1 = new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, true);
    member1.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_ZONE, "us-east-1");
    MemberImpl member2 = new MemberImpl(new Address("192.192.0.2", fakeAddress, 5701), VERSION, true);
    member2.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_ZONE, "us-west-1");
    MemberImpl member3 = new MemberImpl(new Address("192.192.0.3", fakeAddress, 5701), VERSION, true);
    member3.setAttribute(PartitionGroupMetaData.PARTITION_GROUP_ZONE, "eu-central-1");
    members.add(member1);
    members.add(member2);
    members.add(member3);
    return members;
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) HashSet(java.util.HashSet)

Example 100 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MemberGroupFactoryTest method createMembers.

private Collection<Member> createMembers() {
    Collection<Member> members = new HashSet<Member>();
    members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5702), VERSION, false));
    members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5701), VERSION, false));
    members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5702), VERSION, false));
    return members;
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) HashSet(java.util.HashSet)

Aggregations

MemberImpl (com.hazelcast.cluster.impl.MemberImpl)123 Address (com.hazelcast.cluster.Address)41 Test (org.junit.Test)37 QuickTest (com.hazelcast.test.annotation.QuickTest)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)32 Member (com.hazelcast.cluster.Member)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 UUID (java.util.UUID)14 ArrayList (java.util.ArrayList)10 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)9 HashMap (java.util.HashMap)9 InetAddress (java.net.InetAddress)8 HashSet (java.util.HashSet)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 Config (com.hazelcast.config.Config)6 Future (java.util.concurrent.Future)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)4 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)4 MembersUpdateOp (com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp)4