private BasicMetricHour getMetricHour(String accountName, String guiPath, long hoursSince1970) {
    // logger.info("getting Metric Hour for account: " + accountName + " guiPath: " + guiPath + "
    // ts: " + hoursSince1970);
    BasicMetricHour metricHour = null;

    Bucket mhBucket = null;
    try {
      mhBucket = riakClient.fetchBucket(accountName + ";" + hoursSince1970).execute();
      metricHour = mhBucket.fetch("" + guiPath, BasicMetricHour.class).execute();
      logger.info("finding: " + accountName + ";" + hoursSince1970 + "/" + guiPath);
      if (metricHour != null) {
        metricHourCache.put(
            metricHour.getAccountName()
                + ";"
                + metricHour.getGuiPath()
                + ";"
                + metricHour.getHoursSince1970(),
            metricHour);
      }
    } catch (RiakRetryFailedException rrfe) {
      rrfe.printStackTrace();
    }

    return metricHour;
  }
  @Override
  public void deleteLiveStatisticsOlderThan(Date date, String accountName) {
    Long fromHoursSince1970 = date.getTime() / (15000 * 240);
    Long toHoursSince1970 = new Date().getTime() / (15000 * 240);
    logger.info("hoursSince1970: " + fromHoursSince1970);
    logger.info("toSince1970: " + toHoursSince1970);

    try {

      for (int index = fromHoursSince1970.intValue();
          index <= toHoursSince1970.intValue();
          index++) {
        int keys = 0;
        Bucket hourBucket = riakClient.fetchBucket(accountName + ";" + index).execute();
        try {
          for (String key : hourBucket.keys()) {
            hourBucket.delete(key);
            keys++;
          }
        } catch (RiakException e) {
          e
              .printStackTrace(); // To change body of catch statement use File | Settings | File
                                  // Templates.
        }

        logger.info("deleted all keys(" + keys + ") in bucket: " + accountName + ";" + index);
      }

    } catch (RiakRetryFailedException rrfe) {
      rrfe.printStackTrace();
    }

    // To change body of implemented methods use File | Settings | File Templates.
  }
  @Override
  public void storeIncomingStatistics(
      String guiPath,
      String accountName,
      Long timeperiod,
      String value,
      ValueType valueType,
      UnitType unitType) {
    Double valueDouble = LiveStatisticsUtil.parseDouble(value);
    Double calculatedValue =
        LiveStatisticsUtil.calculateValueBasedOnUnitType(valueDouble, unitType);

    long hoursSince1970 = timeperiod / 240;
    int fifteenSecondPeriodsSinceStartOfHour =
        LiveStatisticsUtil.getFifteensecondTimeperiodsSinceStartOfHour(timeperiod * 15);

    Bucket myBucket = null;
    try {
      myBucket = riakClient.fetchBucket(accountName + ";" + hoursSince1970).execute();
      BasicMetricHour storedMetricHour =
          myBucket.fetch("" + guiPath, BasicMetricHour.class).execute();
      if (storedMetricHour == null) {
        storedMetricHour =
            new BasicMetricHour(
                guiPath, accountName, hoursSince1970, valueType.toString(), unitType.toString());
      }

      Double prevValue = storedMetricHour.getMetrics()[fifteenSecondPeriodsSinceStartOfHour];
      if (prevValue == null) {
        storedMetricHour.getMetrics()[fifteenSecondPeriodsSinceStartOfHour] = calculatedValue;
      } else {
        storedMetricHour.getMetrics()[fifteenSecondPeriodsSinceStartOfHour] =
            LiveStatisticsUtil.calculateValueBasedOnValueType(
                prevValue, calculatedValue, valueType);
      }

      myBucket.store("" + guiPath, storedMetricHour).execute();
    } catch (RiakRetryFailedException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }