Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
097d4d8d
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
097d4d8d
编写于
8月 29, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove metrics
上级
10b085da
变更
29
显示空白变更内容
内联
并排
Showing
29 changed file
with
73 addition
and
438 deletion
+73
-438
pom.xml
pom.xml
+0
-6
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/java/com/dangdang/ddframe/rdb/sharding/AllSpringTests.java
...ava/com/dangdang/ddframe/rdb/sharding/AllSpringTests.java
+0
-2
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/java/com/dangdang/ddframe/rdb/sharding/spring/cases/namespace/WithNamespaceAlgorithmClassAndPropsTest.java
...es/namespace/WithNamespaceAlgorithmClassAndPropsTest.java
+0
-39
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/resources/META-INF/rdb/namespace/withNamespaceAlgorithmClassAndProps.xml
...INF/rdb/namespace/withNamespaceAlgorithmClassAndProps.xml
+1
-1
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/resources/conf/rdb/conf.properties
...config-spring/src/test/resources/conf/rdb/conf.properties
+0
-2
sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/test/resources/configWithDataSourceWithProps.yaml
...aml/src/test/resources/configWithDataSourceWithProps.yaml
+1
-1
sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/test/resources/configWithoutDataSourceWithProps.yaml
.../src/test/resources/configWithoutDataSourceWithProps.yaml
+1
-1
sharding-jdbc-core/pom.xml
sharding-jdbc-core/pom.xml
+0
-4
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesConstant.java
...frame/rdb/sharding/config/ShardingPropertiesConstant.java
+0
-20
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/batch/BatchPreparedStatementExecutor.java
...g/executor/type/batch/BatchPreparedStatementExecutor.java
+7
-14
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/prepared/PreparedStatementExecutor.java
...ing/executor/type/prepared/PreparedStatementExecutor.java
+24
-43
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/statement/StatementExecutor.java
...b/sharding/executor/type/statement/StatementExecutor.java
+24
-43
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/adapter/AbstractConnectionAdapter.java
.../rdb/sharding/jdbc/adapter/AbstractConnectionAdapter.java
+0
-2
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/connection/ShardingConnection.java
...rdb/sharding/jdbc/core/connection/ShardingConnection.java
+2
-9
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/datasource/MasterSlaveDataSource.java
.../sharding/jdbc/core/datasource/MasterSlaveDataSource.java
+1
-1
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/datasource/ShardingDataSource.java
...rdb/sharding/jdbc/core/datasource/ShardingDataSource.java
+0
-2
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/metrics/MetricsContext.java
...dangdang/ddframe/rdb/sharding/metrics/MetricsContext.java
+0
-93
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/DatabaseHintSQLRouter.java
...me/rdb/sharding/routing/router/DatabaseHintSQLRouter.java
+0
-4
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/ParsingSQLRouter.java
...ddframe/rdb/sharding/routing/router/ParsingSQLRouter.java
+0
-6
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/AllShardingTests.java
...a/com/dangdang/ddframe/rdb/sharding/AllShardingTests.java
+1
-3
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesConstantTest.java
...e/rdb/sharding/config/ShardingPropertiesConstantTest.java
+1
-1
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesTest.java
...g/ddframe/rdb/sharding/config/ShardingPropertiesTest.java
+3
-16
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/metrics/AllMetricsTests.java
...angdang/ddframe/rdb/sharding/metrics/AllMetricsTests.java
+0
-28
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/metrics/MetricsContextTest.java
...dang/ddframe/rdb/sharding/metrics/MetricsContextTest.java
+0
-77
sharding-jdbc-core/src/test/resources/logback-test.xml
sharding-jdbc-core/src/test/resources/logback-test.xml
+0
-3
sharding-jdbc-doc/content/01-start/features.md
sharding-jdbc-doc/content/01-start/features.md
+1
-2
sharding-jdbc-doc/content/02-guide/configuration.md
sharding-jdbc-doc/content/02-guide/configuration.md
+4
-13
sharding-jdbc-example/sharding-jdbc-example-config-yaml/src/main/resources/META-INF/withAssignedDataSource.yaml
...l/src/main/resources/META-INF/withAssignedDataSource.yaml
+1
-1
sharding-jdbc-example/sharding-jdbc-example-config-yaml/src/main/resources/META-INF/withDefaultDataSource.yaml
...ml/src/main/resources/META-INF/withDefaultDataSource.yaml
+1
-1
未找到文件。
pom.xml
浏览文件 @
097d4d8d
...
...
@@ -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>
...
...
@@ -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>
...
...
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/java/com/dangdang/ddframe/rdb/sharding/AllSpringTests.java
浏览文件 @
097d4d8d
...
...
@@ -20,7 +20,6 @@ package com.dangdang.ddframe.rdb.sharding;
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
;
...
...
@@ -36,7 +35,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
WithNamespaceAlgorithmClassTest
.
class
,
WithNamespaceAlgorithmClassAndPropsTest
.
class
,
WithNamespaceDifferentTablesTest
.
class
,
WithNamespaceAlgorithmExpressionTest
.
class
,
WithNamespaceAlgorithmExpressionForDynamicTest
.
class
,
...
...
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/java/com/dangdang/ddframe/rdb/sharding/spring/cases/namespace/WithNamespaceAlgorithmClassAndPropsTest.java
已删除
100644 → 0
浏览文件 @
10b085da
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.spring.cases.namespace
;
import
com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext
;
import
com.dangdang.ddframe.rdb.sharding.spring.AbstractShardingBothDataBasesAndTablesSpringDBUnitTest
;
import
org.junit.Test
;
import
org.springframework.test.context.ContextConfiguration
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
@ContextConfiguration
(
locations
=
"classpath:META-INF/rdb/namespace/withNamespaceAlgorithmClassAndProps.xml"
)
public
final
class
WithNamespaceAlgorithmClassAndPropsTest
extends
AbstractShardingBothDataBasesAndTablesSpringDBUnitTest
{
@Test
public
void
testMetricsContextWhenEnable
()
throws
SQLException
{
try
(
Connection
connection
=
getShardingDataSource
().
getConnection
())
{
assertNotNull
(
MetricsContext
.
start
(
"name"
));
}
}
}
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/resources/META-INF/rdb/namespace/withNamespaceAlgorithmClassAndProps.xml
浏览文件 @
097d4d8d
...
...
@@ -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>
sharding-jdbc-config-parent/sharding-jdbc-config-spring/src/test/resources/conf/rdb/conf.properties
浏览文件 @
097d4d8d
...
...
@@ -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
sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/test/resources/configWithDataSourceWithProps.yaml
浏览文件 @
097d4d8d
...
...
@@ -42,4 +42,4 @@ defaultTableStrategy:
algorithmClassName
:
com.dangdang.ddframe.rdb.sharding.config.yaml.algorithm.MultiAlgorithm
props
:
metrics.enable
:
true
sql.show
:
true
sharding-jdbc-config-parent/sharding-jdbc-config-yaml/src/test/resources/configWithoutDataSourceWithProps.yaml
浏览文件 @
097d4d8d
...
...
@@ -29,4 +29,4 @@ defaultTableStrategy:
algorithmClassName
:
com.dangdang.ddframe.rdb.sharding.config.yaml.algorithm.MultiAlgorithm
props
:
metrics.enable
:
true
sql.show
:
true
sharding-jdbc-core/pom.xml
浏览文件 @
097d4d8d
...
...
@@ -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>
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesConstant.java
浏览文件 @
097d4d8d
...
...
@@ -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.
*
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/batch/BatchPreparedStatementExecutor.java
浏览文件 @
097d4d8d
...
...
@@ -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
;
...
...
@@ -54,8 +52,6 @@ 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
...
...
@@ -63,9 +59,6 @@ public final class BatchPreparedStatementExecutor {
return
baseStatementUnit
.
getStatement
().
executeBatch
();
}
}));
}
finally
{
MetricsContext
.
stop
(
context
);
}
}
private
int
[]
accumulate
(
final
List
<
int
[]>
results
)
{
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/prepared/PreparedStatementExecutor.java
浏览文件 @
097d4d8d
...
...
@@ -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
;
...
...
@@ -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
>()
{
return
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
;
}
/**
...
...
@@ -75,8 +66,6 @@ public final class PreparedStatementExecutor {
* @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
...
...
@@ -85,9 +74,6 @@ public final class PreparedStatementExecutor {
}
});
return
accumulate
(
results
);
}
finally
{
MetricsContext
.
stop
(
context
);
}
}
private
int
accumulate
(
final
List
<
Integer
>
results
)
{
...
...
@@ -104,8 +90,6 @@ public final class PreparedStatementExecutor {
* @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
...
...
@@ -117,8 +101,5 @@ public final class PreparedStatementExecutor {
return
false
;
}
return
result
.
get
(
0
);
}
finally
{
MetricsContext
.
stop
(
context
);
}
}
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/executor/type/statement/StatementExecutor.java
浏览文件 @
097d4d8d
...
...
@@ -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
;
...
...
@@ -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
>()
{
return
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
;
}
/**
...
...
@@ -133,8 +124,6 @@ public final class StatementExecutor {
}
private
int
executeUpdate
(
final
Updater
updater
)
{
Context
context
=
MetricsContext
.
start
(
"ShardingStatement-executeUpdate"
);
try
{
List
<
Integer
>
results
=
executorEngine
.
executeStatement
(
sqlType
,
statementUnits
,
new
ExecuteCallback
<
Integer
>()
{
@Override
...
...
@@ -143,9 +132,6 @@ public final class StatementExecutor {
}
});
return
accumulate
(
results
);
}
finally
{
MetricsContext
.
stop
(
context
);
}
}
private
int
accumulate
(
final
List
<
Integer
>
results
)
{
...
...
@@ -220,8 +206,6 @@ public final class StatementExecutor {
}
private
boolean
execute
(
final
Executor
executor
)
{
Context
context
=
MetricsContext
.
start
(
"ShardingStatement-execute"
);
try
{
List
<
Boolean
>
result
=
executorEngine
.
executeStatement
(
sqlType
,
statementUnits
,
new
ExecuteCallback
<
Boolean
>()
{
@Override
...
...
@@ -233,9 +217,6 @@ public final class StatementExecutor {
return
false
;
}
return
result
.
get
(
0
);
}
finally
{
MetricsContext
.
stop
(
context
);
}
}
private
interface
Updater
{
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/adapter/AbstractConnectionAdapter.java
浏览文件 @
097d4d8d
...
...
@@ -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
;
...
...
@@ -90,7 +89,6 @@ public abstract class AbstractConnectionAdapter extends AbstractUnsupportedOpera
@Override
public
void
close
()
throws
SQLException
{
closed
=
true
;
MetricsContext
.
clear
();
Collection
<
SQLException
>
exceptions
=
new
LinkedList
<>();
for
(
Connection
each
:
getConnections
())
{
try
{
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/connection/ShardingConnection.java
浏览文件 @
097d4d8d
...
...
@@ -17,16 +17,13 @@
package
com.dangdang.ddframe.rdb.sharding.jdbc.core.connection
;
import
com.codahale.metrics.Timer.Context
;
import
com.dangdang.ddframe.rdb.sharding.constant.SQLType
;
import
com.dangdang.ddframe.rdb.sharding.hint.HintManagerHolder
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.ShardingContext
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractConnectionAdapter
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.ShardingContext
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.datasource.MasterSlaveDataSource
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingPreparedStatement
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingStatement
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.datasource.MasterSlaveDataSource
;
import
com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Preconditions
;
import
lombok.Getter
;
...
...
@@ -65,7 +62,6 @@ public final class ShardingConnection extends AbstractConnectionAdapter {
* @throws SQLException SQL exception
*/
public
Collection
<
Connection
>
getConnectionForDDL
(
final
String
dataSourceName
)
throws
SQLException
{
final
Context
metricsContext
=
MetricsContext
.
start
(
Joiner
.
on
(
"-"
).
join
(
"ShardingConnection-getConnectionForDDL"
,
dataSourceName
));
DataSource
dataSource
=
shardingContext
.
getShardingRule
().
getDataSourceRule
().
getDataSource
(
dataSourceName
);
Preconditions
.
checkState
(
null
!=
dataSource
,
"Missing the rule of %s in DataSourceRule"
,
dataSourceName
);
Collection
<
DataSource
>
dataSources
=
new
LinkedList
<>();
...
...
@@ -81,7 +77,6 @@ public final class ShardingConnection extends AbstractConnectionAdapter {
replayMethodsInvocation
(
connection
);
result
.
add
(
connection
);
}
MetricsContext
.
stop
(
metricsContext
);
return
result
;
}
...
...
@@ -98,7 +93,6 @@ public final class ShardingConnection extends AbstractConnectionAdapter {
if
(
connection
.
isPresent
())
{
return
connection
.
get
();
}
Context
metricsContext
=
MetricsContext
.
start
(
Joiner
.
on
(
"-"
).
join
(
"ShardingConnection-getConnection"
,
dataSourceName
));
DataSource
dataSource
=
shardingContext
.
getShardingRule
().
getDataSourceRule
().
getDataSource
(
dataSourceName
);
Preconditions
.
checkState
(
null
!=
dataSource
,
"Missing the rule of %s in DataSourceRule"
,
dataSourceName
);
String
realDataSourceName
;
...
...
@@ -109,7 +103,6 @@ public final class ShardingConnection extends AbstractConnectionAdapter {
realDataSourceName
=
dataSourceName
;
}
Connection
result
=
dataSource
.
getConnection
();
MetricsContext
.
stop
(
metricsContext
);
connectionMap
.
put
(
realDataSourceName
,
result
);
replayMethodsInvocation
(
result
);
return
result
;
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/datasource/MasterSlaveDataSource.java
浏览文件 @
097d4d8d
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/core/datasource/ShardingDataSource.java
浏览文件 @
097d4d8d
...
...
@@ -26,7 +26,6 @@ import com.dangdang.ddframe.rdb.sharding.executor.ExecutorEngine;
import
com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractDataSourceAdapter
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.ShardingContext
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.connection.ShardingConnection
;
import
com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext
;
import
com.google.common.base.Preconditions
;
import
javax.sql.DataSource
;
...
...
@@ -84,7 +83,6 @@ public class ShardingDataSource extends AbstractDataSourceAdapter implements Aut
@Override
public
ShardingConnection
getConnection
()
throws
SQLException
{
MetricsContext
.
init
(
shardingProperties
);
return
new
ShardingConnection
(
shardingContext
);
}
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/metrics/MetricsContext.java
已删除
100644 → 0
浏览文件 @
10b085da
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.metrics
;
import
com.codahale.metrics.MetricRegistry
;
import
com.codahale.metrics.Slf4jReporter
;
import
com.codahale.metrics.Timer
;
import
com.dangdang.ddframe.rdb.sharding.config.ShardingProperties
;
import
com.dangdang.ddframe.rdb.sharding.config.ShardingPropertiesConstant
;
import
lombok.AccessLevel
;
import
lombok.NoArgsConstructor
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.TimeUnit
;
/**
* Metrics context.
*
* @author gaohongtao
* @author zhangliang
*/
@NoArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
final
class
MetricsContext
{
private
static
final
ThreadLocal
<
MetricRegistry
>
HOLDER
=
new
ThreadLocal
<>();
private
static
final
String
LOGGER_NAME
=
"Sharding-JDBC-Metrics"
;
/**
* Initialize metrics context holder.
*
* @param shardingProperties properties for Sharding-JDBC
*/
public
static
void
init
(
final
ShardingProperties
shardingProperties
)
{
HOLDER
.
remove
();
boolean
metricsEnabled
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_ENABLE
);
if
(!
metricsEnabled
)
{
return
;
}
long
period
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
);
MetricRegistry
metricRegistry
=
new
MetricRegistry
();
Slf4jReporter
.
forRegistry
(
metricRegistry
)
.
outputTo
(
LoggerFactory
.
getLogger
(
LOGGER_NAME
))
.
convertRatesTo
(
TimeUnit
.
SECONDS
)
.
convertDurationsTo
(
TimeUnit
.
MILLISECONDS
)
.
withLoggingLevel
(
Slf4jReporter
.
LoggingLevel
.
DEBUG
)
.
build
().
start
(
period
,
TimeUnit
.
MILLISECONDS
);
HOLDER
.
set
(
metricRegistry
);
}
/**
* Start timing.
*
* @param name Metrics target name
* @return timer context
*/
public
static
Timer
.
Context
start
(
final
String
name
)
{
return
null
==
HOLDER
.
get
()
?
null
:
HOLDER
.
get
().
timer
(
MetricRegistry
.
name
(
name
)).
time
();
}
/**
* Stop timing.
*
* @param context timer context
*/
public
static
void
stop
(
final
Timer
.
Context
context
)
{
if
(
null
!=
context
)
{
context
.
stop
();
}
}
/**
* Clear metrics context holder.
*/
public
static
void
clear
()
{
HOLDER
.
remove
();
}
}
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/DatabaseHintSQLRouter.java
浏览文件 @
097d4d8d
...
...
@@ -17,10 +17,8 @@
package
com.dangdang.ddframe.rdb.sharding.routing.router
;
import
com.codahale.metrics.Timer.Context
;
import
com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.ShardingContext
;
import
com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.SQLJudgeEngine
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.SQLStatement
;
import
com.dangdang.ddframe.rdb.sharding.routing.SQLExecutionUnit
;
...
...
@@ -56,13 +54,11 @@ public final class DatabaseHintSQLRouter implements SQLRouter {
@Override
// TODO insert SQL need parse gen key
public
SQLRouteResult
route
(
final
String
logicSQL
,
final
List
<
Object
>
parameters
,
final
SQLStatement
sqlStatement
)
{
Context
context
=
MetricsContext
.
start
(
"Route SQL"
);
SQLRouteResult
result
=
new
SQLRouteResult
(
sqlStatement
);
RoutingResult
routingResult
=
new
DatabaseHintRoutingEngine
(
shardingRule
.
getDataSourceRule
(),
shardingRule
.
getDatabaseShardingStrategy
()).
route
();
for
(
TableUnit
each
:
routingResult
.
getTableUnits
().
getTableUnits
())
{
result
.
getExecutionUnits
().
add
(
new
SQLExecutionUnit
(
each
.
getDataSourceName
(),
logicSQL
));
}
MetricsContext
.
stop
(
context
);
if
(
showSQL
)
{
SQLLogger
.
logSQL
(
logicSQL
,
sqlStatement
,
result
.
getExecutionUnits
(),
parameters
);
}
...
...
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/ParsingSQLRouter.java
浏览文件 @
097d4d8d
...
...
@@ -17,11 +17,9 @@
package
com.dangdang.ddframe.rdb.sharding.routing.router
;
import
com.codahale.metrics.Timer.Context
;
import
com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule
;
import
com.dangdang.ddframe.rdb.sharding.constant.DatabaseType
;
import
com.dangdang.ddframe.rdb.sharding.jdbc.core.ShardingContext
;
import
com.dangdang.ddframe.rdb.sharding.metrics.MetricsContext
;
import
com.dangdang.ddframe.rdb.sharding.parsing.SQLParsingEngine
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GeneratedKey
;
import
com.dangdang.ddframe.rdb.sharding.parsing.parser.sql.SQLStatement
;
...
...
@@ -70,18 +68,15 @@ public final class ParsingSQLRouter implements SQLRouter {
@Override
public
SQLStatement
parse
(
final
String
logicSQL
,
final
int
parametersSize
)
{
SQLParsingEngine
parsingEngine
=
new
SQLParsingEngine
(
databaseType
,
logicSQL
,
shardingRule
);
Context
context
=
MetricsContext
.
start
(
"Parse SQL"
);
SQLStatement
result
=
parsingEngine
.
parse
();
if
(
result
instanceof
InsertStatement
)
{
((
InsertStatement
)
result
).
appendGenerateKeyToken
(
shardingRule
,
parametersSize
);
}
MetricsContext
.
stop
(
context
);
return
result
;
}
@Override
public
SQLRouteResult
route
(
final
String
logicSQL
,
final
List
<
Object
>
parameters
,
final
SQLStatement
sqlStatement
)
{
final
Context
context
=
MetricsContext
.
start
(
"Route SQL"
);
SQLRouteResult
result
=
new
SQLRouteResult
(
sqlStatement
);
if
(
sqlStatement
instanceof
InsertStatement
&&
null
!=
((
InsertStatement
)
sqlStatement
).
getGeneratedKey
())
{
processGeneratedKey
(
parameters
,
(
InsertStatement
)
sqlStatement
,
result
);
...
...
@@ -104,7 +99,6 @@ public final class ParsingSQLRouter implements SQLRouter {
result
.
getExecutionUnits
().
add
(
new
SQLExecutionUnit
(
each
.
getDataSourceName
(),
rewriteEngine
.
generateSQL
(
each
,
sqlBuilder
)));
}
}
MetricsContext
.
stop
(
context
);
if
(
showSQL
)
{
SQLLogger
.
logSQL
(
logicSQL
,
sqlStatement
,
result
.
getExecutionUnits
(),
parameters
);
}
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/AllShardingTests.java
浏览文件 @
097d4d8d
...
...
@@ -25,7 +25,6 @@ import com.dangdang.ddframe.rdb.sharding.hint.AllHintTests;
import
com.dangdang.ddframe.rdb.sharding.jdbc.AllJDBCTests
;
import
com.dangdang.ddframe.rdb.sharding.keygen.AllKeygenTests
;
import
com.dangdang.ddframe.rdb.sharding.merger.AllMergerTests
;
import
com.dangdang.ddframe.rdb.sharding.metrics.AllMetricsTests
;
import
com.dangdang.ddframe.rdb.sharding.parsing.AllParsingTests
;
import
com.dangdang.ddframe.rdb.sharding.rewrite.AllRewriteTests
;
import
com.dangdang.ddframe.rdb.sharding.routing.AllRoutingTests
;
...
...
@@ -47,8 +46,7 @@ import org.junit.runners.Suite.SuiteClasses;
AllJDBCTests
.
class
,
AllHintTests
.
class
,
AllKeygenTests
.
class
,
AllUtilTests
.
class
,
AllMetricsTests
.
class
AllUtilTests
.
class
})
public
class
AllShardingTests
{
}
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesConstantTest.java
浏览文件 @
097d4d8d
...
...
@@ -27,7 +27,7 @@ public class ShardingPropertiesConstantTest {
@Test
public
void
testFindByKey
()
{
assertThat
(
ShardingPropertiesConstant
.
findByKey
(
"
metrics.enable"
),
is
(
ShardingPropertiesConstant
.
METRICS_ENABLE
));
assertThat
(
ShardingPropertiesConstant
.
findByKey
(
"
sql.show"
),
is
(
ShardingPropertiesConstant
.
SQL_SHOW
));
}
@Test
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/config/ShardingPropertiesTest.java
浏览文件 @
097d4d8d
...
...
@@ -34,9 +34,7 @@ public final class ShardingPropertiesTest {
@Before
public
void
setUp
()
{
prop
.
put
(
ShardingPropertiesConstant
.
METRICS_ENABLE
.
getKey
(),
"true"
);
prop
.
put
(
ShardingPropertiesConstant
.
SQL_SHOW
.
getKey
(),
"true"
);
prop
.
put
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
.
getKey
(),
"1000"
);
prop
.
put
(
ShardingPropertiesConstant
.
EXECUTOR_SIZE
.
getKey
(),
"10"
);
shardingProperties
=
new
ShardingProperties
(
prop
);
}
...
...
@@ -44,18 +42,14 @@ public final class ShardingPropertiesTest {
@Test
public
void
assertGetValueForDefaultValue
()
{
ShardingProperties
shardingProperties
=
new
ShardingProperties
(
new
Properties
());
boolean
actualMetricsEnabled
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_ENABLE
);
long
actualMetricsMillisecondsPeriod
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
);
assertThat
(
actualMetricsEnabled
,
is
(
Boolean
.
valueOf
(
ShardingPropertiesConstant
.
METRICS_ENABLE
.
getDefaultValue
())));
assertThat
(
actualMetricsMillisecondsPeriod
,
is
(
Long
.
valueOf
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
.
getDefaultValue
())));
boolean
actualSQLShow
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
SQL_SHOW
);
assertThat
(
actualSQLShow
,
is
(
Boolean
.
valueOf
(
ShardingPropertiesConstant
.
SQL_SHOW
.
getDefaultValue
())));
int
executorMaxSize
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
EXECUTOR_SIZE
);
assertThat
(
executorMaxSize
,
is
(
Integer
.
valueOf
(
ShardingPropertiesConstant
.
EXECUTOR_SIZE
.
getDefaultValue
())));
}
@Test
public
void
assertGetValueForBoolean
()
{
boolean
actualMetricsEnabled
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_ENABLE
);
assertTrue
(
actualMetricsEnabled
);
boolean
showSql
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
SQL_SHOW
);
assertTrue
(
showSql
);
}
...
...
@@ -66,17 +60,10 @@ public final class ShardingPropertiesTest {
assertThat
(
actualExecutorMaxSize
,
is
(
10
));
}
@Test
public
void
assertGetValueForLong
()
{
long
actualMetricsMillisecondsPeriod
=
shardingProperties
.
getValue
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
);
assertThat
(
actualMetricsMillisecondsPeriod
,
is
(
1000L
));
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
assertValidateFailure
()
{
Properties
prop
=
new
Properties
();
prop
.
put
(
ShardingPropertiesConstant
.
METRICS_ENABLE
.
getKey
(),
"error"
);
prop
.
put
(
ShardingPropertiesConstant
.
METRICS_MILLISECONDS_PERIOD
.
getKey
(),
"error"
);
prop
.
put
(
ShardingPropertiesConstant
.
SQL_SHOW
.
getKey
(),
"error"
);
prop
.
put
(
ShardingPropertiesConstant
.
EXECUTOR_SIZE
.
getKey
(),
"error"
);
prop
.
put
(
"other"
,
"other"
);
new
ShardingProperties
(
prop
);
...
...
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/metrics/AllMetricsTests.java
已删除
100644 → 0
浏览文件 @
10b085da
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.metrics
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
@RunWith
(
Suite
.
class
)
@Suite
.
SuiteClasses
(
MetricsContextTest
.
class
)
public
class
AllMetricsTests
{
}
sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/sharding/metrics/MetricsContextTest.java
已删除
100644 → 0
浏览文件 @
10b085da
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.metrics
;
import
com.dangdang.ddframe.rdb.sharding.config.ShardingProperties
;
import
com.dangdang.ddframe.rdb.sharding.config.ShardingPropertiesConstant
;
import
org.junit.After
;
import
org.junit.Test
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
public
final
class
MetricsContextTest
{
@After
public
void
tearDown
()
{
MetricsContext
.
clear
();
}
@Test
public
void
assertStartWhenMetricsDisable
()
{
initDisabledMetrics
();
assertNull
(
MetricsContext
.
start
(
"name"
));
}
@Test
public
void
assertStartWhenMetricsEnable
()
{
initEnabledMetrics
();
assertNotNull
(
MetricsContext
.
start
(
"name"
));
}
@Test
public
void
assertStopWhenMetricsDisable
()
{
initDisabledMetrics
();
MetricsContext
.
stop
(
null
);
}
@Test
public
void
assertStopWhenMetricsEnable
()
{
initEnabledMetrics
();
MetricsContext
.
stop
(
MetricsContext
.
start
(
"name"
));
}
@Test
public
void
assertClear
()
{
initEnabledMetrics
();
MetricsContext
.
clear
();
assertNull
(
MetricsContext
.
start
(
"name"
));
}
private
void
initDisabledMetrics
()
{
MetricsContext
.
init
(
new
ShardingProperties
(
new
Properties
()));
}
private
void
initEnabledMetrics
()
{
Properties
props
=
new
Properties
();
props
.
setProperty
(
ShardingPropertiesConstant
.
METRICS_ENABLE
.
getKey
(),
Boolean
.
TRUE
.
toString
());
MetricsContext
.
init
(
new
ShardingProperties
(
props
));
}
}
sharding-jdbc-core/src/test/resources/logback-test.xml
浏览文件 @
097d4d8d
...
...
@@ -9,9 +9,6 @@
<logger
name=
"com.dangdang"
level=
"info"
additivity=
"false"
>
<appender-ref
ref=
"console"
/>
</logger>
<logger
name=
"com.dangdang.ddframe.rdb.sharding.metrics"
level=
"info"
additivity=
"false"
>
<appender-ref
ref=
"console"
/>
</logger>
<logger
name=
"org.dbunit"
level=
"info"
additivity=
"false"
>
<appender-ref
ref=
"console"
/>
</logger>
...
...
sharding-jdbc-doc/content/01-start/features.md
浏览文件 @
097d4d8d
...
...
@@ -43,7 +43,6 @@ next = "/01-start/limitations/"
2.
2. YAML命名空间支持
2.
3. 基于动态语言的分片策略配置
3.
Metrics统计监控
## 性能
1.
半理解"理念的SQL解析引擎
...
...
sharding-jdbc-doc/content/02-guide/configuration.md
浏览文件 @
097d4d8d
...
...
@@ -67,7 +67,7 @@ defaultDatabaseStrategy:
algorithmClassName
:
com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm
props
:
metrics.enable
:
false
sql.show
:
false
```
...
...
@@ -111,13 +111,8 @@ defaultTableStrategy: 默认数据表分片策略
algorithmExpression
:
分表算法表达式,与algorithmClassName出现一个即可
props
:
属性配置(可选)
metrics.enable
:
是否开启度量采集,默认值
:
false
sql.show
:
是否开启SQL显示,默认值
:
false
metrics.millisecond.period
:
度量输出周期,单位
:
毫秒,默认值
:
30000毫秒
executor.min.idle.size
:
最小空闲工作线程数量,默认值
:
0
executor.max.size
:
最大工作线程数量,默认值
:
CPU核数乘2
executor.max.idle.timeout.millisecond
:
工作线程空闲时超时时间,单位
:
毫秒,默认值
:
60000毫秒
executor.size
:
工作线程数量,默认值
:
CPU核数
```
#### YAML格式特别说明
...
...
@@ -186,7 +181,7 @@ props: 属性配置(可选)
<rdb:default-database-strategy
sharding-columns=
"none"
algorithm-class=
"com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm"
/>
</rdb:sharding-rule>
<rdb:props>
<prop
key=
"
metrics.enable
"
>
true
</prop>
<prop
key=
"
sql.show
"
>
true
</prop>
</rdb:props>
</rdb:data-source>
</beans>
...
...
@@ -274,12 +269,8 @@ props: 属性配置(可选)
|
*名称*
|
*类型*
|
*数据类型*
|
*必填*
|
*说明*
|
| ------------------------------------ | ------------ | ---------- | ----- | ----------------------------------- |
| metrics.enable | 属性 | boolean | 否 | 是否开启度量采集,默认为false不开启 |
| sql.show | 属性 | boolean | 是 | 是否开启SQL显示,默认为false不开启 |
| metrics.millisecond.period | 属性 | String | 否 | 度量输出周期,单位为毫秒 |
| executor.min.idle.size | 属性 | int | 否 | 最小空闲工作线程数量 |
| executor.max.size | 属性 | int | 否 | 最大工作线程数量 |
| executor.max.idle.timeout.millisecond| 属性 | int | 否 | 工作线程空闲时超时时间,默认以毫秒为单位 |
| executor.size | 属性 | int | 否 | 最大工作线程数量 |
#### Spring格式特别说明
如需使用inline表达式,需配置ignore-unresolvable为true,否则placeholder会把inline表达式当成属性key值导致出错.
...
...
sharding-jdbc-example/sharding-jdbc-example-config-yaml/src/main/resources/META-INF/withAssignedDataSource.yaml
浏览文件 @
097d4d8d
...
...
@@ -49,4 +49,4 @@ defaultTableStrategy:
algorithmClassName
:
com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm
props
:
metrics.enable
:
false
sql.show
:
false
sharding-jdbc-example/sharding-jdbc-example-config-yaml/src/main/resources/META-INF/withDefaultDataSource.yaml
浏览文件 @
097d4d8d
...
...
@@ -33,4 +33,4 @@ defaultDatabaseStrategy:
algorithmExpression
:
ds_${user_id.longValue() % 2}
props
:
metrics.enable
:
false
sql.show
:
false
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录