@ Override public void stop ( ) { threadPoolExecutor . shutdown ( ) ; BlockingQueue < Runnable > taskQueue = threadPoolExecutor . getQueue ( ) ; int bufferSizeBeforeShutdown = threadPoolExecutor . getQueue ( ) . size ( ) ; boolean gracefulShutdown = true ; try { gracefulShutdown = threadPoolExecutor . awaitTermination ( shutdownTimeout , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { // we are anyways cleaning up } finally { int bufferSizeAfterShutdown = taskQueue . size ( ) ; if ( ! gracefulShutdown || bufferSizeAfterShutdown > 0 ) { String errorMsg = "Kinesis Log4J Appender (" + name + ") waited for " + shutdownTimeout + " seconds before terminating but could send only " + ( bufferSizeAfterShutdown - bufferSizeBeforeShutdown ) + " logevents, it failed to send " + bufferSizeAfterShutdown + " pending log events from it's processing queue" ; addError ( errorMsg ) ; } } client . shutdown ( ) ; }
Closes this appender instance . Before exiting the implementation tries to flush out buffered log events within configured shutdownTimeout seconds . If that doesn t finish within configured shutdownTimeout it would drop all the buffered log events .