/** * Method to expose the metrics associated with performing reads using the passed result set. A typical pattern is: * * <pre> * {@code * Map<String, Map<MetricType, Long>> overAllQueryMetrics = null; * Map<String, Map<MetricType, Long>> requestReadMetrics = null; * try (ResultSet rs = stmt.executeQuery()) { * while(rs.next()) { * ..... * } * overAllQueryMetrics = PhoenixRuntime.getOverAllReadRequestMetrics(rs); * requestReadMetrics = PhoenixRuntime.getRequestReadMetrics(rs); * PhoenixRuntime.resetMetrics(rs); * } * </pre> * * @param rs * result set to get the metrics for * @return a map of (table name) -> (map of (metric name) -> (metric value)) * @throws SQLException */ public static Map<String, Map<MetricType, Long>> getRequestReadMetricInfo(ResultSet rs) throws SQLException { PhoenixResultSet resultSet = rs.unwrap(PhoenixResultSet.class); return resultSet.getReadMetrics(); }
@Override public void close() throws SQLException { if (isClosed) { return; } try { scanner.close(); } finally { isClosed = true; statement.getResultSets().remove(this); overAllQueryMetrics.endQuery(); overAllQueryMetrics.stopResultSetWatch(); if (!queryLogger.isSynced()) { if(this.exception==null){ queryLogger.log(QueryLogInfo.QUERY_STATUS_I,QueryStatus.COMPLETED.toString()); } queryLogger.log(QueryLogInfo.NO_OF_RESULTS_ITERATED_I, count); if (queryLogger.isDebugEnabled()) { queryLogger.log(QueryLogInfo.SCAN_METRICS_JSON_I, readMetricsQueue.getScanMetricsHolderList().toString()); readMetricsQueue.getScanMetricsHolderList().clear(); } // if not already synced , like closing before result set exhausted queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics()); } } }
queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics());
/** * Method to expose the metrics associated with performing reads using the passed result set. A typical pattern is: * * <pre> * {@code * Map<String, Map<MetricType, Long>> overAllQueryMetrics = null; * Map<String, Map<MetricType, Long>> requestReadMetrics = null; * try (ResultSet rs = stmt.executeQuery()) { * while(rs.next()) { * ..... * } * overAllQueryMetrics = PhoenixRuntime.getOverAllReadRequestMetrics(rs); * requestReadMetrics = PhoenixRuntime.getRequestReadMetrics(rs); * PhoenixRuntime.resetMetrics(rs); * } * </pre> * * @param rs * result set to get the metrics for * @return a map of (table name) -> (map of (metric name) -> (metric value)) * @throws SQLException */ public static Map<String, Map<MetricType, Long>> getRequestReadMetricInfo(ResultSet rs) throws SQLException { PhoenixResultSet resultSet = rs.unwrap(PhoenixResultSet.class); return resultSet.getReadMetrics(); }
/** * Method to expose the metrics associated with performing reads using the passed result set. A typical pattern is: * * <pre> * {@code * Map<String, Map<MetricType, Long>> overAllQueryMetrics = null; * Map<String, Map<MetricType, Long>> requestReadMetrics = null; * try (ResultSet rs = stmt.executeQuery()) { * while(rs.next()) { * ..... * } * overAllQueryMetrics = PhoenixRuntime.getOverAllReadRequestMetrics(rs); * requestReadMetrics = PhoenixRuntime.getRequestReadMetrics(rs); * PhoenixRuntime.resetMetrics(rs); * } * </pre> * * @param rs * result set to get the metrics for * @return a map of (table name) -> (map of (metric name) -> (metric value)) * @throws SQLException */ public static Map<String, Map<MetricType, Long>> getRequestReadMetricInfo(ResultSet rs) throws SQLException { PhoenixResultSet resultSet = rs.unwrap(PhoenixResultSet.class); return resultSet.getReadMetrics(); }
@Override public void close() throws SQLException { if (isClosed) { return; } try { scanner.close(); } finally { isClosed = true; statement.getResultSets().remove(this); overAllQueryMetrics.endQuery(); overAllQueryMetrics.stopResultSetWatch(); if (!queryLogger.isSynced()) { if(this.exception==null){ queryLogger.log(QueryLogInfo.QUERY_STATUS_I,QueryStatus.COMPLETED.toString()); } queryLogger.log(QueryLogInfo.NO_OF_RESULTS_ITERATED_I, count); if (queryLogger.isDebugEnabled()) { queryLogger.log(QueryLogInfo.SCAN_METRICS_JSON_I, readMetricsQueue.getScanMetricsHolderList().toString()); readMetricsQueue.getScanMetricsHolderList().clear(); } // if not already synced , like closing before result set exhausted queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics()); } } }
@Override public void close() throws SQLException { if (isClosed) { return; } try { scanner.close(); } finally { isClosed = true; statement.getResultSets().remove(this); overAllQueryMetrics.endQuery(); overAllQueryMetrics.stopResultSetWatch(); if (!queryLogger.isSynced()) { if(this.exception==null){ queryLogger.log(QueryLogInfo.QUERY_STATUS_I,QueryStatus.COMPLETED.toString()); } queryLogger.log(QueryLogInfo.NO_OF_RESULTS_ITERATED_I, count); if (queryLogger.isDebugEnabled()) { queryLogger.log(QueryLogInfo.SCAN_METRICS_JSON_I, readMetricsQueue.getScanMetricsHolderList().toString()); readMetricsQueue.getScanMetricsHolderList().clear(); } // if not already synced , like closing before result set exhausted queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics()); } } }
queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics());
queryLogger.sync(getReadMetrics(), getOverAllRequestReadMetrics());