Search in sources :

Example 36 with MemberImpl

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

the class ScheduledExecutorServiceBasicTest method scheduleOnMember.

@Test
public void scheduleOnMember() throws Exception {
    int delay = 1;
    HazelcastInstance[] instances = createClusterWithCount(2);
    IScheduledExecutorService executorService = getScheduledExecutor(instances, ANY_EXECUTOR_NAME);
    MemberImpl member = getNodeEngineImpl(instances[0]).getLocalMember();
    IScheduledFuture<Double> future = executorService.scheduleOnMember(new PlainCallableTask(), member, delay, SECONDS);
    assertTrue(future.getHandler().isAssignedToMember());
    assertEquals(25.0, future.get(), 0);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) IScheduledExecutorService(com.hazelcast.scheduledexecutor.IScheduledExecutorService) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 37 with MemberImpl

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

the class RestMultiendpointTest method assertAdvancedNetworkInUse.

@Test
public void assertAdvancedNetworkInUse() {
    int numberOfEndpointsInConfig = instance.getConfig().getAdvancedNetworkConfig().getEndpointConfigs().size();
    MemberImpl local = getNode(instance).getClusterService().getLocalMember();
    assertTrue(local.getAddressMap().size() == numberOfEndpointsInConfig);
    assertFalse(local.getSocketAddress(EndpointQualifier.REST).equals(local.getSocketAddress(EndpointQualifier.MEMBER)));
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 38 with MemberImpl

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

the class MembershipUpdateTest method memberListOrder_shouldBeSame_whenMemberRestartedWithSameIdentity.

@Test
public void memberListOrder_shouldBeSame_whenMemberRestartedWithSameIdentity() {
    ruleStaleJoinPreventionDuration.setOrClearProperty("5");
    Config configMaster = new Config();
    configMaster.setProperty(ClusterProperty.MEMBER_LIST_PUBLISH_INTERVAL_SECONDS.getName(), "5");
    HazelcastInstance hz1 = factory.newHazelcastInstance(configMaster);
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    HazelcastInstance hz3 = factory.newHazelcastInstance();
    HazelcastInstance hz4 = factory.newHazelcastInstance();
    assertClusterSizeEventually(4, hz2, hz3);
    rejectOperationsBetween(hz1, hz2, F_ID, singletonList(MEMBER_INFO_UPDATE));
    MemberImpl member3 = getNode(hz3).getLocalMember();
    hz3.getLifecycleService().terminate();
    assertClusterSizeEventually(3, hz1, hz4);
    assertClusterSize(4, hz2);
    hz3 = newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, member3));
    assertClusterSizeEventually(4, hz1, hz4);
    resetPacketFiltersFrom(hz1);
    assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz3));
    assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz4));
    assertTrueEventually(() -> assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz2)));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 39 with MemberImpl

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

the class MembershipFailureTest method slave_heartbeat_removes_suspicion.

@Test
public void slave_heartbeat_removes_suspicion() {
    Config config = smallInstanceConfig().setProperty(MAX_NO_HEARTBEAT_SECONDS.getName(), "15").setProperty(HEARTBEAT_INTERVAL_SECONDS.getName(), "1");
    HazelcastInstance master = newHazelcastInstance(config);
    HazelcastInstance slave1 = newHazelcastInstance(config);
    HazelcastInstance slave2 = newHazelcastInstance(config);
    assertClusterSize(3, master, slave2);
    assertClusterSizeEventually(3, slave1);
    dropOperationsBetween(slave2, slave1, F_ID, singletonList(HEARTBEAT));
    MembershipManager membershipManager = getNode(slave1).getClusterService().getMembershipManager();
    assertTrueEventually(() -> {
        Member localMember = slave2.getCluster().getLocalMember();
        assertTrue(membershipManager.isMemberSuspected((MemberImpl) localMember));
    });
    resetPacketFiltersFrom(slave2);
    assertTrueEventually(() -> {
        Member localMember = slave2.getCluster().getLocalMember();
        assertFalse(membershipManager.isMemberSuspected((MemberImpl) localMember));
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Member(com.hazelcast.cluster.Member) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 40 with MemberImpl

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

the class MemberMapTest method tailMemberSet_exclusive.

@Test
public void tailMemberSet_exclusive() {
    MemberImpl[] members = newMembers(7);
    MemberMap map = MemberMap.createNew(members);
    MemberImpl member = members[3];
    Set<MemberImpl> set = map.tailMemberSet(member, false);
    assertEquals(3, set.size());
    int k = 4;
    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)

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