/** {@inheritDoc} */ @Override public boolean heldcc() { if (ctx == null) return false; if (job == null) job = ctx.job().activeJob(jobId); return job != null && job.held(); }
/** * Unholds job. */ private void callcc0() { if (ctx != null) { if (job == null) job = ctx.job().activeJob(jobId); if (job != null) { // Execute in the same thread. job.execute(); } } }
/** * @param keys Keys. * @param filter Filter to evaluate. * @return Reload future. */ public GridFuture<?> reloadAllAsync(@Nullable Collection<? extends K> keys, @Nullable GridPredicate<GridCacheEntry<K, V>>... filter) { UUID subjId = ctx.subjectIdPerCall(null); String taskName = ctx.kernalContext().job().currentTaskName(); return reloadAllAsync(keys, false, subjId, taskName, filter); }
/** * @param keys Keys. * @param ret Return flag. * @param filter Optional filter. * @return Non-{@code null} map if return flag is {@code true}. * @throws GridException If failed. */ @Nullable public Map<K, V> reloadAll(@Nullable Collection<? extends K> keys, boolean ret, @Nullable GridPredicate<GridCacheEntry<K, V>>... filter) throws GridException { UUID subjId = ctx.subjectIdPerCall(null); String taskName = ctx.kernalContext().job().currentTaskName(); return reloadAllAsync(keys, ret, subjId, taskName, filter).get(); }
/** * Callback on method enter. */ public void onEnter() { if (!locDepOwner && depEnabled && !ignoreOwnership.get() && !cctx.kernalContext().job().internal()) { ClassLoader ldr = Thread.currentThread().getContextClassLoader(); // We mark node as deployment owner if accessing cache not from p2p deployed job // and not from internal job. if (!U.p2pLoader(ldr)) // If not deployment class loader, classes can be loaded from this node. locDepOwner = true; } }
/** {@inheritDoc} */ @Override public V get(K key, @Nullable GridCacheEntryEx<K, V> entry, boolean deserializePortable, @Nullable GridPredicate<GridCacheEntry<K, V>>... filter) throws GridException { String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(F.asList(key), ctx.hasFlag(GET_PRIMARY), /*skip tx*/false, entry, null, taskName, deserializePortable, filter).get().get(key); }
/** {@inheritDoc} */ @Override public void setAttributes(Map<?, ?> attrs) throws GridException { ses.setAttributes(attrs); if (!isTaskNode()) ctx.job().setAttributes(this, attrs); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override @Nullable public V get(K key, boolean deserializePortable, @Nullable GridPredicate<GridCacheEntry<K, V>> filter) throws GridException { ctx.denyOnFlag(LOCAL); String taskName = ctx.kernalContext().job().currentTaskName(); Map<K, V> m = getAllInternal(Collections.singleton(key), filter != null ? new GridPredicate[]{filter} : null, ctx.isSwapOrOffheapEnabled(), ctx.isStoreEnabled(), ctx.hasFlag(CLONE), taskName, deserializePortable); return m.get(key); }
/** {@inheritDoc} */ @Override public GridFuture<V> getForcePrimaryAsync(final K key) { ctx.denyOnFlag(LOCAL); String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(Collections.singletonList(key), /*force primary*/true, /*skip tx*/false, null, null, taskName, true).chain(new CX1<GridFuture<Map<K, V>>, V>() { @Override public V applyx(GridFuture<Map<K, V>> e) throws GridException { return e.get().get(key); } }); }
/** {@inheritDoc} */ @Nullable @Override public Map<K, V> getAllOutTx(Collection<K> keys) throws GridException { String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/true, null, null, taskName, true).get(); }
/** {@inheritDoc} */ @Override public GridCacheTxLocalAdapter<K, V> newTx(boolean implicit, boolean implicitSingle, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, boolean invalidate, boolean syncCommit, boolean syncRollback, boolean swapOrOffheapEnabled, boolean storeEnabled, int txSize, @Nullable Object grpLockKey, boolean partLock) { // Use null as subject ID for transactions if subject per call is not set. GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); UUID subjId = prj == null ? null : prj.subjectId(); int taskNameHash = ctx.kernalContext().job().currentTaskNameHash(); return new GridNearTxLocal<>(ctx, implicit, implicitSingle, concurrency, isolation, timeout, invalidate, syncCommit, syncRollback, swapOrOffheapEnabled, storeEnabled, txSize, grpLockKey, partLock, subjId, taskNameHash); }
/** {@inheritDoc} */ @Override public GridFuture<Map<K, V>> getAllOutTxAsync(Collection<K> keys) { String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/true, null, null, taskName, true); }
/** {@inheritDoc} */ @Override public V getForcePrimary(K key) throws GridException { ctx.denyOnFlag(LOCAL); String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(F.asList(key), /*force primary*/true, /*skip tx*/false, null, null, taskName, true) .get().get(key); }
/** * @param keys Keys. * @param filter Filter to evaluate. * @return Read future. */ public GridFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys, boolean deserializePortable, @Nullable GridPredicate<GridCacheEntry<K, V>> filter) { String taskName = ctx.kernalContext().job().currentTaskName(); if (ctx.portableEnabled() && !F.isEmpty(keys)) { keys = F.viewReadOnly(keys, new C1<K, K>() { @Override public K apply(K k) { return (K)ctx.marshalToPortable(k); } }); } return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/false, null, null, taskName, deserializePortable, filter); }
/** * Cancel task on master leave event. Does not send cancel request to remote jobs and invokes master-leave * callback on local jobs. * * @return {@code True} if future was cancelled (i.e. was not finished prior to this call). * @throws GridException If failed. */ public boolean cancelOnMasterLeave() throws GridException { checkValid(); if (onCancelled()) { // Invoke master-leave callback on spawned jobs on local node and then cancel them. for (GridNode node : ctx.discovery().nodes(ses.getTopology())) { if (ctx.localNodeId().equals(node.id())) { ctx.job().masterLeaveLocal(ses.getId()); ctx.job().cancelJob(ses.getId(), null, false); } } return true; } return isCancelled(); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public final Map<K, V> getAll(Collection<? extends K> keys, boolean deserializePortable, GridPredicate<GridCacheEntry<K, V>> filter) throws GridException { ctx.denyOnFlag(LOCAL); String taskName = ctx.kernalContext().job().currentTaskName(); return getAllInternal(keys, filter != null ? new GridPredicate[]{filter} : null, ctx.isSwapOrOffheapEnabled(), ctx.isStoreEnabled(), ctx.hasFlag(CLONE), taskName, deserializePortable); }
/** {@inheritDoc} */ @Override public void cancelJob(GridUuid jobId) throws GridException { A.notNull(jobId, "jobId"); guard(); try { boolean loc = F.nodeIds(prj.nodes()).contains(ctx.localNodeId()); if (loc) ctx.job().cancelJob(null, jobId, false); ctx.io().send( prj.forRemotes().nodes(), TOPIC_JOB_CANCEL, new GridJobCancelRequest(null, jobId, false), SYSTEM_POOL ); } finally { unguard(); } }
/** {@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 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(); }