private void cleanupStaleClients ( ) { LocalTime cleanupTime = LocalTime . now ( ) ; LOG . debug ( "Starting cleanup authentication registry at {}" , cleanupTime ) ; // Get a list of stale clients under read lock. List < UUID > staleChannels = new ArrayList <> ( ) ; for ( Map . Entry < UUID , AuthenticatedChannelInfo > clientEntry : mChannels . entrySet ( ) ) { LocalTime lat = clientEntry . getValue ( ) . getLastAccessTime ( ) ; if ( lat . plusSeconds ( mCleanupIntervalMs / 1000 ) . isBefore ( cleanupTime ) ) { staleChannels . add ( clientEntry . getKey ( ) ) ; } } // Unregister stale clients. LOG . debug ( "Found {} stale channels for cleanup." , staleChannels . size ( ) ) ; for ( UUID clientId : staleChannels ) { unregisterChannel ( clientId ) ; } LOG . debug ( "Finished state channel cleanup at {}" , LocalTime . now ( ) ) ; }
Primitive that is invoked periodically for cleaning the registry from clients that has become stale .