Java 类com.hazelcast.core.MultiTask 实例源码

项目:hazelcast-archive    文件:ExecutorServiceClientProxy.java   
private <T> Future<T> submit(DistributedTask dt) {
    ClientDistributedTask cdt = null;
    InnerFutureTask inner = (InnerFutureTask) dt.getInner();
    check(inner.getCallable());
    if (dt instanceof MultiTask) {
        if (inner.getMembers() == null) {
            Set<Member> set = new HashSet<Member>();
            set.add(inner.getMember());
            cdt = new ClientDistributedTask(inner.getCallable(), null, set, null);
        }
    }
    if (cdt == null) {
        cdt = new ClientDistributedTask(inner.getCallable(), inner.getMember(), inner.getMembers(), inner.getKey());
    }
    return submit(dt, cdt);
}
项目:health-and-care-developer-network    文件:ExecutorServiceClientProxy.java   
private <T> Future<T> submit(DistributedTask dt) {
    ClientDistributedTask cdt = null;
    InnerFutureTask inner = (InnerFutureTask) dt.getInner();
    check(inner.getCallable());
    if (dt instanceof MultiTask) {
        if (inner.getMembers() == null) {
            Set<Member> set = new HashSet<Member>();
            set.add(inner.getMember());
            cdt = new ClientDistributedTask(inner.getCallable(), null, set, null);
        }
    }
    if (cdt == null) {
        cdt = new ClientDistributedTask(inner.getCallable(), inner.getMember(), inner.getMembers(), inner.getKey());
    }
    return submit(dt, cdt);
}
项目:openfire-bespoke    文件:ClusteredCacheFactory.java   
public void doClusterTask(final ClusterTask task) {
    if (cluster == null) { return; }
    Set<Member> members = new HashSet<Member>();
    Member current = cluster.getLocalMember();
    for(Member member : cluster.getMembers()) {
        if (!member.getUuid().equals(current.getUuid())) {
            members.add(member);
        }
    }
    if (members.size() > 0) {
     // Asynchronously execute the task on the other cluster members
        logger.debug("Executing asynchronous MultiTask: " + task.getClass().getName());
     hazelcast.getExecutorService().execute(
            new MultiTask<Object>(new CallableTask<Object>(task), members));
    } else {
        logger.warn("No cluster members selected for cluster task " + task.getClass().getName());
    }
}
项目:openfire-bespoke    文件:ClusteredCacheFactory.java   
public Collection<Object> doSynchronousClusterTask(ClusterTask task, boolean includeLocalMember) {
    Collection<Object> result = Collections.emptyList();
    if (cluster == null) { return result; }
    Set<Member> members = new HashSet<Member>();
    Member current = cluster.getLocalMember();
    for(Member member : cluster.getMembers()) {
        if (includeLocalMember || (!member.getUuid().equals(current.getUuid()))) {
            members.add(member);
        }
    }
    if (members.size() > 0) {
     // Asynchronously execute the task on the other cluster members
        MultiTask<Object> multiTask = new MultiTask<Object>(
                new CallableTask<Object>(task), members);
        try {
            logger.debug("Executing MultiTask: " + task.getClass().getName());
            hazelcast.getExecutorService().execute(multiTask);
            result = multiTask.get(MAX_CLUSTER_EXECUTION_TIME,TimeUnit.SECONDS);
            logger.debug("MultiTask result: " + (result == null ? "null" : result.size()));
        } catch (TimeoutException te) {
            logger.error("Failed to execute cluster task within " + MAX_CLUSTER_EXECUTION_TIME + " seconds", te);
        } catch (Exception e) {
            logger.error("Failed to execute cluster task", e);
        }
    } else {
        logger.warn("No cluster members selected for cluster task " + task.getClass().getName());
    }
    return result;
}