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

项目: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 Object doSynchronousClusterTask(ClusterTask task, byte[] nodeID) {
    if (cluster == null) { return null; }
    Member member = getMember(nodeID);
    Object result = null;
    // Check that the requested member was found
    if (member != null) {
        // Asynchronously execute the task on the target member
        DistributedTask<Object> distributedTask = new DistributedTask<Object>(
                new CallableTask<Object>(task), member);
        logger.debug("Executing DistributedTask: " + task.getClass().getName());
     hazelcast.getExecutorService().execute(distributedTask);
        try { 
            result = distributedTask.get(MAX_CLUSTER_EXECUTION_TIME, TimeUnit.SECONDS);
            logger.debug("DistributedTask result: " + (result == null ? "null" : result));
        } 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("Requested node " + StringUtils.getString(nodeID) + " not found in cluster");
    }
    return result;
}
项目:hazelcast-archive    文件:ExecutorManager.java   
void notifyCompletion(final DistributedTask dtask) {
    final InnerFutureTask innerFutureTask = (InnerFutureTask) dtask.getInner();
    getEventExecutorService().execute(new Runnable() {
        public void run() {
            innerFutureTask.innerDone();
            if (innerFutureTask.getExecutionCallback() != null) {
                innerFutureTask.getExecutionCallback().done(dtask);
            }
        }
    });
}
项目:hazelcast-archive    文件:ExecutorManager.java   
MembersCall(String name, Set<Member> members, Data callable, DistributedTask dtask) {
    this.name = name;
    this.members = members;
    this.callable = callable;
    this.dtask = dtask;
    this.innerFutureTask = (InnerFutureTask) dtask.getInner();
}
项目:hazelcast-archive    文件:ExecutorManager.java   
MemberCall(String name, MemberImpl member, Data callable, DistributedTask dtask, boolean singleTask, ExecutionListener executionListener) {
    this.name = name;
    this.member = member;
    this.callable = callable;
    this.dtask = dtask;
    this.innerFutureTask = (InnerFutureTask) dtask.getInner();
    this.singleTask = singleTask;
    this.target = member.getAddress();
    this.executionListener = executionListener;
}
项目:hazelcast-archive    文件:ExecutorServiceClientProxy.java   
public <T> Future<T> submit(Runnable runnable, T t) {
    if (runnable instanceof DistributedTask) {
        return submit((DistributedTask) runnable);
    } else {
        return submit(DistributedTask.callable(runnable, t));
    }
}
项目:health-and-care-developer-network    文件:TestManagedContext.java   
@Test
public void testDistributedTask() throws ExecutionException, InterruptedException {
    SomeTask task = (SomeTask) context.getBean("someTask");
    Future<Long> f = instance1.getExecutorService().submit(task);
    Assert.assertEquals(bean.value, f.get().longValue());

    Future<Long> f2 = (Future<Long>) instance1.getExecutorService()
            .submit(new DistributedTask<Long>(new SomeTask()));
    Assert.assertEquals(bean.value, f2.get().longValue());
}
项目:health-and-care-developer-network    文件:TestManagedContext.java   
@Test
public void testTransactionalTask() throws ExecutionException, InterruptedException {
    Future f = instance1.getExecutorService().submit(new DistributedTask(new SomeTransactionalTask(),
            instance2.getCluster().getLocalMember()));
    f.get();
    Assert.assertTrue("transaction manager could not proxy the submitted task.",
            transactionManager.isCommitted());
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
void notifyCompletion(final DistributedTask dtask) {
    final InnerFutureTask innerFutureTask = (InnerFutureTask) dtask.getInner();
    getEventExecutorService().execute(new Runnable() {
        public void run() {
            innerFutureTask.innerDone();
            if (innerFutureTask.getExecutionCallback() != null) {
                innerFutureTask.getExecutionCallback().done(dtask);
            }
        }
    });
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
MembersCall(String name, Set<Member> members, Data callable, DistributedTask dtask) {
    this.name = name;
    this.members = members;
    this.callable = callable;
    this.dtask = dtask;
    this.innerFutureTask = (InnerFutureTask) dtask.getInner();
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
MemberCall(String name, MemberImpl member, Data callable, DistributedTask dtask, boolean singleTask, ExecutionListener executionListener) {
    this.name = name;
    this.member = member;
    this.callable = callable;
    this.dtask = dtask;
    this.innerFutureTask = (InnerFutureTask) dtask.getInner();
    this.singleTask = singleTask;
    this.target = member.getAddress();
    this.executionListener = executionListener;
}
项目:health-and-care-developer-network    文件:ExecutorServiceClientProxy.java   
public <T> Future<T> submit(Runnable runnable, T t) {
    if (runnable instanceof DistributedTask) {
        return submit((DistributedTask) runnable);
    } else {
        return submit(DistributedTask.callable(runnable, t));
    }
}
项目:openfire-bespoke    文件:ClusteredCacheFactory.java   
public boolean doClusterTask(final ClusterTask task, byte[] nodeID) {
    if (cluster == null) { return false; }
    Member member = getMember(nodeID);
      // Check that the requested member was found
      if (member != null) {
          // Asynchronously execute the task on the target member
        logger.debug("Executing asynchronous DistributedTask: " + task.getClass().getName());
       hazelcast.getExecutorService().execute(
            new DistributedTask<Object>(new CallableTask<Object>(task), member));
          return true;
      } else {
       logger.warn("Requested node " + StringUtils.getString(nodeID) + " not found in cluster");
        return false;
}
  }
项目:hazelcast-archive    文件:ExecutorManager.java   
MemberCall(String name, MemberImpl member, Data callable, DistributedTask dtask) {
    this(name, member, callable, dtask, true, null);
}
项目:hazelcast-archive    文件:ExecutorServiceProxy.java   
public <T> Future<T> submit(Callable<T> task) {
    if (task instanceof DistributedTask) {
        return submit((Runnable) task, null);
    }
    return submit(new DistributedTask(task), null);
}
项目:hazelcast-archive    文件:ExecutorServiceClientProxy.java   
public <T> Future<T> submit(Callable<T> callable) {
    return submit(new DistributedTask(callable));
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
MemberCall(String name, MemberImpl member, Data callable, DistributedTask dtask) {
    this(name, member, callable, dtask, true, null);
}
项目:health-and-care-developer-network    文件:ExecutorServiceProxy.java   
public <T> Future<T> submit(Callable<T> task) {
    if (task instanceof DistributedTask) {
        return submit((Runnable) task, null);
    }
    return submit(new DistributedTask(task), null);
}
项目:health-and-care-developer-network    文件:ExecutorServiceClientProxy.java   
public <T> Future<T> submit(Callable<T> callable) {
    return submit(new DistributedTask(callable));
}