You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/08/25 09:02:54 UTC

[shardingsphere] branch master updated: Rename MetricsUtils methods (#7059)

This is an automated email from the ASF dual-hosted git repository.

zhangyonglun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new f86bdb9  Rename MetricsUtils methods (#7059)
f86bdb9 is described below

commit f86bdb97a39867c6288803493e6bd0374c27b4a4
Author: kimmking <ki...@163.com>
AuthorDate: Tue Aug 25 17:02:43 2020 +0800

    Rename MetricsUtils methods (#7059)
---
 .../jdbc/connection/BackendTransactionManager.java           |  6 +++---
 .../jdbc/wrapper/PreparedStatementExecutorWrapper.java       | 12 ++++++------
 .../communication/jdbc/wrapper/StatementExecutorWrapper.java |  4 ++--
 .../shardingsphere/proxy/backend/metrics/MetricsUtils.java   | 12 ++++++------
 .../proxy/backend/metrics/MetricsUtilsTest.java              |  8 ++++----
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java
index 311ceb1..82c5bcb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java
@@ -58,7 +58,7 @@ public final class BackendTransactionManager implements TransactionManager {
         } else {
             shardingTransactionManager.begin();
         }
-        MetricsUtils.buriedTransactionMetric("begin");
+        MetricsUtils.collectTransactionMetric("begin");
     }
     
     @Override
@@ -70,7 +70,7 @@ public final class BackendTransactionManager implements TransactionManager {
                 } else {
                     shardingTransactionManager.commit();
                 }
-                MetricsUtils.buriedTransactionMetric("commit");
+                MetricsUtils.collectTransactionMetric("commit");
             } finally {
                 connection.getStateHandler().setStatus(ConnectionStatus.TERMINATED);
             }
@@ -86,7 +86,7 @@ public final class BackendTransactionManager implements TransactionManager {
                 } else {
                     shardingTransactionManager.rollback();
                 }
-                MetricsUtils.buriedTransactionMetric("rollback");
+                MetricsUtils.collectTransactionMetric("rollback");
             } finally {
                 connection.getStateHandler().setStatus(ConnectionStatus.TERMINATED);
             }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java
index ddb416b..2a2bbef 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/PreparedStatementExecutorWrapper.java
@@ -68,7 +68,7 @@ public final class PreparedStatementExecutorWrapper implements JDBCExecutorWrapp
                     new CommonSQLStatementContext(sqlStatement), new ExecutionUnit(schema.getSchema().getDataSources().keySet().iterator().next(), new SQLUnit(sql, parameters)));
         }
         RouteContext routeContext = new DataNodeRouter(schema.getSchema().getMetaData(), PROXY_SCHEMA_CONTEXTS.getSchemaContexts().getProps(), rules).route(sqlStatement, sql, parameters);
-        routeMetricsCollect(routeContext, rules);
+        collectRouteMetrics(routeContext, rules);
         SQLRewriteEntry sqlRewriteEntry = new SQLRewriteEntry(schema.getSchema().getMetaData().getSchema().getConfiguredSchemaMetaData(), PROXY_SCHEMA_CONTEXTS.getSchemaContexts().getProps(), rules);
         SQLRewriteResult sqlRewriteResult = sqlRewriteEntry.rewrite(sql, new ArrayList<>(parameters), routeContext);
         return new ExecutionContext(routeContext.getSqlStatementContext(), ExecutionContextBuilder.build(schema.getSchema().getMetaData(), sqlRewriteResult));
@@ -79,14 +79,14 @@ public final class PreparedStatementExecutorWrapper implements JDBCExecutorWrapp
         return ((PreparedStatement) statement).execute();
     }
     
-    private void routeMetricsCollect(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
-        MetricsUtils.buriedShardingMetrics(routeContext.getRouteResult().getRouteUnits());
-        MetricsUtils.buriedShardingRuleMetrics(routeContext, rules);
-    }
-    
     @Override
     public ExecuteGroupEngine<?> getExecuteGroupEngine(final BackendConnection backendConnection, final StatementOption option) {
         int maxConnectionsSizePerQuery = PROXY_SCHEMA_CONTEXTS.getSchemaContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
         return new PreparedStatementExecuteGroupEngine(maxConnectionsSizePerQuery, backendConnection, option, schema.getSchema().getRules());
     }
