/** * Adds shutdown hook with default priority (10) * @param shutdownHook - shutdown hook */ public static void addShutdownHook(Runnable shutdownHook) { addShutdownHook(shutdownHook, FileSystem.SHUTDOWN_HOOK_PRIORITY); }
DbTxnManager() { shutdownRunner = new Runnable() { @Override public void run() { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { LOG.info("Shutting down Heartbeater thread pool."); heartbeatExecutorService.shutdown(); } } }; ShutdownHookManager.addShutdownHook(shutdownRunner, SHUTDOWN_HOOK_PRIORITY); }
private void createShutdownHook() { // Add a shutdown hook for cleanup, if there are elements remaining in the cache which were not cleaned up. // This is the best effort approach. Ignore any error while doing so. Notice that most of the clients // would get cleaned up via either the removalListener or the close() call, only the active clients // that are in the cache or expired but being used in other threads wont get cleaned. The following code will only // clean the active cache ones. The ones expired from cache but being hold by other threads are in the mercy // of finalize() being called. Thread cleanupHiveClientShutdownThread = new Thread() { @Override public void run() { LOG.debug("Cleaning up hive client cache in ShutDown hook"); cleanupHandle.cancel(false); // Cancel the maintenance thread. closeAllClientsQuietly(); } }; ShutdownHookManager.addShutdownHook(cleanupHiveClientShutdownThread); }
private void createShutdownHook() { // Add a shutdown hook for cleanup, if there are elements remaining in the cache which were not cleaned up. // This is the best effort approach. Ignore any error while doing so. Notice that most of the clients // would get cleaned up via either the removalListener or the close() call, only the active clients // that are in the cache or expired but being used in other threads wont get cleaned. The following code will only // clean the active cache ones. The ones expired from cache but being hold by other threads are in the mercy // of finalize() being called. Thread cleanupHiveClientShutdownThread = new Thread() { @Override public void run() { LOG.debug("Cleaning up hive client cache in ShutDown hook"); cleanupHandle.cancel(false); // Cancel the maintenance thread. closeAllClientsQuietly(); } }; ShutdownHookManager.addShutdownHook(cleanupHiveClientShutdownThread); }
DbTxnManager() { shutdownRunner = new Runnable() { @Override public void run() { if (heartbeatExecutorService != null && !heartbeatExecutorService.isShutdown() && !heartbeatExecutorService.isTerminated()) { LOG.info("Shutting down Heartbeater thread pool."); heartbeatExecutorService.shutdown(); } } }; ShutdownHookManager.addShutdownHook(shutdownRunner, SHUTDOWN_HOOK_PRIORITY); }
private void addBeelineShutdownHook() throws IOException { // add shutdown hook to flush the history to history file and it also close all open connections ShutdownHookManager.addShutdownHook(getShutdownHook()); }
static EventLogger getInstance(HiveConf conf) { if (instance == null) { synchronized (EventLogger.class) { if (instance == null) { instance = new EventLogger(conf, SystemClock.getInstance()); ShutdownHookManager.addShutdownHook(instance::shutdown); } } } return instance; } }
ShutdownHookManager.addShutdownHook(new Runnable() { @Override public void run() {
timelineClient.start(); ShutdownHookManager.addShutdownHook(new Runnable() { @Override public void run() {
ShutdownHookManager.addShutdownHook( new Runnable() { @Override
timelineClient.start(); ShutdownHookManager.addShutdownHook(new Runnable() { @Override public void run() {
ShutdownHookManager.addShutdownHook(streamingConnection.onShutdownRunner, FileSystem.SHUTDOWN_HOOK_PRIORITY + 1); Thread.setDefaultUncaughtExceptionHandler((t, e) -> streamingConnection.close()); return streamingConnection;
ShutdownHookManager.addShutdownHook(new CompositeServiceShutdownHook(llapDaemon), 1);
ShutdownHookManager.addShutdownHook(() -> hiveServer2.stop());
ShutdownHookManager.addShutdownHook(shutdownRunner, SHUTDOWN_HOOK_PRIORITY);
ShutdownHookManager.addShutdownHook(shutdownRunner, SHUTDOWN_HOOK_PRIORITY);
/** * Adds shutdown hook with default priority (10) * @param shutdownHook - shutdown hook */ public static void addShutdownHook(Runnable shutdownHook) { addShutdownHook(shutdownHook, FileSystem.SHUTDOWN_HOOK_PRIORITY); }
private void createShutdownHook() { // Add a shutdown hook for cleanup, if there are elements remaining in the cache which were not cleaned up. // This is the best effort approach. Ignore any error while doing so. Notice that most of the clients // would get cleaned up via either the removalListener or the close() call, only the active clients // that are in the cache or expired but being used in other threads wont get cleaned. The following code will only // clean the active cache ones. The ones expired from cache but being hold by other threads are in the mercy // of finalize() being called. Thread cleanupHiveClientShutdownThread = new Thread() { @Override public void run() { LOG.debug("Cleaning up hive client cache in ShutDown hook"); cleanupHandle.cancel(false); // Cancel the maintenance thread. closeAllClientsQuietly(); } }; ShutdownHookManager.addShutdownHook(cleanupHiveClientShutdownThread); }
private void addBeelineShutdownHook() throws IOException { // add shutdown hook to flush the history to history file and it also close all open connections ShutdownHookManager.addShutdownHook(getShutdownHook()); }
/** * Returning a streaming connection to hive. * * @return - hive streaming connection */ public HiveStreamingConnection connect() throws StreamingException { if (database == null) { throw new StreamingException("Database cannot be null for streaming connection"); } if (table == null) { throw new StreamingException("Table cannot be null for streaming connection"); } if (recordWriter == null) { throw new StreamingException("Record writer cannot be null for streaming connection"); } HiveStreamingConnection streamingConnection = new HiveStreamingConnection(this); // assigning higher priority than FileSystem shutdown hook so that streaming connection gets closed first before // filesystem close (to avoid ClosedChannelException) ShutdownHookManager.addShutdownHook(streamingConnection::close, FileSystem.SHUTDOWN_HOOK_PRIORITY + 1); Thread.setDefaultUncaughtExceptionHandler((t, e) -> streamingConnection.close()); return streamingConnection; } }