public final void stop ( ) { m_stopping = true ; ImmutableMap < URI , AbstractImporter > oldReference ; boolean success = false ; do { // onChange also could set m_importers. Use while loop to pick up latest ref oldReference = m_importers . get ( ) ; success = m_importers . compareAndSet ( oldReference , ImmutableMap . < URI , AbstractImporter > of ( ) ) ; } while ( ! success ) ; if ( ! m_starting . get ( ) ) return ; stopImporters ( oldReference . values ( ) ) ; if ( ! m_factory . isImporterRunEveryWhere ( ) ) { m_distributer . registerChannels ( m_distributerDesignation , Collections . < URI > emptySet ( ) ) ; m_distributer . unregisterCallback ( m_distributerDesignation ) ; } if ( m_executorService == null ) { return ; } //graceful shutdown to allow importers to properly process post shutdown tasks. m_executorService . shutdown ( ) ; try { m_executorService . awaitTermination ( 60 , TimeUnit . SECONDS ) ; m_executorService = null ; } catch ( InterruptedException ex ) { //Should never come here. s_logger . warn ( "Unexpected interrupted exception waiting for " + m_factory . getTypeName ( ) + " to shutdown" , ex ) ; } }
This is called by the importer framework to stop importers . All resources for this importer will be unregistered from the resource distributer .