@ Override public void storeNotification ( NamespaceNotification notification ) { int notificationsCount = 0 ; historyLock . writeLock ( ) . lock ( ) ; try { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Storing into history: " + NotifierUtils . asString ( notification ) ) ; } String [ ] paths = DFSUtil . split ( notification . path , Path . SEPARATOR_CHAR ) ; long timestamp = System . currentTimeMillis ( ) ; HistoryTreeEntry entry = new HistoryTreeEntry ( timestamp , notification . txId , notification . type ) ; // Store the notification HistoryNode node = historyTree ; for ( String path : paths ) { if ( path . trim ( ) . length ( ) == 0 ) { continue ; } node = node . addOrGetChild ( path ) ; } if ( node . notifications == null ) { node . notifications = new HashMap < Byte , List < HistoryTreeEntry > > ( ) ; } if ( ! node . notifications . containsKey ( notification . type ) ) { node . notifications . put ( notification . type , new LinkedList < HistoryTreeEntry > ( ) ) ; } entry . node = node ; node . notifications . get ( notification . type ) . add ( entry ) ; orderedHistoryList . add ( entry ) ; notificationsCount = orderedHistoryList . size ( ) ; } finally { historyLock . writeLock ( ) . unlock ( ) ; } core . getMetrics ( ) . historySize . set ( notificationsCount ) ; core . getMetrics ( ) . historyQueues . set ( historyQueuesCount ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Notification stored." ) ; } }
Called when we should store a notification in the our history . The timestamp used to store it is generated when this method is called .