private void storeFlowMetrics(byte[] rowKey, Set<TimelineMetric> metrics, Attribute... attributes) throws IOException { for (TimelineMetric metric : metrics) { byte[] metricColumnQualifier = stringKeyConverter.encode(metric.getId()); Map<Long, Number> timeseries = metric.getValues(); for (Map.Entry<Long, Number> timeseriesEntry : timeseries.entrySet()) { Long timestamp = timeseriesEntry.getKey(); ColumnRWHelper.store(rowKey, flowRunTable, FlowRunColumnPrefix.METRIC, metricColumnQualifier, timestamp, timeseriesEntry.getValue(), attributes); } } }
/** * stores the {@linkplain TimelineMetric} information from the * {@linkplain TimelineEvent} object. */ private <T extends BaseTable<T>> void storeMetrics( byte[] rowKey, Set<TimelineMetric> metrics, ColumnPrefix<T> columnPrefix, TypedBufferedMutator<T> table) throws IOException { if (metrics != null) { for (TimelineMetric metric : metrics) { byte[] metricColumnQualifier = stringKeyConverter.encode(metric.getId()); Map<Long, Number> timeseries = metric.getValues(); for (Map.Entry<Long, Number> timeseriesEntry : timeseries.entrySet()) { Long timestamp = timeseriesEntry.getKey(); ColumnRWHelper.store(rowKey, table, columnPrefix, metricColumnQualifier, timestamp, timeseriesEntry.getValue()); } } } }
Set<TimelineMetric> metrics = resultEntity.getMetrics(); for (TimelineMetric m : metrics) { if (m.getId().startsWith("HDFS_BYTES_WRITE")) { assertEquals(100 * n, m.getSingleDataValue().intValue()); } else if (m.getId().startsWith("VCORES_USED")) { assertEquals(3 * n, m.getSingleDataValue().intValue()); } else if (m.getId().startsWith("TXN_FINISH_TIME")) { assertEquals(n - 1, m.getSingleDataValue()); } else { fail("Unrecognized metric! " + m.getId()); if (m.getId().equals("HDFS_BYTES_WRITE")) { assertEquals(100 * n, m.getSingleDataValue().intValue()); } else if (m.getId().equals("VCORES_USED")) { assertEquals(3 * n, m.getSingleDataValue().intValue()); } else if (m.getId().equals("TXN_FINISH_TIME")) { assertEquals(n - 1, m.getSingleDataValue()); } else { fail("Unrecognized metric! " + m.getId());