Skip to content

Commit

Permalink
remove metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Aug 29, 2017
1 parent 10b085d commit 097d4d8
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 438 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<gson.version>2.6.1</gson.version>
<logback.version>1.1.2</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<metrics.version>3.1.0</metrics.version>
<groovy.version>2.4.5</groovy.version>
<snakeyaml.version>1.16</snakeyaml.version>
<springframework.version>4.1.1.RELEASE</springframework.version>
Expand Down Expand Up @@ -82,11 +81,6 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.dangdang.ddframe.rdb.sharding.spring.GenerateKeyDBUnitTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.WithoutNamespaceDefaultStrategyTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.WithoutNamespaceTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.namespace.WithNamespaceAlgorithmClassAndPropsTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.namespace.WithNamespaceAlgorithmClassTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.namespace.WithNamespaceAlgorithmExpressionForDynamicTest;
import com.dangdang.ddframe.rdb.sharding.spring.cases.namespace.WithNamespaceAlgorithmExpressionTest;
Expand All @@ -36,7 +35,6 @@
@RunWith(Suite.class)
@SuiteClasses({
WithNamespaceAlgorithmClassTest.class,
WithNamespaceAlgorithmClassAndPropsTest.class,
WithNamespaceDifferentTablesTest.class,
WithNamespaceAlgorithmExpressionTest.class,
WithNamespaceAlgorithmExpressionForDynamicTest.class,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</rdb:table-rules>
</rdb:sharding-rule>
<rdb:props>
<prop key="metrics.enable">${metrics_enable}</prop>
<prop key="sql.show">${sql_show}</prop>
</rdb:props>
</rdb:data-source>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ dbtbl_1.driver=org.h2.Driver
dbtbl_1.url=jdbc:h2:mem:dbtbl_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1.username=sa
dbtbl_1.password=

metrics_enable=true
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ defaultTableStrategy:
algorithmClassName: com.dangdang.ddframe.rdb.sharding.config.yaml.algorithm.MultiAlgorithm

props:
metrics.enable: true
sql.show: true
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ defaultTableStrategy:
algorithmClassName: com.dangdang.ddframe.rdb.sharding.config.yaml.algorithm.MultiAlgorithm

props:
metrics.enable: true
sql.show: true
4 changes: 0 additions & 4 deletions sharding-jdbc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ public enum ShardingPropertiesConstant {
*/
SQL_SHOW("sql.show", Boolean.FALSE.toString(), boolean.class),

/**
* Enable or Disable to show metrics info.
*
* <p>
* Print metrics info can help developers locate performance issue easier.
* Default: false
* </p>
*/
METRICS_ENABLE("metrics.enable", Boolean.FALSE.toString(), boolean.class),

/**
* Metrics Period.
*
* <p>
* Unit: Mills.
* Default: 30000 Mills.
* </p>
*/
METRICS_MILLISECONDS_PERIOD("metrics.millisecond.period", "30000", long.class),

/**
* Worker thread max size.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@

package com.dangdang.ddframe.rdb.sharding.executor.type.batch;

import com.codahale.metrics.Timer.Context;
import com.dangdang.ddframe.rdb.sharding.constant.DatabaseType;
import com.dangdang.ddframe.rdb.sharding.constant.SQLType;
import com.dangdang.ddframe.rdb.sharding.executor.BaseStatementUnit;
import com.dangdang.ddframe.rdb.sharding.executor.ExecuteCallback;
import com.dangdang.ddframe.rdb.sharding.executor.ExecutorEngine;
import com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext;
import lombok.RequiredArgsConstructor;

import java.util.Collection;
Expand Down Expand Up @@ -54,18 +52,13 @@ public final class BatchPreparedStatementExecutor {
* @return execute results
*/
public int[] executeBatch() {
Context context = MetricsContext.start("ShardingPreparedStatement-executeBatch");
try {
return accumulate(executorEngine.executeBatch(sqlType, batchPreparedStatementUnits, parameterSets, new ExecuteCallback<int[]>() {

@Override
public int[] execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return baseStatementUnit.getStatement().executeBatch();
}
}));
} finally {
MetricsContext.stop(context);
}
return accumulate(executorEngine.executeBatch(sqlType, batchPreparedStatementUnits, parameterSets, new ExecuteCallback<int[]>() {

@Override
public int[] execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return baseStatementUnit.getStatement().executeBatch();
}
}));
}

private int[] accumulate(final List<int[]> results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package com.dangdang.ddframe.rdb.sharding.executor.type.prepared;

import com.codahale.metrics.Timer.Context;
import com.dangdang.ddframe.rdb.sharding.constant.SQLType;
import com.dangdang.ddframe.rdb.sharding.executor.BaseStatementUnit;
import com.dangdang.ddframe.rdb.sharding.executor.ExecuteCallback;
import com.dangdang.ddframe.rdb.sharding.executor.ExecutorEngine;
import com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext;
import lombok.RequiredArgsConstructor;

import java.sql.PreparedStatement;
Expand Down Expand Up @@ -53,20 +51,13 @@ public final class PreparedStatementExecutor {
* @return result set list
*/
public List<ResultSet> executeQuery() {
Context context = MetricsContext.start("ShardingPreparedStatement-executeQuery");
List<ResultSet> result;
try {
result = executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<ResultSet>() {

@Override
public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).executeQuery();
}
});
} finally {
MetricsContext.stop(context);
}
return result;
return executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<ResultSet>() {

@Override
public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).executeQuery();
}
});
}

