Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 b553f96a2 -> ba0ddb0dd
PHOENIX-3248 Amend - add missing file Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ba0ddb0d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ba0ddb0d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ba0ddb0d Branch: refs/heads/4.x-HBase-1.1 Commit: ba0ddb0dde4053f6f7b799c0f6bf8c1f63b018b4 Parents: b553f96 Author: Samarth Jain <[email protected]> Authored: Fri May 26 09:53:16 2017 -0700 Committer: Samarth Jain <[email protected]> Committed: Fri May 26 09:53:16 2017 -0700 ---------------------------------------------------------------------- .../phoenix/monitoring/ScanMetricsHolder.java | 104 +++++++++++++++++++ 1 file changed, 104 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba0ddb0d/phoenix-core/src/main/java/org/apache/phoenix/monitoring/ScanMetricsHolder.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/ScanMetricsHolder.java b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/ScanMetricsHolder.java new file mode 100644 index 0000000..440bdb0 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/ScanMetricsHolder.java @@ -0,0 +1,104 @@ +package org.apache.phoenix.monitoring; + +import static org.apache.phoenix.monitoring.MetricType.COUNT_RPC_CALLS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_REMOTE_RPC_CALLS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_MILLS_BETWEEN_NEXTS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_NOT_SERVING_REGION_EXCEPTION; +import static org.apache.phoenix.monitoring.MetricType.COUNT_BYTES_REGION_SERVER_RESULTS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_BYTES_IN_REMOTE_RESULTS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_SCANNED_REGIONS; + +import org.apache.hadoop.hbase.client.Scan; + +import static org.apache.phoenix.monitoring.MetricType.COUNT_RPC_RETRIES; +import static org.apache.phoenix.monitoring.MetricType.COUNT_REMOTE_RPC_RETRIES; +import static org.apache.phoenix.monitoring.MetricType.COUNT_ROWS_SCANNED; +import static org.apache.phoenix.monitoring.MetricType.COUNT_ROWS_FILTERED; + +public class ScanMetricsHolder { + + private final CombinableMetric countOfRPCcalls; + private final CombinableMetric countOfRemoteRPCcalls; + private final CombinableMetric sumOfMillisSecBetweenNexts; + private final CombinableMetric countOfNSRE; + private final CombinableMetric countOfBytesInResults; + private final CombinableMetric countOfBytesInRemoteResults; + private final CombinableMetric countOfRegions; + private final CombinableMetric countOfRPCRetries; + private final CombinableMetric countOfRemoteRPCRetries; + private final CombinableMetric countOfRowsScanned; + private final CombinableMetric countOfRowsFiltered; + + private static final ScanMetricsHolder NO_OP_INSTANCE = + new ScanMetricsHolder(new ReadMetricQueue(false), ""); + + public static ScanMetricsHolder getInstance(ReadMetricQueue readMetrics, String tableName, + Scan scan, boolean isRequestMetricsEnabled) { + if (!isRequestMetricsEnabled) { + return NO_OP_INSTANCE; + } + scan.setScanMetricsEnabled(true); + return new ScanMetricsHolder(readMetrics, tableName); + } + + private ScanMetricsHolder(ReadMetricQueue readMetrics, String tableName) { + countOfRPCcalls = readMetrics.allotMetric(COUNT_RPC_CALLS, tableName); + countOfRemoteRPCcalls = readMetrics.allotMetric(COUNT_REMOTE_RPC_CALLS, tableName); + sumOfMillisSecBetweenNexts = readMetrics.allotMetric(COUNT_MILLS_BETWEEN_NEXTS, tableName); + countOfNSRE = readMetrics.allotMetric(COUNT_NOT_SERVING_REGION_EXCEPTION, tableName); + countOfBytesInResults = + readMetrics.allotMetric(COUNT_BYTES_REGION_SERVER_RESULTS, tableName); + countOfBytesInRemoteResults = + readMetrics.allotMetric(COUNT_BYTES_IN_REMOTE_RESULTS, tableName); + countOfRegions = readMetrics.allotMetric(COUNT_SCANNED_REGIONS, tableName); + countOfRPCRetries = readMetrics.allotMetric(COUNT_RPC_RETRIES, tableName); + countOfRemoteRPCRetries = readMetrics.allotMetric(COUNT_REMOTE_RPC_RETRIES, tableName); + countOfRowsScanned = readMetrics.allotMetric(COUNT_ROWS_SCANNED, tableName); + countOfRowsFiltered = readMetrics.allotMetric(COUNT_ROWS_FILTERED, tableName); + } + + public CombinableMetric getCountOfRemoteRPCcalls() { + return countOfRemoteRPCcalls; + } + + public CombinableMetric getSumOfMillisSecBetweenNexts() { + return sumOfMillisSecBetweenNexts; + } + + public CombinableMetric getCountOfNSRE() { + return countOfNSRE; + } + + public CombinableMetric getCountOfBytesInRemoteResults() { + return countOfBytesInRemoteResults; + } + + public CombinableMetric getCountOfRegions() { + return countOfRegions; + } + + public CombinableMetric getCountOfRPCRetries() { + return countOfRPCRetries; + } + + public CombinableMetric getCountOfRemoteRPCRetries() { + return countOfRemoteRPCRetries; + } + + public CombinableMetric getCountOfRowsFiltered() { + return countOfRowsFiltered; + } + + public CombinableMetric getCountOfRPCcalls() { + return countOfRPCcalls; + } + + public CombinableMetric getCountOfBytesInResults() { + return countOfBytesInResults; + } + + public CombinableMetric getCountOfRowsScanned() { + return countOfRowsScanned; + } + +}
