/** * @return Resolves task name. */ public String resolveTaskName() { if (taskName != null) return taskName; return (taskName = cctx.kernalContext().task().resolveTaskName(taskNameHash)); }
/** {@inheritDoc} */ @Override public <T, R> GridComputeTaskFuture<R> execute(String taskName, @Nullable T arg) { A.notNull(taskName, "taskName"); guard(); try { ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes()); ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId); return ctx.task().execute(taskName, arg); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public <T, R> GridComputeTaskFuture<R> execute(GridComputeTask<T, R> task, @Nullable T arg) { A.notNull(task, "task"); guard(); try { ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes()); ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId); return ctx.task().execute(task, arg); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public <T, R> GridComputeTaskFuture<R> execute(Class<? extends GridComputeTask<T, R>> taskCls, @Nullable T arg) { A.notNull(taskCls, "taskCls"); guard(); try { ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes()); ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId); return ctx.task().execute(taskCls, arg); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public <T, R> GridFuture<R> execute(GridGgfsTask<T, R> task, @Nullable GridGgfsRecordResolver rslvr, Collection<GridGgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) { return ggfsCtx.kernalContext().task().execute(task, new GridGgfsTaskArgsImpl<>(cfg.getName(), paths, rslvr, skipNonExistentFiles, maxRangeLen, arg)); }
/** {@inheritDoc} */ @Override public void setAttributes(Map<?, ?> attrs) throws GridException { A.notNull(attrs, "attrs"); checkFullSupport(); if (attrs.isEmpty()) return; // Note that there is no mux notification in this block. // The reason is that we wait for ordered attributes to // come back from task prior to notification. The notification // will happen in 'setInternal(...)' method. synchronized (mux) { if (this.attrs == null) this.attrs = new HashMap<>(attrs.size(), 1.0f); this.attrs.putAll(attrs); } if (isTaskNode()) ctx.task().setAttributes(this, attrs); }
/** {@inheritDoc} */ @Override public <T, R> GridFuture<R> execute(GridGgfsTask<T, R> task, @Nullable GridGgfsRecordResolver rslvr, Collection<GridGgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) { return ggfsCtx.kernalContext().task().execute(task, new GridGgfsTaskArgsImpl<>(cfg.getName(), paths, rslvr, skipNonExistentFiles, maxRangeLen, arg)); }
/** {@inheritDoc} */ @Override public <T, R> GridFuture<R> execute(Class<? extends GridGgfsTask<T, R>> taskCls, @Nullable GridGgfsRecordResolver rslvr, Collection<GridGgfsPath> paths, boolean skipNonExistentFiles, long maxRangeSize, @Nullable T arg) { return ggfsCtx.kernalContext().task().execute((Class<GridGgfsTask<T, R>>)taskCls, new GridGgfsTaskArgsImpl<>(cfg.getName(), paths, rslvr, skipNonExistentFiles, maxRangeSize, arg)); }
/** {@inheritDoc} */ @Override public <T, R> GridFuture<R> execute(Class<? extends GridGgfsTask<T, R>> taskCls, @Nullable GridGgfsRecordResolver rslvr, Collection<GridGgfsPath> paths, boolean skipNonExistentFiles, long maxRangeSize, @Nullable T arg) { return ggfsCtx.kernalContext().task().execute((Class<GridGgfsTask<T, R>>)taskCls, new GridGgfsTaskArgsImpl<>(cfg.getName(), paths, rslvr, skipNonExistentFiles, maxRangeSize, arg)); }
/** {@inheritDoc} */ @Nullable @Override public <R> GridComputeTaskFuture<R> taskFuture(GridUuid sesId) { A.notNull(sesId, "sesId"); guard(); try { return ctx.task().taskFuture(sesId); } finally { unguard(); } }
@Nullable private String taskName() { String taskName = null; if (ctx.security().enabled()) { assert GridCacheContinuousQueryHandler.this instanceof GridCacheContinuousQueryHandlerV2; int taskHash = ((GridCacheContinuousQueryHandlerV2)GridCacheContinuousQueryHandler.this).taskHash(); taskName = ctx.task().resolveTaskName(taskHash); } return taskName; } };
/** {@inheritDoc} */ @Override public GridCompute withNoFailover() { guard(); try { ctx.task().setThreadContext(TC_NO_FAILOVER, true); } finally { unguard(); } return this; }
/** {@inheritDoc} */ @Nullable @Override public GridDeployment getDeployment(GridUuid ldrId) { synchronized (mux) { for (ConcurrentLinkedDeque8<GridDeployment> deps : cache.values()) for (GridDeployment dep : deps) if (dep.classLoaderId().equals(ldrId)) return dep; } for (GridDeployment dep : ctx.task().getUsedDeployments()) if (dep.classLoaderId().equals(ldrId)) return dep; return null; }
/** * @param job Job closure. * @param arg Optional job argument. * @param nodes Grid nodes. * @return Grid future for execution result. */ public <T, R> GridFuture<Collection<R>> broadcast(GridClosure<T, R> job, @Nullable T arg, @Nullable Collection<GridNode> nodes) { enterBusy(); try { if (F.isEmpty(nodes)) return new GridFinishedFuture<>(ctx, U.emptyTopologyException()); ctx.task().setThreadContext(TC_SUBGRID, nodes); return ctx.task().execute(new T11<>(job, arg, nodes), null, false); } finally { leaveBusy(); } }
/** {@inheritDoc} */ @Override public GridCompute withName(String taskName) { A.notNull(taskName, "taskName"); guard(); try { ctx.task().setThreadContext(TC_TASK_NAME, taskName); } finally { unguard(); } return this; }
/** {@inheritDoc} */ @Override public GridCompute withTimeout(long timeout) { A.ensure(timeout >= 0, "timeout >= 0"); guard(); try { ctx.task().setThreadContext(TC_TIMEOUT, timeout); } finally { unguard(); } return this; }
/** {@inheritDoc} */ @Override public void resetMetrics() { guard(); try { ctx.jobMetric().reset(); ctx.io().resetMetrics(); ctx.task().resetMetrics(); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public boolean cancel() throws GridException { ctx.security().authorize(ses.getTaskName(), GridSecurityPermission.TASK_CANCEL, null); checkValid(); if (onCancelled()) { ctx.task().onCancelled(ses.getId()); return true; } return isCancelled(); }
/** {@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} */ @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; }