synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }
@SuppressWarnings("rawtypes") public void testMovingWindow() throws Exception { StatisticsCollector collector = new StatisticsCollector(1); TimeWindow window = new TimeWindow("test", 6, 2); TimeWindow sincStart = StatisticsCollector.SINCE_START; TimeWindow[] windows = {sincStart, window};
public void testMovingWindow() throws Exception { StatisticsCollector collector = new StatisticsCollector(1); TimeWindow window = new TimeWindow("test", 6, 2); TimeWindow sincStart = StatisticsCollector.SINCE_START; TimeWindow[] windows = {sincStart, window};
synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }
synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }
synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }
synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }
synchronized Stat createStat(String name, TimeWindow[] windows) { if (statistics.get(name) != null) { throw new RuntimeException("Stat with name "+ name + " is already defined"); } Map<TimeWindow, TimeStat> timeStats = new LinkedHashMap<TimeWindow, TimeStat>(); for (TimeWindow window : windows) { StatUpdater collector = updaters.get(window); if (collector == null) { if(SINCE_START.equals(window)) { collector = new StatUpdater(); } else { collector = new TimeWindowStatUpdater(window, period); } updaters.put(window, collector); } TimeStat timeStat = new TimeStat(); collector.addTimeStat(name, timeStat); timeStats.put(window, timeStat); } Stat stat = new Stat(name, timeStats); statistics.put(name, stat); return stat; }