public void close ( ) { LOG . info ( "Begin to shutdown NettyServer" ) ; if ( allChannels != null ) { new Thread ( new Runnable ( ) { @ Override public void run ( ) { try { // await(5, TimeUnit.SECONDS) // sometimes allChannels.close() will block the exit thread allChannels . close ( ) . await ( 1 , TimeUnit . SECONDS ) ; LOG . info ( "Successfully close all channel" ) ; factory . releaseExternalResources ( ) ; } catch ( Exception ignored ) { } allChannels = null ; } } ) . start ( ) ; JStormUtils . sleepMs ( 1000 ) ; } LOG . info ( "Successfully shutdown NettyServer" ) ; }
close all channels and release resources