Search in sources :

Example 46 with MemberImpl

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

the class MemberMapTest method cloneExcluding.

@Test
public void cloneExcluding() {
    MemberImpl[] members = newMembers(6);
    MemberImpl exclude0 = members[0];
    MemberImpl exclude1 = new MemberImpl.Builder(newAddress(6000)).version(VERSION).uuid(members[1].getUuid()).build();
    MemberImpl exclude2 = new MemberImpl.Builder(members[2].getAddress()).version(VERSION).uuid(newUnsecureUUID()).build();
    MemberMap map = MemberMap.cloneExcluding(MemberMap.createNew(members), exclude0, exclude1, exclude2);
    int numOfExcludedMembers = 3;
    assertEquals(members.length - numOfExcludedMembers, map.getMembers().size());
    assertEquals(members.length - numOfExcludedMembers, map.getAddresses().size());
    assertEquals(members.length - numOfExcludedMembers, map.size());
    for (int i = 0; i < numOfExcludedMembers; i++) {
        MemberImpl member = members[i];
        assertNotContains(map, member.getAddress());
        assertNotContains(map, member.getUuid());
        assertNull(map.getMember(member.getAddress()));
        assertNull(map.getMember(member.getUuid()));
    }
    for (int i = numOfExcludedMembers; i < members.length; i++) {
        MemberImpl member = members[i];
        assertContains(map, member.getAddress());
        assertContains(map, member.getUuid());
        assertSame(member, map.getMember(member.getAddress()));
        assertSame(member, map.getMember(member.getUuid()));
    }
    assertMemberSet(map);
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 47 with MemberImpl

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

the class MemberMapTest method createNew.

@Test
public void createNew() {
    MemberImpl[] members = newMembers(5);
    MemberMap map = MemberMap.createNew(members);
    assertEquals(members.length, map.getMembers().size());
    assertEquals(members.length, map.getAddresses().size());
    assertEquals(members.length, map.size());
    for (MemberImpl member : members) {
        assertContains(map, member.getAddress());
        assertContains(map, member.getUuid());
        assertSame(member, map.getMember(member.getAddress()));
        assertSame(member, map.getMember(member.getUuid()));
    }
    assertMemberSet(map);
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 48 with MemberImpl

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

the class MembersViewTest method getAddresses.

@Test
public void getAddresses() {
    MemberImpl[] members = MemberMapTest.newMembers(3);
    MembersView view = MembersView.createNew(1, Arrays.asList(members));
    Set<Address> addresses = view.getAddresses();
    assertEquals(members.length, addresses.size());
    for (MemberImpl member : members) {
        assertTrue(addresses.contains(member.getAddress()));
    }
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 49 with MemberImpl

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

the class MembersViewTest method cloneAdding.

@Test
public void cloneAdding() {
    int version = 6;
    MemberImpl[] members = MemberMapTest.newMembers(4);
    List<MemberInfo> additionalMembers = Arrays.asList(new MemberInfo(newMember(6000)), new MemberInfo(newMember(7000)));
    MembersView view = MembersView.cloneAdding(MembersView.createNew(version, Arrays.asList(members)), additionalMembers);
    assertEquals(version + additionalMembers.size(), view.getVersion());
    MemberImpl[] newMembers = Arrays.copyOf(members, members.length + additionalMembers.size());
    for (int i = 0; i < additionalMembers.size(); i++) {
        newMembers[members.length + i] = additionalMembers.get(i).toMember();
    }
    assertMembersViewEquals(newMembers, view);
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 50 with MemberImpl

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

the class MembersViewTest method containsMember.

@Test
public void containsMember() {
    MemberImpl[] members = MemberMapTest.newMembers(3);
    MembersView view = MembersView.createNew(1, Arrays.asList(members));
    for (MemberImpl member : members) {
        assertTrue(view.containsMember(member.getAddress(), member.getUuid()));
    }
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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