Search in sources :

Example 56 with MemberImpl

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

the class FrozenPartitionTableTest method partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember.

@Test
public void partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember() {
    ruleStaleJoinPreventionDuration.setOrClearProperty("5");
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    HazelcastInstance hz3 = factory.newHazelcastInstance();
    HazelcastInstance hz4 = factory.newHazelcastInstance();
    assertClusterSizeEventually(4, hz2, hz3);
    warmUpPartitions(hz1, hz2, hz3, hz4);
    changeClusterStateEventually(hz4, ClusterState.FROZEN);
    int member3PartitionId = getPartitionId(hz3);
    int member4PartitionId = getPartitionId(hz4);
    MemberImpl member3 = getNode(hz3).getLocalMember();
    MemberImpl member4 = getNode(hz4).getLocalMember();
    hz3.shutdown();
    hz4.shutdown();
    assertClusterSizeEventually(2, hz1, hz2);
    newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, member4.getUuid(), member3.getAddress()));
    assertClusterSizeEventually(3, hz1, hz2);
    waitAllForSafeState(hz1, hz2);
    OperationServiceImpl operationService = getOperationService(hz1);
    operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member3PartitionId).join();
    try {
        operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member4PartitionId).joinInternal();
        fail("Invocation to missing member should have failed!");
    } catch (TargetNotMemberException ignored) {
    }
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Config(com.hazelcast.config.Config) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 57 with MemberImpl

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

the class SerializationIssueTest method testMemberLeftException.

private void testMemberLeftException(UUID uuid, String host, int port, Member member) throws Exception {
    MemberLeftException exception = new MemberLeftException(member);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(exception);
    ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    MemberLeftException exception2 = (MemberLeftException) in.readObject();
    MemberImpl member2 = (MemberImpl) exception2.getMember();
    assertEquals(uuid, member2.getUuid());
    assertEquals(host, member2.getAddress().getHost());
    assertEquals(port, member2.getAddress().getPort());
    assertEquals(member.isLiteMember(), member2.isLiteMember());
    assertEquals(member.getVersion(), member2.getVersion());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) SimpleMemberImpl(com.hazelcast.instance.SimpleMemberImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) MemberLeftException(com.hazelcast.core.MemberLeftException) ObjectInputStream(java.io.ObjectInputStream)

Example 58 with MemberImpl

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

the class TcpClientConnectionManagerTranslateTest method testTranslateFromMemberIsNotUsedWhenAlreadyTranslatedByAddressProvider.

@Test(expected = Exception.class)
public void testTranslateFromMemberIsNotUsedWhenAlreadyTranslatedByAddressProvider() throws UnknownHostException {
    // given
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.getName(), "true");
    TestAddressProvider provider = new TestAddressProvider(false);
    HazelcastInstance client = HazelcastClientUtil.newHazelcastClient(provider, clientConfig);
    TcpClientConnectionManager clientConnectionManager = new TcpClientConnectionManager(getHazelcastClientInstanceImpl(client));
    clientConnectionManager.start();
    provider.shouldTranslate = true;
    privateAddress = new Address("192.168.0.1", 5702);
    // private member address is correct
    Member member = new MemberImpl(privateAddress, VERSION, false, UUID.randomUUID());
    // public member address is correct
    member.getAddressMap().put(EndpointQualifier.resolve(ProtocolType.CLIENT, "public"), new Address("127.0.0.1", 5701));
    // when
    clientConnectionManager.getOrConnectToMember(member, false);
// then
// throws exception because it can't connect to the incorrect address
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 59 with MemberImpl

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

the class FlakeIdGenerator_NodeIdOverflowIntegrationTest method assignOverflowedNodeId.

private static void assignOverflowedNodeId(HazelcastInstance instance2) {
    MemberImpl member = (MemberImpl) instance2.getCluster().getLocalMember();
    member.setMemberListJoinVersion(100000);
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 60 with MemberImpl

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

the class AddPartitionLostListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    final IPartitionService partitionService = getService(getServiceName());
    final PartitionLostListener listener = event -> {
        if (endpoint.isAlive()) {
            ClusterService clusterService = getService(ClusterServiceImpl.SERVICE_NAME);
            Address eventSource = event.getEventSource();
            MemberImpl member = clusterService.getMember(eventSource);
            ClientMessage eventMessage = ClientAddPartitionLostListenerCodec.encodePartitionLostEvent(event.getPartitionId(), event.getLostBackupCount(), member.getUuid());
            sendClientMessage(null, eventMessage);
        }
    };
    if (parameters) {
        return newCompletedFuture(partitionService.addLocalPartitionLostListener(listener));
    }
    return partitionService.addPartitionLostListenerAsync(listener);
}
Also used : Address(com.hazelcast.cluster.Address) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) Connection(com.hazelcast.internal.nio.Connection) IPartitionService(com.hazelcast.internal.partition.IPartitionService) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) Node(com.hazelcast.instance.impl.Node) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ClusterService(com.hazelcast.internal.cluster.ClusterService) ClientAddPartitionLostListenerCodec(com.hazelcast.client.impl.protocol.codec.ClientAddPartitionLostListenerCodec) PARTITION_LOST_EVENT_TOPIC(com.hazelcast.internal.partition.InternalPartitionService.PARTITION_LOST_EVENT_TOPIC) Permission(java.security.Permission) PartitionLostListener(com.hazelcast.partition.PartitionLostListener) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) PartitionLostListener(com.hazelcast.partition.PartitionLostListener) ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) IPartitionService(com.hazelcast.internal.partition.IPartitionService) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

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