@Override public void storeIncomingStatistics(List<LiveStatistics> liveStatisticsList) { for (LiveStatistics ls : liveStatisticsList) { long hoursSince1970 = ls.getTimeperiod() / 240; int fifteenSecondPeriodsSinceStartOfHour = LiveStatisticsUtil.getFifteensecondTimeperiodsSinceStartOfHour(ls.getTimeperiod() * 15); Double calculatedValue = LiveStatisticsUtil.calculateValueBasedOnUnitType( ls.getValue(), UnitType.fromValue(ls.getUnitType())); BasicMetricHour mhToStore = metricHoursToStoreHash.get( ls.getAccountName() + ";" + ls.getGuiPath() + ";" + hoursSince1970); boolean wasInStoreHash = mhToStore != null; if (mhToStore == null) { // Not in store-hash chech in metricHourCache mhToStore = metricHourCache.getIfPresent( ls.getAccountName() + ";" + ls.getGuiPath() + ";" + hoursSince1970); } if (mhToStore == null) { // Not in metricHourCache, fetch from Riak mhToStore = getMetricHour(ls.getAccountName(), ls.getGuiPath(), hoursSince1970); } if (mhToStore == null) { // Not in Riak, create mhToStore = new BasicMetricHour( ls.getGuiPath(), ls.getAccountName(), hoursSince1970, ls.getValueType(), ls.getUnitType()); } mhToStore.getMetrics()[fifteenSecondPeriodsSinceStartOfHour] = LiveStatisticsUtil.calculateValueBasedOnValueType( ls, calculatedValue, ValueType.fromValue(ls.getValueType())); if (!wasInStoreHash) { metricHoursToStoreHash.put( ls.getAccountName() + ";" + ls.getGuiPath() + ";" + hoursSince1970, mhToStore); } } persistRecentMetricHours(); }