use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method createInvocations.
private List<Future> createInvocations(Collection<Member> members, Predicate predicate) {
List<Future> futures = new ArrayList<>(members.size());
final OperationServiceImpl operationService = nodeEngine.getOperationService();
final Query query = buildQuery(predicate);
MapService mapService = nodeEngine.getService(getServiceName());
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
for (Member member : members) {
try {
Future future = operationService.createInvocationBuilder(SERVICE_NAME, createQueryOperation(query, mapServiceContext), member.getAddress()).invoke();
futures.add(future);
} catch (Throwable t) {
if (!(t instanceof HazelcastException)) {
// these are programmatic errors that needs to be visible
throw rethrow(t);
} else if (t.getCause() instanceof QueryResultSizeExceededException) {
throw rethrow(t);
} else {
// the missing partition IDs will be queried anyway, so it's not a terminal failure
if (logger.isFineEnabled()) {
logger.fine("Query invocation failed on member " + member, t);
}
}
}
}
return futures;
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class ExecutionCallbackAdapterFactory method triggerOnComplete.
private void triggerOnComplete() {
if (members.size() != responses.size() || !setDone()) {
return;
}
Map<Member, Object> realResponses = createHashMap(members.size());
for (Map.Entry<Member, ValueWrapper> entry : responses.entrySet()) {
Member key = entry.getKey();
Object value = entry.getValue().value;
realResponses.put(key, value);
}
multiExecutionCallback.onComplete(realResponses);
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class ExecutorServiceProxy method selectMembers.
private List<Member> selectMembers(@Nonnull MemberSelector memberSelector) {
checkNotNull(memberSelector, "memberSelector must not be null");
List<Member> selected = new ArrayList<>();
Collection<Member> members = getNodeEngine().getClusterService().getMembers();
for (Member member : members) {
if (memberSelector.select(member)) {
selected.add(member);
}
}
if (selected.isEmpty()) {
throw new RejectedExecutionException("No member selected with memberSelector[" + memberSelector + "]");
}
return selected;
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToMembers.
@Override
public <T> Map<Member, Future<T>> submitToMembers(@Nonnull Callable<T> task, @Nonnull Collection<Member> members) {
checkNotNull(task, "task must not be null");
checkNotNull(members, "members must not be null");
checkNotShutdown();
Data taskData = getNodeEngine().toData(task);
Map<Member, Future<T>> futures = createHashMap(members.size());
for (Member member : members) {
futures.put(member, submitToMember(taskData, member));
}
return futures;
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class DurableExecutorServiceProxy method shutdown.
@Override
public void shutdown() {
NodeEngine nodeEngine = getNodeEngine();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
OperationService operationService = nodeEngine.getOperationService();
Collection<Future> calls = new LinkedList<>();
for (Member member : members) {
ShutdownOperation op = new ShutdownOperation(name);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
calls.add(f);
}
waitWithDeadline(calls, 3, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Aggregations