/** {@inheritDoc} */ @Override public Object call() throws Exception { return g.forSubjectId(clientId).compute().execute( name, !params.isEmpty() ? params.size() == 1 ? params.get(0) : params.toArray() : null).get(); }
/** {@inheritDoc} */ @Override public Collection<GridComputeJobSibling> getJobSiblings() throws GridException { Collection<GridComputeJobSibling> sibs = ses.getJobSiblings(); if (sibs == null) { if (isTaskNode()) { assert !ses.isFullSupport(); // Need to fetch task session from task worker. GridComputeTaskFuture<Object> fut = ctx.task().taskFuture(ses.getId()); return fut.getTaskSession().getJobSiblings(); } // Request siblings list from task node (task is continuous). ses.setJobSiblings(sibs = ctx.job().requestJobSiblings(this)); } return sibs; }
/** {@inheritDoc} */ @Override public void cancelTask(GridUuid sesId) throws GridException { A.notNull(sesId, "sesId"); guard(); try { GridComputeTaskFuture<Object> task = ctx.task().taskFuture(sesId); if (task != null) // Cancel local task. task.cancel(); else if (prj.node(sesId.globalId()) != null) // Cancel remote task only if its master is in projection. ctx.io().send( sesId.globalId(), TOPIC_TASK_CANCEL, new GridTaskCancelRequest(sesId), SYSTEM_POOL ); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public Collection<GridComputeJobSibling> refreshJobSiblings() throws GridException { if (!isTaskNode()) { Collection<GridComputeJobSibling> sibs = ctx.job().requestJobSiblings(this); // Request siblings list from task node (task is continuous). ses.setJobSiblings(sibs); return sibs; } if (!ses.isFullSupport()) { // Need to fetch task session from task worker. GridComputeTaskFuture<Object> fut = ctx.task().taskFuture(ses.getId()); return fut.getTaskSession().getJobSiblings(); } return ses.getJobSiblings(); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public String executeTask(String taskName, String arg) throws JMException { try { return compute().<String, String>execute(taskName, arg).get(); } catch (GridException e) { throw U.jmException(e); } }
assert taskFut instanceof GridComputeTaskFuture; GridUuid tid = ((GridComputeTaskFuture)taskFut).getTaskSession().getId();
/** {@inheritDoc} */ @Override public void stopNodes() throws GridException { guard(); try { compute().execute(GridKillTask.class, false).get(); } finally { unguard(); } }
assert taskFut instanceof GridComputeTaskFuture; GridUuid tid = ((GridComputeTaskFuture)taskFut).getTaskSession().getId();
/** {@inheritDoc} */ @Override public void restartNodes() throws GridException { guard(); try { compute().execute(GridKillTask.class, true).get(); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public void restartNodes(Collection<UUID> ids) throws GridException { guard(); try { forNodeIds(ids).compute().execute(GridKillTask.class, true).get(); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public void stopNodes(Collection<UUID> ids) throws GridException { guard(); try { forNodeIds(ids).compute().execute(GridKillTask.class, false).get(); } finally { unguard(); } }
if (restart && !neighbors.isEmpty()) { try { forNodes(neighbors).compute().execute(GridKillTask.class, false).get();
/** {@inheritDoc} */ @SuppressWarnings("ConstantConditions") @Override public GridGgfsStatus globalSpace() throws GridException { if (busyLock.enterBusy()) { try { GridBiTuple<Long, Long> space = ggfsCtx.kernalContext().grid().compute().execute( new GgfsGlobalSpaceTask(name()), null).get(); return new GridGgfsStatus(space.get1(), space.get2()); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get global space because Grid is stopping."); }
/** {@inheritDoc} */ @SuppressWarnings("ConstantConditions") @Override public GridGgfsStatus globalSpace() throws GridException { if (enterBusy()) { try { GridBiTuple<Long, Long> space = ggfsCtx.kernalContext().grid().compute().execute( new GgfsGlobalSpaceTask(name()), null).get(); return new GridGgfsStatus(space.get1(), space.get2()); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get global space because Grid is stopping."); }
/** * Execute method on grid. * * @param subgrid Subgrid. * @param cls Joint point signature class. * @param arg GridifyArgument with all method signature parameters. * @param nodeFilter Node filter. * @param threshold Parameter that defines the minimal value below which the * execution will NOT be grid-enabled. * @param splitSize Size of elements to send in job argument. * @param timeout Execution timeout. * @return Result. * @throws GridException If execution failed. */ protected Object execute(GridProjection subgrid, Class<?> cls, GridifyRangeArgument arg, GridifyNodeFilter nodeFilter, int threshold, int splitSize, long timeout) throws GridException { long now = U.currentTimeMillis(); long end = timeout == 0 ? Long.MAX_VALUE : timeout + now; // Prevent overflow. if (end < 0) end = Long.MAX_VALUE; if (now > end) throw new GridComputeTaskTimeoutException("Timeout occurred while waiting for completion."); Collection<?> res = subgrid.compute().withTimeout(timeout == 0 ? 0L : (end - now)).execute( new GridifyDefaultRangeTask(cls, nodeFilter, threshold, splitSize, false), arg).get(); return result(arg.getMethodReturnType(), res); }
/** {@inheritDoc} */ @Override public <R> Collection<R> query(GridClosure<GridStreamerContext, R> clo, Collection<GridNode> nodes) throws GridException { ctx.gateway().readLock(); try { GridProjection prj = projection0(); if (!F.isEmpty(nodes)) prj = prj.forNodes(nodes); long startTime = U.currentTimeMillis(); Collection<R> res = prj.compute().execute(new GridStreamerQueryTask<>(clo, streamer.name()), null).get(); streamer.onQueryCompleted(U.currentTimeMillis() - startTime, prj.nodes().size()); return res; } finally { ctx.gateway().readUnlock(); } }
new GridifyDefaultRangeTask(cls, nodeFilter, threshold, splitSize, true), taskArg).get();
/** {@inheritDoc} */ @Override public void broadcast(GridInClosure<GridStreamerContext> clo, Collection<GridNode> nodes) throws GridException { ctx.gateway().readLock(); try { GridProjection prj = projection0(); if (!F.isEmpty(nodes)) prj = prj.forNodes(nodes); prj.compute().execute(new GridStreamerBroadcastTask(clo, streamer.name()), null).get(); } finally { ctx.gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public <R1, R2> R2 reduce(GridClosure<GridStreamerContext, R1> clo, GridReducer<R1, R2> rdc, Collection<GridNode> nodes) throws GridException { ctx.gateway().readLock(); try { GridProjection prj = projection0(); if (!F.isEmpty(nodes)) prj = prj.forNodes(nodes); return prj.compute().execute(new GridStreamerReduceTask<>(clo, rdc, streamer.name()), null).get(); } finally { ctx.gateway().readUnlock(); } }