/** {@inheritDoc} */ @Override public void onUpdated(final Iterable<CacheEntryEvent<?, ?>> deps) { GridSpinBusyLock busyLock = GridServiceProcessor.this.busyLock; if (busyLock == null || !busyLock.enterBusy()) return; try { depExe.execute(new DepRunnable() { @Override public void run0() { onSystemCacheUpdated(deps); } }); } finally { busyLock.leaveBusy(); } } }
/** {@inheritDoc} */ @Override public void onKernalStop() { busyLock.block(); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { super.onKernalStop(cancel); if (cancel && idx != null) { try { while (!busyLock.tryBlock(500)) idx.onKernalStop(); return; } catch (InterruptedException ignored) { U.warn(log, "Interrupted while waiting for active queries cancellation."); Thread.currentThread().interrupt(); } } busyLock.block(); }
/** * Leaves busy state. */ private void leaveBusy() { busyLock.leaveBusy(); }
/** * Enters busy state. * * @return {@code true} if entered to busy state. */ private boolean enterBusy() { return busyLock.enterBusy(); }
/** * @param cctx Cache context. * @param delegate Delegate set. */ public GridCacheSetProxy(GridCacheContext cctx, GridCacheSetImpl<T> delegate) { this.cctx = cctx; this.delegate = delegate; gate = cctx.gate(); busyLock = new GridSpinBusyLock(); }
/** * Leaves busy state. */ private void leaveBusy() { busyLock.leaveBusy(); } }
/** * @return {@code True} if entered busy state. */ private boolean enterBusy() { return busyLock.enterBusy(); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { super.onKernalStop(cancel); if (cancel && idx != null) { try { while (!busyLock.tryBlock(500)) idx.cancelAllQueries(); return; } catch (InterruptedException ignored) { U.warn(log, "Interrupted while waiting for active queries cancellation."); Thread.currentThread().interrupt(); } } busyLock.block(); }
/** {@inheritDoc} */ @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException { if (log.isDebugEnabled()) log.debug("Activate service processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]"); busyLock = new GridSpinBusyLock(); depExe = Executors.newSingleThreadExecutor(new IgniteThreadFactory(ctx.igniteInstanceName(), "srvc-deploy", oomeHnd)); start(); onKernalStart0(); }
/** * Cancel active lazy queries and prevent submit of new queries. */ public void cancelLazyWorkers() { if (!lazyWorkerStopGuard.compareAndSet(false, true)) return; lazyWorkerBusyLock.block(); for (MapQueryLazyWorker worker : lazyWorkers.values()) worker.stop(false); lazyWorkers.clear(); }
/** * */ final void onProcessEnd() { busyLock.leaveBusy(); }
/** * Stops processing of services deployments tasks. * * @param stopErr Cause error of deployment manager stop. */ void stopProcessing(IgniteCheckedException stopErr) { busyLock.block(); try { ctx.event().removeDiscoveryEventListener(discoLsnr); ctx.io().removeMessageListener(commLsnr); U.cancel(depWorker); U.join(depWorker, log); depWorker.tasksQueue.clear(); pendingEvts.clear(); tasks.values().forEach(t -> t.completeError(stopErr)); tasks.clear(); } finally { busyLock.unblock(); } }
/** * @return {@code True} if is able to start processing. */ final boolean onProcessStart() { boolean start = rtState.errForClose == null && busyLock.enterBusy(); if (!start) { assert rtState.errForClose != null; onStartFailed(); return false; } return true; }
protected final GridSpinBusyLock busyLock = new GridSpinBusyLock();
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> submit(HadoopJobId jobId, HadoopJobInfo jobInfo) { if (busyLock.enterBusy()) { try { return proc.submit(jobId, jobInfo); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to submit job (grid is stopping)."); }
/** * Remove callback. */ public void blockOnRemove() { delegate.removed(true); busyLock.block(); }
/** * Leaves busy state. */ private void leaveBusy() { busyLock.leaveBusy(); }