@Test public void metrics() throws IOException { MetricsCommand metricsCommand = new MetricsCommand(mMetricsMasterClient, mPrintStream); metricsCommand.run(); checkIfOutputValid(); }
public int run() throws IOException { mMetricsMap = mMetricsMasterClient.getMetrics(); SortedSet<String> names = new TreeSet<>(mMetricsMap.keySet()); for (String name : names) { if (!isAlluxioMetric(name)) { continue; } MetricValue metricValue = mMetricsMap.get(name); String strValue; if (metricValue.hasStringValue()) { strValue = metricValue.getStringValue(); } else { double doubleValue = metricValue.getDoubleValue(); if (name.contains(BYTES_METRIC_IDENTIFIER)) { strValue = FormatUtils.getSizeFromBytes((long) doubleValue); if (name.contains(THROUGHPUT_METRIC_IDENTIFIER)) { strValue = strValue + "/MIN"; } } else if (DoubleMath.isMathematicalInteger(doubleValue)) { strValue = DECIMAL_FORMAT.format((long) doubleValue); } else { strValue = String.valueOf(doubleValue); } } mPrintStream.printf(INFO_FORMAT, name, metricValue.getMetricType(), strValue); } return 0; }
MetricsCommand { public int run() throws IOException { mMetricsMap = mMetricsMasterClient.getMetrics(); SortedSet<String> names = new TreeSet<>(mMetricsMap.keySet()); for (String name : names) { if (!isAlluxioMetric(name)) { continue; } MetricValue metricValue = mMetricsMap.get(name); String strValue; if (metricValue.hasStringValue()) { strValue = metricValue.getStringValue(); } else { double doubleValue = metricValue.getDoubleValue(); if (name.contains(BYTES_METRIC_IDENTIFIER)) { strValue = FormatUtils.getSizeFromBytes((long) doubleValue); if (name.contains(THROUGHPUT_METRIC_IDENTIFIER)) { strValue = strValue + "/MIN"; } } else if (DoubleMath.isMathematicalInteger(doubleValue)) { strValue = DECIMAL_FORMAT.format((long) doubleValue); } else { strValue = String.valueOf(doubleValue); } } mPrintStream.printf(INFO_FORMAT, name, metricValue.getMetricType(), strValue); } return 0; } }
MetricsCommand { public int run() throws IOException { mMetricsMap = mMetricsMasterClient.getMetrics(); SortedSet<String> names = new TreeSet<>(mMetricsMap.keySet()); for (String name : names) { if (!isAlluxioMetric(name)) { continue; } MetricValue metricValue = mMetricsMap.get(name); String strValue; if (metricValue.hasStringValue()) { strValue = metricValue.getStringValue(); } else { double doubleValue = metricValue.getDoubleValue(); if (name.contains(BYTES_METRIC_IDENTIFIER)) { strValue = FormatUtils.getSizeFromBytes((long) doubleValue); if (name.contains(THROUGHPUT_METRIC_IDENTIFIER)) { strValue = strValue + "/MIN"; } } else if (DoubleMath.isMathematicalInteger(doubleValue)) { strValue = DECIMAL_FORMAT.format((long) doubleValue); } else { strValue = String.valueOf(doubleValue); } } mPrintStream.printf(INFO_FORMAT, name, metricValue.getMetricType(), strValue); } return 0; } MetricsCommand(MetricsMasterClient metricsMasterClient, PrintStream printStream); }
MetricsCommand { public int run() throws IOException { mMetricsMap = mMetricsMasterClient.getMetrics(); SortedSet<String> names = new TreeSet<>(mMetricsMap.keySet()); for (String name : names) { if (!isAlluxioMetric(name)) { continue; } MetricValue metricValue = mMetricsMap.get(name); String strValue; if (metricValue.hasStringValue()) { strValue = metricValue.getStringValue(); } else { double doubleValue = metricValue.getDoubleValue(); if (name.contains(BYTES_METRIC_IDENTIFIER)) { strValue = FormatUtils.getSizeFromBytes((long) doubleValue); if (name.contains(THROUGHPUT_METRIC_IDENTIFIER)) { strValue = strValue + "/MIN"; } } else if (DoubleMath.isMathematicalInteger(doubleValue)) { strValue = DECIMAL_FORMAT.format((long) doubleValue); } else { strValue = String.valueOf(doubleValue); } } mPrintStream.printf(INFO_FORMAT, name, metricValue.getMetricType(), strValue); } return 0; } MetricsCommand(MetricsMasterClient metricsMasterClient, PrintStream printStream); int run(); }
MetricsCommand { public int run() throws IOException { mMetricsMap = mMetricsMasterClient.getMetrics(); SortedSet<String> names = new TreeSet<>(mMetricsMap.keySet()); for (String name : names) { if (!isAlluxioMetric(name)) { continue; } MetricValue metricValue = mMetricsMap.get(name); String strValue; if (metricValue.hasStringValue()) { strValue = metricValue.getStringValue(); } else { double doubleValue = metricValue.getDoubleValue(); if (name.contains(BYTES_METRIC_IDENTIFIER)) { strValue = FormatUtils.getSizeFromBytes((long) doubleValue); if (name.contains(THROUGHPUT_METRIC_IDENTIFIER)) { strValue = strValue + "/MIN"; } } else if (DoubleMath.isMathematicalInteger(doubleValue)) { strValue = DECIMAL_FORMAT.format((long) doubleValue); } else { strValue = String.valueOf(doubleValue); } } mPrintStream.printf(INFO_FORMAT, name, metricValue.getMetricType(), strValue); } return 0; } MetricsCommand(MetricsMasterClient metricsMasterClient, PrintStream printStream); int run();  }