@Override public Map<StashTimeKey, StashRunTimeInfo> getAllStashTimes() { try { return _localCompactionControl.getAllStashTimes(); } catch (Exception e) { _log.error("Failed to get all stash timestamps info", e); throw Throwables.propagate(e); } }
private void updateMetrics(long currentTimeInMillis) { Map<StashTimeKey, StashRunTimeInfo> stashTimeInfoMap = _compactionControlSource.getAllStashTimes(); if (stashTimeInfoMap.size() > 0) { long oldestCompactionControlTime = stashTimeInfoMap.values().stream() .map(StashRunTimeInfo::getTimestamp) .min(Ordering.natural()) .orElse(currentTimeInMillis); _lag = currentTimeInMillis - oldestCompactionControlTime; } else { _lag = 0L; } }
@GET @Path ("/stash-time") @RequiresPermissions ("system|comp_control") public Map<StashTimeKey, StashRunTimeInfo> getStashTimesForPlacement(@QueryParam ("placement") String placement) { return Strings.isNullOrEmpty(placement) ? _compactionControlSource.getAllStashTimes() : _compactionControlSource.getStashTimesForPlacement(placement); } }
@VisibleForTesting void deleteExpiredStashTimes(long currentTimeInMillis) { try { _log.debug("Checking for expired stash times at {}", currentTimeInMillis); Map<StashTimeKey, StashRunTimeInfo> expiredStashTimes = _compactionControlSource.getAllStashTimes().entrySet().stream() .filter(entry -> entry.getValue().getExpiredTimestamp() < currentTimeInMillis).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); for (Map.Entry<StashTimeKey, StashRunTimeInfo> expiredStashTimeInfo : expiredStashTimes.entrySet()) { // If we are deleting the entries here, then there could be a problem which we may want to know. So setting it as a warn. _log.warn("Deleting the stash time entry for id: {} and datacenter: {}", expiredStashTimeInfo.getKey().getId(), expiredStashTimeInfo.getKey().getDatacenter()); _compactionControlSource.deleteStashTime(expiredStashTimeInfo.getKey().getId(), expiredStashTimeInfo.getValue().getDataCenter()); } } catch (Exception e) { _log.error("Unexpected exception deleting the expired stash times", e); } } }