From c80f733800086c40b43ef9909f537ef6177663a9 Mon Sep 17 00:00:00 2001 From: gaodayue Date: Sat, 27 Feb 2016 16:30:37 +0800 Subject: [PATCH] KYLIN-1455 HBase ScanMetrics are not properly logged in query log --- .../storage/hbase/CubeSegmentTupleIterator.java | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/storage/src/main/java/org/apache/kylin/storage/hbase/CubeSegmentTupleIterator.java b/storage/src/main/java/org/apache/kylin/storage/hbase/CubeSegmentTupleIterator.java index 9627efb..b2c50f7 100644 --- a/storage/src/main/java/org/apache/kylin/storage/hbase/CubeSegmentTupleIterator.java +++ b/storage/src/main/java/org/apache/kylin/storage/hbase/CubeSegmentTupleIterator.java @@ -140,23 +140,25 @@ public class CubeSegmentTupleIterator implements ITupleIterator { } private void closeScanner() { - flushScanCountDelta(); - - if (logger.isDebugEnabled() && scan != null) { - logger.debug("Scan " + scan.toString()); - byte[] metricsBytes = scan.getAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA); - if (metricsBytes != null) { - ScanMetrics scanMetrics = ProtobufUtil.toScanMetrics(metricsBytes); - logger.debug("HBase Metrics: " + "count={}, ms={}, bytes={}, remote_bytes={}, regions={}, not_serving_region={}, rpc={}, rpc_retries={}, remote_rpc={}, remote_rpc_retries={}", new Object[] { scanCount, scanMetrics.sumOfMillisSecBetweenNexts, scanMetrics.countOfBytesInResults, scanMetrics.countOfBytesInRemoteResults, scanMetrics.countOfRegions, scanMetrics.countOfNSRE, scanMetrics.countOfRPCcalls, scanMetrics.countOfRPCRetries, scanMetrics.countOfRemoteRPCcalls, scanMetrics.countOfRemoteRPCRetries }); - } - } - try { - if (scanner != null) { + if (scanner != null) { + flushScanCountDelta(); + + try { scanner.close(); scanner = null; + } catch (Throwable t) { + throw new StorageException("Error when close scanner for table " + tableName, t); + } + + if (logger.isDebugEnabled()) { + logger.debug("Scan " + scan); + byte[] metricsBytes = scan.getAttribute(Scan.SCAN_ATTRIBUTES_METRICS_DATA); + if (metricsBytes != null) { // shouldn't be null, but we add a check to be safe anyway + ScanMetrics scanMetrics = ProtobufUtil.toScanMetrics(metricsBytes); + logger.debug("HBase Metrics: count={}, ms={}, bytes={}, remote_bytes={}, regions={}, not_serving_region={}, rpc={}, rpc_retries={}, remote_rpc={}, remote_rpc_retries={}", + new Object[] { scanCount, scanMetrics.sumOfMillisSecBetweenNexts, scanMetrics.countOfBytesInResults, scanMetrics.countOfBytesInRemoteResults, scanMetrics.countOfRegions, scanMetrics.countOfNSRE, scanMetrics.countOfRPCcalls, scanMetrics.countOfRPCRetries, scanMetrics.countOfRemoteRPCcalls, scanMetrics.countOfRemoteRPCRetries }); + } } - } catch (Throwable t) { - throw new StorageException("Error when close scanner for table " + tableName, t); } } -- 2.5.4 (Apple Git-61)