@SuppressWarnings("unchecked") public Set<StatisticEntry> getStatisticEntries(StatisticType statisticType) { Statistic statistic = statisticsMap.get(statisticType); return statistic != null ? statistic.getEntries() : Collections.EMPTY_SET; }
public long getStatisticValue(StatisticType statisticType, Object entryKey) { Statistic statistic = statisticsMap.get(statisticType); return statistic != null ? statistic.getStatisticValue(entryKey) : 0; }
protected Statistic increment(StatisticType statisticType, Object statisticEntryKey, long value) { // If statistics are not enabled, just return and do nothing. if (!isStatisticsEnabled()) { return null; } if (statisticType == null) { throw new IllegalArgumentException("statistic type must be specified"); } // Get Statistic object for the specified type. If it doesn't already exist, create it Statistic statistic = statisticsMap.get(statisticType); if (statistic == null) { Statistic newStatistic = new Statistic(statisticType); statistic = statisticsMap.putIfAbsent(statisticType, newStatistic); if (statistic == null) { statistic = newStatistic; } } // increment the statistic statistic.increment(statisticEntryKey, value); return statistic; }
File file = new File("file.txt"); FileReader reader = new FileReader(file); BufferedReader r = new BufferedReader(reader); List<Statistic> statistics = new ArrayList<Statistic>(); String line; while ((line = r.readLine()) != null) { statistics.add(new Statistic(line.split(","))); } int column = 0; Collections.sort(statistics, getComparator(column)); for (Statistic statistic : statistics) System.out.println(statistic);
protected Statistic increment(StatisticType statisticType, Object statisticEntryKey, long value) { // If statistics are not enabled, just return and do nothing. if (!isStatisticsEnabled()) { return null; } if (statisticType == null) { throw new IllegalArgumentException("statistic type must be specified"); } // Get Statistic object for the specified type. If it doesn't already // exist, create it Statistic statistic = statisticsMap.get(statisticType); if (statistic == null) { Statistic newStatistic = new Statistic(statisticType); statistic = statisticsMap.putIfAbsent(statisticType, newStatistic); if (statistic == null) { statistic = newStatistic; } } // increment the statistic statistic.increment(statisticEntryKey, value); return statistic; }
public void run() { Statistic stat = new Statistic(); for(int i = 0; i < REQUESTS; i++) {
@SuppressWarnings("unchecked") public Set<StatisticEntry> getStatisticEntries(StatisticType statisticType) { Statistic statistic = statisticsMap.get(statisticType); return statistic != null ? statistic.getEntries() : Collections.EMPTY_SET; }
public long getStatisticValue(StatisticType statisticType, Object entryKey) { Statistic statistic = statisticsMap.get(statisticType); return statistic != null ? statistic.getStatisticValue(entryKey) : 0; }