@Override public void writeFailed(ICachedPage page, Throwable failure) { ExitUtil.halt(ExitUtil.EC_ABNORMAL_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 operationFailed(ILSMIOOperation operation, Throwable t) { LOGGER.error("Operation {} has failed", operation, t); if (operation.getIOOpertionType() == LSMIOOperationType.FLUSH) { ExitUtil.halt(ExitUtil.EC_FLUSH_FAILED); } } }
@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); } }
@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); } } }
if (reqId == currentReqId) { if (TimeUnit.NANOSECONDS.toMinutes(System.nanoTime() - currentTime) > 0) { ExitUtil.halt(ExitUtil.EC_FAILED_TO_PROCESS_UN_INTERRUPTIBLE_REQUEST);
@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); } }
@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") @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); } }
@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); } }); } }
public synchronized CcId registerNode(NodeRegistration nodeRegistration, int registrationId) throws Exception { registrationPending = true; ccs.registerNode(nodeRegistration, registrationId); try { InvokeUtil.runWithTimeout(() -> { this.wait(REGISTRATION_RESPONSE_POLL_PERIOD); // NOSONAR while loop in timeout call }, () -> !registrationPending, 1, TimeUnit.MINUTES); } catch (Exception e) { registrationException = e; } if (registrationException != null) { LOGGER.fatal("Registering with {} failed with exception", this, registrationException); ExitUtil.halt(ExitUtil.EC_NODE_REGISTRATION_FAILURE); } return getCcId(); }
@Override public Boolean call() { started.release(); boolean interrupted = false; try { while (true) { flushPage = null; interrupted = InvokeUtil.doUninterruptiblyGet(() -> flushPage = flushQ.take()) || interrupted; if (flushPage == POISON_PILL) { return true; } flushPage.flush(stopping); // TODO(mblow): recycle large pages emptyQ.add(flushPage.getLogPageSize() == logMgr.getLogPageSize() ? flushPage : stashQ.remove()); } } catch (Exception e) { LOGGER.log(Level.ERROR, "LogFlusher is terminating abnormally. System is in unusable state; halting", e); ExitUtil.halt(ExitUtil.EC_TXN_LOG_FLUSHER_FAILURE); throw new AssertionError("not reachable"); } finally { if (interrupted) { Thread.currentThread().interrupt(); } } } }
private void cancelJob(Throwable th) { cancelJobSafely(metadataProvider, th); final WaitForStateSubscriber cancelSubscriber = new WaitForStateSubscriber(this, EnumSet.of(ActivityState.STOPPED)); final Span span = Span.start(2, TimeUnit.MINUTES); InvokeUtil.doUninterruptibly(() -> { if (!cancelSubscriber.sync(span)) { ExitUtil.halt(ExitUtil.EC_FAILED_TO_CANCEL_ACTIVE_START_STOP); } }); }
@SuppressWarnings("squid:S1181") @Override public void commitTransaction(MetadataTransactionContext ctx) { try { metadataNode.commitTransaction(ctx.getTxnId()); cache.commit(ctx); } catch (Throwable th) { // Metadata node should abort all transactions on re-joining the new CC LOGGER.fatal("Failure committing a metadata transaction", th); ExitUtil.halt(ExitUtil.EC_FAILED_TO_COMMIT_METADATA_TXN); } }
} catch (InterruptedException e) { LOGGER.error("BufferCache Write Queue was interrupted", e); ExitUtil.halt(ExitUtil.EC_ABNORMAL_TERMINATION); return; // Keep compiler happy
public void resumeOrHalt(IActiveEntityEventsListener listener, MetadataProvider metadataProvider) { try { if (LOGGER.isEnabled(level)) { LOGGER.log(level, "Resuming " + listener.getEntityId()); } ((ActiveEntityEventsListener) listener).resume(metadataProvider); if (LOGGER.isEnabled(level)) { LOGGER.log(level, listener.getEntityId() + " resumed"); } } catch (Throwable th) { // NOSONAR must halt in case of any failure LOGGER.error("Resume active failed", th); ExitUtil.halt(ExitUtil.EC_ACTIVE_RESUME_FAILURE); } } }
ExitUtil.halt(ExitUtil.EC_NETWORK_FAILURE);