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

Traffic Monitor always clears list of updaters after fetching all stats #1354

Merged
merged 1 commit into from
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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