@Override public void writeFailed(ICachedPage page, Throwable failure) { ExitUtil.halt(ExitUtil.EC_ABNORMAL_TERMINATION); }
@Override public void run() { ExitUtil.exit(terminateNCService ? EC_TERMINATE_NC_SERVICE_DIRECTIVE : EC_NORMAL_TERMINATION); }
@Override public void schedulerFailed(ILSMIOOperationScheduler scheduler, Throwable failure) { LOGGER.error("IO Scheduler has failed", failure); ExitUtil.halt(ExitUtil.EC_IO_SCHEDULER_FAILED); }
@Override public void schedulerFailed(ILSMIOOperationScheduler scheduler, Throwable failure) { ExitUtil.exit(ExitUtil.EC_IO_SCHEDULER_FAILED); } });
@Override public void operationFailed(ILSMIOOperation operation, Throwable t) { LOGGER.error("Operation {} has failed", operation, t); if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { ExitUtil.halt(ExitUtil.EC_FLUSH_FAILED); } } }
@Override public void uncaughtException(Thread t, Throwable e) { try { LOGGER.log(Level.ERROR, "Uncaught Exception from thread " + t.getName() + ". Calling shutdown hook", e); } finally { ExitUtil.exit(EC_UNHANDLED_EXCEPTION); } }
@SuppressWarnings("squid:S2142") @Override public void put(ICachedPage page, IPageWriteFailureCallback callback) throws HyracksDataException { failIfPreviousPageFailed(callback); page.setFailureCallback(callback); try { if (!poisoned.get()) { queue.put(page); } else { LOGGER.error("An attempt to write a page found buffer cache closed"); ExitUtil.halt(ExitUtil.EC_ABNORMAL_TERMINATION); } } catch (InterruptedException e) { LOGGER.error("IO Operation interrupted", e); ExitUtil.halt(ExitUtil.EC_ABNORMAL_TERMINATION); } }
public static void exit(int status, long timeBeforeHalt, TimeUnit timeBeforeHaltUnit) { shutdownHaltDelay.setValue(timeBeforeHaltUnit.toMillis(timeBeforeHalt)); exit(status); }
@SuppressWarnings("squid:S1181") private void cleanup(FileReference resourceFile) { if (resourceFile.getFile().exists()) { try { IoUtil.delete(resourceFile); } catch (Throwable th) { LOGGER.error("Error cleaning up corrupted resource {}", resourceFile, th); ExitUtil.halt(ExitUtil.EC_FAILED_TO_DELETE_CORRUPTED_RESOURCES); } } }
@Override public void startGlobalRecovery(ICcApplicationContext appCtx) { if (!recoveryCompleted && !recovering) { synchronized (this) { if (!recovering) { recovering = true; /** * Perform recovery on a different thread to avoid deadlocks in * {@link org.apache.asterix.common.cluster.IClusterStateManager} */ serviceCtx.getControllerService().getExecutor().submit(() -> { try { recover(appCtx); } catch (HyracksDataException e) { LOGGER.log(Level.ERROR, "Global recovery failed. Shutting down...", e); ExitUtil.exit(ExitUtil.EC_FAILED_TO_RECOVER); } }); } } } }
if (reqId == currentReqId) { if (TimeUnit.NANOSECONDS.toMinutes(System.nanoTime() - currentTime) > 0) { ExitUtil.halt(ExitUtil.EC_FAILED_TO_PROCESS_UN_INTERRUPTIBLE_REQUEST);
ExitUtil.exit(cleanShutdown ? EC_NORMAL_TERMINATION : EC_ABNORMAL_TERMINATION); } catch (Exception e) { callback.setException(e);
@Override public void run() { try { LOGGER.info("Ensuring all tasks of CC {} have completed", ccId); final Span maxWaitTime = Span.start(2, TimeUnit.MINUTES); while (!maxWaitTime.elapsed()) { removeCompleted(); if (runningTasks.isEmpty()) { break; } LOGGER.info("{} tasks are still running", runningTasks.size()); TimeUnit.SECONDS.sleep(1); // Check once a second } if (runningTasks.isEmpty()) { LOGGER.info("All tasks of CC {} have completed", ccId); ncs.notifyTasksCompleted(ccId); } else { LOGGER.error("{} tasks associated with CC {} failed to complete after {}ms. Giving up", runningTasks.size(), ccId, TIMEOUT); logPendingTasks(); ExitUtil.halt(ExitUtil.EC_NC_FAILED_TO_ABORT_ALL_PREVIOUS_TASKS); } } catch (Throwable th) { LOGGER.error("Failed to abort all previous tasks associated with CC {}", ccId, th); ExitUtil.halt(ExitUtil.EC_NC_FAILED_TO_ABORT_ALL_PREVIOUS_TASKS); } }
if (!success) { ExitUtil.exit(ExitUtil.EC_FAILED_TO_STARTUP);
@Override public void run() { startSemaphore.acquireUninterruptibly(); LOGGER.info("starting shutdown watchdog- system will halt if shutdown is not completed within {} seconds", TimeUnit.MILLISECONDS.toSeconds(shutdownHaltDelay.getValue())); try { exitThread.join(shutdownHaltDelay.getValue()); if (exitThread.isAlive()) { try { LOGGER.fatal("shutdown did not complete within configured delay; halting"); } finally { ExitUtil.halt(EC_HALT_SHUTDOWN_TIMED_OUT); } } } catch (Throwable th) { // NOSONAR must catch them all ExitUtil.halt(EC_HALT_WATCHDOG_FAILED); } }
@SuppressWarnings("squid:S1181") // System must halt on all IO errors @Override public void write(ICachedPage page, BufferCache bufferCache) { CachedPage cPage = (CachedPage) page; try { bufferCache.write(cPage); } catch (Exception e) { page.writeFailed(e); LOGGER.warn("Failed to write page {}", cPage, e); } catch (Throwable th) { // Halt LOGGER.error("FIFOLocalWriter has encountered a fatal error", th); ExitUtil.halt(ExitUtil.EC_ABNORMAL_TERMINATION); } finally { bufferCache.returnPage(cPage); if (DEBUG) { LOGGER.error("[FIFO] Return page: {}, {}", cPage.cpid, cPage.dpid); } } }
@SuppressWarnings("squid:S1181") @Override public void commitTransaction(TxnId txnId) throws RemoteException { try { transactionSubsystem.getTransactionManager().commitTransaction(txnId); } catch (Throwable th) { // Metadata node should abort all Metadata transactions on re-start LOGGER.fatal("Failure committing a metadata transaction", th); ExitUtil.halt(ExitUtil.EC_FAILED_TO_COMMIT_METADATA_TXN); } }
@SuppressWarnings("squid:S1181") // Catch Error private void stopRuntime(ActiveManagerMessage message) { StopRuntimeParameters content = (StopRuntimeParameters) message.getPayload(); ActiveRuntimeId runtimeId = content.getRuntimeId(); IActiveRuntime runtime = runtimes.get(runtimeId); if (runtime == null) { LOGGER.warn("Request to stop runtime: " + runtimeId + " that is not registered. Could be that the runtime completed execution on" + " this node before the cluster controller sent the stop request"); } else { executor.execute(() -> { try { stopIfRunning(runtime, content.getTimeout(), content.getUnit()); } catch (Throwable th) { LOGGER.warn("Failed to stop runtime: {}", runtimeId, th); ExitUtil.halt(ExitUtil.EC_UNCAUGHT_THROWABLE); } }); } }
@SuppressWarnings("squid:S1181") @Override public void abortTransaction(MetadataTransactionContext ctx) { try { metadataNode.abortTransaction(ctx.getTxnId()); } catch (Throwable th) { // Metadata node should abort all transactions on re-joining the new CC LOGGER.fatal("Failure aborting a metadata transaction", th); ExitUtil.halt(ExitUtil.EC_FAILED_TO_ABORT_METADATA_TXN); } }
@SuppressWarnings("squid:S1181") @Override public void abortTransaction(TxnId txnId) throws RemoteException { try { transactionSubsystem.getTransactionManager().abortTransaction(txnId); } catch (Throwable th) { // Metadata node should abort all uncommitted transactions on re-start LOGGER.fatal("Failure committing a metadata transaction", th); ExitUtil.halt(ExitUtil.EC_FAILED_TO_ABORT_METADATA_TXN); } }