Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
ab39cecb
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab39cecb
编写于
12月 26, 2019
作者:
Z
Zhang Yonglun
提交者:
wu-sheng
12月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shardingsphere 4.x RC1 RC2 test (#4118)
上级
30cbe38d
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
1592 addition
and
4 deletion
+1592
-4
.github/workflows/plugins-test.yaml
.github/workflows/plugins-test.yaml
+2
-0
apm-sniffer/apm-sdk-plugin/sharding-sphere-4.x-plugin/pom.xml
...sniffer/apm-sdk-plugin/sharding-sphere-4.x-plugin/pom.xml
+4
-3
test/plugin/scenarios/shardingsphere-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/Application.java
...e/skywalking/apm/testcase/shardingsphere/Application.java
+1
-1
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/bin/startup.sh
...narios/shardingsphere-4.x-RC1-RC2-scenario/bin/startup.sh
+21
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml
...rdingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml
+200
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/configuration.yml
...ios/shardingsphere-4.x-RC1-RC2-scenario/configuration.yml
+21
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/pom.xml
...gin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/pom.xml
+154
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/assembly/assembly.xml
...phere-4.x-RC1-RC2-scenario/src/main/assembly/assembly.xml
+41
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/Application.java
...e/skywalking/apm/testcase/shardingsphere/Application.java
+53
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/controller/CaseController.java
...pm/testcase/shardingsphere/controller/CaseController.java
+51
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/entity/Order.java
...apm/testcase/shardingsphere/service/api/entity/Order.java
+61
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/entity/OrderItem.java
...testcase/shardingsphere/service/api/entity/OrderItem.java
+71
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/CommonRepository.java
...ardingsphere/service/api/repository/CommonRepository.java
+38
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/OrderItemRepository.java
...ingsphere/service/api/repository/OrderItemRepository.java
+24
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/OrderRepository.java
...hardingsphere/service/api/repository/OrderRepository.java
+24
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/service/CommonService.java
...ase/shardingsphere/service/api/service/CommonService.java
+32
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/service/CommonServiceImpl.java
...shardingsphere/service/api/service/CommonServiceImpl.java
+108
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/config/ShardingDatabasesAndTablesConfigurationPrecise.java
...onfig/ShardingDatabasesAndTablesConfigurationPrecise.java
+76
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/jdbc/JDBCOrderItemRepositoryImpl.java
.../service/repository/jdbc/JDBCOrderItemRepositoryImpl.java
+130
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/jdbc/JDBCOrderRepositoryImpl.java
...here/service/repository/jdbc/JDBCOrderRepositoryImpl.java
+127
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/service/RawPojoService.java
...dingsphere/service/repository/service/RawPojoService.java
+59
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/PreciseModuloShardingDatabaseAlgorithm.java
...ity/algorithm/PreciseModuloShardingDatabaseAlgorithm.java
+37
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/PreciseModuloShardingTableAlgorithm.java
...tility/algorithm/PreciseModuloShardingTableAlgorithm.java
+37
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/RangeModuloShardingDatabaseAlgorithm.java
...ility/algorithm/RangeModuloShardingDatabaseAlgorithm.java
+53
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/RangeModuloShardingTableAlgorithm.java
.../utility/algorithm/RangeModuloShardingTableAlgorithm.java
+45
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/config/DataSourceUtil.java
...shardingsphere/service/utility/config/DataSourceUtil.java
+57
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/config/ExampleConfiguration.java
...ngsphere/service/utility/config/ExampleConfiguration.java
+29
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/resources/application.properties
...C1-RC2-scenario/src/main/resources/application.properties
+18
-0
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/support-version.list
.../shardingsphere-4.x-RC1-RC2-scenario/support-version.list
+18
-0
未找到文件。
.github/workflows/plugins-test.yaml
浏览文件 @
ab39cecb
...
...
@@ -322,6 +322,8 @@ jobs:
run
:
bash test/plugin/run.sh redisson-scenario
-
name
:
Run shardingsphere-3.x-scenario 3.0.0 (1)
run
:
bash test/plugin/run.sh shardingsphere-3.x-scenario
-
name
:
Run shardingsphere-4.x-RC1-RC2-scenario 4.0.0-RC1-4.0.0-RC2 (2)
run
:
bash test/plugin/run.sh shardingsphere-4.x-RC1-RC2-scenario
-
name
:
Run zookeeper 3.4.x (14)
run
:
bash test/plugin/run.sh zookeeper-scenario
...
...
apm-sniffer/apm-sdk-plugin/sharding-sphere-4.x-plugin/pom.xml
浏览文件 @
ab39cecb
...
...
@@ -33,6 +33,7 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<shardingsphere.version>
[4.0.0-RC1, 4.0.0-RC2]
</shardingsphere.version>
</properties>
<dependencies>
...
...
@@ -45,19 +46,19 @@
<dependency>
<groupId>
org.apache.shardingsphere
</groupId>
<artifactId>
sharding-core-execute
</artifactId>
<version>
4.0.0-RC2
</version>
<version>
${shardingsphere.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.shardingsphere
</groupId>
<artifactId>
sharding-jdbc-core
</artifactId>
<version>
4.0.0-RC2
</version>
<version>
${shardingsphere.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.shardingsphere
</groupId>
<artifactId>
sharding-proxy-frontend-core
</artifactId>
<version>
4.0.0-RC2
</version>
<version>
${shardingsphere.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
...
...
test/plugin/scenarios/shardingsphere-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/Application.java
浏览文件 @
ab39cecb
...
...
@@ -41,9 +41,9 @@ public class Application extends SpringBootServletInitializer {
DataSourceUtil
.
createDataSource
(
"demo_ds_0"
);
DataSourceUtil
.
createDataSource
(
"demo_ds_1"
);
DataSource
dataSource
=
new
ShardingDatabasesAndTablesConfigurationPrecise
().
createDataSource
();
SpringApplication
.
run
(
Application
.
class
,
args
);
CommonService
commonService
=
new
RawPojoService
(
new
JDBCOrderRepositoryImpl
(
dataSource
),
new
JDBCOrderItemRepositoryImpl
(
dataSource
));
commonService
.
initEnvironment
();
SpringApplication
.
run
(
Application
.
class
,
args
);
}
catch
(
Exception
e
)
{
// Never do this
}
...
...
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/bin/startup.sh
0 → 100644
浏览文件 @
ab39cecb
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
home
=
"
$(
cd
"
$(
dirname
$0
)
"
;
pwd
)
"
java
-jar
${
agent_opts
}
${
home
}
/../libs/shardingsphere-4.x-RC1-RC2-scenario.jar &
\ No newline at end of file
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml
0 → 100644
浏览文件 @
ab39cecb
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
registryItems
:
applications
:
-
{
shardingsphere-4.x-RC1-RC2-scenario
:
nq 0
}
instances
:
-
{
shardingsphere-4.x-RC1-RC2-scenario
:
1
}
operationNames
:
-
shardingsphere-4.x-RC1-RC2-scenario
:
[
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
]
heartbeat
:
[]
segmentItems
:
-
applicationCode
:
shardingsphere-4.x-RC1-RC2-scenario
segmentSize
:
not
null
segments
:
-
segmentId
:
not
null
spans
:
-
operationName
:
H2/JDBI/PreparedStatement/executeQuery
operationId
:
0
parentSpanId
:
0
spanId
:
1
spanLayer
:
Database
startTime
:
not
null
endTime
:
not
null
componentId
:
32
componentName
:
'
'
isError
:
false
spanType
:
Exit
peer
:
localhost:-1
peerId
:
0
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
demo_ds_1
}
-
{
key
:
db.statement
,
value
:
SELECT * FROM t_order_1
}
-
operationName
:
/ShardingSphere/executeSQL/
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Unknown
startTime
:
not
null
endTime
:
not
null
componentId
:
60
componentName
:
'
'
isError
:
false
spanType
:
Local
peer
:
'
'
peerId
:
0
refs
:
-
{
parentEndpointId
:
0
,
parentEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
networkAddressId
:
0
,
entryEndpointId
:
0
,
refType
:
CrossThread
,
parentSpanId
:
2
,
parentTraceSegmentId
:
nq 0
,
parentServiceInstanceId
:
1
,
networkAddress
:
'
'
,
entryEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
entryServiceInstanceId
:
1
}
-
segmentId
:
not
null
spans
:
-
operationName
:
H2/JDBI/PreparedStatement/executeQuery
operationId
:
0
parentSpanId
:
0
spanId
:
1
spanLayer
:
Database
startTime
:
not
null
endTime
:
not
null
componentId
:
32
componentName
:
'
'
isError
:
false
spanType
:
Exit
peer
:
localhost:-1
peerId
:
0
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
demo_ds_0
}
-
{
key
:
db.statement
,
value
:
SELECT * FROM t_order_1
}
-
operationName
:
/ShardingSphere/executeSQL/
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Unknown
startTime
:
not
null
endTime
:
not
null
componentId
:
60
componentName
:
'
'
isError
:
false
spanType
:
Local
peer
:
'
'
peerId
:
0
refs
:
-
{
parentEndpointId
:
0
,
parentEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
networkAddressId
:
0
,
entryEndpointId
:
0
,
refType
:
CrossThread
,
parentSpanId
:
2
,
parentTraceSegmentId
:
nq 0
,
parentServiceInstanceId
:
1
,
networkAddress
:
'
'
,
entryEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
entryServiceInstanceId
:
1
}
-
segmentId
:
not
null
spans
:
-
operationName
:
H2/JDBI/PreparedStatement/executeQuery
operationId
:
0
parentSpanId
:
0
spanId
:
1
spanLayer
:
Database
startTime
:
not
null
endTime
:
not
null
componentId
:
32
componentName
:
'
'
isError
:
false
spanType
:
Exit
peer
:
localhost:-1
peerId
:
0
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
demo_ds_1
}
-
{
key
:
db.statement
,
value
:
SELECT * FROM t_order_0
}
-
operationName
:
/ShardingSphere/executeSQL/
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Unknown
startTime
:
not
null
endTime
:
not
null
componentId
:
60
componentName
:
'
'
isError
:
false
spanType
:
Local
peer
:
'
'
peerId
:
0
refs
:
-
{
parentEndpointId
:
0
,
parentEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
networkAddressId
:
0
,
entryEndpointId
:
0
,
refType
:
CrossThread
,
parentSpanId
:
2
,
parentTraceSegmentId
:
nq 0
,
parentServiceInstanceId
:
1
,
networkAddress
:
'
'
,
entryEndpoint
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
,
entryServiceInstanceId
:
1
}
-
segmentId
:
not
null
spans
:
-
operationName
:
/ShardingSphere/parseSQL/
operationId
:
0
parentSpanId
:
0
spanId
:
1
spanLayer
:
Unknown
startTime
:
not
null
endTime
:
not
null
componentId
:
60
componentName
:
'
'
isError
:
false
spanType
:
Local
peer
:
'
'
peerId
:
0
tags
:
-
{
key
:
db.statement
,
value
:
SELECT * FROM t_order
}
-
operationName
:
H2/JDBI/PreparedStatement/executeQuery
operationId
:
0
parentSpanId
:
3
spanId
:
4
spanLayer
:
Database
startTime
:
not
null
endTime
:
not
null
componentId
:
32
componentName
:
'
'
isError
:
false
spanType
:
Exit
peer
:
localhost:-1
peerId
:
0
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
demo_ds_0
}
-
{
key
:
db.statement
,
value
:
SELECT * FROM t_order_0
}
-
{
operationName
:
/ShardingSphere/executeSQL/
,
operationId
:
0
,
parentSpanId
:
2
,
spanId
:
3
,
spanLayer
:
Unknown
,
startTime
:
not null
,
endTime
:
not null
,
componentId
:
60
,
componentName
:
'
'
,
isError
:
false
,
spanType
:
Local
,
peer
:
'
'
,
peerId
:
0
}
-
{
operationName
:
/ShardingSphere/JDBCRootInvoke/
,
operationId
:
0
,
parentSpanId
:
0
,
spanId
:
2
,
spanLayer
:
Unknown
,
startTime
:
not null
,
endTime
:
not null
,
componentId
:
60
,
componentName
:
'
'
,
isError
:
false
,
spanType
:
Local
,
peer
:
'
'
,
peerId
:
0
}
-
operationName
:
/shardingsphere-4.x-RC1-RC2-scenario/case/execute
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Http
startTime
:
not
null
endTime
:
not
null
componentId
:
1
componentName
:
'
'
isError
:
false
spanType
:
Entry
peer
:
'
'
peerId
:
0
tags
:
-
{
key
:
url
,
value
:
'
http://localhost:8080/shardingsphere-4.x-RC1-RC2-scenario/case/execute'
}
-
{
key
:
http.method
,
value
:
GET
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/configuration.yml
0 → 100644
浏览文件 @
ab39cecb
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
type
:
jvm
entryService
:
http://localhost:8080/shardingsphere-4.x-RC1-RC2-scenario/case/execute
healthCheck
:
http://localhost:8080/shardingsphere-4.x-RC1-RC2-scenario/case/healthCheck
startScript
:
./bin/startup.sh
framework
:
ShardingSphere
\ No newline at end of file
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/pom.xml
0 → 100644
浏览文件 @
ab39cecb
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You 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.
~
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
shardingsphere-4.x-RC1-RC2-scenario
</artifactId>
<version>
5.0.0
</version>
<name>
skywalking-shardingsphere-4.x-RC1-RC2-scenario
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<test.framework.version>
4.0.0-RC1
</test.framework.version>
<log4j.version>
2.6.2
</log4j.version>
<spring.version>
4.3.8.RELEASE
</spring.version>
<spring-boot-version>
1.5.2.RELEASE
</spring-boot-version>
</properties>
<dependencies>
<dependency>
<groupId>
org.apache.shardingsphere
</groupId>
<artifactId>
sharding-core-execute
</artifactId>
<version>
${test.framework.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.shardingsphere
</groupId>
<artifactId>
sharding-jdbc-core
</artifactId>
<version>
${test.framework.version}
</version>
</dependency>
<dependency>
<groupId>
commons-dbcp
</groupId>
<artifactId>
commons-dbcp
</artifactId>
<version>
1.4
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
<version>
${spring-boot-version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-api
</artifactId>
<version>
${log4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
${log4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-slf4j-impl
</artifactId>
<version>
${log4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-jcl
</artifactId>
<version>
${log4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-tomcat
</artifactId>
<version>
${spring-boot-version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
${spring-boot-version}
</version>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
1.4.196
</version>
</dependency>
</dependencies>
<build>
<finalName>
shardingsphere-4.x-RC1-RC2-scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.6.0
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
1.5.9.RELEASE
</version>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<executions>
<execution>
<id>
assemble
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
src/main/assembly/assembly.xml
</descriptor>
</descriptors>
<outputDirectory>
./target/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>
spring-snapshots
</id>
<url>
http://repo.spring.io/snapshot
</url>
</pluginRepository>
<pluginRepository>
<id>
spring-milestones
</id>
<url>
http://repo.spring.io/milestone
</url>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/assembly/assembly.xml
0 → 100644
浏览文件 @
ab39cecb
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You 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.
~
-->
<assembly
xmlns=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"
>
<formats>
<format>
zip
</format>
</formats>
<fileSets>
<fileSet>
<directory>
./bin
</directory>
<fileMode>
0775
</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>
${project.build.directory}/shardingsphere-4.x-RC1-RC2-scenario.jar
</source>
<outputDirectory>
./libs
</outputDirectory>
<fileMode>
0775
</fileMode>
</file>
</files>
</assembly>
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/Application.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.service.CommonService
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.config.ShardingDatabasesAndTablesConfigurationPrecise
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderItemRepositoryImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderRepositoryImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.service.RawPojoService
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.config.DataSourceUtil
;
import
javax.sql.DataSource
;
@SpringBootApplication
public
class
Application
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
{
try
{
DataSourceUtil
.
createDataSource
(
""
);
DataSourceUtil
.
createSchema
(
"demo_ds_0"
);
DataSourceUtil
.
createSchema
(
"demo_ds_1"
);
DataSourceUtil
.
createDataSource
(
"demo_ds_0"
);
DataSourceUtil
.
createDataSource
(
"demo_ds_1"
);
DataSource
dataSource
=
new
ShardingDatabasesAndTablesConfigurationPrecise
().
createDataSource
();
CommonService
commonService
=
new
RawPojoService
(
new
JDBCOrderRepositoryImpl
(
dataSource
),
new
JDBCOrderItemRepositoryImpl
(
dataSource
));
commonService
.
initEnvironment
();
SpringApplication
.
run
(
Application
.
class
,
args
);
}
catch
(
Exception
e
)
{
// Never do this
}
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/controller/CaseController.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.controller
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.service.CommonService
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.config.ShardingDatabasesAndTablesConfigurationPrecise
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderItemRepositoryImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderRepositoryImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.service.RawPojoService
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
@RestController
@RequestMapping
(
"/case"
)
public
class
CaseController
{
@RequestMapping
(
"/healthCheck"
)
@ResponseBody
public
String
healthCheck
()
{
return
"Success"
;
}
@RequestMapping
(
"/execute"
)
@ResponseBody
public
String
execute
()
throws
SQLException
{
DataSource
dataSource
=
new
ShardingDatabasesAndTablesConfigurationPrecise
().
getDataSource
();
CommonService
commonService
=
new
RawPojoService
(
new
JDBCOrderRepositoryImpl
(
dataSource
),
new
JDBCOrderItemRepositoryImpl
(
dataSource
));
commonService
.
processSuccess
(
false
);
return
"Success"
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/entity/Order.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity
;
import
java.io.Serializable
;
public
class
Order
implements
Serializable
{
private
static
final
long
serialVersionUID
=
661434701950670670L
;
private
long
orderId
;
private
int
userId
;
private
String
status
;
public
long
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
final
long
orderId
)
{
this
.
orderId
=
orderId
;
}
public
int
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
final
int
userId
)
{
this
.
userId
=
userId
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
final
String
status
)
{
this
.
status
=
status
;
}
@Override
public
String
toString
()
{
return
String
.
format
(
"order_id: %s, user_id: %s, status: %s"
,
orderId
,
userId
,
status
);
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/entity/OrderItem.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity
;
import
java.io.Serializable
;
public
class
OrderItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
263434701950670170L
;
private
long
orderItemId
;
private
long
orderId
;
private
int
userId
;
private
String
status
;
public
long
getOrderItemId
()
{
return
orderItemId
;
}
public
void
setOrderItemId
(
final
long
orderItemId
)
{
this
.
orderItemId
=
orderItemId
;
}
public
long
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
final
long
orderId
)
{
this
.
orderId
=
orderId
;
}
public
int
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
final
int
userId
)
{
this
.
userId
=
userId
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
final
String
status
)
{
this
.
status
=
status
;
}
@Override
public
String
toString
()
{
return
String
.
format
(
"order_item_id:%s, order_id: %s, user_id: %s, status: %s"
,
orderItemId
,
orderId
,
userId
,
status
);
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/CommonRepository.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository
;
import
java.util.List
;
public
interface
CommonRepository
<
T
>
{
void
createTableIfNotExists
();
void
dropTable
();
void
truncateTable
();
Long
insert
(
T
entity
);
void
delete
(
Long
id
);
List
<
T
>
selectAll
();
List
<
T
>
selectRange
();
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/OrderItemRepository.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.OrderItem
;
public
interface
OrderItemRepository
extends
CommonRepository
<
OrderItem
>
{
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/repository/OrderRepository.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.Order
;
public
interface
OrderRepository
extends
CommonRepository
<
Order
>
{
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/service/CommonService.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.service
;
public
interface
CommonService
{
void
initEnvironment
();
void
cleanEnvironment
();
void
processSuccess
(
boolean
isRangeSharding
);
void
processFailure
();
void
printData
(
boolean
isRangeSharding
);
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/api/service/CommonServiceImpl.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.api.service
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.Order
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.OrderItem
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderItemRepository
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderRepository
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
CommonServiceImpl
implements
CommonService
{
@Override
public
void
initEnvironment
()
{
getOrderRepository
().
createTableIfNotExists
();
getOrderItemRepository
().
createTableIfNotExists
();
getOrderRepository
().
truncateTable
();
getOrderItemRepository
().
truncateTable
();
insertData
();
}
@Override
public
void
cleanEnvironment
()
{
getOrderRepository
().
dropTable
();
getOrderItemRepository
().
dropTable
();
}
@Override
public
void
processSuccess
(
final
boolean
isRangeSharding
)
{
printData
(
isRangeSharding
);
}
@Override
public
void
processFailure
()
{
insertData
();
throw
new
RuntimeException
(
"Exception occur for transaction test."
);
}
private
List
<
Long
>
insertData
()
{
List
<
Long
>
result
=
new
ArrayList
<>(
10
);
for
(
int
i
=
1
;
i
<=
10
;
i
++)
{
Order
order
=
newOrder
();
order
.
setUserId
(
i
);
order
.
setStatus
(
"INSERT_TEST"
);
getOrderRepository
().
insert
(
order
);
OrderItem
item
=
newOrderItem
();
item
.
setOrderId
(
order
.
getOrderId
());
item
.
setUserId
(
i
);
item
.
setStatus
(
"INSERT_TEST"
);
getOrderItemRepository
().
insert
(
item
);
result
.
add
(
order
.
getOrderId
());
}
return
result
;
}
private
void
deleteData
(
final
List
<
Long
>
orderIds
)
{
for
(
Long
each
:
orderIds
)
{
getOrderRepository
().
delete
(
each
);
getOrderItemRepository
().
delete
(
each
);
}
}
@Override
public
void
printData
(
final
boolean
isRangeSharding
)
{
if
(
isRangeSharding
)
{
printDataRange
();
}
else
{
printDataAll
();
}
}
private
void
printDataRange
()
{
for
(
Object
each
:
getOrderRepository
().
selectRange
())
{
}
for
(
Object
each
:
getOrderItemRepository
().
selectRange
())
{
}
}
private
void
printDataAll
()
{
for
(
Object
each
:
getOrderRepository
().
selectAll
())
{
}
}
protected
abstract
OrderRepository
getOrderRepository
();
protected
abstract
OrderItemRepository
getOrderItemRepository
();
protected
abstract
Order
newOrder
();
protected
abstract
OrderItem
newOrderItem
();
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/config/ShardingDatabasesAndTablesConfigurationPrecise.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.config
;
import
org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.strategy.InlineShardingStrategyConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingStrategyConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.algorithm.PreciseModuloShardingTableAlgorithm
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.config.DataSourceUtil
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.config.ExampleConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
public
final
class
ShardingDatabasesAndTablesConfigurationPrecise
implements
ExampleConfiguration
{
private
static
DataSource
dataSource
;
@Override
public
DataSource
createDataSource
()
throws
SQLException
{
ShardingRuleConfiguration
shardingRuleConfig
=
new
ShardingRuleConfiguration
();
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
InlineShardingStrategyConfiguration
(
"user_id"
,
"demo_ds_${user_id % 2}"
));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"max.connections.size.per.query"
,
"16"
);
dataSource
=
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
properties
);
return
dataSource
;
}
@Override
public
DataSource
getDataSource
()
{
return
dataSource
;
}
private
static
TableRuleConfiguration
getOrderTableRuleConfiguration
()
{
TableRuleConfiguration
result
=
new
TableRuleConfiguration
(
"t_order"
,
"demo_ds_${0..1}.t_order_${[0, 1]}"
);
result
.
setKeyGeneratorConfig
(
new
KeyGeneratorConfiguration
(
"SNOWFLAKE"
,
"order_id"
));
return
result
;
}
private
static
TableRuleConfiguration
getOrderItemTableRuleConfiguration
()
{
TableRuleConfiguration
result
=
new
TableRuleConfiguration
(
"t_order_item"
,
"demo_ds_${0..1}.t_order_item_${[0, 1]}"
);
return
result
;
}
private
static
Map
<
String
,
DataSource
>
createDataSourceMap
()
{
Map
<
String
,
DataSource
>
result
=
new
HashMap
<>();
result
.
put
(
"demo_ds_0"
,
DataSourceUtil
.
getDataSource
(
"demo_ds_0"
));
result
.
put
(
"demo_ds_1"
,
DataSourceUtil
.
getDataSource
(
"demo_ds_1"
));
return
result
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/jdbc/JDBCOrderItemRepositoryImpl.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.OrderItem
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderItemRepository
;
import
javax.sql.DataSource
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.LinkedList
;
import
java.util.List
;
public
final
class
JDBCOrderItemRepositoryImpl
implements
OrderItemRepository
{
private
final
DataSource
dataSource
;
public
JDBCOrderItemRepositoryImpl
(
final
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
void
createTableIfNotExists
()
{
String
sql
=
"CREATE TABLE IF NOT EXISTS t_order_item "
+
"(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_item_id))"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
void
dropTable
()
{
String
sql
=
"DROP TABLE t_order_item"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
void
truncateTable
()
{
String
sql
=
"TRUNCATE TABLE t_order_item"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
Long
insert
(
final
OrderItem
orderItem
)
{
String
sql
=
"INSERT INTO t_order_item (order_id, user_id, status) VALUES (?, ?, ?)"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
))
{
preparedStatement
.
setLong
(
1
,
orderItem
.
getOrderId
());
preparedStatement
.
setInt
(
2
,
orderItem
.
getUserId
());
preparedStatement
.
setString
(
3
,
orderItem
.
getStatus
());
preparedStatement
.
executeUpdate
();
try
(
ResultSet
resultSet
=
preparedStatement
.
getGeneratedKeys
())
{
if
(
resultSet
.
next
())
{
orderItem
.
setOrderItemId
(
resultSet
.
getLong
(
1
));
}
}
}
catch
(
final
SQLException
ignored
)
{
}
return
orderItem
.
getOrderItemId
();
}
@Override
public
void
delete
(
final
Long
orderItemId
)
{
String
sql
=
"DELETE FROM t_order_item WHERE order_item_id=?"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
))
{
preparedStatement
.
setLong
(
1
,
orderItemId
);
preparedStatement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
List
<
OrderItem
>
selectAll
()
{
String
sql
=
"SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id"
;
return
getOrderItems
(
sql
);
}
@Override
public
List
<
OrderItem
>
selectRange
()
{
String
sql
=
"SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id AND o.user_id BETWEEN 1 AND 5"
;
return
getOrderItems
(
sql
);
}
private
List
<
OrderItem
>
getOrderItems
(
final
String
sql
)
{
List
<
OrderItem
>
result
=
new
LinkedList
<>();
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
ResultSet
resultSet
=
preparedStatement
.
executeQuery
())
{
while
(
resultSet
.
next
())
{
OrderItem
orderItem
=
new
OrderItem
();
orderItem
.
setOrderItemId
(
resultSet
.
getLong
(
1
));
orderItem
.
setOrderId
(
resultSet
.
getLong
(
2
));
orderItem
.
setUserId
(
resultSet
.
getInt
(
3
));
orderItem
.
setStatus
(
resultSet
.
getString
(
4
));
result
.
add
(
orderItem
);
}
}
catch
(
final
SQLException
ignored
)
{
}
return
result
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/jdbc/JDBCOrderRepositoryImpl.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.Order
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderRepository
;
import
javax.sql.DataSource
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.LinkedList
;
import
java.util.List
;
public
final
class
JDBCOrderRepositoryImpl
implements
OrderRepository
{
private
final
DataSource
dataSource
;
public
JDBCOrderRepositoryImpl
(
final
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
void
createTableIfNotExists
()
{
String
sql
=
"CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT NULL AUTO_INCREMENT, user_id INT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id))"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
void
dropTable
()
{
String
sql
=
"DROP TABLE t_order"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
void
truncateTable
()
{
String
sql
=
"TRUNCATE TABLE t_order"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
executeUpdate
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
Long
insert
(
final
Order
order
)
{
String
sql
=
"INSERT INTO t_order (user_id, status) VALUES (?, ?)"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
))
{
preparedStatement
.
setInt
(
1
,
order
.
getUserId
());
preparedStatement
.
setString
(
2
,
order
.
getStatus
());
preparedStatement
.
executeUpdate
();
try
(
ResultSet
resultSet
=
preparedStatement
.
getGeneratedKeys
())
{
if
(
resultSet
.
next
())
{
order
.
setOrderId
(
resultSet
.
getLong
(
1
));
}
}
}
catch
(
final
SQLException
ignored
)
{
}
return
order
.
getOrderId
();
}
@Override
public
void
delete
(
final
Long
orderId
)
{
String
sql
=
"DELETE FROM t_order WHERE order_id=?"
;
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
))
{
preparedStatement
.
setLong
(
1
,
orderId
);
preparedStatement
.
executeUpdate
();
}
catch
(
final
SQLException
ignored
)
{
}
}
@Override
public
List
<
Order
>
selectAll
()
{
String
sql
=
"SELECT * FROM t_order"
;
return
getOrders
(
sql
);
}
@Override
public
List
<
Order
>
selectRange
()
{
String
sql
=
"SELECT * FROM t_order WHERE order_id BETWEEN 200000000000000000 AND 400000000000000000"
;
return
getOrders
(
sql
);
}
private
List
<
Order
>
getOrders
(
final
String
sql
)
{
List
<
Order
>
result
=
new
LinkedList
<>();
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
ResultSet
resultSet
=
preparedStatement
.
executeQuery
())
{
while
(
resultSet
.
next
())
{
Order
order
=
new
Order
();
order
.
setOrderId
(
resultSet
.
getLong
(
1
));
order
.
setUserId
(
resultSet
.
getInt
(
2
));
order
.
setStatus
(
resultSet
.
getString
(
3
));
result
.
add
(
order
);
}
}
catch
(
final
SQLException
ignored
)
{
}
return
result
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/repository/service/RawPojoService.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.service
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.Order
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.entity.OrderItem
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderItemRepository
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.repository.OrderRepository
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.api.service.CommonServiceImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderItemRepositoryImpl
;
import
org.apache.skywalking.apm.testcase.shardingsphere.service.repository.jdbc.JDBCOrderRepositoryImpl
;
public
class
RawPojoService
extends
CommonServiceImpl
{
private
final
OrderRepository
orderRepository
;
private
final
OrderItemRepository
orderItemRepository
;
public
RawPojoService
(
final
JDBCOrderRepositoryImpl
orderRepository
,
final
JDBCOrderItemRepositoryImpl
orderItemRepository
)
{
this
.
orderRepository
=
orderRepository
;
this
.
orderItemRepository
=
orderItemRepository
;
}
@Override
protected
OrderRepository
getOrderRepository
()
{
return
orderRepository
;
}
@Override
protected
OrderItemRepository
getOrderItemRepository
()
{
return
orderItemRepository
;
}
@Override
protected
Order
newOrder
()
{
return
new
Order
();
}
@Override
protected
OrderItem
newOrderItem
()
{
return
new
OrderItem
();
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/PreciseModuloShardingDatabaseAlgorithm.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.algorithm
;
import
org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm
;
import
org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue
;
import
java.util.Collection
;
public
class
PreciseModuloShardingDatabaseAlgorithm
implements
PreciseShardingAlgorithm
<
Integer
>
{
@Override
public
String
doSharding
(
final
Collection
<
String
>
databaseNames
,
final
PreciseShardingValue
<
Integer
>
shardingValue
)
{
for
(
String
each
:
databaseNames
)
{
if
(
each
.
endsWith
(
shardingValue
.
getValue
()
%
2
+
""
))
{
return
each
;
}
}
throw
new
UnsupportedOperationException
();
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/PreciseModuloShardingTableAlgorithm.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.algorithm
;
import
org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm
;
import
org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue
;
import
java.util.Collection
;
public
class
PreciseModuloShardingTableAlgorithm
implements
PreciseShardingAlgorithm
<
Long
>
{
@Override
public
String
doSharding
(
final
Collection
<
String
>
tableNames
,
final
PreciseShardingValue
<
Long
>
shardingValue
)
{
for
(
String
each
:
tableNames
)
{
if
(
each
.
endsWith
(
shardingValue
.
getValue
()
%
2
+
""
))
{
return
each
;
}
}
throw
new
UnsupportedOperationException
();
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/RangeModuloShardingDatabaseAlgorithm.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.algorithm
;
import
com.google.common.collect.Range
;
import
org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm
;
import
org.apache.shardingsphere.api.sharding.standard.RangeShardingValue
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
public
class
RangeModuloShardingDatabaseAlgorithm
implements
RangeShardingAlgorithm
<
Integer
>
{
@Override
public
Collection
<
String
>
doSharding
(
final
Collection
<
String
>
databaseNames
,
final
RangeShardingValue
<
Integer
>
shardingValue
)
{
Set
<
String
>
result
=
new
LinkedHashSet
<>();
if
(
Range
.
closed
(
1
,
5
).
encloses
(
shardingValue
.
getValueRange
()))
{
for
(
String
each
:
databaseNames
)
{
if
(
each
.
endsWith
(
"0"
))
{
result
.
add
(
each
);
}
}
}
else
if
(
Range
.
closed
(
6
,
10
).
encloses
(
shardingValue
.
getValueRange
()))
{
for
(
String
each
:
databaseNames
)
{
if
(
each
.
endsWith
(
"1"
))
{
result
.
add
(
each
);
}
}
}
else
if
(
Range
.
closed
(
1
,
10
).
encloses
(
shardingValue
.
getValueRange
()))
{
result
.
addAll
(
databaseNames
);
}
else
{
throw
new
UnsupportedOperationException
();
}
return
result
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/algorithm/RangeModuloShardingTableAlgorithm.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.algorithm
;
import
com.google.common.collect.Range
;
import
org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm
;
import
org.apache.shardingsphere.api.sharding.standard.RangeShardingValue
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
public
class
RangeModuloShardingTableAlgorithm
implements
RangeShardingAlgorithm
<
Long
>
{
@Override
public
Collection
<
String
>
doSharding
(
final
Collection
<
String
>
tableNames
,
final
RangeShardingValue
<
Long
>
shardingValue
)
{
Set
<
String
>
result
=
new
LinkedHashSet
<>();
if
(
Range
.
closed
(
200000000000000000L
,
400000000000000000L
).
encloses
(
shardingValue
.
getValueRange
()))
{
for
(
String
each
:
tableNames
)
{
if
(
each
.
endsWith
(
"0"
))
{
result
.
add
(
each
);
}
}
}
else
{
throw
new
UnsupportedOperationException
();
}
return
result
;
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/config/DataSourceUtil.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.config
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
javax.sql.DataSource
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
DataSourceUtil
{
private
static
final
String
DEFAULT_SCHEMA
=
""
;
private
static
final
Map
<
String
,
DataSource
>
datasourceMap
=
new
HashMap
<>();
public
static
void
createDataSource
(
final
String
dataSourceName
)
{
BasicDataSource
result
=
new
BasicDataSource
();
result
.
setDriverClassName
(
"org.h2.Driver"
);
result
.
setUrl
(
String
.
format
(
"jdbc:h2:mem:%s"
,
dataSourceName
));
result
.
setUsername
(
"sa"
);
result
.
setPassword
(
""
);
datasourceMap
.
put
(
dataSourceName
,
result
);
}
public
static
DataSource
getDataSource
(
final
String
dataSourceName
)
{
return
datasourceMap
.
get
(
dataSourceName
);
}
public
static
void
createSchema
(
final
String
dataSourceName
)
{
String
sql
=
"CREATE SCHEMA "
+
dataSourceName
;
try
(
Connection
connection
=
getDataSource
(
DEFAULT_SCHEMA
).
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
sql
);
}
catch
(
final
SQLException
ignored
)
{
}
}
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/java/org/apache/skywalking/apm/testcase/shardingsphere/service/utility/config/ExampleConfiguration.java
0 → 100644
浏览文件 @
ab39cecb
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package
org.apache.skywalking.apm.testcase.shardingsphere.service.utility.config
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
public
interface
ExampleConfiguration
{
DataSource
createDataSource
()
throws
SQLException
;
DataSource
getDataSource
();
}
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/src/main/resources/application.properties
0 → 100644
浏览文件 @
ab39cecb
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
server.port
=
8080
server.contextPath
=
/shardingsphere-4.x-RC1-RC2-scenario
\ No newline at end of file
test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/support-version.list
0 → 100644
浏览文件 @
ab39cecb
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version
# "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.
4.0.0-RC1
4.0.0-RC2
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录