/**
Expand All @@ -75,19 +66,14 @@ public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Excep
* @return effected records count
*/
public int executeUpdate() {
Context context = MetricsContext.start("ShardingPreparedStatement-executeUpdate");
try {
List<Integer> results = executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<Integer>() {

@Override
public Integer execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).executeUpdate();
}
});
return accumulate(results);
} finally {
MetricsContext.stop(context);
}
List<Integer> results = executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<Integer>() {

@Override
public Integer execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).executeUpdate();
}
});
return accumulate(results);
}

private int accumulate(final List<Integer> results) {
Expand All @@ -104,21 +90,16 @@ private int accumulate(final List<Integer> results) {
* @return return true if is DQL, false if is DML
*/
public boolean execute() {
Context context = MetricsContext.start("ShardingPreparedStatement-execute");
try {
List<Boolean> result = executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<Boolean>() {

@Override
public Boolean execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).execute();
}
});
if (null == result || result.isEmpty() || null == result.get(0)) {
return false;
List<Boolean> result = executorEngine.executePreparedStatement(sqlType, preparedStatementUnits, parameters, new ExecuteCallback<Boolean>() {

@Override
public Boolean execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return ((PreparedStatement) baseStatementUnit.getStatement()).execute();
}
return result.get(0);
} finally {
MetricsContext.stop(context);
});
if (null == result || result.isEmpty() || null == result.get(0)) {
return false;
}
return result.get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package com.dangdang.ddframe.rdb.sharding.executor.type.statement;

import com.codahale.metrics.Timer.Context;
import com.dangdang.ddframe.rdb.sharding.constant.SQLType;
import com.dangdang.ddframe.rdb.sharding.executor.BaseStatementUnit;
import com.dangdang.ddframe.rdb.sharding.executor.ExecuteCallback;
import com.dangdang.ddframe.rdb.sharding.executor.ExecutorEngine;
import com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext;
import lombok.RequiredArgsConstructor;

import java.sql.ResultSet;
Expand Down Expand Up @@ -53,20 +51,13 @@ public final class StatementExecutor {
* @return result set list
*/
public List<ResultSet> executeQuery() {
Context context = MetricsContext.start("ShardingStatement-executeQuery");
List<ResultSet> result;
try {
result = executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<ResultSet>() {

@Override
public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return baseStatementUnit.getStatement().executeQuery(baseStatementUnit.getSqlExecutionUnit().getSql());
}
});
} finally {
MetricsContext.stop(context);
}
return result;
return executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<ResultSet>() {

@Override
public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return baseStatementUnit.getStatement().executeQuery(baseStatementUnit.getSqlExecutionUnit().getSql());
}
});
}

/**
Expand Down Expand Up @@ -133,19 +124,14 @@ public int executeUpdate(final Statement statement, final String sql) throws SQL
}

private int executeUpdate(final Updater updater) {
Context context = MetricsContext.start("ShardingStatement-executeUpdate");
try {
List<Integer> results = executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<Integer>() {

@Override
public Integer execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return updater.executeUpdate(baseStatementUnit.getStatement(), baseStatementUnit.getSqlExecutionUnit().getSql());
}
});
return accumulate(results);
} finally {
MetricsContext.stop(context);
}
List<Integer> results = executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<Integer>() {

@Override
public Integer execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return updater.executeUpdate(baseStatementUnit.getStatement(), baseStatementUnit.getSqlExecutionUnit().getSql());
}
});
return accumulate(results);
}

private int accumulate(final List<Integer> results) {
Expand Down Expand Up @@ -220,22 +206,17 @@ public boolean execute(final Statement statement, final String sql) throws SQLEx
}

private boolean execute(final Executor executor) {
Context context = MetricsContext.start("ShardingStatement-execute");
try {
List<Boolean> result = executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<Boolean>() {

@Override
public Boolean execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return executor.execute(baseStatementUnit.getStatement(), baseStatementUnit.getSqlExecutionUnit().getSql());
}
});
if (null == result || result.isEmpty() || null == result.get(0)) {
return false;
List<Boolean> result = executorEngine.executeStatement(sqlType, statementUnits, new ExecuteCallback<Boolean>() {

@Override
public Boolean execute(final BaseStatementUnit baseStatementUnit) throws Exception {
return executor.execute(baseStatementUnit.getStatement(), baseStatementUnit.getSqlExecutionUnit().getSql());
}
return result.get(0);
} finally {
MetricsContext.stop(context);
});
if (null == result || result.isEmpty() || null == result.get(0)) {
return false;
}
return result.get(0);
}

private interface Updater {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package com.dangdang.ddframe.rdb.sharding.jdbc.adapter;

import com.dangdang.ddframe.rdb.sharding.jdbc.unsupported.AbstractUnsupportedOperationConnection;
import com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext;

import java.sql.Connection;
import java.sql.ResultSet;
Expand Down Expand Up @@ -90,7 +89,6 @@ public final void rollback() throws SQLException {
@Override
public void close() throws SQLException {
closed = true;
MetricsContext.clear();
Collection<SQLException> exceptions = new LinkedList<>();
for (Connection each : getConnections()) {
try {
Expand Down
Loading

0 comments on commit 097d4d8

Please sign in to comment.