/** * Removes timeout handler. * * @return {@code True} if handler was removed. */ private boolean removeTimeoutHandler() { assert trackTimeout; return cctx.time().removeTimeoutObject(this); }
/** * Schedules next full partitions update. */ public void scheduleResendPartitions() { ResendTimeoutObject timeout = pendingResend.get(); if (timeout == null || timeout.started()) { ResendTimeoutObject update = new ResendTimeoutObject(); if (pendingResend.compareAndSet(timeout, update)) cctx.time().addTimeoutObject(update); } }
/** {@inheritDoc} */ @Override public long timeout(long timeout) { long old = super.timeout(timeout); if (old == timeout) return old; if (trackTimeout) { if (!cctx.time().removeTimeoutObject(this)) return old; // Do nothing, because transaction is started to roll back. } if (timeout() > 0) // Method can be called only for explicit transactions. trackTimeout = cctx.time().addTimeoutObject(this); return old; }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable TxDeadlock res, @Nullable Throwable err) { if (super.onDone(res, err)) { cctx.tm().removeFuture(futId); if (timeoutObj != null) cctx.time().removeTimeoutObject(timeoutObj); return true; } return false; }
/** * @param cctx Context. * @param txId Tx ID. * @param topVer Transaction topology version. * @param keys Keys. */ private TxDeadlockFuture(GridCacheSharedContext cctx, GridCacheVersion txId, AffinityTopologyVersion topVer, Set<IgniteTxKey> keys) { this.cctx = cctx; this.txId = txId; this.topVer = topVer; this.keys = keys; if (DEADLOCK_TIMEOUT > 0) { timeoutObj = new DeadlockTimeoutObject(); cctx.time().addTimeoutObject(timeoutObj); } }
/** * Schedules next check of inactivity period expired. Based on current record update timestamp. At timeout method * does check of inactivity period and schedules new launch. */ private void scheduleNextInactivityPeriodElapsedCheck() { final long lastRecMs = lastRecordLoggedMs.get(); final long nextPossibleAutoArchive = (lastRecMs <= 0 ? U.currentTimeMillis() : lastRecMs) + walAutoArchiveAfterInactivity; if (log.isDebugEnabled()) log.debug("Schedule WAL rollover check at " + new Time(nextPossibleAutoArchive).toString()); nextAutoArchiveTimeoutObj = new GridTimeoutObject() { private final IgniteUuid id = IgniteUuid.randomUuid(); @Override public IgniteUuid timeoutId() { return id; } @Override public long endTime() { return nextPossibleAutoArchive; } @Override public void onTimeout() { if (log.isDebugEnabled()) log.debug("Checking if WAL rollover required (" + new Time(U.currentTimeMillis()).toString() + ")"); checkWalRolloverRequiredDuringInactivityPeriod(); scheduleNextInactivityPeriodElapsedCheck(); } }; cctx.time().addTimeoutObject(nextAutoArchiveTimeoutObj); }
@Override public void onEvent(DiscoveryEvent evt, DiscoCache discoCache) { assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT; UUID nodeId = evt.eventNode().id(); // Wait some time in case there are some unprocessed messages from failed node. cctx.time().addTimeoutObject( new NodeFailureTimeoutObject(evt.eventNode(), cctx.coordinators().currentCoordinator())); if (txFinishSync != null) txFinishSync.onNodeLeft(nodeId); for (TxDeadlockFuture fut : deadlockDetectFuts.values()) fut.onNodeLeft(nodeId); for (Map.Entry<GridCacheVersion, Object> entry : completedVersHashMap.entrySet()) { Object obj = entry.getValue(); if (obj instanceof GridCacheReturnCompletableWrapper && nodeId.equals(((GridCacheReturnCompletableWrapper)obj).nodeId())) removeTxReturn(entry.getKey()); } } },
/** * Method is called twice on deactivate and stop. * It shutdown workers but do not deallocate them to avoid duplication. * */ @Override protected void stop0(boolean cancel) { final GridTimeoutProcessor.CancelableTask schedule = backgroundFlushSchedule; if (schedule != null) schedule.close(); final GridTimeoutObject timeoutObj = nextAutoArchiveTimeoutObj; if (timeoutObj != null) cctx.time().removeTimeoutObject(timeoutObj); try { fileHandleManager.onDeactivate(); segmentAware.interrupt(); if (archiver != null) archiver.shutdown(); if (compressor != null) compressor.shutdown(); if (decompressor != null) decompressor.shutdown(); } catch (Exception e) { U.error(log, "Failed to gracefully close WAL segment: " + this.currHnd, e); } }
/** * Completeness callback. * * @param res Response. * @return {@code True} if {@code done} flag was changed as a result of this call. */ private boolean onComplete(@Nullable GridNearTxPrepareResponse res) { if (!tx.onePhaseCommit() && ((last || tx.isSystemInvalidate()) && !(tx.near() && tx.local()))) tx.state(PREPARED); if (super.onDone(res, res == null ? err : null)) { // Don't forget to clean up. cctx.mvcc().removeVersionedFuture(this); if (timeoutObj != null) cctx.time().removeTimeoutObject(timeoutObj); return true; } return false; }
if (!cctx.time().removeTimeoutObject(timeoutObj)) return true; // Should not proceed with prepare if tx is already timed out.
ctx.time().removeTimeoutObject(obj);
cctx.time().waitAsync(topFut, tx.remainingTime(), (e, timedOut) -> { if (errorOrTimeoutOnTopologyVersion(e, timedOut)) return;
deferredAckMsgSnd = new GridDeferredAckMessageSender<GridCacheVersion>(cctx.time(), cctx.kernalContext().closure()) { @Override public int getTimeout() { return DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT;
parent.cctx.exchange().affinityReadyFuture(res.clientRemapVersion()); parent.cctx.time().waitAsync(affFut, parent.tx.remainingTime(), (e, timedOut) -> { if (parent.errorOrTimeoutOnTopologyVersion(e, timedOut)) return;
ctx.time().waitAsync(topFut, req.timeout(), (e, timedOut) -> { if (e != null || timedOut) { sendResponseOnTimeoutOrError(e, topFut, node, req);
parent.cctx.time().waitAsync(affFut, parent.tx.remainingTime(), new IgniteBiInClosure<IgniteCheckedException, Boolean>() { @Override public void apply(IgniteCheckedException e, Boolean timedOut) { if (parent.errorOrTimeoutOnTopologyVersion(e, timedOut))
cctx.time().removeTimeoutObject(resendTimeoutObj);
Collection set = U.field(near.context().cache().context().time(), "timeoutObjs");
backgroundFlushSchedule = cctx.time().schedule(this::doFlush, flushFreq, flushFreq);
cctx.time().addTimeoutObject(timeoutObj);