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;
}
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);
}
}
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());
}
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());
}
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);
}
});
}
Aggregations