Skip to content

Commit

Permalink
Handle not predictable vehicle timeout appropriately based on configu…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
nselikoff committed Apr 10, 2019
1 parent 3f45aec commit 1055141
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,36 @@ private void handlePredictablePossibleTimeout(VehicleState vehicleState, long no
}

/**
* For not predictable vehicle. If haven't reported in too long removes the
* vehicle from map and possibly cache
* For not predictable vehicle. If not removing vehicles from cache,
* removes the vehicle from the map to avoid looking at it again. If
* configured to remove timed out vehicles from cache, and haven't
* reported in too long, removes the vehicle from map and cache.
*
* @param mapIterator
* So can remove AVL report from map
*/
private void handleNotPredictablePossibleTimeout(VehicleState vehicleState,
long now, Iterator<AvlReport> mapIterator) {
// Log the situation
logger.info("For not predictable vehicleId={} generated timeout "
+ "event.", vehicleState.getVehicleId());
if (!removeTimedOutVehiclesFromVehicleDataCache.getValue()) {
// Remove vehicle from map for next time looking for timeouts and return
mapIterator.remove();
return;
}

// If haven't reported in too long...
long maxNoAvl = allowableNoAvlSecs.getValue() * Time.MS_PER_SEC;
if (now > vehicleState.getAvlReport().getTime() + maxNoAvl) {

// Log the situation
logger.info("For not predictable vehicleId={} generated timeout "
+ "event.", vehicleState.getVehicleId());

// Remove vehicle from map for next time looking for timeouts
mapIterator.remove();
// Remove vehicle from map for next time looking for timeouts
mapIterator.remove();

// Remove vehicle from cache if configured to do so
removeFromVehicleDataCache(vehicleState.getVehicleId());
// Remove vehicle from cache
removeFromVehicleDataCache(vehicleState.getVehicleId());
}
}

/**
Expand Down

0 comments on commit 1055141

Please sign in to comment.