Search in sources :

Example 61 with MemberImpl

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

the class AbstractTargetMessageTask method processInternal.

@Override
protected CompletableFuture<Object> processInternal() {
    Operation op = prepareOperation();
    op.setCallerUuid(endpoint.getUuid());
    MemberImpl member = nodeEngine.getClusterService().getMember(getTargetUuid());
    if (member == null) {
        throw new TargetNotMemberException(String.format("Member with uuid(%s) is not in member list ", getTargetUuid()));
    }
    return nodeEngine.getOperationService().createInvocationBuilder(getServiceName(), op, member.getAddress()).setResultDeserialized(false).invoke();
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 62 with MemberImpl

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

the class AbstractJetMessageTask method getInvocationBuilder.

@Override
protected InvocationBuilder getInvocationBuilder(Operation operation) {
    Address address;
    if (getLightJobCoordinator() != null) {
        MemberImpl member = nodeEngine.getClusterService().getMember(getLightJobCoordinator());
        if (member == null) {
            throw new TopologyChangedException("Light job coordinator left the cluster");
        }
        address = member.getAddress();
    } else {
        address = nodeEngine.getMasterAddress();
        if (address == null) {
            throw new RetryableHazelcastException("master not yet known");
        }
    }
    return nodeEngine.getOperationService().createInvocationBuilder(JetServiceBackend.SERVICE_NAME, operation, address);
}
Also used : Address(com.hazelcast.cluster.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Example 63 with MemberImpl

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

the class ScheduledFutureProxy method invokeOnTarget.

private <T> InvocationFuture<T> invokeOnTarget(Operation op, UUID uuid) {
    NodeEngineImpl nodeEngine = ((HazelcastInstanceImpl) instance).node.getNodeEngine();
    MemberImpl member = nodeEngine.getClusterService().getMember(uuid);
    if (member == null) {
        throw new IllegalStateException("Member with address: " + uuid + ",  holding this scheduled task" + " is not part of this cluster.");
    }
    OperationService opService = nodeEngine.getOperationService();
    return opService.invokeOnTarget(op.getServiceName(), op, member.getAddress());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 64 with MemberImpl

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

the class TcpClientConnectionManagerTranslateTest method testTranslateIsUsedWhenMemberHasPublicClientAddress.

@Test
public void testTranslateIsUsedWhenMemberHasPublicClientAddress() throws UnknownHostException {
    // given
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.getName(), "true");
    HazelcastInstance client = HazelcastClientUtil.newHazelcastClient(null, clientConfig);
    TcpClientConnectionManager clientConnectionManager = new TcpClientConnectionManager(getHazelcastClientInstanceImpl(client));
    clientConnectionManager.start();
    // private member address is unreachable
    Member member = new MemberImpl(new Address("192.168.0.1", 5701), VERSION, false, UUID.randomUUID());
    // public member address is reachable
    member.getAddressMap().put(EndpointQualifier.resolve(ProtocolType.CLIENT, "public"), new Address("127.0.0.1", 5701));
    // when
    Connection connection = clientConnectionManager.getOrConnectToMember(member, false);
    // then
    assertNotNull(connection);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Connection(com.hazelcast.internal.nio.Connection) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 65 with MemberImpl

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

the class TcpClientConnectionManagerTranslateTest method testTranslateIsNotUsedWhenPublicIpDisabled.

@Test(expected = Exception.class)
public void testTranslateIsNotUsedWhenPublicIpDisabled() throws UnknownHostException {
    // given
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.getName(), "false");
    HazelcastInstance client = HazelcastClientUtil.newHazelcastClient(null, clientConfig);
    TcpClientConnectionManager clientConnectionManager = new TcpClientConnectionManager(getHazelcastClientInstanceImpl(client));
    clientConnectionManager.start();
    // private member address is incorrect
    Member member = new MemberImpl(new Address("192.168.0.1", 5701), VERSION, false);
    // 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 member 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)

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