Search in sources :

Example 31 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class MemberMapTest method cloneExcluding.

@Test
public void cloneExcluding() {
    MemberImpl[] members = new MemberImpl[6];
    for (int i = 0; i < members.length; i++) {
        members[i] = newMember(5000 + i);
    }
    MemberImpl exclude0 = members[0];
    MemberImpl exclude1 = new MemberImpl(newAddress(6000), VERSION, false, members[1].getUuid(), null);
    MemberImpl exclude2 = new MemberImpl(members[2].getAddress(), VERSION, false, newUnsecureUuidString(), null);
    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.instance.MemberImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 32 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class MemberMapTest method cloneAdding.

@Test
public void cloneAdding() {
    MemberImpl[] members = new MemberImpl[5];
    for (int i = 0; i < members.length; i++) {
        members[i] = newMember(5000 + i);
    }
    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.instance.MemberImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 33 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class MemberMapTest method createNew.

@Test
public void createNew() {
    MemberImpl[] members = new MemberImpl[5];
    for (int i = 0; i < members.length; i++) {
        members[i] = newMember(5000 + i);
    }
    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.instance.MemberImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 34 with MemberImpl

use of com.hazelcast.instance.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.instance.MemberImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 35 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class MapDestroyCacheMessageTask method call.

@Override
protected Object call() throws Exception {
    ClusterService clusterService = clientEngine.getClusterService();
    Collection<MemberImpl> members = clusterService.getMemberImpls();
    List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>(members.size());
    createInvocations(members, futures);
    Collection<Boolean> results = FutureUtil.returnWithDeadline(futures, 1, TimeUnit.MINUTES);
    return reduce(results);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) MemberImpl(com.hazelcast.instance.MemberImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Aggregations

MemberImpl (com.hazelcast.instance.MemberImpl)86 Address (com.hazelcast.nio.Address)37 Test (org.junit.Test)18 Member (com.hazelcast.core.Member)17 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelTest (com.hazelcast.test.annotation.ParallelTest)14 ArrayList (java.util.ArrayList)12 InetAddress (java.net.InetAddress)9 Future (java.util.concurrent.Future)9 HashSet (java.util.HashSet)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)5 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)5 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)5 ILogger (com.hazelcast.logging.ILogger)5 OperationService (com.hazelcast.spi.OperationService)5 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)5 Before (org.junit.Before)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4