diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/GlobalClientMetrics.java b/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/GlobalClientMetrics.java index 8763a7c5ecf..e003659571c 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/GlobalClientMetrics.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/GlobalClientMetrics.java @@ -17,7 +17,51 @@ */ package org.apache.phoenix.monitoring; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.hadoop.hbase.metrics.Gauge; +import org.apache.hadoop.hbase.metrics.MetricRegistries; +import org.apache.hadoop.hbase.metrics.MetricRegistry; +import org.apache.hadoop.hbase.metrics.MetricRegistryInfo; +import org.apache.phoenix.query.QueryServicesOptions; + +import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.phoenix.monitoring.MetricType.CLIENT_METADATA_CACHE_HIT_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.CLIENT_METADATA_CACHE_MISS_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.COUNTER_GET_TABLE_REGIONS_FAIL; +import static org.apache.phoenix.monitoring.MetricType.COUNTER_METADATA_INCONSISTENCY; +import static org.apache.phoenix.monitoring.MetricType.COUNT_BYTES_IN_REMOTE_RESULTS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_BYTES_REGION_SERVER_RESULTS; +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_REMOTE_RPC_CALLS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_REMOTE_RPC_RETRIES; +import static org.apache.phoenix.monitoring.MetricType.COUNT_ROWS_FILTERED; +import static org.apache.phoenix.monitoring.MetricType.COUNT_ROWS_SCANNED; +import static org.apache.phoenix.monitoring.MetricType.COUNT_RPC_CALLS; +import static org.apache.phoenix.monitoring.MetricType.COUNT_RPC_RETRIES; +import static org.apache.phoenix.monitoring.MetricType.COUNT_SCANNED_REGIONS; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_CREATED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_ERROR_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_FALLBACK_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_END_TO_END_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_EXECUTED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_EXECUTION_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_QUEUE_WAIT_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_REJECTED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_END_TO_END_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_EXECUTED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_EXECUTION_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_QUEUE_WAIT_TIME; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_REJECTED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_TASK_TIMEOUT_COUNTER; import static org.apache.phoenix.monitoring.MetricType.HCONNECTIONS_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.INDEX_COMMIT_FAILURE_SIZE; import static org.apache.phoenix.monitoring.MetricType.MEMORY_CHUNK_BYTES; import static org.apache.phoenix.monitoring.MetricType.MEMORY_WAIT_TIME; import static org.apache.phoenix.monitoring.MetricType.MUTATION_BATCH_FAILED_SIZE; @@ -29,8 +73,10 @@ import static org.apache.phoenix.monitoring.MetricType.NUM_PARALLEL_SCANS; import static org.apache.phoenix.monitoring.MetricType.OPEN_INTERNAL_PHOENIX_CONNECTIONS_COUNTER; import static org.apache.phoenix.monitoring.MetricType.OPEN_PHOENIX_CONNECTIONS_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.INDEX_COMMIT_FAILURE_SIZE; import static org.apache.phoenix.monitoring.MetricType.PAGED_ROWS_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_ATTEMPTED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_FAILED_COUNTER; +import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_THROTTLED_COUNTER; import static org.apache.phoenix.monitoring.MetricType.QUERY_FAILED_COUNTER; import static org.apache.phoenix.monitoring.MetricType.QUERY_SERVICES_COUNTER; import static org.apache.phoenix.monitoring.MetricType.QUERY_TIME; @@ -44,53 +90,7 @@ import static org.apache.phoenix.monitoring.MetricType.TASK_EXECUTED_COUNTER; import static org.apache.phoenix.monitoring.MetricType.TASK_EXECUTION_TIME; import static org.apache.phoenix.monitoring.MetricType.TASK_QUEUE_WAIT_TIME; -import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_THROTTLED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_ATTEMPTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.PHOENIX_CONNECTIONS_FAILED_COUNTER; import static org.apache.phoenix.monitoring.MetricType.TASK_REJECTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_END_TO_END_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_EXECUTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_EXECUTION_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_QUEUE_WAIT_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL1_TASK_REJECTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_END_TO_END_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_EXECUTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_EXECUTION_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_QUEUE_WAIT_TIME; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_POOL2_TASK_REJECTED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_TASK_TIMEOUT_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_FALLBACK_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_CREATED_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.HA_PARALLEL_CONNECTION_ERROR_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.CLIENT_METADATA_CACHE_HIT_COUNTER; -import static org.apache.phoenix.monitoring.MetricType.CLIENT_METADATA_CACHE_MISS_COUNTER; - -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 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; -import static org.apache.phoenix.monitoring.MetricType.COUNTER_METADATA_INCONSISTENCY; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.hadoop.hbase.metrics.Gauge; -import org.apache.hadoop.hbase.metrics.MetricRegistries; -import org.apache.hadoop.hbase.metrics.MetricRegistry; -import org.apache.hadoop.hbase.metrics.MetricRegistryInfo; -import org.apache.phoenix.query.QueryServicesOptions; - -import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Central place where we keep track of all the global client phoenix metrics. These metrics are different from @@ -141,6 +141,7 @@ public enum GlobalClientMetrics { GLOBAL_HBASE_COUNT_ROWS_SCANNED(COUNT_ROWS_SCANNED), GLOBAL_HBASE_COUNT_ROWS_FILTERED(COUNT_ROWS_FILTERED), GLOBAL_HBASE_COUNTER_METADATA_INCONSISTENCY(COUNTER_METADATA_INCONSISTENCY), + GLOBAL_HBASE_COUNTER_GET_TABLE_REGIONS_FAIL(COUNTER_GET_TABLE_REGIONS_FAIL), GLOBAL_HA_PARALLEL_POOL1_TASK_QUEUE_WAIT_TIME(HA_PARALLEL_POOL1_TASK_QUEUE_WAIT_TIME), GLOBAL_HA_PARALLEL_POOL1_TASK_END_TO_END_TIME(HA_PARALLEL_POOL1_TASK_END_TO_END_TIME), diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/MetricType.java b/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/MetricType.java index b7b0c4b562e..641d9d374f0 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/MetricType.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/monitoring/MetricType.java @@ -168,6 +168,8 @@ public enum MetricType { COUNT_ROWS_FILTERED("wf", "Number of rows filtered",LogLevel.DEBUG,PLong.INSTANCE), COUNTER_METADATA_INCONSISTENCY("mi", "Number of times the metadata inconsistencies ", LogLevel.DEBUG, PLong.INSTANCE), + COUNTER_GET_TABLE_REGIONS_FAIL("gtrf", "Number of times get table regions fail ", + LogLevel.DEBUG, PLong.INSTANCE), NUM_SYSTEM_TABLE_RPC_SUCCESS("nstrs", "Number of successful system table RPC calls", LogLevel.DEBUG,PLong.INSTANCE), NUM_SYSTEM_TABLE_RPC_FAILURES("nstcf", "Number of Failed system table RPC calls ", diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index b7e1e84f97e..8f894f97a75 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -67,9 +67,10 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_CONSTANT; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_INDEX_ID; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME; +import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNTER_GET_TABLE_REGIONS_FAIL; +import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNTER_METADATA_INCONSISTENCY; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HCONNECTIONS_COUNTER; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_QUERY_SERVICES_COUNTER; -import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNTER_METADATA_INCONSISTENCY; import static org.apache.phoenix.monitoring.MetricType.NUM_SYSTEM_TABLE_RPC_FAILURES; import static org.apache.phoenix.monitoring.MetricType.NUM_SYSTEM_TABLE_RPC_SUCCESS; import static org.apache.phoenix.monitoring.MetricType.TIME_SPENT_IN_SYSTEM_TABLE_RPC_CALLS; @@ -898,6 +899,7 @@ public List getTableRegions(final byte[] tableName, final byte[ if (retryCount++ < maxRetryCount) { continue; } + GLOBAL_HBASE_COUNTER_GET_TABLE_REGIONS_FAIL.increment(); throw new SQLExceptionInfo.Builder( SQLExceptionCode.GET_TABLE_REGIONS_FAIL).setRootCause(e).build() .buildException(); @@ -6250,6 +6252,7 @@ public HRegionLocation getTableRegionLocation(byte[] tableName, byte[] row) thro if (retryCount++ < maxRetryCount) { // One retry, in case split occurs while navigating continue; } + GLOBAL_HBASE_COUNTER_GET_TABLE_REGIONS_FAIL.increment(); throw new SQLExceptionInfo.Builder(SQLExceptionCode.GET_TABLE_REGIONS_FAIL) .setRootCause(e).build().buildException(); }