Skip to content
This repository has been archived by the owner on Nov 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1354 from trevorackerman/gh-1316
Browse files Browse the repository at this point in the history
Traffic Monitor always clears list of updaters after fetching all stats
  • Loading branch information
elsloo committed Apr 27, 2016
2 parents 1c75485 + 8ef5e88 commit 8454aa0
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public class CacheWatcher {
private static final CacheDataModel totalMem = new CacheDataModel("Total Memory (MB)");
private static final CacheDataModel maxMemory = new CacheDataModel("Max Memory (MB)");
final MonitorConfig config = ConfigHandler.getInstance().getConfig();
private final Map<String, CacheStateUpdater> cacheUpdaterMap = new HashMap<String, CacheStateUpdater>();

private final List<CacheStateUpdater> cacheStateUpdaters = new ArrayList<CacheStateUpdater>();
boolean isActive = true;

private FetchService mainThread;
Expand Down Expand Up @@ -120,14 +119,11 @@ private List<CacheState> checkCaches(final RouterConfig crConfig, final AtomicIn
state.putDataPoint("_queryUrl_", cache.getStatisticsUrl());
state.setHistoryTime(cache.getHistoryTime());

if (!cacheUpdaterMap.containsKey(cache.getStatisticsUrl())) {
cacheUpdaterMap.put(cache.getStatisticsUrl(), new CacheStateUpdater(state, errorCount));
}

final long requestTimeout = System.currentTimeMillis() + myHealthDeterminer.getConnectionTimeout(cache, 2000);

final CacheStateUpdater updater = cacheUpdaterMap.get(cache.getStatisticsUrl()).update(myHealthDeterminer,failCount, requestTimeout);
cacheStatisticsClient.fetchCacheStatistics(cache, updater);
final CacheStateUpdater cacheStateUpdater = new CacheStateUpdater(state, errorCount).update(myHealthDeterminer, failCount, requestTimeout);
cacheStateUpdaters.add(cacheStateUpdater);
cacheStatisticsClient.fetchCacheStatistics(cache, cacheStateUpdater);

cacheTimePad();
}
Expand Down Expand Up @@ -179,11 +175,12 @@ public void run() {
while (waitForFinish) {
waitForFinish = false;

for (CacheStateUpdater updater : cacheUpdaterMap.values()) {
for (CacheStateUpdater updater : cacheStateUpdaters) {
waitForFinish |= !updater.completeFetchStatistics(cancelCount);
}
}

cacheStateUpdaters.clear();
cacheStateRegistry.removeAllBut(states);
final long completedTime = System.currentTimeMillis();

Expand Down

0 comments on commit 8454aa0

Please sign in to comment.