public TopMetrics(Configuration conf, int[] reportingPeriods) { logConf(conf); for (int i = 0; i < reportingPeriods.length; i++) { rollingWindowManagers.put(reportingPeriods[i], new RollingWindowManager( conf, reportingPeriods[i])); } isMetricsSourceEnabled = conf.getBoolean(DFSConfigKeys.NNTOP_ENABLED_KEY, DFSConfigKeys.NNTOP_ENABLED_DEFAULT); }
public void report(long currTime, String userName, String cmd) { LOG.debug("a metric is reported: cmd: {} user: {}", cmd, userName); userName = UserGroupInformation.trimLoginMethod(userName); for (RollingWindowManager rollingWindowManager : rollingWindowManagers .values()) { rollingWindowManager.recordMetric(currTime, cmd, userName, 1); rollingWindowManager.recordMetric(currTime, TopConf.ALL_CMDS, userName, 1); } }
/** * Get a list of the current TopWindow statistics, one TopWindow per tracked * time interval. */ public List<TopWindow> getTopWindows() { long monoTime = Time.monotonicNow(); List<TopWindow> windows = Lists.newArrayListWithCapacity (rollingWindowManagers.size()); for (Entry<Integer, RollingWindowManager> entry : rollingWindowManagers .entrySet()) { TopWindow window = entry.getValue().snapshot(monoTime); windows.add(window); } return windows; }
long time = WINDOW_LEN_MS + BUCKET_LEN * 3 / 2; for (int i = 0; i < users.length; i++) manager.recordMetric(time, "open", users[i], (i + 1) * 2); time++; for (int i = 0; i < users.length; i++) manager.recordMetric(time, "close", users[i], i + 1); time++; TopWindow tops = manager.snapshot(time); tops = manager.snapshot(time); assertEquals("Unexpected number of ops", 1, tops.getOps().size()); final Op op = tops.getOps().get(0);
/** * Called when the metric command is changed by "delta" units at time "time" * via user "user" * * @param time the time of the event * @param command the metric that is updated, e.g., the operation name * @param user the user that updated the metric * @param delta the amount of change in the metric, e.g., +1 */ public void recordMetric(long time, String command, String user, long delta) { RollingWindow window = getRollingWindow(command, user); window.incAt(time, delta); }
String metricName = entry.getKey(); RollingWindowMap rollingWindows = entry.getValue(); TopN topN = getTopUsersForMetric(time, metricName, rollingWindows); final int size = topN.size(); if (size == 0) {
/** * Called when the metric command is changed by "delta" units at time "time" * via user "user" * * @param time the time of the event * @param command the metric that is updated, e.g., the operation name * @param user the user that updated the metric * @param delta the amount of change in the metric, e.g., +1 */ public void recordMetric(long time, String command, String user, long delta) { RollingWindow window = getRollingWindow(command, user); window.incAt(time, delta); }
String metricName = entry.getKey(); RollingWindowMap rollingWindows = entry.getValue(); TopN topN = getTopUsersForMetric(time, metricName, rollingWindows); final int size = topN.size(); if (size == 0) {
public TopMetrics(Configuration conf, int[] reportingPeriods) { logConf(conf); for (int i = 0; i < reportingPeriods.length; i++) { rollingWindowManagers.put(reportingPeriods[i], new RollingWindowManager( conf, reportingPeriods[i])); } }
public void report(long currTime, String userName, String cmd) { LOG.debug("a metric is reported: cmd: {} user: {}", cmd, userName); userName = UserGroupInformation.trimLoginMethod(userName); for (RollingWindowManager rollingWindowManager : rollingWindowManagers .values()) { rollingWindowManager.recordMetric(currTime, cmd, userName, 1); rollingWindowManager.recordMetric(currTime, TopConf.ALL_CMDS, userName, 1); } }
/** * Get a list of the current TopWindow statistics, one TopWindow per tracked * time interval. */ public List<TopWindow> getTopWindows() { long monoTime = Time.monotonicNow(); List<TopWindow> windows = Lists.newArrayListWithCapacity (rollingWindowManagers.size()); for (Entry<Integer, RollingWindowManager> entry : rollingWindowManagers .entrySet()) { TopWindow window = entry.getValue().snapshot(monoTime); windows.add(window); } return windows; }
/** * Called when the metric command is changed by "delta" units at time "time" * via user "user" * * @param time the time of the event * @param command the metric that is updated, e.g., the operation name * @param user the user that updated the metric * @param delta the amount of change in the metric, e.g., +1 */ public void recordMetric(long time, String command, String user, long delta) { RollingWindow window = getRollingWindow(command, user); window.incAt(time, delta); }
String metricName = entry.getKey(); RollingWindowMap rollingWindows = entry.getValue(); TopN topN = getTopUsersForMetric(time, metricName, rollingWindows); final int size = topN.size(); if (size == 0) {
public TopMetrics(Configuration conf, int[] reportingPeriods) { logConf(conf); for (int i = 0; i < reportingPeriods.length; i++) { rollingWindowManagers.put(reportingPeriods[i], new RollingWindowManager( conf, reportingPeriods[i])); } isMetricsSourceEnabled = conf.getBoolean(DFSConfigKeys.NNTOP_ENABLED_KEY, DFSConfigKeys.NNTOP_ENABLED_DEFAULT); }
public void report(long currTime, String userName, String cmd) { LOG.debug("a metric is reported: cmd: {} user: {}", cmd, userName); userName = UserGroupInformation.trimLoginMethod(userName); for (RollingWindowManager rollingWindowManager : rollingWindowManagers .values()) { rollingWindowManager.recordMetric(currTime, cmd, userName, 1); rollingWindowManager.recordMetric(currTime, TopConf.ALL_CMDS, userName, 1); } } }
/** * Get a list of the current TopWindow statistics, one TopWindow per tracked * time interval. */ public List<TopWindow> getTopWindows() { long monoTime = Time.monotonicNow(); List<TopWindow> windows = Lists.newArrayListWithCapacity (rollingWindowManagers.size()); for (Entry<Integer, RollingWindowManager> entry : rollingWindowManagers .entrySet()) { TopWindow window = entry.getValue().snapshot(monoTime); windows.add(window); } return windows; }
@Before public void init() { conf = new Configuration(); conf.setInt(DFSConfigKeys.NNTOP_BUCKETS_PER_WINDOW_KEY, BUCKET_CNT); conf.setInt(DFSConfigKeys.NNTOP_NUM_USERS_KEY, N_TOP_USERS); manager = new RollingWindowManager(conf, WINDOW_LEN_MS); users = new String[2 * N_TOP_USERS]; for (int i = 0; i < users.length; i++) { users[i] = "user" + i; } }