public void recordMetric(long time, String command,
      String user, long delta) {
    RollingWindow window = getRollingWindow(command, user);
    window.incAt(time, delta);
  }
@Test
  public void testTotal() throws Exception {
    Configuration config = new Configuration();
    config.setInt(DFSConfigKeys.NNTOP_BUCKETS_PER_WINDOW_KEY, 1);
    config.setInt(DFSConfigKeys.NNTOP_NUM_USERS_KEY, N_TOP_USERS);
    int period = 10;
    RollingWindowManager rollingWindowManager =
        new RollingWindowManager(config, period);

    long t = 0;
    rollingWindowManager.recordMetric(t, "op1", users[0], 3);
    checkValues(rollingWindowManager, t, "op1", 3, 3);

    // both should have a value.
    t = (long)(period * .5);
    rollingWindowManager.recordMetric(t, "op2", users[0], 4);
    checkValues(rollingWindowManager, t, "op1", 3, 7);
    checkValues(rollingWindowManager, t, "op2", 4, 7);

    // neither should reset.
    t = period - 1;
    checkValues(rollingWindowManager, t, "op1", 3, 7);
    checkValues(rollingWindowManager, t, "op2", 4, 7);

    // op1 should reset in its next period, but not op2.
    t = period;
    rollingWindowManager.recordMetric(10, "op1", users[0], 10);
    checkValues(rollingWindowManager, t, "op1", 10, 14);
    checkValues(rollingWindowManager, t, "op2", 4, 14);

    // neither should reset.
    t = (long)(period * 1.25);
    rollingWindowManager.recordMetric(t, "op2", users[0], 7);
    checkValues(rollingWindowManager, t, "op1", 10, 21);
    checkValues(rollingWindowManager, t, "op2", 11, 21);

    // op2 should reset.
    t = (long)(period * 1.5);
    rollingWindowManager.recordMetric(t, "op2", users[0], 13);
    checkValues(rollingWindowManager, t, "op1", 10, 23);
    checkValues(rollingWindowManager, t, "op2", 13, 23);
  }