+    
+    private void collectRouteMetrics(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
+        MetricsUtils.collectRouteUnitMetrics(routeContext.getRouteResult().getRouteUnits());
+        MetricsUtils.collectShardingRuleMetrics(routeContext, rules);
+    }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java
index a0dccf3..8b76bb2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/wrapper/StatementExecutorWrapper.java
@@ -81,8 +81,8 @@ public final class StatementExecutorWrapper implements JDBCExecutorWrapper {
     }
     
     private void routeMetricsCollect(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
-        MetricsUtils.buriedShardingMetrics(routeContext.getRouteResult().getRouteUnits());
-        MetricsUtils.buriedShardingRuleMetrics(routeContext, rules);
+        MetricsUtils.collectRouteUnitMetrics(routeContext.getRouteResult().getRouteUnits());
+        MetricsUtils.collectShardingRuleMetrics(routeContext, rules);
     }
     
     @Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
index a0ba3c4..81a549f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
@@ -36,11 +36,11 @@ import java.util.Collection;
 public final class MetricsUtils {
     
     /**
-     * Buried sharding metrics.
+     * Collect sharding metrics.
      *
      * @param routeUnits route units
      */
-    public static void buriedShardingMetrics(final Collection<RouteUnit> routeUnits) {
+    public static void collectRouteUnitMetrics(final Collection<RouteUnit> routeUnits) {
         if (!routeUnits.isEmpty()) {
             for (RouteUnit each : routeUnits) {
                 Collection<RouteMapper> tableMappers = each.getTableMappers();
@@ -55,21 +55,21 @@ public final class MetricsUtils {
     }
     
     /**
-     * Buried transaction metric.
+     * Collect transaction metric.
      *
      * @param labelValue label value
      */
-    public static void buriedTransactionMetric(final String labelValue) {
+    public static void collectTransactionMetric(final String labelValue) {
         SingletonFacadeEngine.buildMetrics().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterIncrement(MetricsLabelEnum.TRANSACTION.getName(), labelValue));
     }
     
     /**
-     * Buried sharding rule metrics.
+     * Collect sharding rule metrics.
      *
      * @param routeContext route context
      * @param rules rules
      */
-    public static void buriedShardingRuleMetrics(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
+    public static void collectShardingRuleMetrics(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
         routeContext.getRouteResult().getActualDataSourceNames().forEach(dataSourceName -> rules.forEach(each -> {
             if (each instanceof ShadowRule && ((ShadowRule) each).getShadowMappings().containsValue(dataSourceName)) {
                 SingletonFacadeEngine.buildMetrics().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterIncrement(MetricsLabelEnum.SHADOW_HIT_TOTAL.getName()));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtilsTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtilsTest.java
index 066ed9b..32842df 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtilsTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtilsTest.java
@@ -33,14 +33,14 @@ public final class MetricsUtilsTest {
         RouteMapper dataSourceMapper = new RouteMapper("ds", "ds_0");
         RouteMapper tableMapper = new RouteMapper("t_order", "t_order_0");
         RouteUnit unit = new RouteUnit(dataSourceMapper, Collections.singletonList(tableMapper));
-        MetricsUtils.buriedShardingMetrics(Collections.singleton(unit));
+        MetricsUtils.collectRouteUnitMetrics(Collections.singleton(unit));
     }
     
     @Test
     public void testBuriedTransactionMetric() {
-        MetricsUtils.buriedTransactionMetric("begin");
-        MetricsUtils.buriedTransactionMetric("commit");
-        MetricsUtils.buriedTransactionMetric("rollback");
+        MetricsUtils.collectTransactionMetric("begin");
+        MetricsUtils.collectTransactionMetric("commit");
+        MetricsUtils.collectTransactionMetric("rollback");
     }
     
 }