Search in sources :

Example 6 with MemberLeftException

use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.

the class JetInstanceImpl method getJobsInt.

@Override
public Map<Address, GetJobIdsResult> getJobsInt(String onlyName, Long onlyJobId) {
    Map<Address, CompletableFuture<GetJobIdsResult>> futures = new HashMap<>();
    Address masterAddress = null;
    // if onlyName != null, only send the operation to master. Light jobs cannot have a name
    Collection<Member> targetMembers = onlyName == null ? nodeEngine.getClusterService().getMembers(DATA_MEMBER_SELECTOR) : singleton(nodeEngine.getClusterService().getMembers().iterator().next());
    for (Member member : targetMembers) {
        if (masterAddress == null) {
            masterAddress = member.getAddress();
        }
        GetJobIdsOperation operation = new GetJobIdsOperation(onlyName, onlyJobId);
        InvocationFuture<GetJobIdsResult> future = nodeEngine.getOperationService().createInvocationBuilder(JetServiceBackend.SERVICE_NAME, operation, member.getAddress()).invoke();
        futures.put(member.getAddress(), future);
    }
    Map<Address, GetJobIdsResult> res = new HashMap<>(futures.size());
    for (Entry<Address, CompletableFuture<GetJobIdsResult>> en : futures.entrySet()) {
        GetJobIdsResult result;
        try {
            result = en.getValue().get();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            result = GetJobIdsResult.EMPTY;
        } catch (ExecutionException e) {
            // important. If we don't get response from the master, we report it to the user.
            if (!en.getKey().equals(masterAddress) && (e.getCause() instanceof TargetNotMemberException || e.getCause() instanceof MemberLeftException)) {
                result = GetJobIdsResult.EMPTY;
            } else {
                throw new RuntimeException("Error when getting job IDs: " + e, e);
            }
        }
        res.put(en.getKey(), result);
    }
    return res;
}
Also used : Address(com.hazelcast.cluster.Address) HashMap(java.util.HashMap) GetJobIdsOperation(com.hazelcast.jet.impl.operation.GetJobIdsOperation) CompletableFuture(java.util.concurrent.CompletableFuture) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) ExecutionException(java.util.concurrent.ExecutionException) Member(com.hazelcast.cluster.Member) GetJobIdsResult(com.hazelcast.jet.impl.operation.GetJobIdsOperation.GetJobIdsResult) MemberLeftException(com.hazelcast.core.MemberLeftException)

Example 7 with MemberLeftException

use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.

the class MigrationManager method logMigrationCommitFailure.

private void logMigrationCommitFailure(MigrationInfo migration, Throwable t) {
    boolean memberLeft = t instanceof MemberLeftException || t.getCause() instanceof TargetNotMemberException || t.getCause() instanceof HazelcastInstanceNotActiveException;
    PartitionReplica destination = migration.getDestination();
    if (memberLeft) {
        if (destination.isIdentical(node.getLocalMember())) {
            logger.fine("Migration commit failed for " + migration + " since this node is shutting down.");
            return;
        }
        logger.warning("Migration commit failed for " + migration + " since destination " + destination + " left the cluster");
    } else {
        logger.severe("Migration commit to " + destination + " failed for " + migration, t);
    }
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) MemberLeftException(com.hazelcast.core.MemberLeftException)

Example 8 with MemberLeftException

use of com.hazelcast.core.MemberLeftException 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 9 with MemberLeftException

use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.

the class ChainingFutureTest method testTopologyChangesExceptionsAreIgnored.

@Test
public void testTopologyChangesExceptionsAreIgnored() {
    InternalCompletableFuture<Object> future1 = newFuture();
    InternalCompletableFuture<Object> future2 = newFuture();
    InternalCompletableFuture<Object> future3 = newFuture();
    CountingIterator<InternalCompletableFuture<Object>> iterator = toIterator(future1, future2, future3);
    ChainingFuture.ExceptionHandler handler = repairingIterator;
    ChainingFuture<Object> future = new ChainingFuture<>(iterator, handler);
    assertEquals(1, iterator.getHasNextCounter());
    assertEquals(1, iterator.getNextCounter());
    assertFalse(future.isDone());
    future1.complete(new MemberLeftException("this should be ignored"));
    assertEquals(2, iterator.getHasNextCounter());
    assertEquals(2, iterator.getNextCounter());
    assertFalse(future.isDone());
    future2.complete(new TargetNotMemberException("this should be ignored"));
    assertEquals(3, iterator.getHasNextCounter());
    assertEquals(3, iterator.getNextCounter());
    assertFalse(future.isDone());
    future3.complete("foo");
    assertTrue(future.isDone());
    assertEquals(4, iterator.getHasNextCounter());
    assertEquals(3, iterator.getNextCounter());
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) MemberLeftException(com.hazelcast.core.MemberLeftException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with MemberLeftException

use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.

the class AbstractInvocationFuture_AndThenTest method whenExceptionalResponseAvailableAfterSomeWaiting_MemberLeftException.

@Test
public void whenExceptionalResponseAvailableAfterSomeWaiting_MemberLeftException() {
    final ExecutionCallback callback = mock(ExecutionCallback.class);
    future.andThen(callback);
    final MemberLeftException ex = new MemberLeftException();
    future.complete(ex);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            verify(callback).onFailure(ex);
        }
    });
}
Also used : AssertTask(com.hazelcast.test.AssertTask) ExecutionCallback(com.hazelcast.core.ExecutionCallback) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) MemberLeftException(com.hazelcast.core.MemberLeftException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MemberLeftException (com.hazelcast.core.MemberLeftException)17 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)8 Member (com.hazelcast.cluster.Member)4 ExecutionException (java.util.concurrent.ExecutionException)4 Test (org.junit.Test)4 Address (com.hazelcast.cluster.Address)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 ArrayList (java.util.ArrayList)3 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)2 Config (com.hazelcast.config.Config)2 Member (com.hazelcast.core.Member)2 SimpleMemberImpl (com.hazelcast.instance.SimpleMemberImpl)2 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)2 Data (com.hazelcast.internal.serialization.Data)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 SerializableList (com.hazelcast.spi.impl.SerializableList)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)2 AssertTask (com.hazelcast.test.AssertTask)2