@Override public void apply(Throwable t) { if (grid != null) grid.context().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t)); } },
/** {@inheritDoc} */ @Override public byte state(long crdVer, long cntr) { assert txLog != null && mvccEnabled; try { return txLog.get(crdVer, cntr); } catch (IgniteCheckedException e) { ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } return TxState.NA; }
/** * Invoke failure handler and rethrow passed exception, possibly wrapped into the unchecked one. */ private RuntimeException criticalError(Throwable e) { ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); if (e instanceof Error) throw (Error) e; throw U.convertException((IgniteCheckedException)e); }
@Override public void apply(Throwable t) { if (grid != null) grid.context().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t)); } },
/** {@inheritDoc} */ @Override public void uncaughtException(Thread t, Throwable e) { if (X.hasCause(e, OutOfMemoryError.class)) ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } }
/** {@inheritDoc} */ @Override public void finishRecover() throws IgniteCheckedException { try { for (CacheStoreHolder holder : idxCacheStores.values()) { holder.idxStore.finishRecover(); for (PageStore partStore : holder.partStores) partStore.finishRecover(); } } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
@Override public void uncaughtException(Thread t, Throwable e) { if (grid != null && X.hasCause(e, OutOfMemoryError.class)) grid.context().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } };
/** {@inheritDoc} */ @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { while (!isCancelled()) { try { body0(); } catch (InterruptedException e) { if (!isCancelled) ctx.failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, e)); throw e; } catch (Throwable t) { U.error(log, "Exception in discovery notyfier worker thread.", t); FailureType type = t instanceof OutOfMemoryError ? CRITICAL_ERROR : SYSTEM_WORKER_TERMINATION; ctx.failure().process(new FailureContext(type, t)); throw t; } } } }
/** {@inheritDoc} */ @Override public void readHeader(int grpId, int partId, ByteBuffer buf) throws IgniteCheckedException { PageStore store = getStore(grpId, partId); try { store.readHeader(buf); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
/** {@inheritDoc} */ @Override public void sync(int grpId, int partId) throws IgniteCheckedException { try { getStore(grpId, partId).sync(); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
/** {@inheritDoc} */ @Override public void ensure(int grpId, int partId) throws IgniteCheckedException { try { getStore(grpId, partId).ensure(); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
/** * Invokes critical failure processing. Always throws. * * @throws CheckpointReadLockTimeoutException If node was not invalidated as result of handling. * @throws IgniteException If node was invalidated as result of handling. */ private void failCheckpointReadLock() throws CheckpointReadLockTimeoutException, IgniteException { String msg = "Checkpoint read lock acquisition has been timed out."; IgniteException e = new IgniteException(msg); if (cctx.kernalContext().failure().process(new FailureContext(SYSTEM_CRITICAL_OPERATION_TIMEOUT, e))) throw e; throw new CheckpointReadLockTimeoutException(msg); }
/** {@inheritDoc} */ @Override protected void body() throws InterruptedException { while (!isCancelled()) { try { body0(); onIdle(); } catch (InterruptedException e) { if (!isCancelled) ctx.failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, e)); throw e; } catch (Throwable t) { U.error(log, "Exception in discovery event worker thread.", t); FailureType type = t instanceof OutOfMemoryError ? CRITICAL_ERROR : SYSTEM_WORKER_TERMINATION; ctx.failure().process(new FailureContext(type, t)); throw t; } } }
/** {@inheritDoc} */ @Override public void updateState(MvccVersion ver, byte state, boolean primary) { assert txLog != null && mvccEnabled; try { txLog.put(new TxKey(ver.coordinatorVersion(), ver.counter()), state, primary); } catch (IgniteCheckedException e) { ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } }
@Override public void apply(GridWorker deadWorker, FailureType failureType) { if (grid != null) grid.context().failure().process(new FailureContext( failureType, new IgniteException(S.toString(GridWorker.class, deadWorker)))); } },
/** {@inheritDoc} */ @Override public long allocatePage(int grpId, int partId, byte flags) throws IgniteCheckedException { assert partId <= PageIdAllocator.MAX_PARTITION_ID || partId == PageIdAllocator.INDEX_PARTITION; PageStore store = getStore(grpId, partId); try { long pageIdx = store.allocatePage(); return PageIdUtils.pageId(partId, flags, (int)pageIdx); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }
/** * Checks if there was elapsed significant period of inactivity. If WAL auto-archive is enabled using * {@link #walAutoArchiveAfterInactivity} > 0 this method will activate roll over by timeout.<br> */ private void checkWalRolloverRequiredDuringInactivityPeriod() { if (walAutoArchiveAfterInactivity <= 0) return; // feature not configured, nothing to do final long lastRecMs = lastRecordLoggedMs.get(); if (lastRecMs == 0) return; //no records were logged to current segment, does not consider inactivity final long elapsedMs = U.currentTimeMillis() - lastRecMs; if (elapsedMs <= walAutoArchiveAfterInactivity) return; // not enough time elapsed since last write if (!lastRecordLoggedMs.compareAndSet(lastRecMs, 0)) return; // record write occurred concurrently final FileWriteHandle handle = currentHandle(); try { closeBufAndRollover(handle, null, RolloverType.NONE); } catch (IgniteCheckedException e) { U.error(log, "Unable to perform segment rollover: " + e.getMessage(), e); cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, e)); } }
@Override public void apply() { ((IgniteEx)ignite).context().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, null)); } });
/** * @param cacheId ID of cache initiated counter update. * @param topVer Topology version for current operation. * @return Next update index. */ public long nextUpdateCounter(int cacheId, AffinityTopologyVersion topVer, boolean primary, @Nullable Long primaryCntr) { long nextCntr = store.nextUpdateCounter(); if (grp.sharedGroup()) grp.onPartitionCounterUpdate(cacheId, id, primaryCntr != null ? primaryCntr : nextCntr, topVer, primary); // This is first update in partition, we should log partition state information for further crash recovery. if (nextCntr == 1) { if (grp.persistenceEnabled() && grp.walEnabled()) try { ctx.wal().log(new PartitionMetaStateRecord(grp.groupId(), id, state(), 0)); } catch (IgniteCheckedException e) { U.error(log, "Failed to log partition state snapshot to WAL.", e); ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } } return nextCntr; }
/** * Will preserve crc in buffer if keepCrc is true. * * @param cacheId Cache ID. * @param pageId Page ID. * @param pageBuf Page buffer. * @param keepCrc Keep CRC flag. * @throws IgniteCheckedException If failed. */ public void read(int cacheId, long pageId, ByteBuffer pageBuf, boolean keepCrc) throws IgniteCheckedException { PageStore store = getStore(cacheId, PageIdUtils.partId(pageId)); try { store.read(pageId, pageBuf, keepCrc); assert keepCrc || PageIO.getCrc(pageBuf) == 0: store.size() - store.pageOffset(pageId); cctx.kernalContext().compress().decompressPage(pageBuf, store.getPageSize()); } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } }