generator.cc
// Get a Flow to update.
Get a Flow to update.
Get a Flow to update .
flow::Key FlowGenerator::GetFlowKeyToUpdate() {
   uint64_t currentTime = GetCurrentTimeSeconds();
   for (auto iter = persistentFlowInfo_.begin(); iter != persistentFlowInfo_.end();
         ++iter) {
      flow::Key key = iter->first;
      if (currentTime - iter->second->lastUpdateSecs >= flowTimeoutSeconds_ / 2) {
         return key;
      }
   }
   return allFlowKeys_[rand() % allFlowKeys_.size()];
}
flow :: Key FlowGenerator :: GetFlowKeyToUpdate ( ) { uint64_t currentTime = GetCurrentTimeSeconds ( ) ; for ( auto iter = persistentFlowInfo_ . begin ( ) ; iter != persistentFlowInfo_ . end ( ) ; ++ iter ) { flow :: Key key = iter -> first ; if ( currentTime - iter -> second -> lastUpdateSecs >= flowTimeoutSeconds_ / 2 ) { return key ; } } return allFlowKeys_ [ rand ( ) % allFlowKeys_ . size ( ) ] ; }
Get a Flow to update.
Get a Flow to update .
// Check if any Persistent Flow needs to be updated. // Update this flow before it times out. // Select a random Flow to update.