@Override public void uncaughtException(Thread t, Throwable e) { LOG.info("UncaughtExceptionHandler invoked"); if(ShutdownHookManager.isShutdownInProgress()) { LOG.warn("Thread {} threw a Throwable, but we are shutting down, so ignoring this", t, e); } else if(e instanceof Error) { try { LOG.error("Thread {} threw an Error. Shutting down now...", t, e); } catch (Throwable err) { //We don't want to not exit because of an issue with logging } if(e instanceof OutOfMemoryError) { //After catching an OOM java says it is undefined behavior, so don't //even try to clean up or we can get stuck on shutdown. try { System.err.println("Halting due to Out Of Memory Error..."); e.printStackTrace(); } catch (Throwable err) { //Again we done want to exit because of logging issues. } ExitUtil.halt(-1); } else { ExitUtil.terminate(-1); } } else { LOG.error("Thread {} threw an Exception. Shutting down now...", t, e); ExitUtil.terminate(-1); } } }
/** * Close connection */ @Override public void close() { if (isConnectionClosed.get()) { return; } isConnectionClosed.set(true); try { if (currentTransactionBatch != null) { currentTransactionBatch.close(); } } catch (StreamingException e) { LOG.warn("Unable to close current transaction batch: " + currentTransactionBatch, e); } finally { if (manageTransactions) { getMSC().close(); getHeatbeatMSC().close(); } //remove shutdown hook entry added while creating this connection via HiveStreamingConnection.Builder#connect() if (!ShutdownHookManager.isShutdownInProgress()) { ShutdownHookManager.removeShutdownHook(this.onShutdownRunner); } } if (LOG.isInfoEnabled()) { LOG.info("Closed streaming connection. Agent: {} Stats: {}", getAgentInfo(), getConnectionStats()); } }
@Override public void uncaughtException(Thread t, Throwable e) { LOG.info("UncaughtExceptionHandler invoked"); if(ShutdownHookManager.isShutdownInProgress()) { LOG.warn("Thread {} threw a Throwable, but we are shutting down, so ignoring this", t, e); } else if(e instanceof Error) { try { LOG.error("Thread {} threw an Error. Shutting down now...", t, e); } catch (Throwable err) { //We don't want to not exit because of an issue with logging } if(e instanceof OutOfMemoryError) { //After catching an OOM java says it is undefined behavior, so don't //even try to clean up or we can get stuck on shutdown. try { System.err.println("Halting due to Out Of Memory Error..."); e.printStackTrace(); } catch (Throwable err) { //Again we done want to exit because of logging issues. } ExitUtil.halt(-1); } else { ExitUtil.terminate(-1); } } else { LOG.error("Thread {} threw an Exception. Shutting down now...", t, e); ExitUtil.terminate(-1); } } }