Search in sources :

Example 41 with MemberImpl

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

the class MemberMapTest method testConstructor_whenMapsHaveDifferentMembers_thenThrowAssertionError.

@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testConstructor_whenMapsHaveDifferentMembers_thenThrowAssertionError() {
    Map<Address, MemberImpl> addressMap = new HashMap<>();
    Map<UUID, MemberImpl> uuidMap = new HashMap<>();
    MemberImpl addressMember = newMember(5701);
    MemberImpl uuidMember = newMember(5702);
    addressMap.put(addressMember.getAddress(), addressMember);
    uuidMap.put(uuidMember.getUuid(), uuidMember);
    new MemberMap(0, addressMap, uuidMap);
}
Also used : Address(com.hazelcast.cluster.Address) InetAddress(java.net.InetAddress) HashMap(java.util.HashMap) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) UUID(java.util.UUID) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 42 with MemberImpl

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

the class MemberMapTest method cloneAdding_failsWithDuplicateAddress.

@Test(expected = IllegalArgumentException.class)
public void cloneAdding_failsWithDuplicateAddress() {
    MemberImpl[] members = newMembers(3);
    MemberImpl member = newMember(5000);
    MemberMap.cloneAdding(MemberMap.createNew(members), member);
}
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 43 with MemberImpl

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

the class MemberMapTest method createSingleton.

@Test
public void createSingleton() {
    MemberImpl member = newMember(5000);
    MemberMap map = MemberMap.singleton(member);
    assertEquals(1, map.getMembers().size());
    assertEquals(1, map.getAddresses().size());
    assertEquals(1, map.size());
    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 44 with MemberImpl

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

the class MemberMapTest method headMemberSet_exclusive.

@Test
public void headMemberSet_exclusive() {
    MemberImpl[] members = newMembers(7);
    MemberMap map = MemberMap.createNew(members);
    MemberImpl member = members[3];
    Set<MemberImpl> set = map.headMemberSet(member, false);
    assertEquals(3, set.size());
    int k = 0;
    for (MemberImpl m : set) {
        assertEquals(members[k++], m);
    }
}
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 45 with MemberImpl

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

the class MemberMapTest method cloneAdding.

@Test
public void cloneAdding() {
    MemberImpl[] members = newMembers(5);
    MemberMap map = MemberMap.cloneAdding(MemberMap.createNew(members[0], members[1], members[2]), members[3], members[4]);
    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)

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