You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ki...@apache.org on 2020/06/28 06:37:27 UTC
[shardingsphere-benchmark] 01/01: Revert "remove localhost to real
ip of database (#55)"
This is an automated email from the ASF dual-hosted git repository.
kimmking pushed a commit to branch revert-55-5.0.0
in repository https://gitbox.apache.org/repos/asf/shardingsphere-benchmark.git
commit 8b1ba724cb95430770d2cc3b1ee2652a4063b13c
Author: kimmking <ki...@gmail.com>
AuthorDate: Sun Jun 28 14:37:17 2020 +0800
Revert "remove localhost to real ip of database (#55)"
This reverts commit 72e974f9c1df0365629df40bcfbe128e89fe4c87.
---
.gitignore | 3 -
shardingsphere-benchmark/.gitignore | 3 -
.../dependency-reduced-pom.xml | 49 ---
shardingsphere-benchmark/pom.xml | 141 +++----
shardingsphere-benchmark/pom.xml.5.0 | 170 --------
.../src/main/java/jdbc/JdbcSingleTableInsert.java | 46 ---
.../src/main/java/jdbc/JdbcSingleTableSelect.java | 44 --
.../src/main/java/jdbc/perf/JdbcSelect.java | 75 ++++
.../src/main/java/jdbc/perf/JdbcWrite.java | 61 +++
.../src/main/java/jdbc/perf/JdbcWriteRead.java | 63 +++
.../apache/shardingsphere/benchmark/bean/Iou.java | 28 --
.../benchmark/db/BaseDataSource.java | 70 ----
.../db/fixture/DecrementKeyGenerateAlgorithm.java | 49 ---
.../db/fixture/IncrementKeyGenerateAlgorithm.java | 31 --
.../benchmark/db/fixture/StandardAlgorithm.java | 58 ---
.../db/fixture/UUIDKeyGenerateAlgorithm.java | 30 --
.../benchmark/db/jdbc/JDBCDataSourceUtil.java | 189 ---------
.../db/shardingjdbc/ShardingConfigType.java | 21 -
.../ShardingJDBCDataSourceFactory.java | 116 ------
.../jmeter/jdbc/JMeterJDBCDeleteSbTest3.java | 105 -----
.../jmeter/jdbc/JMeterJDBCDeleteSbTest6.java | 113 ------
.../jmeter/jdbc/JMeterJDBCDeleteSbTest99.java | 107 -----
.../jmeter/jdbc/JMeterJDBCInsertOneSbTest99.java | 112 ------
.../jmeter/jdbc/JMeterJDBCInsertSbTest6.java | 110 -----
.../jmeter/jdbc/JMeterJDBCInsertSbTest99.java | 105 -----
.../jdbc/JMeterJDBCInsertUpdateDeleteSbTest6.java | 125 ------
.../jdbc/JMeterJDBCMasterSlaveInsertSbTest6.java | 112 ------
.../JMeterJDBCMasterSlaveInsertUpdateDelete.java | 121 ------
.../jmeter/jdbc/JMeterJDBCSelectSbTest6.java | 107 -----
.../jmeter/jdbc/JMeterJDBCSelectSbTest99.java | 110 -----
.../proxy/JMeterProxyMasterSlaveDeleteSbTest.java | 110 -----
...asterSlaveEncryptAllDbAllTableSbTestDelete.java | 113 ------
...erSlaveEncryptAllDbAllTableSbTestInsertOne.java | 110 -----
...cryptAllDbAllTableSbTestInsertUpdateDelete.java | 133 -------
...asterSlaveEncryptAllDbAllTableSbTestSelect.java | 128 ------
...rProxyMasterSlaveEncryptInsertSbTestAction.java | 110 -----
...erProxyMasterSlaveInsertUpdateDeleteSbTest.java | 129 ------
.../proxy/JMeterProxyMasterSlaveSbTestInsert.java | 112 ------
...eterProxyShardingAllDbAllTableSbTestDelete.java | 111 ------
...rdingAllDbAllTableSbTestInsertUpdateDelete.java | 134 -------
...oxyShardingAllDbAllTableSelectSbTestSelect.java | 113 ------
...terProxyShardingAllDbAllTabletSbTestInsert.java | 115 ------
...ProxyShardingAllDbAllTabletSbTestInsertOne.java | 116 ------
...gAllDbSingleTableSbTest3InsertUpdateDelete.java | 131 ------
...ProxyShardingAllDbSingleTableSbTest4Delete.java | 110 -----
...ProxyShardingAllDbSingleTableSbTest4Insert.java | 113 ------
...ProxyShardingAllDbSingleTableSbTest4Select.java | 103 -----
...rdingAllDbAllTableInsertSbTestUpdateDelete.java | 139 -------
.../JMeterShardingAllDbAllTableSbTestSelect.java | 123 ------
...ShardingAllDbSingleTableInsertUpdateDelete.java | 135 -------
...MeterShardingAllDbSingleTableSbTest4Delete.java | 119 ------
...MeterShardingAllDbSingleTableSbTest4Insert.java | 117 ------
...MeterShardingAllDbSingleTableSbTest4Select.java | 119 ------
...rdingMasterSlaveEncryptAllDbAllTableSelect.java | 121 ------
...MeterShardingMasterSlaveInsertUpdateDelete.java | 133 -------
...cryptAllDbAllTableInsertUpdateDeleteAction.java | 133 -------
.../benchmark/jmeter/sharding/JmeterTest.java | 39 --
.../src/main/java/perfstmt/ShardingPerfStmt.java | 59 +++
.../src/main/java/service/api/entity/Iou.java | 64 +--
.../src/main/java/service/api/entity/Order.java | 44 --
.../main/java/service/api/entity/OrderItem.java | 53 ---
.../service/api/repository/CommonRepository.java | 21 -
.../api/repository/OrderItemRepository.java | 7 -
.../service/api/repository/OrderRepository.java | 6 -
.../java/service/api/service/CommonService.java | 16 -
.../service/api/service/CommonServiceImpl.java | 92 -----
.../java/service/api/service/SJPerfService.java | 30 +-
.../service/config/MasterSlaveConfiguration.java | 47 ---
...dingDatabasesAndTablesConfigurationPrecise.java | 66 ---
.../jdbc/JDBCOrderItemRepositoryImpl.java | 108 -----
.../repository/jdbc/JDBCOrderRepositoryImpl.java | 104 -----
.../service/repository/service/RawPojoService.java | 42 --
.../PreciseModuleShardingDatabaseAlgorithm.java} | 49 ++-
.../PreciseModuleShardingTableAlgorithm.java} | 49 ++-
.../RangeModuleShardingDatabaseAlgorithm.java | 63 +++
.../RangeModuleShardingTableAlgorithm.java | 54 +++
.../service/util/config/AesDataSourceUtil.java | 185 ---------
.../service/util/config/DataSourceMultiUtil.java | 176 --------
.../java/service/util/config/DataSourceUtil.java | 437 ++++----------------
.../util/config/DataSourceUtilPostgreSQL.java | 72 ----
.../service/util/config/ExampleConfiguration.java | 10 -
.../service/util/config/SJDataSourceFactory.java | 179 +++++++++
.../java/service/util/config/SJDataSourceUtil.java | 203 ++++++++++
.../java/service/util/config/SPDataSourceUtil.java | 239 +++++++++++
.../config/lastversion/SJDataSourceFactory.java | 147 +++++++
.../util/config/sjperf/SJPerfDataSourceOp.java | 368 -----------------
.../util/config/sjperf/SJPerfDataSourceUtil.java | 443 ---------------------
.../masterslave/SJMasterSlaveDelete.java | 70 ++++
.../masterslave/SJMasterSlaveInsert.java | 70 ++++
.../masterslave/SJMasterSlaveSelect.java | 70 ++++
.../masterslave/SJMasterSlaveUpdate.java | 69 ++++
.../lastversion/sharding/SJShardingDelete.java | 69 ++++
.../lastversion/sharding/SJShardingInsert.java | 69 ++++
.../lastversion/sharding/SJShardingSelect.java | 68 ++++
.../lastversion/sharding/SJShardingUpdate.java | 69 ++++
.../perf/masterslave/SJMasterSlaveDelete.java | 70 ++++
.../perf/masterslave/SJMasterSlaveInsert.java | 70 ++++
.../perf/masterslave/SJMasterSlaveSelect.java | 70 ++++
.../perf/masterslave/SJMasterSlaveUpdate.java | 71 ++++
.../perf/masterslave/SJMasterSlaveWrite.java | 65 +++
.../SJMsEncryptShardingDelete.java | 69 ++++
.../SJMsEncryptShardingInsert.java | 69 ++++
.../SJMsEncryptShardingSelect.java | 69 ++++
.../SJMsEncryptShardingUpdate.java | 70 ++++
.../SJMsEncryptShardingWrite.java | 65 +++
.../perf/sharding/SJShardingDelete.java | 70 ++++
.../perf/sharding/SJShardingFullRouteSelect.java | 70 ++++
.../perf/sharding/SJShardingInsert.java | 69 ++++
.../perf/sharding/SJShardingSelect.java | 70 ++++
.../perf/sharding/SJShardingSingleRouteSelect.java | 70 ++++
.../perf/sharding/SJShardingUpdate.java | 71 ++++
.../perf/sharding/SJShardingWrite.java | 65 +++
.../perf/sharding/SPShardingDelete.java | 80 ++++
.../perf/sharding/SPShardingFullRouteSelect.java | 79 ++++
.../perf/sharding/SPShardingInsert.java | 78 ++++
.../perf/sharding/SPShardingSelect.java | 79 ++++
.../perf/sharding/SPShardingSingleRouteSelect.java | 79 ++++
.../perf/sharding/SPShardingUpdate.java | 79 ++++
.../perf/sharding/SPShardingWrite.java | 74 ++++
.../java/sjperf/SJEncrypt/SJPerformanceAll.java | 48 ---
.../java/sjperf/SJEncrypt/SJPerformanceInsert.java | 50 ---
.../sjperf/SJEncrypt/SJPerformanceMSClean.java | 49 ---
.../sjperf/SJEncrypt/SJPerformanceMSDelete.java | 50 ---
.../java/sjperf/SJEncrypt/SJPerformanceMSDemo.java | 49 ---
.../sjperf/SJEncrypt/SJPerformanceMSInsert.java | 52 ---
.../sjperf/SJEncrypt/SJPerformanceMSSelect.java | 50 ---
.../sjperf/SJEncrypt/SJPerformanceMSUpdate.java | 49 ---
.../java/sjperf/SJEncrypt/SJPerformanceSelect.java | 48 ---
.../sjperf/SJEncryptSharding/SJPerformanceAll.java | 48 ---
.../SJEncryptSharding/SJPerformanceMSClean.java | 49 ---
.../SJEncryptSharding/SJPerformanceMSDelete.java | 50 ---
.../SJEncryptSharding/SJPerformanceMSDemo.java | 49 ---
.../SJEncryptSharding/SJPerformanceMSInsert.java | 52 ---
.../SJEncryptSharding/SJPerformanceMSSelect.java | 50 ---
.../SJEncryptSharding/SJPerformanceMSUpdate.java | 49 ---
.../SJEncryptSharding/SJPerformanceSelect.java | 48 ---
.../sjperf/SJFullRouting/SJPerformanceAll.java | 47 ---
.../sjperf/SJFullRouting/SJPerformanceClean.java | 47 ---
.../SJFullRouting/SJPerformanceCleanNew.java | 47 ---
.../sjperf/SJFullRouting/SJPerformanceInsert.java | 52 ---
.../sjperf/SJFullRouting/SJPerformanceMSClean.java | 49 ---
.../SJFullRouting/SJPerformanceMSDelete.java | 50 ---
.../sjperf/SJFullRouting/SJPerformanceMSDemo.java | 49 ---
.../SJFullRouting/SJPerformanceMSInsert.java | 52 ---
.../SJFullRouting/SJPerformanceMSSelect.java | 50 ---
.../SJFullRouting/SJPerformanceMSUpdate.java | 49 ---
.../SJFullRouting/SJPerformanceNewInsert.java | 53 ---
.../SJFullRouting/SJPerformanceNewSelect.java | 48 ---
.../SJFullRouting/SJPerformanceNewSelectTest.java | 48 ---
.../sjperf/SJFullRouting/SJPerformanceSelect.java | 51 ---
.../sjperf/SJFullRouting/SJPerfromanceNewAll.java | 48 ---
.../sjperf/SJMSEncSharding/SJPerformanceAll.java | 47 ---
.../sjperf/SJMSEncSharding/SJPerformanceClean.java | 47 ---
.../SJMSEncSharding/SJPerformanceInsert.java | 52 ---
.../SJMSEncSharding/SJPerformanceMSClean.java | 49 ---
.../SJMSEncSharding/SJPerformanceMSDelete.java | 50 ---
.../SJMSEncSharding/SJPerformanceMSDemo.java | 49 ---
.../SJMSEncSharding/SJPerformanceMSInsert.java | 52 ---
.../SJMSEncSharding/SJPerformanceMSSelect.java | 53 ---
.../SJMSEncSharding/SJPerformanceMSUpdate.java | 49 ---
.../SJMSEncSharding/SJPerformanceSelect.java | 54 ---
.../sjperf/SJMasterSlave/SJPerformanceMSClean.java | 49 ---
.../SJMasterSlave/SJPerformanceMSDelete.java | 50 ---
.../sjperf/SJMasterSlave/SJPerformanceMSDemo.java | 49 ---
.../SJMasterSlave/SJPerformanceMSInsert.java | 52 ---
.../SJMasterSlave/SJPerformanceMSSelect.java | 50 ---
.../SJMasterSlave/SJPerformanceMSUpdate.java | 49 ---
.../sjperf/SJMasterSlave/SJPerformanceNewAll.java | 48 ---
.../SJMasterSlave/SJPerformanceNewSelect.java | 48 ---
.../SJMasterSlaveSharding/SJPerformanceAll.java | 48 ---
.../SJPerformanceMSClean.java | 49 ---
.../SJPerformanceMSDelete.java | 50 ---
.../SJMasterSlaveSharding/SJPerformanceMSDemo.java | 49 ---
.../SJPerformanceMSInsert.java | 52 ---
.../SJPerformanceMSSelect.java | 50 ---
.../SJPerformanceMSUpdate.java | 49 ---
.../SJMasterSlaveSharding/SJPerformanceSelect.java | 48 ---
.../main/java/sjperf/SJPerformanceAesSelect.java | 46 ---
.../main/java/sjperf/SJPerformanceMSSelect.java | 59 ---
.../main/java/sjperf/SJPerformanceSingleTable.java | 62 ---
.../SJSingleRouting/SJSingleRoutingDeletePerf.java | 40 --
.../SJSingleRouting/SJSingleRoutingInsertPerf.java | 40 --
.../SJSingleRouting/SJSingleRoutingSelectPerf.java | 39 --
.../SJSingleRouting/SJSingleRoutingUpdatePerf.java | 40 --
.../sjperf/SJTableRouting/SJPerformanceAll.java | 41 --
.../sjperf/SJTableRouting/SJPerformanceSelect.java | 41 --
.../sjperf/SJTableRouting/SJTableRoutingClean.java | 40 --
.../SJTableRouting/SJTableRoutingDeletePerf.java | 41 --
.../SJTableRouting/SJTableRoutingInsertDemo.java | 40 --
.../SJTableRouting/SJTableRoutingInsertPerf.java | 39 --
.../SJTableRouting/SJTableRoutingSelectPerf.java | 40 --
.../SJTableRouting/SJTableRoutingUpdatePerf.java | 39 --
.../src/main/java/sjperf/v3/SQLStatement.java | 51 ---
.../main/java/spperf/SPEncrypt/SPEncrptClean.java | 43 --
.../java/spperf/SPEncrypt/SPEncrptDeletePerf.java | 43 --
.../java/spperf/SPEncrypt/SPEncrptInsertDemo.java | 43 --
.../java/spperf/SPEncrypt/SPEncrptInsertPerf.java | 42 --
.../java/spperf/SPEncrypt/SPEncrptSelectPerf.java | 41 --
.../java/spperf/SPEncrypt/SPEncrptUpdatePerf.java | 43 --
.../main/java/spperf/SPEncrypt/SPEncryptAll.java | 41 --
.../java/spperf/SPEncrypt/SPEncryptDelete.java | 43 --
.../java/spperf/SPEncrypt/SPEncryptInsert.java | 42 --
.../main/java/spperf/SPEncrypt/SPEncryptMsAll.java | 41 --
.../java/spperf/SPEncrypt/SPEncryptSelect.java | 41 --
.../SPEncryptSharding/SPEncryptShardingAll.java | 43 --
.../SPEncryptSharding/SPEncryptShardingClean.java | 45 ---
.../SPEncryptShardingDeletePerf.java | 44 --
.../SPEncryptSharding/SPEncryptShardingDemo.java | 42 --
.../SPEncryptShardingInsertPerf.java | 42 --
.../SPEncryptSharding/SPEncryptShardingSelect.java | 42 --
.../SPEncryptShardingSelectPerf.java | 42 --
.../SPEncryptShardingUpdatePerf.java | 44 --
.../spperf/SPMasterSlave/SPMasterSlaveClean.java | 4 -
.../SPMasterSlave/SPMasterSlaveDeletePerf.java | 4 -
.../spperf/SPMasterSlave/SPMasterSlaveDemo.java | 4 -
.../SPMasterSlave/SPMasterSlaveInsertPerf.java | 4 -
.../SPMasterSlave/SPMasterSlaveSelectPerf.java | 4 -
.../SPMasterSlave/SPMasterSlaveUpdatePerf.java | 4 -
.../SPMasterSlaveSharding/SPMsShardingClean.java | 4 -
.../SPMsShardingDeletePerf.java | 4 -
.../SPMasterSlaveSharding/SPMsShardingDemo.java | 4 -
.../SPMsShardingInsertPerf.java | 4 -
.../SPMsShardingSelectPerf.java | 4 -
.../SPMsShardingUpdatePerf.java | 4 -
.../java/spperf/SPPerformanceSingleTableClean.java | 46 ---
.../spperf/SPPerformanceSingleTableDelete.java | 46 ---
.../java/spperf/SPPerformanceSingleTableDemo.java | 46 ---
.../spperf/SPPerformanceSingleTableInsert.java | 46 ---
.../spperf/SPPerformanceSingleTableSelect.java | 45 ---
.../spperf/SPPerformanceSingleTableUpdate.java | 46 ---
.../src/main/java/test/DatasourceTest.java | 73 ----
...hardingsphere.sharding.spi.KeyGenerateAlgorithm | 20 -
...e.shardingsphere.sharding.spi.ShardingAlgorithm | 19 -
.../src/main/resources/shell/install/build.sh | 12 -
.../shell/proxy/deploy/deploy_ms_enc_sharding.sh | 17 -
.../resources/shell/proxy/deploy/deploy_ms_v4.sh | 18 -
.../shell/proxy/deploy/deploy_single_table.sh | 16 -
.../shell/proxy/deploy/deploy_sp_all_new.sh | 17 -
.../shell/proxy/deploy/deploy_sp_select_new.sh | 17 -
.../main/resources/shell/proxy/single/clean_env.sh | 6 -
.../jdbc/jdbc-masterslave-sbtest6-insert.jmx | 111 ------
.../jdbc-masterslave-sbtest6-inserupdatedelete.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest6-delete.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest6-insert.jmx | 111 ------
.../jdbc/jdbc-sbtest6-insertupdatedelete.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest6-select.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest99-delete.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest99-insert-1.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest99-insert.jmx | 111 ------
.../testplan/jdbc/jdbc-sbtest99-select.jmx | 111 ------
.../testplan/proxy/proxy-alldb-alltable-delete.jmx | 112 ------
.../testplan/proxy/proxy-masterslave-delete.jmx | 111 ------
...y-masterslave-encrypt-alldb-alltable-delete.jmx | 111 ------
...e-encrypt-alldb-alltable-insertupdatedelete.jmx | 111 ------
.../proxy/proxy-masterslave-encrypt-insert-1.jmx | 111 ------
.../proxy/proxy-masterslave-encrypt-insert-1w.jmx | 113 ------
.../proxy/proxy-masterslave-encrypt-select.jmx | 111 ------
.../testplan/proxy/proxy-masterslave-insert.jmx | 111 ------
.../proxy/proxy-masterslave-insertupdatedelete.jmx | 111 ------
.../proxy-sharding-alldb-alltable-insert-1.jmx | 111 ------
.../proxy-sharding-alldb-alltable-insert-1w.jmx | 112 ------
...-sharding-alldb-alltable-insertupdatedelete.jmx | 111 ------
.../proxy/proxy-sharding-alldb-alltable-select.jmx | 111 ------
...arding-alldb-singletable-insertupdatedelete.jmx | 111 ------
...y-sharding-alldb-singletable-sbtest4-delete.jmx | 111 ------
...y-sharding-alldb-singletable-sbtest4-insert.jmx | 111 ------
...y-sharding-alldb-singletable-sbtest4-select.jmx | 111 ------
.../resources/testplan/sharding/jmeter_test.jmx | 111 ------
.../sharding-alldb-alltable-insertupdatedelete.jmx | 111 ------
.../sharding/sharding-alldb-alltable-select.jmx | 111 ------
...arding-alldb-singletable-insertupdatedelete.jmx | 111 ------
.../sharding-alldb-singletable-sbtest4-delete.jmx | 111 ------
.../sharding-alldb-singletable-sbtest4-select.jmx | 111 ------
.../sharding-alldbsingletable-sbtest4-insert.jmx | 111 ------
...e-encrypt-alldb-alltable-insertupdatedelete.jmx | 111 ------
...g-masterslave-encrypt-alldb-alltable-select.jmx | 111 ------
.../sharding-masterslave-insertupdatedelete.jmx | 111 ------
.../resources/yaml/proxy/config-master_slave.yaml | 60 ---
.../proxy/config-master_slave_enc_sharding.yaml | 133 -------
.../yaml/proxy/config-sharding_alldb_alltable.yaml | 64 ---
.../proxy/config-sharding_alldb_singletable.yaml | 64 ---
.../config-sharding_alldb_singletable_new.yaml | 65 ---
.../src/main/resources/yaml/proxy/server.yaml | 39 --
.../all-db-all-table-sharding-config.yaml | 79 ----
.../all-db-single-table-sharding-config.yaml | 82 ----
.../all-db-single-table-sharding-new-config.yaml | 79 ----
.../yaml/shardingjdbc/encrypt-config.yaml | 39 --
.../yaml/shardingjdbc/master-slave-config.yaml | 43 --
.../master-slave-encrypt-sharding-config.yaml | 140 -------
.../shardingjdbc/master-slave-sharding-config.yaml | 95 -----
.../single-db-single-table-sharding-config.yaml | 64 ---
291 files changed, 3657 insertions(+), 17766 deletions(-)
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 333dabd..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/shardingsphere-benchmark/target/
-/shardingsphere-benchmark/*.iml
-/shardingsphere-benchmark/.idea
\ No newline at end of file
diff --git a/shardingsphere-benchmark/.gitignore b/shardingsphere-benchmark/.gitignore
deleted file mode 100644
index 9edb5fe..0000000
--- a/shardingsphere-benchmark/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/target/
-/*.iml
-/.idea
\ No newline at end of file
diff --git a/shardingsphere-benchmark/dependency-reduced-pom.xml b/shardingsphere-benchmark/dependency-reduced-pom.xml
deleted file mode 100644
index d7bb786..0000000
--- a/shardingsphere-benchmark/dependency-reduced-pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>shardingsphere-benchmark</groupId>
- <artifactId>shardingsphere-benchmark</artifactId>
- <version>1.1-SNAPSHOT</version>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer>
- <resource>META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration</resource>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.jmeter</groupId>
- <artifactId>ApacheJMeter_core</artifactId>
- <version>4.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jmeter</groupId>
- <artifactId>ApacheJMeter_java</artifactId>
- <version>4.0</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/shardingsphere-benchmark/pom.xml b/shardingsphere-benchmark/pom.xml
index b9d1167..c22e592 100644
--- a/shardingsphere-benchmark/pom.xml
+++ b/shardingsphere-benchmark/pom.xml
@@ -1,4 +1,20 @@
<?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">
@@ -6,96 +22,30 @@
<groupId>shardingsphere-benchmark</groupId>
<artifactId>shardingsphere-benchmark</artifactId>
- <version>1.1-SNAPSHOT</version>
-
+ <version>1.0-SNAPSHOT</version>
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sharding-api</artifactId>
+ <artifactId>sharding-core-api</artifactId>
<version>[5.0.0-RC1-SNAPSHOT,)</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-encrypt-common</artifactId>
+ <artifactId>sharding-jdbc-core</artifactId>
<version>[5.0.0-RC1-SNAPSHOT,)</version>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
+ <groupId>io.shardingsphere</groupId>
+ <artifactId>sharding-core</artifactId>
+ <version>3.1.0</version>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-orchestration</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
+ <groupId>io.shardingsphere</groupId>
+ <artifactId>sharding-jdbc-core</artifactId>
+ <version>3.1.0</version>
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-core-common</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-core-facade</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-center-api</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-center-configuration</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-cluster-facade</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.zaxxer</groupId>
- <artifactId>HikariCP</artifactId>
- <version>3.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- <version>2.2.0</version>
- </dependency>
- <dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <version>1.6</version>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.4.196</version>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>sharding-core-api</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>sharding-jdbc-core</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>encrypt-core-common</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
@@ -106,6 +56,11 @@
<version>42.2.5</version>
</dependency>
<dependency>
+ <groupId>com.zaxxer</groupId>
+ <artifactId>HikariCP</artifactId>
+ <version>3.2.0</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>4.0</version>
@@ -122,25 +77,14 @@
<artifactId>lombok</artifactId>
<version>1.16.4</version>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-nop</artifactId>
- <version>1.7.27</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.7</version>
- </dependency>
-
</dependencies>
-
+
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
@@ -149,6 +93,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.1</version>
<executions>
<execution>
<goals>
@@ -165,6 +110,24 @@
</execution>
</executions>
</plugin>
+ <!--<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>assemble-all</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>-->
</plugins>
</build>
</project>
diff --git a/shardingsphere-benchmark/pom.xml.5.0 b/shardingsphere-benchmark/pom.xml.5.0
deleted file mode 100644
index b9d1167..0000000
--- a/shardingsphere-benchmark/pom.xml.5.0
+++ /dev/null
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>shardingsphere-benchmark</groupId>
- <artifactId>shardingsphere-benchmark</artifactId>
- <version>1.1-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sharding-api</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-encrypt-common</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-orchestration</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-core-common</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-core-facade</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-center-api</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-orchestration-center-configuration</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-cluster-facade</artifactId>
- <version>[5.0.0-RC1-SNAPSHOT,)</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.zaxxer</groupId>
- <artifactId>HikariCP</artifactId>
- <version>3.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- <version>2.2.0</version>
- </dependency>
- <dependency>
- <groupId>commons-pool</groupId>
- <artifactId>commons-pool</artifactId>
- <version>1.6</version>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.4.196</version>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>sharding-core-api</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>sharding-jdbc-core</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.shardingsphere</groupId>-->
- <!--<artifactId>encrypt-core-common</artifactId>-->
- <!--<version>[5.0.0-RC1-SNAPSHOT,)</version>-->
- <!--</dependency>-->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.47</version>
- </dependency>
- <dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>42.2.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jmeter</groupId>
- <artifactId>ApacheJMeter_core</artifactId>
- <version>4.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jmeter</groupId>
- <artifactId>ApacheJMeter_java</artifactId>
- <version>4.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <version>1.16.4</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-nop</artifactId>
- <version>1.7.27</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.7</version>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer
- implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration</resource>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableInsert.java b/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableInsert.java
deleted file mode 100644
index 44bbd70..0000000
--- a/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableInsert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import service.util.config.DataSourceUtil;
-
-import java.sql.SQLException;
-
-/**
- * for jdbc single table insert performance
- */
-public class JdbcSingleTableInsert extends AbstractJavaSamplerClient {
- static {
- DataSourceUtil.createDataSource("test", "#####", 3306, "####");
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- @Override
- public void setupTest(JavaSamplerContext context) {
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableInsert");
- results.sampleStart();
- try {
- String insertSql = "INSERT INTO test (k,c,pad) VALUES (?,?,?)";
- DataSourceUtil.insertIou(insertSql,"test");
- } catch (SQLException ex) {
- results.setSuccessful(false);
- return results;
- } finally {
- results.sampleEnd();
- }
- results.setSuccessful(true);
- return results;
- }
-}
-
diff --git a/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableSelect.java b/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableSelect.java
deleted file mode 100644
index f89e734..0000000
--- a/shardingsphere-benchmark/src/main/java/jdbc/JdbcSingleTableSelect.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import service.util.config.DataSourceUtil;
-
-import java.sql.SQLException;
-
-/**
- * jdbc single table select
- */
-public class JdbcSingleTableSelect extends AbstractJavaSamplerClient {
- static {
- DataSourceUtil.createDataSource("test", "####", 3306, "####");
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- @Override
- public void setupTest(JavaSamplerContext context) {
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
- try {
- DataSourceUtil.getIou( "SELECT id,k from test where id=1 and k=1", "test");
- } catch (SQLException ex) {
- results.setSuccessful(false);
- return results;
- } finally {
- results.sampleEnd();
- }
- results.setSuccessful(true);
- return results;
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcSelect.java b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcSelect.java
new file mode 100644
index 0000000..ac064f5
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcSelect.java
@@ -0,0 +1,75 @@
+/*
+ * 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 jdbc.perf;
+
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
+import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
+import org.apache.jmeter.samplers.SampleResult;
+import perfstmt.ShardingPerfStmt;
+import service.util.config.DataSourceUtil;
+
+import java.sql.SQLException;
+
+public class JdbcSelect extends AbstractJavaSamplerClient {
+ private static final String SELECT_STMT = ShardingPerfStmt.SELECT_STMT.getValue();
+
+ static {
+ DataSourceUtil.createDataSource("###", "sharding_db", "###", 3306, "###");
+ }
+
+ /**
+ * get default params.
+ * @return null
+ */
+ @Override
+ public Arguments getDefaultParameters() {
+ return null;
+ }
+
+ /**
+ * setup.
+ * @param context context
+ */
+ @Override
+ public void setupTest(JavaSamplerContext context) {
+ }
+
+ /**
+ * run test.
+ * @param context context
+ * @return sample res
+ */
+ @Override
+ public SampleResult runTest(JavaSamplerContext context) {
+ SampleResult results = new SampleResult();
+ results.setSampleLabel("JdbcSelect");
+ results.sampleStart();
+ try {
+ DataSourceUtil.getSelectRes(SELECT_STMT, "sharding_db");
+ } catch (SQLException ex) {
+ results.setSuccessful(false);
+ return results;
+ } finally {
+ results.sampleEnd();
+ }
+ results.setSuccessful(true);
+ return results;
+ }
+}
+
diff --git a/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWrite.java b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWrite.java
new file mode 100644
index 0000000..863fb31
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWrite.java
@@ -0,0 +1,61 @@
+/*
+ * 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 jdbc.perf;
+
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
+import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
+import org.apache.jmeter.samplers.SampleResult;
+import service.util.config.DataSourceUtil;
+
+import java.sql.SQLException;
+
+/**
+ * for mysql insert+update+delete
+ */
+public class JdbcWrite extends AbstractJavaSamplerClient {
+ static {
+ DataSourceUtil.createDataSource("###", "sharding_db", "###", 3306, "###");
+ }
+
+ @Override
+ public Arguments getDefaultParameters() {
+ return null;
+ }
+
+ @Override
+ public void setupTest(JavaSamplerContext context) {
+ }
+
+ @Override
+ public SampleResult runTest(JavaSamplerContext context) {
+ SampleResult results = new SampleResult();
+ results.setSampleLabel("JdbcWrite");
+ results.sampleStart();
+ try {
+ DataSourceUtil.writeOp( "sharding_db");
+ } catch (SQLException ex) {
+ results.setSuccessful(false);
+ return results;
+ } finally {
+ results.sampleEnd();
+ }
+ results.setSuccessful(true);
+ return results;
+ }
+}
+
diff --git a/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWriteRead.java b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWriteRead.java
new file mode 100644
index 0000000..df521d0
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/jdbc/perf/JdbcWriteRead.java
@@ -0,0 +1,63 @@
+/*
+ * 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 jdbc.perf;
+
+import org.apache.jmeter.config.Arguments;
+import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
+import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
+import org.apache.jmeter.samplers.SampleResult;
+import service.util.config.DataSourceUtil;
+
+import java.sql.SQLException;
+
+/**
+ * for mysql compare in master slave scene
+ */
+public class JdbcWriteRead extends AbstractJavaSamplerClient {
+ static {
+ DataSourceUtil.createDataSource("###", "sharding_db", "###", 3306, "###");
+ }
+
+ @Override
+ public Arguments getDefaultParameters() {
+ return null;
+ }
+
+ @Override
+ public void setupTest(JavaSamplerContext context) {
+ }
+
+ @Override
+ public SampleResult runTest(JavaSamplerContext context) {
+ SampleResult results = new SampleResult();
+ results.setSampleLabel("JdbcWriteRead");
+ results.sampleStart();
+ try {
+ DataSourceUtil.writeReadOp( "sharding_db");
+ } catch (SQLException ex) {
+ results.setSuccessful(false);
+ return results;
+ } finally {
+ results.sampleEnd();
+ }
+ results.setSuccessful(true);
+ return results;
+ }
+}
+
+
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/bean/Iou.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/bean/Iou.java
deleted file mode 100644
index 92c9bc1..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/bean/Iou.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.shardingsphere.benchmark.bean;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.io.Serializable;
-
-/**
- * operation object for jmeter performance
- */
-@Getter
-@Setter
-public class Iou implements Serializable {
-
- private static final long serialVersionUID = 5377660875939152645L;
-
- private int k;
-
- private String c;
-
- private String pad;
-
- @Override
- public String toString() {
- return String.format("k: %s, c: %s, pad: %s", k, c, pad);
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/BaseDataSource.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/BaseDataSource.java
deleted file mode 100644
index 00b4158..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/BaseDataSource.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.apache.shardingsphere.benchmark.db;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-
-import javax.sql.DataSource;
-
-public class BaseDataSource {
-
- /**
- * create HikariDataSource
- * @param dataSourceName
- * @param host
- * @param port
- * @param userName
- * @param password
- * @return
- */
- public DataSource createHikariDataSource(String dataSourceName, String host, int port, String userName , String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("com.mysql.jdbc.Driver");
- config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(userName);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.setConnectionTimeout(30000);
- config.setIdleTimeout(60000);
- config.setMaxLifetime(1800000);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- return new HikariDataSource(config);
- }
-
-
- /**
- * create C3p0DataSource
- * @param dataSourceName
- * @param host
- * @param port
- * @param userName
- * @param password
- * @return
- */
- public DataSource createC3p0DataSource(String dataSourceName, String host, int port, String userName , String password){
- return null;
- }
-
- /**
- * create DhcpDataSource
- * @param dataSourceName
- * @param host
- * @param port
- * @param userName
- * @param password
- * @return
- */
- public DataSource createDhcpDataSource(String dataSourceName, String host, int port, String userName , String password){
- return null;
-
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/DecrementKeyGenerateAlgorithm.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/DecrementKeyGenerateAlgorithm.java
deleted file mode 100644
index 2058386..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/DecrementKeyGenerateAlgorithm.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.shardingsphere.benchmark.db.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public final class DecrementKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
-
- private final AtomicInteger sequence = new AtomicInteger(100);
-
- @Getter
- @Setter
- private Properties props = new Properties();
-
- @Override
- public Comparable<?> generateKey() {
- return sequence.decrementAndGet();
- }
-
- @Override
- public String getType() {
- return "DECREMENT";
- }
-
- @Override
- public void init() {
-
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/IncrementKeyGenerateAlgorithm.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/IncrementKeyGenerateAlgorithm.java
deleted file mode 100644
index bcba740..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/IncrementKeyGenerateAlgorithm.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.shardingsphere.benchmark.db.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-@Getter
-@Setter
-public class IncrementKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
- private static final AtomicInteger SEQUENCE = new AtomicInteger(110);
-
- private Properties props = new Properties();
-
- @Override
- public Comparable<?> generateKey() {
- return SEQUENCE.incrementAndGet();
- }
-
- @Override
- public String getType() {
- return "INCREMENT";
- }
-
- @Override
- public void init() {
-
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/StandardAlgorithm.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/StandardAlgorithm.java
deleted file mode 100644
index 8a30b75..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/StandardAlgorithm.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.shardingsphere.benchmark.db.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
-import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
-import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
-
-import java.util.Collection;
-import java.util.Properties;
-
-@Getter
-@Setter
-public final class StandardAlgorithm implements StandardShardingAlgorithm<Integer> {
-
- private Properties props = new Properties();
-
- @Override
- public void init() {
- }
-
- @Override
- public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Integer> shardingValue) {
- for (String each : availableTargetNames) {
- if (each.endsWith(shardingValue.getValue() % 10 + "")) {
- return each;
- }
- }
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Integer> shardingValue) {
- throw new UnsupportedOperationException("Cannot find range sharding strategy in sharding rule.");
- }
-
- @Override
- public String getType() {
- return "STANDARD_TEST";
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/UUIDKeyGenerateAlgorithm.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/UUIDKeyGenerateAlgorithm.java
deleted file mode 100644
index 91dfba5..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/UUIDKeyGenerateAlgorithm.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.shardingsphere.benchmark.db.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-
-import java.util.Properties;
-import java.util.UUID;
-
-@Getter
-@Setter
-public final class UUIDKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
-
- private Properties props = new Properties();
-
- @Override
- public synchronized Comparable<?> generateKey() {
- return UUID.randomUUID().toString().replaceAll("-", "");
- }
-
- @Override
- public String getType() {
- return "UUID";
- }
-
- @Override
- public void init() {
-
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/jdbc/JDBCDataSourceUtil.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/jdbc/JDBCDataSourceUtil.java
deleted file mode 100644
index e940722..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/jdbc/JDBCDataSourceUtil.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package org.apache.shardingsphere.benchmark.db.jdbc;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class JDBCDataSourceUtil {
-
- private static final Map<String, DataSource> DATASOURCES = new HashMap<>();
-
- /**
- * Init datasource.
- *
- * @param dataSourceName
- * @param host
- * @param port
- * @param userName
- * @param password
- * @return
- */
- public static DataSource initDb(String dataSourceName, String host, int port, String userName, String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("com.mysql.jdbc.Driver");
- config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(userName);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.setConnectionTimeout(30000);
- config.setIdleTimeout(60000);
- config.setMaxLifetime(1800000);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- return new HikariDataSource(config);
- //DATASOURCES.put(dataSourceName, dataSource);
- //return dataSource;
- }
-
-
- /**
- * Get dataSource by its name.
- *
- * @param dataSourceName
- * @return
- */
- public static DataSource getDataSource(String dataSourceName) {
- return DATASOURCES.get(dataSourceName);
- }
-
-
- /**
- * create an item by criteria.
- * @param conn
- * @param insertSql
- * @param params
- * @return
- * @throws SQLException
- */
- public static ResultSet insert(Connection conn, String insertSql, List params) throws SQLException {
-
- ResultSet result = null;
- Connection connection = null;
- PreparedStatement preparedStatement=null;
-
- if(conn != null){
- preparedStatement = conn.prepareStatement(insertSql, Statement.RETURN_GENERATED_KEYS);
- preparedStatement = setParams(preparedStatement, params);
- preparedStatement.execute();
- result = preparedStatement.getGeneratedKeys();
- }
-
- return result;
- }
-
-
- /**
- * Update an item by criteria..
- * @param conn
- * @param updateSql
- * @param params
- * @return
- * @throws SQLException
- */
- public static ResultSet update(Connection conn, String updateSql, List params) throws SQLException {
- ResultSet result = null;
- PreparedStatement preparedStatement=null;
-
- if(conn != null){
- preparedStatement = conn.prepareStatement(updateSql);
- preparedStatement = setParams(preparedStatement, params);
- preparedStatement.executeUpdate();
- }
-
- return result;
- }
-
-
- /**
- * Delete an item by criteria.
- *
- * @param conn
- * @param deleteSql
- * @return
- * @throws SQLException
- */
- public static ResultSet delete(Connection conn, String deleteSql, List params) throws SQLException {
- ResultSet result = null;
- PreparedStatement preparedStatement=null;
-
- if(conn != null){
- preparedStatement = conn.prepareStatement(deleteSql);
- preparedStatement = setParams(preparedStatement, params);
- preparedStatement.executeUpdate();
- }
-
- return result;
- }
-
-
- /**
- * Query items by criteria.
- *
- * @param conn
- * @param selectSql
- */
- public static ResultSet select(Connection conn, String selectSql, List params) throws SQLException {
- ResultSet result = null;
- PreparedStatement preparedStatement=null;
-
- if(conn != null){
- preparedStatement = conn.prepareStatement(selectSql);
- preparedStatement = setParams(preparedStatement, params);
- preparedStatement.executeQuery();
- }
-
- return result;
-
- }
-
- /**
- * Allocate values to PreparedStatement.
- *
- * @param ps
- * @param params
- * @return
- * @throws SQLException
- */
- public static PreparedStatement setParams(PreparedStatement ps, List params) throws SQLException {
- if(params != null){
- for (int i = 0; i < params.size(); i++){
- if (params.get(i) instanceof Long){
- ps.setLong(i+1, (Long) params.get(i));
- } else if(params.get(i) instanceof Integer){
- ps.setInt(i+1, (Integer) params.get(i));
- } else if(params.get(i) instanceof String){
- ps.setString(i+1, (String)params.get(i));
- }
- }
- }
- return ps;
- }
-
-
- /**
- * Close database connection.
- *
- * @param conn
- * @throws SQLException
- */
- public static void close(Connection conn) throws SQLException {
- if(conn != null){
- conn.close();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingConfigType.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingConfigType.java
deleted file mode 100644
index f985b7c..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingConfigType.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.shardingsphere.benchmark.db.shardingjdbc;
-
-public enum ShardingConfigType {
-
- ENCRYPT_CONFIG,
-
- MASTER_SLAVE_CONFIG,
-
- MASTER_SLAVE_SHARDING_CONFIG,
-
- MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG,
-
- SINGLE_DATABASE_SINGLE_TABLE_SHARDING_CONFIG,
-
- ALL_DATABASE_SINGLE_TABLE_SHARDING_CONFIG,
-
- ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG,
-
- ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG,
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingJDBCDataSourceFactory.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingJDBCDataSourceFactory.java
deleted file mode 100644
index 5d241b4..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/shardingjdbc/ShardingJDBCDataSourceFactory.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.apache.shardingsphere.benchmark.db.shardingjdbc;
-
-import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.*;
-import java.sql.SQLException;
-
-/**
- * Sharding scenario which to create DataSource based on different yaml config.
- *
- */
-public class ShardingJDBCDataSourceFactory {
-
- private static final String ENCRYPT_CONFIG_PATH = "/yaml/shardingjdbc/encrypt-config.yaml";
-
- private static final String MASTER_SLAVE_CONFIG_PATH = "/yaml/shardingjdbc/master-slave-config.yaml";
-
- private static final String MASTER_SLAVE_SHARDING_CONFIG_PATH = "/yaml/shardingjdbc/master-slave-sharding-config.yaml";
-
- private static final String SINGLE_DATABASE_SINGLE_TABLE_SHARDING_CONFIG_PATH = "/yaml/shardingjdbc/single-db-single-table-sharding-config.yaml";
-
- private static final String ALL_DATABASE_SINGLE_TABLE_SHARDING_CONFIG_PATH = "/yaml/shardingjdbc/all-db-single-table-sharding-config.yaml";
-
- private static final String ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG_PATH = "/yaml/shardingjdbc/all-db-single-table-sharding-new-config.yaml";
-
- private static final String ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG_PATH = "/yaml/shardingjdbc/all-db-all-table-sharding-config.yaml";
-
- private static final String MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG_PATH = "/yaml/shardingjdbc/master-slave-encrypt-sharding-config.yaml";
-
-
- /**
- * Create datasource by configType
- *
- * @param shardingConfigType
- * @return
- */
- public static DataSource newInstance(ShardingConfigType shardingConfigType) throws IOException, SQLException {
- switch (shardingConfigType) {
- case SINGLE_DATABASE_SINGLE_TABLE_SHARDING_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(SINGLE_DATABASE_SINGLE_TABLE_SHARDING_CONFIG_PATH));
-
- case ALL_DATABASE_SINGLE_TABLE_SHARDING_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(ALL_DATABASE_SINGLE_TABLE_SHARDING_CONFIG_PATH));
-
- case ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG_PATH));
-
- case ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG_PATH));
-
- case ENCRYPT_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(ENCRYPT_CONFIG_PATH));
-
- case MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG_PATH));
-
- case MASTER_SLAVE_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(MASTER_SLAVE_CONFIG_PATH));
-
- case MASTER_SLAVE_SHARDING_CONFIG:
- return YamlShardingSphereDataSourceFactory.createDataSource
- (getFileContents(MASTER_SLAVE_SHARDING_CONFIG_PATH));
-
- default:
- throw new UnsupportedOperationException(shardingConfigType.name());
- }
- }
-
-
- /**
- * Get yaml file by fileName.
- *
- * @param fileName
- * @return
- */
- private static File getFile(final String fileName) {
- return new File(ShardingJDBCDataSourceFactory.class.getResource(fileName).getFile());
- }
-
-
- /**
- * Get yaml file content bytes by file name.
- *
- * @param fileName
- * @return
- */
- public static byte[] getFileContents(String fileName) {
- byte[] yamlContentBytes = null;
- try {
-
- String line = "";
- StringBuilder yamlContent = new StringBuilder();
-
- InputStream in = ShardingJDBCDataSourceFactory.class.getResourceAsStream(fileName);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
-
- while ((line = br.readLine()) != null) {
- yamlContent.append(line).append("\n");
- }
-
- yamlContentBytes = yamlContent.toString().getBytes();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return yamlContentBytes;
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest3.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest3.java
deleted file mode 100644
index 7a4edd1..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest3.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * TODO: type old case here.
- *
- * JDBC Scenario
- * truncate table to clear data.
- */
-public class JMeterJDBCDeleteSbTest3 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest3";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute truncate action to clear data.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableDelete");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest6.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest6.java
deleted file mode 100644
index 407d5ef..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest6.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_clean.jmx
- *
- * JDBC scenario:
- * truncate table to clear data.
- */
-public class JMeterJDBCDeleteSbTest6 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute truncate action to clear data.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableDelete");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
-
- return null;
- }
-
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest99.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest99.java
deleted file mode 100644
index 05f4a55..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCDeleteSbTest99.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-/**
- * Refactor old case test_plan/direct/delete_all.jmx
- *
- * JDBC scenario:
- * trigger delete action.
- */
-public class JMeterJDBCDeleteSbTest99 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.156";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest99";
-
- public static final String DELETE_SQL = "delete from sbtest99";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertOneSbTest99.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertOneSbTest99.java
deleted file mode 100644
index 2ced994..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertOneSbTest99.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/direct/insert_direct_demo.jmx
- *
- * JDBC Scenario:
- * trigger insert action.
- */
-public class JMeterJDBCInsertOneSbTest99 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.156";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest99";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (id,k,c,pad) VALUES (?,?,?,?)";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableDemo");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(1, 3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest6.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest6.java
deleted file mode 100644
index 920af85..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest6.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.bouncycastle.crypto.paddings.TBCPadding;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_insert_test.jmx
- *
- * JDBC Scenario:
- * trigger insert action.
- */
-public class JMeterJDBCInsertSbTest6 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcInsert");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest99.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest99.java
deleted file mode 100644
index 58697fe..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertSbTest99.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-
-/**
- * Refactor old case test_plan/direct/insert_direct.jmx
- *
- * JDBC Scenario:
- * trigger insert action.
- */
-public class JMeterJDBCInsertSbTest99 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.156";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest99";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableInsert");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertUpdateDeleteSbTest6.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertUpdateDeleteSbTest6.java
deleted file mode 100644
index 71e83ea..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCInsertUpdateDeleteSbTest6.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_all.jmx
- *
- * JDBC scenario:
- * trigger insert, update, delete action.
- */
-public class JMeterJDBCInsertUpdateDeleteSbTest6 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=1";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert, update, delete action.
- * @param javaSamplerContext
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
- try {
-
- //insert a record
- List insertParams = Arrays.asList(1, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update a record
- List updateParams = Arrays.asList("##-####", "##-####", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete a record
- List deleteParams = Arrays.asList(1, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException throwables) {
-
- results.setSuccessful(false);
- throwables.printStackTrace();
- return results;
-
- } finally {
- results.sampleEnd();
- }
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertSbTest6.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertSbTest6.java
deleted file mode 100644
index c427275..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertSbTest6.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_insert_ms_test.jmx
- *
- * JDBC scenario(master-slave):
- * trigger insert action
- */
-public class JMeterJDBCMasterSlaveInsertSbTest6 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcInsert");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertUpdateDelete.java
deleted file mode 100644
index c9dc1d3..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCMasterSlaveInsertUpdateDelete.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_all_ms.jmx
- *
- * JDBC scenario(master-slave):
- * trigger insert, update, delete action.
- */
-public class JMeterJDBCMasterSlaveInsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=1";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
- try {
-
- //insert a record
- List insertParams = Arrays.asList(1, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update a record
- List updateParams = Arrays.asList("##-####", "##-####", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete a record
- List deleteParams = Arrays.asList(1, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException throwables) {
-
- results.setSuccessful(false);
- throwables.printStackTrace();
- return results;
-
- } finally {
- results.sampleEnd();
- }
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest6.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest6.java
deleted file mode 100644
index d4232bb..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest6.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/new_sharding/jdbc_select.jmx
- *
- * JDBC scenario:
- * trigger select action.
- */
-public class JMeterJDBCSelectSbTest6 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.97";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest6";
-
- public static final String SELECT_SQL = "select max(id) from " + TABLE_NAME + " where id % 4 = 1";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
-
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest99.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest99.java
deleted file mode 100644
index b5cea55..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/jdbc/JMeterJDBCSelectSbTest99.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.jdbc;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-/**
- * Refactor old case test_plan/direct/select_direct.jmx
- *
- * JDBC scenario:
- * trigger select action.
- */
-public class JMeterJDBCSelectSbTest99 extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3306;
-
- public static final String DB_PASSWORD = "";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.156";
-
- public static final String DB_NAME = "baitiao_test";
-
- public static final String TABLE_NAME = "sbtest99";
-
- public static final String SELECT_SQL = "SELECT id,k from " + TABLE_NAME + " ignore index(`PRIMARY`) where id=1 and k=3";
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveDeleteSbTest.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveDeleteSbTest.java
deleted file mode 100644
index 4eb2470..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveDeleteSbTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-/**
- * Refactor old case test_plan/master_slave_new/delete_all.jmx
- *
- * Proxy scenario:
- * Its master-slave: master_ds* -> slave_ds*
- * Its config: yaml/proxy/config-master_slave.yaml
- *
- */
-public class JMeterProxyMasterSlaveDeleteSbTest extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest3";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
- // Init mysql dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableClean");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestDelete.java
deleted file mode 100644
index 5935ec4..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestDelete.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/ms_enc_sharding_new/delete_all.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its database algorithm.expression: ms_ds_${id % 4}
- * Its table algorithm.expression: sbtest${k % 1024}
- * Its master-slave: ms_ds_* -> slave_ds_*
- * Its type: INLINE
- * Its config: yaml/proxy/config-master_slave_enc_sharding.yaml
- *
- */
-public class JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
-
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute truncate action to clear data.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableClean");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertOne.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertOne.java
deleted file mode 100644
index fbb768f..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertOne.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/ms_enc_sharding/insert_demo.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its database algorithm.expression: ms_ds_${id % 4}
- * Its table algorithm.expression: sbtest${k % 1024}
- * Its master-slave: ms_ds_* -> slave_ds_*
- * Its type: INLINE
- * Its config: yaml/proxy/config-master_slave_enc_sharding.yaml
- *
- */
-public class JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertOne extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (id,k,c,pad) VALUES (?,?,?,?)";
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableDemo");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(1, 3, "##-####", "##-####");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertUpdateDelete.java
deleted file mode 100644
index 8675895..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertUpdateDelete.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/ms_enc_sharding_new/sp_all.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its database algorithm.expression: ms_ds_${id % 4}
- * Its table algorithm.expression: sbtest${k % 1024}
- * Its master-slave: ms_ds_* -> slave_ds_*
- * Its type: INLINE
- * Its config: yaml/proxy/config-master_slave_enc_sharding.yaml
- *
- */
-public class JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestInsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPEncryptShardingAll");
- results.sampleStart();
-
- try {
-
- //Insert record
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet result = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- result.next();
- Long id = result.getLong(1);
-
- //update record
- List updateParams = Arrays.asList("new", "new", id);;
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //Delete record
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
-
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestSelect.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestSelect.java
deleted file mode 100644
index 6b1b3ba..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestSelect.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import service.api.entity.Iou;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/ms_enc_sharding_new/select_one.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its database algorithm.expression: ms_ds_${id % 4}
- * Its table algorithm.expression: sbtest${k % 1024}
- * Its master-slave: ms_ds_* -> slave_ds_*
- * Its type: INLINE
- * Its config: yaml/proxy/config-master_slave_enc_sharding.yaml
- *
- */
-public class JMeterProxyMasterSlaveEncryptAllDbAllTableSbTestSelect extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String SELECT_SQL = "SELECT id,k from " + TABLE_NAME + " ignore index(`PRIMARY`) where id=1 and k=3";
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPEncryptShardingSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
-
- return null;
- }
-
- public List getIou(ResultSet resultSet) throws SQLException {
- List<Iou> result = new LinkedList<>();
- while (resultSet.next()) {
- Iou iou = new Iou();
- iou.setK(resultSet.getInt(2));
- result.add(iou);
- }
- return result;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptInsertSbTestAction.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptInsertSbTestAction.java
deleted file mode 100644
index 2646438..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveEncryptInsertSbTestAction.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- *
- * Proxy scenario:
- * Its master-slave: master_ds* -> slave_ds*
- * Its config: yaml/proxy/config-master_slave.yaml
- *
- */
-public class JMeterProxyMasterSlaveEncryptInsertSbTestAction extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- //Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableInsert");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveInsertUpdateDeleteSbTest.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveInsertUpdateDeleteSbTest.java
deleted file mode 100644
index dbe322e..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveInsertUpdateDeleteSbTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/master_slave_new/sp_all_new.jmx
- *
- * Proxy scenario:
- * Its master-slave: master_ds* -> slave_ds*
- * Its config: yaml/proxy/config-master_slave.yaml
- *
- */
-public class JMeterProxyMasterSlaveInsertUpdateDeleteSbTest extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest3";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableAllnew");
- results.sampleStart();
-
- try {
- //Insert a record
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet result = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- result.next();
- Long id = result.getLong(1);
-
- //Update a record
- List updateParams = Arrays.asList("new", "new", id);;
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //Delete a record
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
-
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveSbTestInsert.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveSbTestInsert.java
deleted file mode 100644
index d711453..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyMasterSlaveSbTestInsert.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/master_slave_new/insert_1w.jmx
- *
- * Proxy scenario:
- * Its master-slave: master_ds* -> slave_ds*
- * Its config: yaml/proxy/config-master_slave.yaml
- *
- */
-public class JMeterProxyMasterSlaveSbTestInsert extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest3";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute inser action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableInsertNew");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestDelete.java
deleted file mode 100644
index 677c39e..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestDelete.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/sp_single_new/delete_all.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_alltable.yaml
- */
-public class JMeterProxyShardingAllDbAllTableSbTestDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute truncate action to clear data.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableDelete");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestInsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestInsertUpdateDelete.java
deleted file mode 100644
index 474ee91..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSbTestInsertUpdateDelete.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/sp_single_new/sp_all.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_alltable.yaml
- */
-public class JMeterProxyShardingAllDbAllTableSbTestInsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("JdbcSingleTableDelete");
- results.sampleStart();
-
- try {
-
- //insert an item
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update an item
- List updateParams = Arrays.asList("##-####", "##-####", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete an item
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSelectSbTestSelect.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSelectSbTestSelect.java
deleted file mode 100644
index 7d75b4f..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTableSelectSbTestSelect.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-/**
- /**
- * Refator old case test_plan/sp_single_new/sp_select.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_alltable.yaml
- */
-public class JMeterProxyShardingAllDbAllTableSelectSbTestSelect extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- public static final String SELECT_SQL = "select id,k from sbtest ignore index(`PRIMARY`) where id=1 and k=3";
-
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSelect");
- results.sampleStart();
-
- try {
-
- //select items
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsert.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsert.java
deleted file mode 100644
index 2648a0d..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsert.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/sp_single_new/insert_1w.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_alltable.yaml
- */
-public class JMeterProxyShardingAllDbAllTabletSbTestInsert extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (id,k,c,pad) VALUES (?,?,?,?)";
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableDemo");
- results.sampleStart();
-
- try {
-
- //insert an item
- List insertParams = Arrays.asList(1, 3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsertOne.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsertOne.java
deleted file mode 100644
index 96f7849..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbAllTabletSbTestInsertOne.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/insert_demo.jmx
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_alltable.yaml
- *
- */
-public class JMeterProxyShardingAllDbAllTabletSbTestInsertOne extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (id,k,c,pad) VALUES (?,?,?,?)";
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableDemo");
- results.sampleStart();
-
- try {
-
- //insert an item
- List insertParams = Arrays.asList(1, 3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest3InsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest3InsertUpdateDelete.java
deleted file mode 100644
index aefa5ef..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest3InsertUpdateDelete.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/sp_all.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest3
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest3
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_singletable.yaml
- */
-public class JMeterProxyShardingAllDbSingleTableSbTest3InsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- // Init dataSource.
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSelect");
- results.sampleStart();
-
- try {
-
- //Insert record
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet result = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- result.next();
- Long id = result.getLong(1);
-
- //update record
- List updateParams = Arrays.asList("##-####", "##-####", id);;
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //Delete record
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
-
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Delete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Delete.java
deleted file mode 100644
index ea0adb5..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Delete.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/sp_single_new/delete_all.jmx
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest4
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest4
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_singletable_new.yaml
- */
-public class JMeterProxyShardingAllDbSingleTableSbTest4Delete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableClean");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Insert.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Insert.java
deleted file mode 100644
index 23aefa9..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Insert.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/sp_single_new/insert_1w.jmx
- *
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest4
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest4
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_singletable_new.yaml
- */
-public class JMeterProxyShardingAllDbSingleTableSbTest4Insert extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- /**
- * Execute insert action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableClean");
- results.sampleStart();
-
- try {
-
- List insertParams = Arrays.asList(3, "testtest", "test");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Select.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Select.java
deleted file mode 100644
index c300c7a..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/proxy/JMeterProxyShardingAllDbSingleTableSbTest4Select.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.proxy;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/new_sharding/sp_select.jmx
- * Proxy scenario:
- * Its actualDataNodes: press_test_${0..3}.sbtest4
- * Its dataSource.algorithm expression: press_test_${id % 4}
- * Its table.algorithm expression: sbtest4
- * Its type: INLINE
- * Its config: yaml/proxy/config-sharding_alldb_singletable_new.yaml
- */
-public class JMeterProxyShardingAllDbSingleTableSbTest4Select extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final int DB_PORT = 3307;
-
- public static final String DB_PASSWORD = "root";
-
- public static final String DB_USER_NAME = "root";
-
- public static final String DB_HOST = "10.222.16.178";
-
- public static final String DB_NAME = "sharding_db";
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String SELECT_SQL = "select max(id) from " + TABLE_NAME + " where id % 4 = 1";
-
- // Init dataSource
- static {
- dataSource = JDBCDataSourceUtil.initDb(DB_NAME, DB_HOST, DB_PORT, DB_USER_NAME, DB_PASSWORD);
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SPPerformanceSingleTableClean");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
- results.setSuccessful(false);
- e.printStackTrace();
- } finally {
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableInsertSbTestUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableInsertSbTestUpdateDelete.java
deleted file mode 100644
index 1de3c1b..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableInsertSbTestUpdateDelete.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/jdbc_sharding_new/all_test.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: {0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its type: INLINE
- */
-public class JMeterShardingAllDbAllTableInsertSbTestUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Execute insert, upadate, delete acition.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSSelect");
- results.sampleStart();
-
- try {
-
- //insert an record
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update an record
- List updateParams = Arrays.asList("new", "new", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete an record
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
-
- }
-
- return results;
- }
-
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableSbTestSelect.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableSbTestSelect.java
deleted file mode 100644
index a2ed3de..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbAllTableSbTestSelect.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/jdbc_sharding_new/select_one.jmx
- *
- * Sharding scenario
-
- * Its actualDataNodes: ds{0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- **/
-
-public class JMeterShardingAllDbAllTableSbTestSelect extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String SELECT_SQL = "select id,k from " + TABLE_NAME + " ignore index(`PRIMARY`) where id=1 and k=3";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_ALL_TABLE_SHARDING_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceNewSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableInsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableInsertUpdateDelete.java
deleted file mode 100644
index cb7c0ce..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableInsertUpdateDelete.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/sj_all.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: {0..3}.sbtest3
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its table.algorithm expression: sbtest3
- * Its type: INLINE
- *
- **/
-public class JMeterShardingAllDbSingleTableInsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_SINGLE_TABLE_SHARDING_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSSelect");
- results.sampleStart();
-
- try {
-
- //insert an record
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update an record
- List updateParams = Arrays.asList("new", "new", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete an record
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Delete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Delete.java
deleted file mode 100644
index 5c0f4be..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Delete.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/new_sharding/sj_clean_new.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: {0..3}.sbtest4
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its table.algorithm expression: sbtest4
- * Its type: INLINE
- *
- */
-public class JMeterShardingAllDbSingleTableSbTest4Delete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "truncate table " + TABLE_NAME;
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- *Execute truncate action to clear data.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSInsert");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, null);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get database connection.
- *
- * @param context
- */
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Insert.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Insert.java
deleted file mode 100644
index 2c33d32..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Insert.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/new_sharding/sj_insert.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: {0..3}.sbtest3
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its table.algorithm expression: sbtest3
- * Its type: INLINE
- *
- */
-public class JMeterShardingAllDbSingleTableSbTest4Insert extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String INSERT_SQL = "INSERT INTO " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformancecleanclean");
- results.sampleStart();
-
- try {
-
- //insert an record
- List insertParams = Arrays.asList(1, "##-####", "##-####");
- JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
-
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get dataSource connection.
- *
- * @param context
- */
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Select.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Select.java
deleted file mode 100644
index 65dc401..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingAllDbSingleTableSbTest4Select.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Refactor old case test_plan/new_sharding/sj_select.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: {0..3}.sbtest4
- * Its dataSource.algorithm expression: ds_${id % 4}
- * Its table.algorithm expression: sbtest4
- * Its type: INLINE
- *
- */
-public class JMeterShardingAllDbSingleTableSbTest4Select extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String SELECT_SQL = "select max(id) from " + TABLE_NAME + "where id %4 = 1";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.ALL_DATABASE_SINGLE_TABLE_SHARDING_NEW_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSInsert");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
-
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get dataSource connection.
- *
- * @param context
- */
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveEncryptAllDbAllTableSelect.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveEncryptAllDbAllTableSelect.java
deleted file mode 100644
index a7d29ce..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveEncryptAllDbAllTableSelect.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-
-/**
- * Refactor old case test_plan/jdbc_ms_enc_sharding_new/select_one.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: ms_ds_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its encrypt: aes, md5
- * Its master-slave: ms_ds_* -> ds_*_slave_*
- *
- */
-public class JMeterShardingMasterSlaveEncryptAllDbAllTableSelect extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String SELECT_SQL = "SELECT id,k from " + TABLE_NAME + " where id=1 and k=1";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Execute select action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSSelect");
- results.sampleStart();
-
- try {
-
- JDBCDataSourceUtil.select(connection, SELECT_SQL, null);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get dataSource connection.
- *
- * @param context
- */
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveInsertUpdateDelete.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveInsertUpdateDelete.java
deleted file mode 100644
index 4d8efef..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JMeterShardingMasterSlaveInsertUpdateDelete.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor old case test_plan/jdbc_ms_new/all_test.jmx.
- * Sharding scenario:
- * Its master-slave: ds_master* -> ds_slave*
- *
- */
-public class JMeterShardingMasterSlaveInsertUpdateDelete extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest3";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.MASTER_SLAVE_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-
- /**
- * Execute insert, update, delete action.
- *
- * @param context
- * @return
- */
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSSelect");
- results.sampleStart();
-
- try {
-
- //insert an item
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update an item
- List updateParams = Arrays.asList("new", "new", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete an item
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get dataSource connection.
- *
- * @param context
- */
- public void setupTest(JavaSamplerContext context) {
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterShardingMasterSlaveEncryptAllDbAllTableInsertUpdateDeleteAction.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterShardingMasterSlaveEncryptAllDbAllTableInsertUpdateDeleteAction.java
deleted file mode 100644
index 09f27ca..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterShardingMasterSlaveEncryptAllDbAllTableInsertUpdateDeleteAction.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.config.Arguments;
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.apache.shardingsphere.benchmark.db.jdbc.JDBCDataSourceUtil;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingConfigType;
-import org.apache.shardingsphere.benchmark.db.shardingjdbc.ShardingJDBCDataSourceFactory;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Refactor test_plan/jdbc_ms_enc_sharding_new/all_test.jmx
- *
- * Sharding scenario:
- * Its actualDataNodes: ms_ds_${0..3}.sbtest${0..1023}
- * Its dataSource.algorithm expression: ms_ds_${id % 4}
- * Its table.algorithm expression: sbtest${k % 1024}
- * Its type: INLINE
- * Its encrypt: aes, md5
- * Its master-slave: ms_ds_* -> ds_*_slave_*
- *
- */
-public class JmeterShardingMasterSlaveEncryptAllDbAllTableInsertUpdateDeleteAction extends AbstractJavaSamplerClient {
-
- public Connection connection;
-
- public static DataSource dataSource;
-
- public static final String TABLE_NAME = "sbtest";
-
- public static final String DELETE_SQL = "delete from " + TABLE_NAME + " where k=? and id=?";
-
- public static final String INSERT_SQL = "insert into " + TABLE_NAME + " (k,c,pad) VALUES (?,?,?)";
-
- public static final String UPDATE_SQL = "update " + TABLE_NAME + " set c=?,pad =? where id=? and k=3";
-
- // Init dataSource.
- static{
- try {
- dataSource = ShardingJDBCDataSourceFactory.newInstance (ShardingConfigType.MASTER_SLAVE_ENCRYPT_SHARDING_CONFIG);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext context) {
-
- SampleResult results = new SampleResult();
- results.setSampleLabel("SJPerformanceMSSelect");
- results.sampleStart();
-
- try {
-
- //insert an item
- List insertParams = Arrays.asList(3, "##-####", "##-####");
- ResultSet rs = JDBCDataSourceUtil.insert(connection, INSERT_SQL, insertParams);
- rs.next();
- Long id = rs.getLong(1);
-
- //update an item
- List updateParams = Arrays.asList("new", "new", id);
- JDBCDataSourceUtil.update(connection, UPDATE_SQL, updateParams);
-
- //delete an item
- List deleteParams = Arrays.asList(3, id);
- JDBCDataSourceUtil.delete(connection, DELETE_SQL, deleteParams);
- results.setSuccessful(true);
-
- } catch (SQLException e) {
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- } catch (Exception e){
-
- results.setSuccessful(false);
- e.printStackTrace();
-
- }finally {
-
- results.sampleEnd();
- }
-
- return results;
- }
-
- @Override
- public Arguments getDefaultParameters() {
- return null;
- }
-
- /**
- * Get dataSource connection.
- *
- * @param context
- */
- public void setupTest(JavaSamplerContext context) {
-
- try {
-
- connection = dataSource.getConnection();
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-
- /**
- * Close dataSource connection.
- *
- * @param context
- */
- @Override
- public void teardownTest(JavaSamplerContext context) {
-
- try {
-
- JDBCDataSourceUtil.close(connection);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterTest.java b/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterTest.java
deleted file mode 100644
index e12da69..0000000
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/jmeter/sharding/JmeterTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.shardingsphere.benchmark.jmeter.sharding;
-
-import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
-import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
-import org.apache.jmeter.samplers.SampleResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JmeterTest extends AbstractJavaSamplerClient {
-
- private static final Logger log = LoggerFactory.getLogger(JmeterTest.class);
-
- static {
- System.out.println("static .....");
- }
-
- @Override
- public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
- log.debug(this.getClass().getName() + ": runTest");
- System.out.println(this.getClass().getName() + ": runTest");
- return null;
- }
-
- @Override
- public void setupTest(JavaSamplerContext context) {
-
- log.debug(this.getClass().getName() + ": setupTest");
- System.out.println(this.getClass().getName() + ": setupTest");
- }
-
- @Override
- public void teardownTest(JavaSamplerContext context) {
- log.debug(this.getClass().getName() + ": teardownTest");
- System.out.println(this.getClass().getName() + ": teardownTest");
- super.teardownTest(context);
-
-
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/perfstmt/ShardingPerfStmt.java b/shardingsphere-benchmark/src/main/java/perfstmt/ShardingPerfStmt.java
new file mode 100644
index 0000000..9c2f3ad
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/perfstmt/ShardingPerfStmt.java
@@ -0,0 +1,59 @@
+/*
+ * 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 perfstmt;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * sql statements used for performance.
+ *
+ * @author nancyzrh
+ */
+@RequiredArgsConstructor
+@Getter
+public enum ShardingPerfStmt {
+
+ /**
+ * stmt for perf.
+ */
+ CLEAN_ALL_STMT("delete from ssperf"),
+
+ DELETE_STMT("delete from ssperf where k=? and id=?"),
+
+ INSERT_STMT("INSERT INTO ssperf(k,c,pad) VALUES (?,?,?)"),
+
+ INSET_DEMO_STMT("INSERT INTO ssperf(id,k,c,pad) VALUES (?,?,?,?)"),
+
+ SELECT_STMT("SELECT id,k from ssperf where id=1 and k=1"),
+
+ UPDATE_STMT("update ssperf set c=?,pad=? where id=? and k=?"),
+
+ INSERT_SQL_STMT("INSERT INTO ssperf(k,c,pad) VALUES (?,?,?)"),
+
+ UPDATE_SQL_STMT("update ssperf set c=?,pad =? where id=? and k=?"),
+
+ DELETE_SQL_STMT("delete from ssperf where k=? and id=?"),
+
+ SINGLE_ROUTE_SELECT("SELECT id,k from ssperf where id=1 and k=1"),
+
+ FULL_ROUTE_SELECT("SELECT max(id) from ssperf where id%4=1");
+
+ private final String value;
+
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/entity/Iou.java b/shardingsphere-benchmark/src/main/java/service/api/entity/Iou.java
index 4f40395..20ed67a 100644
--- a/shardingsphere-benchmark/src/main/java/service/api/entity/Iou.java
+++ b/shardingsphere-benchmark/src/main/java/service/api/entity/Iou.java
@@ -1,44 +1,50 @@
+/*
+ * 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 service.api.entity;
+import lombok.Getter;
+import lombok.Setter;
+
import java.io.Serializable;
/**
- * operation object for jmeter performance
+ * Iou entity.
+ * @author nancyzrh
*/
+@Setter
+@Getter
public class Iou implements Serializable {
- private static final long serialVersionUID = 5377660875939152645L;
-
+ private static final long serialVersionUID = -4245146895898370269L;
+
private int k;
+
private String c;
+
private String pad;
-
- public int getK() {
- return k;
- }
-
- public void setK(int k) {
- this.k = k;
- }
-
- public String getC() {
- return c;
- }
-
- public void setC(String c) {
- this.c = c;
- }
-
- public String getPad() {
- return pad;
- }
-
- public void setPad(String pad) {
- this.pad = pad;
- }
-
+
+ /**
+ * impliment to string.
+ * @return result string
+ */
@Override
public String toString() {
return String.format("k: %s, c: %s, pad: %s", k, c, pad);
}
-
+
}
+
diff --git a/shardingsphere-benchmark/src/main/java/service/api/entity/Order.java b/shardingsphere-benchmark/src/main/java/service/api/entity/Order.java
deleted file mode 100644
index 4ffe979..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/entity/Order.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package service.api.entity;
-
-import java.io.Serializable;
-
-public class Order implements Serializable {
-
- private static final long serialVersionUID = 6432654733117035282L;
-
- 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);
- }
-}
-
diff --git a/shardingsphere-benchmark/src/main/java/service/api/entity/OrderItem.java b/shardingsphere-benchmark/src/main/java/service/api/entity/OrderItem.java
deleted file mode 100644
index 925bb11..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/entity/OrderItem.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package service.api.entity;
-
-import java.io.Serializable;
-
-public class OrderItem implements Serializable {
-
- private static final long serialVersionUID = -4101080582770159612L;
-
- 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);
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/repository/CommonRepository.java b/shardingsphere-benchmark/src/main/java/service/api/repository/CommonRepository.java
deleted file mode 100644
index bd3ef23..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/repository/CommonRepository.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package service.api.repository;
-
-import java.sql.SQLException;
-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(String sql) throws SQLException;
-
- List<T> selectRange() throws SQLException;
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/repository/OrderItemRepository.java b/shardingsphere-benchmark/src/main/java/service/api/repository/OrderItemRepository.java
deleted file mode 100644
index c91ebb5..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/repository/OrderItemRepository.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package service.api.repository;
-
-import service.api.entity.OrderItem;
-
-public interface OrderItemRepository extends CommonRepository<OrderItem> {
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/repository/OrderRepository.java b/shardingsphere-benchmark/src/main/java/service/api/repository/OrderRepository.java
deleted file mode 100644
index 908aa8a..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/repository/OrderRepository.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package service.api.repository;
-
-import service.api.entity.Order;
-
-public interface OrderRepository extends CommonRepository<Order> {
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/service/CommonService.java b/shardingsphere-benchmark/src/main/java/service/api/service/CommonService.java
deleted file mode 100644
index 0dcc258..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/service/CommonService.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package service.api.service;
-
-import java.sql.SQLException;
-
-public interface CommonService {
-
- void initEnvironment();
-
- void cleanEnvironment();
-
- void processSuccess(boolean isRangeSharding, String sql) throws SQLException;
-
- void processFailure();
-
- void printData(boolean isRangeSharding, String sql) throws SQLException;
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/service/CommonServiceImpl.java b/shardingsphere-benchmark/src/main/java/service/api/service/CommonServiceImpl.java
deleted file mode 100644
index 2b2c121..0000000
--- a/shardingsphere-benchmark/src/main/java/service/api/service/CommonServiceImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package service.api.service;
-
-import service.api.entity.Order;
-import service.api.entity.OrderItem;
-import service.api.repository.OrderItemRepository;
-import service.api.repository.OrderRepository;
-
-import java.sql.SQLException;
-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, String sql) throws SQLException {
- printData(isRangeSharding, sql);
- }
-
- @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, String sql) throws SQLException {
- if (isRangeSharding) {
- printDataRange();
- } else {
- printDataAll(sql);
- }
- }
-
- private void printDataRange() throws SQLException {
- for (Object each : getOrderRepository().selectRange()) {
- }
- for (Object each : getOrderItemRepository().selectRange()) {
- }
- }
-
- private void printDataAll(String sql) throws SQLException {
- for (Object each : getOrderRepository().selectAll(sql)) {
- }
- }
-
- protected abstract OrderRepository getOrderRepository();
-
- protected abstract OrderItemRepository getOrderItemRepository();
-
- protected abstract Order newOrder();
-
- protected abstract OrderItem newOrderItem();
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/api/service/SJPerfService.java b/shardingsphere-benchmark/src/main/java/service/api/service/SJPerfService.java
index dabc2f7..343ce4b 100644
--- a/shardingsphere-benchmark/src/main/java/service/api/service/SJPerfService.java
+++ b/shardingsphere-benchmark/src/main/java/service/api/service/SJPerfService.java
@@ -1,12 +1,36 @@
+/*
+ * 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 service.api.service;
+import lombok.Getter;
+
import javax.sql.DataSource;
import java.sql.SQLException;
+/**
+ * sj performance service.
+ * @author nancyzrh
+ */
+@Getter
public class SJPerfService {
- public final DataSource dataSource;
-
- public SJPerfService (DataSource dataSource) throws SQLException {
+ private final DataSource dataSource;
+
+ public SJPerfService(final DataSource dataSource) throws SQLException {
this.dataSource = dataSource;
}
}
diff --git a/shardingsphere-benchmark/src/main/java/service/config/MasterSlaveConfiguration.java b/shardingsphere-benchmark/src/main/java/service/config/MasterSlaveConfiguration.java
deleted file mode 100644
index bc8d753..0000000
--- a/shardingsphere-benchmark/src/main/java/service/config/MasterSlaveConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package service.config;
-
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
-import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
-import org.apache.shardingsphere.masterslave.rule.MasterSlaveRule;
-import service.util.config.DataSourceUtil;
-import service.util.config.ExampleConfiguration;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-import java.util.*;
-
-public class MasterSlaveConfiguration implements ExampleConfiguration {
-
- private static DataSource dataSource;
-
- @Override
- public DataSource createDataSource() throws SQLException {
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig = new MasterSlaveDataSourceRuleConfiguration("master_slave", "master_ds", Arrays.asList("slave_ds_0", "slave_ds_1"), null);
-
- MasterSlaveRuleConfiguration masterSlaveRuleConfiguration = new MasterSlaveRuleConfiguration(Collections.singleton(masterSlaveRuleConfig), Collections.<String, ShardingSphereAlgorithmConfiguration>emptyMap());
-
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- dataSource = ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), Arrays.<RuleConfiguration>asList(masterSlaveRuleConfiguration), properties);
- return dataSource;
- }
-
- @Override
- public DataSource getDataSource() {
- return dataSource;
- }
-
- private Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("master_ds", DataSourceUtil.getDataSource("master_ds"));
- result.put("slave_ds_0", DataSourceUtil.getDataSource("master_ds"));
- result.put("slave_ds_1", DataSourceUtil.getDataSource("master_ds"));
- return result;
- }
-
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/config/ShardingDatabasesAndTablesConfigurationPrecise.java b/shardingsphere-benchmark/src/main/java/service/config/ShardingDatabasesAndTablesConfigurationPrecise.java
deleted file mode 100644
index d37c33d..0000000
--- a/shardingsphere-benchmark/src/main/java/service/config/ShardingDatabasesAndTablesConfigurationPrecise.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package service.config;
-
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-//import org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm;
-import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import service.util.config.DataSourceUtil;
-import service.util.config.ExampleConfiguration;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class ShardingDatabasesAndTablesConfigurationPrecise implements ExampleConfiguration {
-
- private static DataSource dataSource;
-
- @Override
- public DataSource createDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTables().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTables().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "p_ds_${user_id % 2}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "t_order_${order_id % 2}");*/
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "inline"));
- shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("order_id", "inline"));
-
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- dataSource = ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), Arrays.<RuleConfiguration>asList(shardingRuleConfig), properties);
- return dataSource;
- }
-
-
- @Override
- public DataSource getDataSource() {
- return dataSource;
- }
-
- private static ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_order", "p_ds_${0..1}.t_order_${[0, 1]}");
- return result;
- }
-
- private static ShardingTableRuleConfiguration getOrderItemTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_order_item", "p_ds_${0..1}.t_order_item_${[0, 1]}");
- return result;
- }
-
- private static Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("p_ds_0", DataSourceUtil.getDataSource("p_ds_0"));
- result.put("p_ds_1", DataSourceUtil.getDataSource("p_ds_1"));
- return result;
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderItemRepositoryImpl.java b/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderItemRepositoryImpl.java
deleted file mode 100644
index 353f292..0000000
--- a/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderItemRepositoryImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package service.repository.jdbc;
-
-import service.api.entity.OrderItem;
-import service.api.repository.OrderItemRepository;
-
-import javax.sql.DataSource;
-import java.sql.*;
-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) {
- 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;
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderRepositoryImpl.java b/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderRepositoryImpl.java
deleted file mode 100644
index a85d53e..0000000
--- a/shardingsphere-benchmark/src/main/java/service/repository/jdbc/JDBCOrderRepositoryImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package service.repository.jdbc;
-
-import service.api.entity.Order;
-import service.api.repository.OrderRepository;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.LinkedList;
-import java.util.List;
-
-public 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) throws SQLException {
- return getOrders(sql);
- }
-
- @Override
- public List<Order> selectRange() throws SQLException {
- String sql = "SELECT * FROM t_order WHERE order_id BETWEEN 1 AND 10";
- return getOrders(sql);
- }
-
- private List<Order> getOrders(final String sql) throws SQLException {
- 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);
- }
- }
- return result;
- }
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/repository/service/RawPojoService.java b/shardingsphere-benchmark/src/main/java/service/repository/service/RawPojoService.java
deleted file mode 100644
index 5a65e7a..0000000
--- a/shardingsphere-benchmark/src/main/java/service/repository/service/RawPojoService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package service.repository.service;
-
-import service.api.entity.Order;
-import service.api.entity.OrderItem;
-import service.api.repository.OrderItemRepository;
-import service.api.repository.OrderRepository;
-import service.api.service.CommonServiceImpl;
-import service.repository.jdbc.JDBCOrderItemRepositoryImpl;
-import 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();
- }
-}
-
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java b/shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingDatabaseAlgorithm.java
similarity index 50%
copy from shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java
copy to shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingDatabaseAlgorithm.java
index 5e3f3e9..64fd089 100644
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java
+++ b/shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingDatabaseAlgorithm.java
@@ -15,35 +15,32 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.benchmark.db.fixture;
+package service.util.algorithm;
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
-import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
+import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
+import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
import java.util.Collection;
-import java.util.Properties;
-
-@Getter
-@Setter
-public final class MultiAlgorithm implements ComplexKeysShardingAlgorithm<String> {
-
- private Properties props = new Properties();
-
- @Override
- public void init() {
- }
-
- @Override
- public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<String> shardingValue) {
- return null;
- }
+/**
+ * precise module sharding database algorithm.
+ * @author nancyzrh
+ */
+public class PreciseModuleShardingDatabaseAlgorithm implements PreciseShardingAlgorithm<Integer> {
+
+ /**
+ * do sharding.
+ * @param databaseNames database names
+ * @param shardingValue sharding value
+ * @return string
+ */
@Override
- public String getType() {
- return "COMPLEX_TEST";
+ 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();
}
-
-
-}
\ No newline at end of file
+}
diff --git a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java b/shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingTableAlgorithm.java
similarity index 50%
rename from shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java
rename to shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingTableAlgorithm.java
index 5e3f3e9..fd942ec 100644
--- a/shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/db/fixture/MultiAlgorithm.java
+++ b/shardingsphere-benchmark/src/main/java/service/util/algorithm/PreciseModuleShardingTableAlgorithm.java
@@ -15,35 +15,32 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.benchmark.db.fixture;
+package service.util.algorithm;
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
-import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
+import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
+import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
import java.util.Collection;
-import java.util.Properties;
-
-@Getter
-@Setter
-public final class MultiAlgorithm implements ComplexKeysShardingAlgorithm<String> {
-
- private Properties props = new Properties();
-
- @Override
- public void init() {
- }
-
- @Override
- public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<String> shardingValue) {
- return null;
- }
+/**
+ * precise module sharding table algorithm.
+ * @author nancyzrh
+ */
+public class PreciseModuleShardingTableAlgorithm implements PreciseShardingAlgorithm<Integer> {
+
+ /**
+ * do sharding.
+ * @param tableNames table names
+ * @param shardingValue sharding value
+ * @return string
+ */
@Override
- public String getType() {
- return "COMPLEX_TEST";
+ public String doSharding(final Collection<String> tableNames, final PreciseShardingValue<Integer> shardingValue) {
+ for (String each : tableNames) {
+ if (each.endsWith(shardingValue.getValue() % 2 + "")) {
+ return each;
+ }
+ }
+ throw new UnsupportedOperationException();
}
-
-
-}
\ No newline at end of file
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingDatabaseAlgorithm.java b/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingDatabaseAlgorithm.java
new file mode 100644
index 0000000..f8dcccf
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingDatabaseAlgorithm.java
@@ -0,0 +1,63 @@
+/*
+ * 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 service.util.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;
+
+/**
+ * range module sharding database algorithm.
+ * @author nancyzrh
+ */
+public class RangeModuleShardingDatabaseAlgorithm implements RangeShardingAlgorithm<Integer> {
+
+ /**
+ * do sharding.
+ * @param databaseNames database names
+ * @param shardingValue sharding value
+ * @return collection result
+ */
+ @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;
+ }
+}
+
diff --git a/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingTableAlgorithm.java b/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingTableAlgorithm.java
new file mode 100644
index 0000000..cf0ffe9
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/algorithm/RangeModuleShardingTableAlgorithm.java
@@ -0,0 +1,54 @@
+/*
+ * 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 service.util.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;
+
+/**
+ * range module sharding table algorithm.
+ * @author nancyzrh
+ */
+public class RangeModuleShardingTableAlgorithm implements RangeShardingAlgorithm<Long> {
+
+ /**
+ * do sharding.
+ * @param tableNames table names
+ * @param shardingValue sharding value
+ * @return collection result
+ */
+ @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;
+ }
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/AesDataSourceUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/AesDataSourceUtil.java
deleted file mode 100644
index 0705b3c..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/AesDataSourceUtil.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package service.util.config;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-import service.api.entity.Iou;
-
-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.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-public class AesDataSourceUtil {
- private static final String USER_NAME = "####";
- private static final String DEFAULT_SCHEMA = "test";
- private static final Map<String, DataSource> datasourceMap = new HashMap<>();
-
- /**
- * create data source
- * @param dataSourceName
- * @param host
- * @param port
- * @param password
- */
- public static void createDataSource(final String dataSourceName, final String host, final int port, final String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("com.mysql.jdbc.Driver");
- config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(USER_NAME);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- DataSource dataSource = new HikariDataSource(config);
- Properties properties = new Properties();
- // EncryptRuleConfiguration ruleConfiguration = createEncryptRuleConfiguration();
- // try {
- // dataSource = EncryptDataSourceFactory.createDataSource(dataSource, ruleConfiguration, properties);
- // } catch (final SQLException ignored) {
- // }
- datasourceMap.put(dataSourceName, dataSource);
- }
-
- /**
- * get datasource
- * @param dataSourceName
- * @return datasource
- */
- public static DataSource getDataSource(final String dataSourceName) {
- return datasourceMap.get(dataSourceName);
- }
-
- /**
- * create default schema
- * @param dataSourceName
- */
- public static void createSchema(final String dataSourceName) {
- String sql = "CREATE DATABASE " + dataSourceName;
- try (Connection connection = getDataSource(DEFAULT_SCHEMA).getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(sql);
- } catch (final SQLException ignored) {
- }
- }
-
- /**
- * insert demo data
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void insertDemo(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1, 1);
- preparedStatement.setInt(2, 1);
- preparedStatement.setString(3, "##-####");
- preparedStatement.setString(4, "##-####");
- preparedStatement.execute();
- } catch (final SQLException ignored) {
- }
- }
-
- /**
- * for select
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static List<Iou> getIou(final String sql, String datasource) throws SQLException {
- List<Iou> result = new LinkedList<>();
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery()) {
- while (resultSet.next()) {
- Iou iou = new Iou();
- iou.setK(resultSet.getInt(2));
- result.add(iou);
- }
- }
- return result;
- }
-
- /**
- * for update
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int updateStmt(final String sql, String datasource) throws SQLException{
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1,"##-#####");
- preparedStatement.setString(2,"##-#####");
- preparedStatement.setInt(3,1);
- preparedStatement.setInt(4,1);
- return preparedStatement.executeUpdate();
- }
- }
-
- /**
- * for insert performance
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void insertIou(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1, 1);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.execute();
- } catch (final SQLException ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * clean up environment
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void clean(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.executeUpdate();
- }
- }
-
- /**
- * for delete performance
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int deleteIou(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,1);
- preparedStatement.setInt(2,1);
- return preparedStatement.executeUpdate();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceMultiUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceMultiUtil.java
deleted file mode 100644
index 25df88a..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceMultiUtil.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package service.util.config;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-import service.api.entity.Iou;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-public class DataSourceMultiUtil {
- private static final String USER_NAME = "root";
- private static final String DEFAULT_SCHEMA = "test";
- private static final Map<String, DataSource> datasourceMap = new HashMap<>();
-
- /**
- * create data source
- * @param dataSourceName
- * @param host
- * @param port
- * @param password
- */
- public static void createDataSource(final String dataSourceName, final String host, final int port, final String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("com.mysql.jdbc.Driver");
- config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(USER_NAME);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- DataSource dataSource = new HikariDataSource(config);
- datasourceMap.put(dataSourceName, dataSource);
- }
-
- /**
- * get datasource
- * @param dataSourceName
- * @return datasource
- */
- public static DataSource getDataSource(final String dataSourceName) {
- return datasourceMap.get(dataSourceName);
- }
-
- /**
- * create default schema
- * @param dataSourceName
- */
- public static void createSchema(final String dataSourceName) {
- String sql = "CREATE DATABASE " + dataSourceName;
- try (Connection connection = getDataSource(DEFAULT_SCHEMA).getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(sql);
- } catch (final SQLException ignored) {
- }
- }
-
- /**
- * insert demo data
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void insertDemo(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1, 1);
- preparedStatement.setInt(2, 1);
- preparedStatement.setString(3, "##-####");
- preparedStatement.setString(4, "##-####");
- preparedStatement.execute();
- } catch (final SQLException ignored) {
- }
- }
-
- /**
- * for select
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static List<Iou> getIou(final String sql, String datasource) throws SQLException {
- List<Iou> result = new LinkedList<>();
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery()) {
- while (resultSet.next()) {
- Iou iou = new Iou();
- iou.setK(resultSet.getInt(2));
- result.add(iou);
- }
- }
- return result;
- }
-
- /**
- * for update
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int updateStmt(final String sql, String datasource) throws SQLException{
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1,"##-#####");
- preparedStatement.setString(2,"##-#####");
- preparedStatement.setInt(3,1);
- preparedStatement.setInt(4,1);
- return preparedStatement.executeUpdate();
- }
- }
-
- /**
- * for insert performance
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void insertIou(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- //preparedStatement.setInt(1, 1);
- preparedStatement.setInt(1, ThreadLocalRandom.current().nextInt(1024));
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.execute();
- } catch (final SQLException ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * clean up environment
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void clean(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.executeUpdate();
- }
- }
-
- /**
- * for delete performance
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int deleteIou(final String sql, String datasource) throws SQLException {
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,1);
- preparedStatement.setInt(2,1);
- return preparedStatement.executeUpdate();
- }
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtil.java
index c5fa4f8..b5dec38 100644
--- a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtil.java
+++ b/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtil.java
@@ -1,37 +1,54 @@
+/*
+ * 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 service.util.config;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
-import service.api.entity.Iou;
-import java.util.Date;
-import java.text.SimpleDateFormat;
+
import javax.sql.DataSource;
import java.sql.*;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
- * dataSource util
- * @author nancyzrh
+ * datasource utils for MySQL Jdbc.
*/
public class DataSourceUtil {
- private static final String USER_NAME = "root";
- private static final String DEFAULT_SCHEMA = "test";
private static final Map<String, DataSource> datasourceMap = new HashMap<>();
-
+
/**
- * create data source
- * @param dataSourceName
- * @param host
- * @param port
- * @param password
+ * create data source for jdbc
+ * @param userName user name
+ * @param dataSourceName datasource name
+ * @param host host
+ * @param port port
+ * @param password pwd
*/
- public static void createDataSource(final String dataSourceName, final String host, final int port, final String password) {
+ public static void createDataSource(final String userName, final String dataSourceName, final String host, final int port, final String password) {
HikariConfig config = new HikariConfig();
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(USER_NAME);
+ config.setUsername(userName);
config.setPassword(password);
config.setMaximumPoolSize(200);
+ config.setConnectionTimeout(30000);
+ config.setIdleTimeout(60000);
+ config.setMaxLifetime(1800000);
config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", 250);
@@ -46,400 +63,104 @@ public class DataSourceUtil {
DataSource dataSource = new HikariDataSource(config);
datasourceMap.put(dataSourceName, dataSource);
}
-
+
/**
- * get datasource
- * @param dataSourceName
+ * get datasource from name.
+ * @param dataSourceName input name
* @return datasource
*/
public static DataSource getDataSource(final String dataSourceName) {
return datasourceMap.get(dataSourceName);
}
-
- /**
- * create default schema
- * @param dataSourceName
- */
- public static void createSchema(final String dataSourceName) throws SQLException {
- String sql = "CREATE DATABASE " + dataSourceName;
- Connection connection = null;
- try {
- connection = getDataSource(DEFAULT_SCHEMA).getConnection();
- Statement statement = connection.createStatement();
- statement.execute(sql);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if(connection != null){
- connection.close();
- }
- }
- }
-
- public static void main(String args[]) {
- DataSourceUtil.createDataSource("sharding_db", "10.222.16.178", 3307, "root");
- String insertSql = "INSERT INTO sbtest99 (id,k,c,pad) VALUES (?,?,?,?)";
- try {
- DataSourceUtil.insertDemo(insertSql, "sharding_db");
- } catch (final SQLException ex) {
-
- }
- }
+
/**
- * insert demo data
- * @param sql
+ * for master slave compare
* @param datasource
* @throws SQLException
*/
- public static void insertDemo(final String sql, String datasource) throws SQLException {
+ public static void writeReadOp(final String datasource) throws SQLException {
+ String sql = "INSERT INTO ssperf (k,c,pad) VALUES (?,?,?)";
Connection connection = null;
try {
connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
preparedStatement.setInt(1, 1);
- preparedStatement.setInt(2, 3);
- preparedStatement.setString(3, "##-####");
- preparedStatement.setString(4, "##-####");
- preparedStatement.execute();
- } catch (final SQLException e) {
- e.printStackTrace();
- } finally {
- if(connection != null){
- connection.close();
- }
- }
- }
-
- /**
- * for select
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static List<Iou> getIou(final String sql, String datasource) throws SQLException {
- List<Iou> result = new LinkedList<>();
- Connection connection = null;
- try {
- connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery();
- while (resultSet.next()) {
- Iou iou = new Iou();
- iou.setK(resultSet.getInt(2));
- result.add(iou);
- }
- } catch (Exception e){
- e.printStackTrace();
- } finally {
- if(connection != null){
- connection.close();
- }
- }
- return result;
- }
- public static void singleMsAll(String datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet resultSet= null;
- try {
- connection = getDataSource(datasource).getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
preparedStatement.setString(2, "##-####");
preparedStatement.setString(3, "##-####");
preparedStatement.executeUpdate();
ResultSet result = preparedStatement.getGeneratedKeys();
result.next();
- id = result.getLong(1);
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=1 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- sql = "select count(id) from sbtest3";
+ Long id = result.getLong(1);
+ sql = "select count(id) from ssperf";
preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
preparedStatement.executeQuery();
- sql = "select max(id) from sbtest3 ignore index(`PRIMARY`)";
- //sql = "select max(id) from sbtest3";
+ sql = "select max(id) from ssperf ignore index(`PRIMARY`)";
preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
preparedStatement.executeQuery();
- // sql = "update sbtest3 set c=?,pad =? where id=? and k=3";
- // preparedStatement = connection.prepareStatement(sql);
- // preparedStatement.setString(1,"new");
- // preparedStatement.setString(2,"new");
- // preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- // preparedStatement.executeUpdate();
- sql = "delete from sbtest3 where k=? and id=?";
+ sql = "delete from ssperf where k=? and id=?";
preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setLong(2, id);
preparedStatement.executeUpdate();
+ preparedStatement.close();
+ result.close();
}catch (final SQLException ex) {
ex.printStackTrace();
} finally {
connection.close();
}
}
-
- public static void singleAll(String datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet resultSet= null;
+
+ /**
+ * for mysql compare without master slave scene
+ * @param datasource
+ * @throws SQLException
+ */
+ public static void writeOp(final String datasource) throws SQLException {
+ String sql = "INSERT INTO ssperf (k,c,pad) VALUES (?,?,?)";
+ Connection connection = null;
try {
connection = getDataSource(datasource).getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
+ PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
+ preparedStatement.setInt(1, 1);
preparedStatement.setString(2, "##-####");
preparedStatement.setString(3, "##-####");
preparedStatement.executeUpdate();
ResultSet result = preparedStatement.getGeneratedKeys();
result.next();
- id = result.getLong(1);
- sql = "update sbtest3 set c=?,pad =? where id=? and k=3";
+ Long id = result.getLong(1);
+ sql = "update ssperf set c=?,pad =? where id=? and k=1";
preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
+ preparedStatement.setString(1, "##-#####");
+ preparedStatement.setString(2, "##-#####");
+ preparedStatement.setLong(3, id);
preparedStatement.executeUpdate();
- sql = "delete from sbtest3 where k=? and id=?";
+ sql = "delete from ssperf where k=? and id=?";
preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- }catch (SQLException ex) {
- ex.printStackTrace();
- } finally {
- if (connection != null){
- connection.close();
- }
- //preparedStatement.close();
- //resultSet.close();
- //connection=null;
- }
- }
- /**
- * operation
- */
- public static void singleAllbak(String datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- long id = Long.MIN_VALUE;
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setInt(1, 1);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
+ preparedStatement.setLong(2, id);
preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- }catch (final SQLException ex) {
- ex.printStackTrace();
- }
- sql = "update sbtest3 set c=?,pad =? where id=? and k=?";
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement pr = connection.prepareStatement(sql)) {
- pr.setString(1,"new");
- pr.setString(2,"new");
- pr.setLong(3,id);
- pr.setInt(4,1);
- int res = pr.executeUpdate();
+ preparedStatement.close();
+ result.close();
}catch (final SQLException ex) {
ex.printStackTrace();
- }
- //sql = "TRUNCATE TABLE sbtest_bt";
- sql="delete from sbtest3 where k=? and id=?";
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,1);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- }
- }
-
- public static void changeAll(String datasource) throws SQLException {
- String sql = "INSERT INTO sbtest (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet resultSet= null;
- try {
- connection = getDataSource(datasource).getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- sql = "update sbtest set c=?,pad =? where id=? and k=3";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- sql = "delete from sbtest where k=? and id=?";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- }catch (SQLException ex) {
- ex.printStackTrace();
} finally {
- if (connection != null){
- connection.close();
- }
- // preparedStatement.close();
- // resultSet.close();
- // connection=null;
+ connection.close();
}
}
+
/**
- * operation for sharindg
+ * for select
+ * @param sql sql stmt
+ * @param datasource dataSource name
+ * @throws SQLException
*/
- public static void changeAllbak(String datasource) throws SQLException {
- String sql = "INSERT INTO sbtest (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS)) {
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- }catch (final SQLException ex) {
- ex.printStackTrace();
- }
- sql = "update sbtest set c=?,pad =? where id=? and k=?";
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- }
- sql = "delete from sbtest where k=? and id=?";
+ public static void getSelectRes(final String sql, String datasource) throws SQLException {
try (Connection connection = getDataSource(datasource).getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- }
- }
-
- /**
- * for update
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int updateStmt(final String sql, String datasource) throws SQLException{
- int result = 0;
- Connection connection = null;
- try {
- connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"##-#####");
- preparedStatement.setString(2,"##-#####");
- preparedStatement.setInt(3,1);
- preparedStatement.setInt(4,1);
- result = preparedStatement.executeUpdate();
- } catch (Exception e){
- e.printStackTrace();
- } finally {
- if (connection != null){
- connection.close();
- }
- }
- return result;
- }
-
- /**
- * for insert performance
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void insertIou(final String sql, String datasource) throws SQLException {
- Connection connection = null;
- try {
- connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.execute();
- } catch (final SQLException ex) {
- ex.printStackTrace();
- } finally {
- if (connection != null){
- connection.close();
- }
- }
- }
-
- /**
- * clean up environment
- * @param sql
- * @param datasource
- * @throws SQLException
- */
- public static void clean(final String sql, String datasource) throws SQLException {
- Connection connection = null;
- try {
- connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- preparedStatement.executeUpdate();
- } catch (Exception e){
- e.printStackTrace();
- } finally {
- if (connection != null){
- connection.close();
- }
- }
- }
-
- /**
- * for delete performance
- * @param sql
- * @param datasource
- * @return
- * @throws SQLException
- */
- public static int deleteIou(final String sql, String datasource) throws SQLException {
- Connection connection = null;
- int result = 0;
- try {
- connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,1);
- preparedStatement.setInt(2,1);
- result = preparedStatement.executeUpdate();
- } catch (Exception e){
- e.printStackTrace();
- } finally {
- if (connection != null){
- connection.close();
- }
+ ResultSet resultSet = preparedStatement.executeQuery();
}
- return result;
}
-
+
}
+
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtilPostgreSQL.java b/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtilPostgreSQL.java
deleted file mode 100644
index 1a2cf3a..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/DataSourceUtilPostgreSQL.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package service.util.config;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-import service.api.entity.Iou;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-public class DataSourceUtilPostgreSQL {
- private static final String USER_NAME = "###";
-
- private static final String DEFAULT_SCHEMA = "test";
-
- private static final Map<String, DataSource> datasourceMap = new HashMap<>();
-
- public static void createDataSource(final String dataSourceName, final String host, final int port, final String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("org.postgresql.Driver");
- config.setJdbcUrl(String.format("jdbc:postgresql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(USER_NAME);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- DataSource dataSource = new HikariDataSource(config);
- datasourceMap.put(dataSourceName, dataSource);
- }
-
- public static DataSource getDataSource(final String dataSourceName) {
- return datasourceMap.get(dataSourceName);
- }
-
- public static void createSchema(final String dataSourceName) {
- String sql = "CREATE DATABASE " + dataSourceName;
- try (Connection connection = getDataSource(DEFAULT_SCHEMA).getConnection();
- Statement statement = connection.createStatement()) {
- statement.execute(sql);
- } catch (final SQLException ignored) {
- }
- }
-
- public static List<Iou> getIou(final String sql, String datasource) throws SQLException {
- List<Iou> result = new LinkedList<>();
- try (Connection connection = getDataSource(datasource).getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql);
- ResultSet resultSet = preparedStatement.executeQuery()) {
- while (resultSet.next()) {
- Iou iou = new Iou();
- iou.setK(resultSet.getInt(1));
- iou.setC(resultSet.getString(2));
- iou.setPad(resultSet.getString(3));
- result.add(iou);
- }
- }
- return result;
- }
-
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/ExampleConfiguration.java b/shardingsphere-benchmark/src/main/java/service/util/config/ExampleConfiguration.java
deleted file mode 100644
index 8cc64eb..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/ExampleConfiguration.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package service.util.config;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-
-public interface ExampleConfiguration {
- DataSource createDataSource() throws SQLException;
-
- DataSource getDataSource();
-}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceFactory.java b/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceFactory.java
new file mode 100644
index 0000000..ca9ec80
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceFactory.java
@@ -0,0 +1,179 @@
+/*
+ * 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 service.util.config;
+
+import com.google.common.collect.Lists;
+import org.apache.shardingsphere.encrypt.api.EncryptColumnRuleConfiguration;
+import org.apache.shardingsphere.encrypt.api.EncryptRuleConfiguration;
+import org.apache.shardingsphere.encrypt.api.EncryptTableRuleConfiguration;
+import org.apache.shardingsphere.encrypt.api.EncryptorRuleConfiguration;
+import org.apache.shardingsphere.api.config.masterslave.LoadBalanceStrategyConfiguration;
+import org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration;
+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.shardingjdbc.api.MasterSlaveDataSourceFactory;
+import org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Arrays;
+import java.util.List;
+import java.util.LinkedHashMap;
+
+/**
+ * create datasource operation for Sharding-Jdbc.
+ * @author nancyzrh
+ */
+public class SJDataSourceFactory {
+
+ /**
+ * create datasource for master slave.
+ * @return datasource db
+ * @throws SQLException ex
+ */
+ public static DataSource createMSDataSource() throws SQLException {
+ Map<String, DataSource> dataSourceMap = new HashMap<>();
+ dataSourceMap.put("ds_master", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ dataSourceMap.put("ds_slave0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("ds_master_slave", "ds_master", Arrays.asList("ds_slave0"));
+ Properties properties = new Properties();
+ properties.setProperty("max.connections.size.per.query", "200");
+ properties.setProperty("executor.size", "200");
+ DataSource dataSource = MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, masterSlaveRuleConfig, properties);
+ return dataSource;
+ }
+
+ /**
+ * create sharding datasource.
+ * @return datasource db
+ * @throws SQLException ex
+ */
+ public static DataSource createShardingDataSource() throws SQLException {
+ TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration("ssperf", "ds_${0..3}.ssperf${0..1023}");
+ tableRuleConfig.setDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("id", "ds_${id % 4}"));
+ tableRuleConfig.setTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("k", "ssperf${k % 1024}"));
+ tableRuleConfig.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
+ Properties properties = new Properties();
+ properties.setProperty("max.connections.size.per.query", "200");
+ properties.setProperty("executor.size", "200");
+ return ShardingDataSourceFactory.createDataSource(createShardingDataSourceMap(), shardingRuleConfig, properties);
+ }
+
+ /**
+ * create sharding datasource map.
+ * @return datasource map
+ */
+ private static Map<String, DataSource> createShardingDataSourceMap() {
+ Map<String, DataSource> result = new HashMap<>();
+ result.put("ds_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_1", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_2", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_3", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ return result;
+ }
+
+ /**
+ * create datasource for master slave & encrypt & sharding scene.
+ * @return datasource
+ * @throws SQLException sqlexception
+ */
+ public static DataSource createMSEncShardingDataSource() throws SQLException {
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ TableRuleConfiguration tableRuleConfiguration = new TableRuleConfiguration("ssperf", "ms_ds_${0..3}.test${0..1023}");
+ tableRuleConfiguration.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
+ shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfiguration);
+ shardingRuleConfig.getBindingTableGroups().add("ssperf");
+ shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("id", "ms_ds_${id % 2}"));
+ shardingRuleConfig.setDefaultTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("k", "test${k % 1024}"));
+ shardingRuleConfig.setMasterSlaveRuleConfigs(getMSEncRuleConfigurations());
+ shardingRuleConfig.setEncryptRuleConfig(getMsEncRuleConfiguration());
+ Properties properties = new Properties();
+ properties.setProperty("max.connections.size.per.query", "200");
+ properties.setProperty("executor.size", "200");
+ return ShardingDataSourceFactory.createDataSource(createMSEncDataSourceMap(), shardingRuleConfig, properties);
+ }
+
+ /**
+ * * get master slave configurations for master slave & encrypt & sharding.
+ * @return master slave rule configuration
+ */
+ private static List<MasterSlaveRuleConfiguration> getMSEncRuleConfigurations() {
+ LoadBalanceStrategyConfiguration loadBalanceStrategyConfiguration = new LoadBalanceStrategyConfiguration("ROUND_ROBIN");
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveRuleConfiguration("ms_ds_0", "master_0", Arrays.asList("master_0_slave_0"), loadBalanceStrategyConfiguration);
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveRuleConfiguration("ms_ds_1", "master_1", Arrays.asList("master_1_slave_1"), loadBalanceStrategyConfiguration);
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig3 = new MasterSlaveRuleConfiguration("ms_ds_2", "master_2", Arrays.asList("master_2_slave_2"), loadBalanceStrategyConfiguration);
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig4 = new MasterSlaveRuleConfiguration("ms_ds_3", "master_3", Arrays.asList("master_3_slave_3"), loadBalanceStrategyConfiguration);
+ return Lists.newArrayList(masterSlaveRuleConfig1, masterSlaveRuleConfig2, masterSlaveRuleConfig3, masterSlaveRuleConfig4);
+ }
+
+ /**
+ * create datasourceMap for master slave & encrypt & sharding.
+ * @return datasource map
+ */
+ private static Map<String, DataSource> createMSEncDataSourceMap() {
+ final Map<String, DataSource> result = new HashMap<>();
+ result.put("master_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_0_slave_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_1", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_1_slave_1", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_2", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_2_slave_2", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_3", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ result.put("master_3_slave_3", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, ""));
+ return result;
+ }
+
+ /**
+ * get encrypt configuration for master slave & encrypt & sharding.
+ * @return encryptRuleConfiguration
+ */
+ private static EncryptRuleConfiguration getMsEncRuleConfiguration() {
+ Properties props = new Properties();
+ props.setProperty("aes.key.value", "123456abc");
+ Map<String, EncryptColumnRuleConfiguration> columns = new LinkedHashMap<>();
+ EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("AES", props);
+ EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("c_plain", "c", "", "aes");
+ columns.put("c", columnConfig);
+ EncryptorRuleConfiguration encryptorConfigMd5 = new EncryptorRuleConfiguration("md5", new Properties());
+ EncryptColumnRuleConfiguration columnConfigMd5 = new EncryptColumnRuleConfiguration("", "pad", "", "md5");
+ columns.put("pad", columnConfigMd5);
+ EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(columns);
+ EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration();
+ encryptRuleConfig.getEncryptors().put("aes", encryptorConfig);
+ encryptRuleConfig.getEncryptors().put("md5", encryptorConfigMd5);
+ encryptRuleConfig.getTables().put("test", tableConfig);
+ return encryptRuleConfig;
+ }
+
+ /**
+ * get key generator config.
+ * @return keyGeneratorConfiguration
+ */
+ private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
+ return new KeyGeneratorConfiguration("SNOWFLAKE", "id", new Properties());
+ }
+}
+
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceUtil.java
new file mode 100644
index 0000000..6a2c67a
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/config/SJDataSourceUtil.java
@@ -0,0 +1,203 @@
+/*
+ * 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 service.util.config;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import perfstmt.ShardingPerfStmt;
+import service.api.entity.Iou;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.PreparedStatement;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * datasource utils for Sharding-Jdbc.
+ * @author nancyzrh
+ */
+public class SJDataSourceUtil {
+ private static final String DEFAULT_SCHEMA = "test";
+
+ public static DataSource createDataSource(final String usrName, final String dataSourceName, final String host, final int port, final String password) {
+ HikariConfig config = new HikariConfig();
+ config.setDriverClassName("com.mysql.jdbc.Driver");
+ config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
+ config.setUsername(usrName);
+ config.setPassword(password);
+ config.setMaximumPoolSize(200);
+ config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cachePrepStmts", "true");
+ config.addDataSourceProperty("prepStmtCacheSize", 250);
+ config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
+ config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
+ config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
+ config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
+ config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
+ config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
+ DataSource dataSource = new HikariDataSource(config);
+ return dataSource;
+ }
+
+ /**
+ * insert data for update.
+ * @param sql stmt
+ * @param datasource datasource from service
+ * @throws SQLException ex
+ */
+ public static void insertDemo(final String sql, final DataSource datasource) throws SQLException {
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setInt(2, 1);
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.setString(4, "##-####");
+ preparedStatement.execute();
+ } catch (final SQLException ignored) {
+ }
+ }
+
+ /**
+ * for select stmt.
+ * @param sql stmt
+ * @param dataSource datasource from service
+ * @throws SQLException ex
+ */
+ public static void getSelect(final String sql, final DataSource dataSource) throws SQLException {
+ List<Iou> result = new LinkedList<>();
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ Iou iou = new Iou();
+ iou.setK(resultSet.getInt(2));
+ result.add(iou);
+ }
+ }
+ }
+
+ /**
+ * for update stmt.
+ * @param sql stmt
+ * @param datasource datasource from service
+ * @return res
+ * @throws SQLException ex
+ */
+ public static int updateStmt(final String sql, final DataSource datasource) throws SQLException {
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setString(1, "##-#####");
+ preparedStatement.setString(2, "##-#####");
+ preparedStatement.setInt(3, 1);
+ preparedStatement.setInt(4, 1);
+ return preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * for delete stmt.
+ * @param sql stmt
+ * @param datasource datasource from service
+ * @return res
+ * @throws SQLException ex
+ */
+ public static int delete(final String sql, final DataSource datasource) throws SQLException {
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setInt(2, 1);
+ return preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * for clean up.
+ * @param sql stmt
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void clean(final String sql, final DataSource datasource) throws SQLException {
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * * Insert+Update+Delete as one operation.
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void writeOp(final DataSource datasource) throws SQLException {
+ String sqlStmt = ShardingPerfStmt.INSERT_SQL_STMT.getValue();
+ Long id = Long.MIN_VALUE;
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt, Statement.RETURN_GENERATED_KEYS)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setString(2, "##-####");
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.executeUpdate();
+ ResultSet result = preparedStatement.getGeneratedKeys();
+ result.next();
+ id = result.getLong(1);
+ } catch (final SQLException ex) {
+ ex.printStackTrace();
+ }
+ sqlStmt = ShardingPerfStmt.UPDATE_SQL_STMT.getValue();
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt)) {
+ preparedStatement.setString(1, "##-#####");
+ preparedStatement.setString(2, "##-#####");
+ preparedStatement.setLong(3, id);
+ preparedStatement.setInt(4, 1);
+ preparedStatement.executeUpdate();
+ }
+ sqlStmt = ShardingPerfStmt.DELETE_SQL_STMT.getValue();
+ try (Connection connection = datasource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setLong(2, id);
+ preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * for insert stmt.
+ * @param sql stmt
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void insert(final String sql, final DataSource datasource) throws SQLException {
+ try (Connection connection = datasource.getConnection();
+ java.sql.PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setString(2, "##-####");
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.execute();
+ } catch (final SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/SPDataSourceUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/SPDataSourceUtil.java
new file mode 100644
index 0000000..8c8c135
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/config/SPDataSourceUtil.java
@@ -0,0 +1,239 @@
+/*
+ * 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 service.util.config;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+import javax.sql.DataSource;
+import java.sql.PreparedStatement;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import perfstmt.ShardingPerfStmt;
+import service.api.entity.Iou;
+
+/**
+ * datasource utils for Sharding-Proxy.
+ * @author nancyzrh
+ */
+public class SPDataSourceUtil {
+ private static final String DEFAULT_SCHEMA = "test";
+
+ private static final Map<String, DataSource> DATA_SOURCE_MAP = new HashMap<>();
+
+ /**
+ * create datasource.
+ * @param usrName user name
+ * @param dataSourceName datasource name
+ * @param host host ip
+ * @param port port
+ * @param password pwd
+ */
+ public static void createDataSource(final String usrName, final String dataSourceName, final String host, final int port, final String password) {
+ HikariConfig config = new HikariConfig();
+ config.setDriverClassName("com.mysql.jdbc.Driver");
+ config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
+ config.setUsername(usrName);
+ config.setPassword(password);
+ config.setMaximumPoolSize(200);
+ config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cachePrepStmts", "true");
+ config.addDataSourceProperty("prepStmtCacheSize", 250);
+ config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
+ config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
+ config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
+ config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
+ config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
+ config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
+ config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
+ DataSource dataSource = new HikariDataSource(config);
+ DATA_SOURCE_MAP.put(dataSourceName, dataSource);
+ }
+
+ /**
+ * get datasource from name.
+ * @param dataSourceName input name
+ * @return datasource
+ */
+ public static DataSource getDataSource(final String dataSourceName) {
+ return DATA_SOURCE_MAP.get(dataSourceName);
+ }
+
+ /**
+ * create schema if db don't exist.
+ * @param dataSourceName datasource name
+ */
+ public static void createSchema(final String dataSourceName) {
+ String sql = "CREATE DATABASE " + dataSourceName;
+ try (Connection connection = getDataSource(DEFAULT_SCHEMA).getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute(sql);
+ } catch (final SQLException ignored) {
+ }
+ }
+
+ /**
+ * insert data for update.
+ * @param sql input sql
+ * @param datasource datasource
+ * @throws SQLException sql exception
+ */
+ public static void insertDemo(final String sql, final String datasource) throws SQLException {
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setInt(2, 2);
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.setString(4, "##-####");
+ preparedStatement.execute();
+ } catch (final SQLException ignored) {
+ }
+ }
+
+ /**
+ * select result.
+ * @param sql input sql
+ * @param datasource datasource
+ * @return list result
+ * @throws SQLException ex
+ */
+ public static List<Iou> getIou(final String sql, final String datasource) throws SQLException {
+ List<Iou> result = new LinkedList<>();
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ Iou iou = new Iou();
+ iou.setK(resultSet.getInt(2));
+ result.add(iou);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Insert+Update+Delete as one operation.
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void writeOp(final String datasource) throws SQLException {
+ String sqlStmt = ShardingPerfStmt.INSERT_SQL_STMT.getValue();
+ Long id = Long.MIN_VALUE;
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt, Statement.RETURN_GENERATED_KEYS)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setString(2, "##-####");
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.executeUpdate();
+ ResultSet result = preparedStatement.getGeneratedKeys();
+ result.next();
+ id = result.getLong(1);
+ } catch (final SQLException ex) {
+ ex.printStackTrace();
+ }
+ sqlStmt = ShardingPerfStmt.UPDATE_SQL_STMT.getValue();
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt)) {
+ preparedStatement.setString(1, "##-#####");
+ preparedStatement.setString(2, "##-#####");
+ preparedStatement.setLong(3, id);
+ preparedStatement.setInt(4, 1);
+ preparedStatement.executeUpdate();
+ }
+ sqlStmt = ShardingPerfStmt.DELETE_SQL_STMT.getValue();
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sqlStmt)) {
+ preparedStatement.setInt(1, 1);
+ preparedStatement.setLong(2, id);
+ preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * update stmt.
+ * @param sql input stmt
+ * @param datasource datasource
+ * @return execute result
+ * @throws SQLException ex
+ */
+ public static int updateStmt(final String sql, final String datasource) throws SQLException {
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setString(1, "##-#####");
+ preparedStatement.setString(2, "##-#####");
+ preparedStatement.setInt(3, 1);
+ preparedStatement.setInt(4, 2);
+ return preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * insert data.
+ * @param sql input stmt
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void insertIou(final String sql, final String datasource) throws SQLException {
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 2);
+ preparedStatement.setString(2, "##-####");
+ preparedStatement.setString(3, "##-####");
+ preparedStatement.execute();
+ } catch (final SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * clean up.
+ * @param sql input stmt
+ * @param datasource datasource
+ * @throws SQLException ex
+ */
+ public static void clean(final String sql, final String datasource) throws SQLException {
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.executeUpdate();
+ }
+ }
+
+ /**
+ * delete target data.
+ * @param sql input stmt
+ * @param datasource datasource
+ * @return execute
+ * @throws SQLException ex
+ */
+ public static int deleteIou(final String sql, final String datasource) throws SQLException {
+ try (Connection connection = getDataSource(datasource).getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, 2);
+ preparedStatement.setInt(2, 1);
+ return preparedStatement.executeUpdate();
+ }
+ }
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/lastversion/SJDataSourceFactory.java b/shardingsphere-benchmark/src/main/java/service/util/config/lastversion/SJDataSourceFactory.java
new file mode 100644
index 0000000..edc718d
--- /dev/null
+++ b/shardingsphere-benchmark/src/main/java/service/util/config/lastversion/SJDataSourceFactory.java
@@ -0,0 +1,147 @@
+/*
+ * 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 service.util.config.lastversion;
+
+import com.google.common.collect.Lists;
+import io.shardingsphere.api.config.rule.MasterSlaveRuleConfiguration;
+import io.shardingsphere.api.config.rule.ShardingRuleConfiguration;
+import io.shardingsphere.api.config.rule.TableRuleConfiguration;
+import io.shardingsphere.api.config.strategy.InlineShardingStrategyConfiguration;
+import io.shardingsphere.shardingjdbc.api.MasterSlaveDataSourceFactory;
+import io.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory;
+import service.util.config.SJDataSourceUtil;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.List;
+import java.util.Properties;
+import java.util.HashMap;
+import java.util.Arrays;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * create datasource for Sharding-Jdbc version 3.1.0.
+ * @author nancyzrh
+ */
+public class SJDataSourceFactory {
+
+ /**
+ * create sharding datasource.
+ * @return datasource
+ * @throws SQLException ex
+ */
+ public static DataSource createShardingDataSource() throws SQLException {
+ TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration();
+ tableRuleConfig.setLogicTable("ssperf");
+ tableRuleConfig.setActualDataNodes("ds_${0..3}.ssperf${0..1023}");
+ tableRuleConfig.setDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("id", "ds_${id % 4}"));
+ tableRuleConfig.setTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("k", "ssperf${k % 1024}"));
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
+ return ShardingDataSourceFactory.createDataSource(createShardingDataSourceMap(), shardingRuleConfig, new HashMap<String, Object>(), new Properties());
+ }
+
+ /**
+ * create sharding datasource map.
+ * @return res
+ */
+ private static Map<String, DataSource> createShardingDataSourceMap() {
+ Map<String, DataSource> result = new HashMap<>();
+ result.put("ds_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_1", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_2", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_3", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ return result;
+ }
+
+ /**
+ * create master slave sharding datasource.
+ * @return datasource
+ * @throws SQLException ex
+ */
+ public static DataSource createMSShardingDataSource() throws SQLException {
+ ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+ shardingRuleConfig.getTableRuleConfigs().add(getTableRuleConfiguration());
+ shardingRuleConfig.getBindingTableGroups().add("ssperf");
+ shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("id", "ms_ds_${id % 2}"));
+ shardingRuleConfig.setDefaultTableShardingStrategyConfig(new InlineShardingStrategyConfiguration("k", "ssperf${k % 1024}"));
+ shardingRuleConfig.setMasterSlaveRuleConfigs(getMasterSlaveRuleConfigurations());
+ return ShardingDataSourceFactory.createDataSource(createMSsharingDataSourceMap(), shardingRuleConfig, new HashMap<String, Object>(), new Properties());
+ }
+
+ /**
+ * get table rule.
+ * @return res
+ */
+ private static TableRuleConfiguration getTableRuleConfiguration() {
+ TableRuleConfiguration result = new TableRuleConfiguration();
+ result.setLogicTable("ssperf");
+ result.setActualDataNodes("ms_ds_${0..1}.ssperf${0..1023}");
+ result.setKeyGeneratorColumnName("id");
+ return result;
+ }
+
+ /**
+ * get master slave rule.
+ * @return res
+ */
+ private static List<MasterSlaveRuleConfiguration> getMasterSlaveRuleConfigurations() {
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveRuleConfiguration();
+ masterSlaveRuleConfig1.setName("ms_ds_0");
+ masterSlaveRuleConfig1.setMasterDataSourceName("ds_0");
+ masterSlaveRuleConfig1.setSlaveDataSourceNames(Arrays.asList("ds_0_slave_0"));
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveRuleConfiguration();
+ masterSlaveRuleConfig2.setName("ms_ds_1");
+ masterSlaveRuleConfig2.setMasterDataSourceName("ds_1");
+ masterSlaveRuleConfig2.setSlaveDataSourceNames(Arrays.asList("ds_1_slave_0"));
+ return Lists.newArrayList(masterSlaveRuleConfig1, masterSlaveRuleConfig2);
+ }
+
+ /**
+ * create ms sharding datasource map.
+ * @return res
+ */
+ private static Map<String, DataSource> createMSsharingDataSourceMap() {
+ final Map<String, DataSource> result = new HashMap<>();
+ result.put("ds_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_0_slave_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_1", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ result.put("ds_1_slave_0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ return result;
+ }
+
+ /**
+ * create master slave datasource.
+ * @return master slave data source
+ * @throws SQLException ex
+ */
+ public static DataSource createMSDataSource() throws SQLException {
+ Map<String, DataSource> dataSourceMap = new HashMap<>();
+ dataSourceMap.put("ds_master", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ dataSourceMap.put("ds_slave0", SJDataSourceUtil.createDataSource("###", "sharding_db", "####", 3306, "####"));
+ MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration();
+ masterSlaveRuleConfig.setName("ds_master_slave");
+ masterSlaveRuleConfig.setMasterDataSourceName("ds_master");
+ masterSlaveRuleConfig.setSlaveDataSourceNames(Arrays.asList("ds_slave0"));
+ DataSource dataSource = MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, masterSlaveRuleConfig, new ConcurrentHashMap(), new Properties());
+ return dataSource;
+ }
+
+}
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceOp.java b/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceOp.java
deleted file mode 100644
index 5504194..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceOp.java
+++ /dev/null
@@ -1,368 +0,0 @@
-package service.util.config.sjperf;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-
-import org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
-
-import org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
-
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-
-import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-
-//import org.apache.shardingsphere.sharding.strategy.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
-//import org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm;
-
-import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-import java.util.*;
-
-import static java.lang.System.getProperties;
-
-/**
- * for different sjperf dataSource
- */
-public class SJPerfDataSourceOp {
- private final Map<String, EncryptColumnRuleConfiguration> columnsEnc = new LinkedHashMap<>();
- /**
- * create full routing
- * @return data source
- * @throws SQLException
- */
- public static DataSource CreateDataSource() throws SQLException {
- Map<String, DataSource> dataSourceMap = new HashMap<>();
- dataSourceMap.put("baitiao_test", SJPerfDataSourceUtil.createDataSource("baitiao_test", "10.222.16.156", 3306, ""));
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("sbtest", "baitiao_test.sbtest99");
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "baitiao_test");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest99");*/
- tableRuleConfiguration.setTableShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
-
- //tableRuleConfiguration.setTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("id", shardingAlgorithm2));
- //tableRuleConfiguration.setKeyGenerateStrategyConfig(getKeyGeneratorConfiguration());
-
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTables().add(tableRuleConfiguration);
- shardingRuleConfig.getBindingTableGroups().add("sbtest");
- shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
- DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Collections.<RuleConfiguration>singleton(shardingRuleConfig), properties);
- return dataSource;
- }
-
- /**
- * create master slave datasource
- * @return master slave data source
- * @throws SQLException
- */
- public static DataSource CreateMSDataSource() throws SQLException {
- Map<String, DataSource> dataSourceMap = new HashMap<>();
- dataSourceMap.put("ds_master", SJPerfDataSourceUtil.createDataSource("baitiao_test", "10.222.16.144", 3306, ""));
- dataSourceMap.put("ds_slave0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
-
- MasterSlaveDataSourceRuleConfiguration dataSourceConfiguration = new MasterSlaveDataSourceRuleConfiguration(
- "ds_master_slave", "ds_master", Arrays.asList("ds_slave0"),"roundRobin");
- MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration(Collections.singleton(dataSourceConfiguration), ImmutableMap.of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties())));
-
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Collections.<RuleConfiguration>singleton(masterSlaveRuleConfig), properties);
- return dataSource;
- }
-
- /**
- * create encrypt datasource
- * @return encrypt data source
- * @throws SQLException
- */
- public static DataSource CreateEncryptDataSource() throws SQLException {
- DataSource dataSource = SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,"");
- EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("", "c", "", "","aes");
-
-
- Properties properties1 = new Properties();
- properties1.setProperty("max.connections.size.per.query", "200");
- properties1.setProperty("executor.size", "200");
-
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456");
- EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("", "c", "", "", "aes");
- ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = new ShardingSphereAlgorithmConfiguration("aes", props);
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("sbtest99", Arrays.asList(columnConfigAes));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration(Collections.singleton(tableConfig), ImmutableMap.of("aes", encryptAlgorithmConfiguration));
-
-
-
- return ShardingSphereDataSourceFactory.createDataSource(dataSource, Collections.<RuleConfiguration>singleton(encryptRuleConfig), properties1);
- }
-
- public static DataSource CreateMSEncShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("sbtest", "ms_ds_${0..3}.sbtest${0..1023}");
- tableRuleConfiguration.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- shardingRuleConfig.getTables().add(tableRuleConfiguration);
- shardingRuleConfig.getBindingTableGroups().add("sbtest");
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ms_ds_${id % 4}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest${k % 1024}");*/
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- return ShardingSphereDataSourceFactory.createDataSource(createMSEncDataSourceMap(), Arrays.asList(shardingRuleConfig, getMSEncRuleConfigurations(), getMsEncRuleConfiguration()), properties);
- }
-
- private static MasterSlaveRuleConfiguration getMSEncRuleConfigurations() {
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_0", "ds_0", Arrays.asList("ds_0_slave_0"),"roundRobin");
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_1", "ds_1", Arrays.asList("ds_1_slave_1"),"roundRobin");
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig3 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_2", "ds_2", Arrays.asList("ds_2_slave_2"),"roundRobin");
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig4 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_3", "ds_3", Arrays.asList("ds_3_slave_3"),"roundRobin");
-
- return new MasterSlaveRuleConfiguration(Arrays.asList(masterSlaveRuleConfig1, masterSlaveRuleConfig2, masterSlaveRuleConfig3, masterSlaveRuleConfig4),ImmutableMap.of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties())));
-
- }
-
-
- private static Map<String, DataSource> createMSEncDataSourceMap() {
- final Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.86",3306,""));
- result.put("ds_0_slave_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.86",3306,""));
- result.put("ds_1",SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_1_slave_1", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_2", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.144",3306,""));
- result.put("ds_2_slave_2", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.144",3306,""));
- result.put("ds_3",SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
- result.put("ds_3_slave_3", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
- return result;
- }
- /**
- * create ms sharding datasource
- * @return
- */
- public static DataSource CreateMSShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
-
- ShardingTableRuleConfiguration tableRuleConfiguration = new ShardingTableRuleConfiguration("sbtest", "ds_${0..1}.sbtest${0..1023}");
- tableRuleConfiguration.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- shardingRuleConfig.getTables().add(tableRuleConfiguration);
-
- shardingRuleConfig.getBindingTableGroups().add("sbtest");
- shardingRuleConfig.getBroadcastTables().add("t_config");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ds_${id % 2}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest${k % 1024}");*/
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- properties.setProperty("sql.show","true");
- return ShardingSphereDataSourceFactory.createDataSource(createMSsharingDataSourceMap(), Arrays.asList(shardingRuleConfig, getMasterSlaveRuleConfigurations()), properties);
- }
-
- private static MasterSlaveRuleConfiguration getMasterSlaveRuleConfigurations() {
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_0", "ds_0", Arrays.asList("ds_0_slave_0"), null);
- MasterSlaveDataSourceRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveDataSourceRuleConfiguration("ms_ds_1", "ds_1", Arrays.asList("ds_1_slave_0"), null);
-
- return new MasterSlaveRuleConfiguration( Arrays.asList(masterSlaveRuleConfig1, masterSlaveRuleConfig2), ImmutableMap.<String, ShardingSphereAlgorithmConfiguration>of("roundRobin", new ShardingSphereAlgorithmConfiguration("ROUND_ROBIN", new Properties())));
-
- }
- private static Map<String, DataSource> createMSsharingDataSourceMap() {
- final Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_1",SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_1_slave_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
- result.put("ds_0_slave_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
-
- return result;
- }
- /**
- * create sharding datasource
- * @return
- * @throws
- */
- public static DataSource CreateShardingAllDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("sbtest","ds_${0..3}.sbtest3");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ds_${id % 4}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest3");*/
- tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
-
- tableRuleConfig.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- shardingRuleConfig.getTables().add(tableRuleConfig);
-
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- return ShardingSphereDataSourceFactory.createDataSource(createShardingDataAllSourceMap(), Arrays.<RuleConfiguration>asList(shardingRuleConfig), properties);
- }
-
- private static Map<String, DataSource> createShardingDataAllSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_1", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_2", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_3", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- return result;
- }
- /**
- * create sharding datasource
- * @return
- * @throws
- */
- public static DataSource CreateShardingNewDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("sbtest","ds_${0..3}.sbtest4");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ds_${id % 4}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest4");*/
- tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
-
- tableRuleConfig.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- shardingRuleConfig.getTables().add(tableRuleConfig);
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- return ShardingSphereDataSourceFactory.createDataSource(createShardingNewDataSourceMap(), Arrays.<RuleConfiguration>asList(shardingRuleConfig), properties);
- }
-
- private static Map<String, DataSource> createShardingNewDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.86",3306,""));
- result.put("ds_1", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
- result.put("ds_2", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.144",3306,""));
- result.put("ds_3", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- return result;
- }
-
- public static DataSource CreateShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration tableRuleConfig = new ShardingTableRuleConfiguration("sbtest","ds_${0..3}.sbtest${0..1023}");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ds_${id % 4}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest${k % 1024}");*/
- tableRuleConfig.setTableShardingStrategy(new StandardShardingStrategyConfiguration("k", "inline"));
-
- tableRuleConfig.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- shardingRuleConfig.getTables().add(tableRuleConfig);
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- return ShardingSphereDataSourceFactory.createDataSource(createShardingDataSourceMap(), Arrays.<RuleConfiguration>asList(shardingRuleConfig), properties);
- }
-
- private static Map<String, DataSource> createShardingDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_1", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_2", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- result.put("ds_3", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- return result;
- }
- /**
- * create encrypt sharding datasource
- * @return encrypt data source
- * @throws SQLException
- */
- public static DataSource CreateEncryptShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTables().add(getTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("sbtest");
-
- /*InlineShardingAlgorithm shardingAlgorithm1 = new InlineShardingAlgorithm();
- shardingAlgorithm1.getProps().setProperty("algorithm.expression", "ds_${id % 2}");
- InlineShardingAlgorithm shardingAlgorithm2 = new InlineShardingAlgorithm();
- shardingAlgorithm2.getProps().setProperty("algorithm.expression", "sbtest${k % 1024}");*/
- shardingRuleConfig.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "inline"));
- shardingRuleConfig.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration("k", ""));
-
- Properties properties = new Properties();
- properties.setProperty("max.connections.size.per.query", "200");
- properties.setProperty("executor.size", "200");
- return ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), Arrays.asList(shardingRuleConfig, getEncryptRuleConfiguration()), properties);
- }
- private static ShardingTableRuleConfiguration getMSTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("sbtest", "ms_ds_${0..1}.sbtest${0..1023}");
- result.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- return result;
- }
- private static ShardingTableRuleConfiguration getTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("sbtest", "ds_${0..1}.sbtest${0..1023}");
- result.setKeyGenerateStrategy(getKeyGeneratorConfiguration());
- return result;
- }
- private static EncryptRuleConfiguration getEncryptRuleConfiguration() {
-
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456abc");
- ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = new ShardingSphereAlgorithmConfiguration("aes", props);
-
-
- EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("c", "c", "c", "c","aes");
- Map<String, EncryptColumnRuleConfiguration> columns = new HashMap<>();
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("sbtest", Arrays.asList(columnConfigAes));
- return new EncryptRuleConfiguration(Collections.singleton(tableConfig), ImmutableMap.of("aes", encryptAlgorithmConfiguration));
-
-
- }
- private static EncryptRuleConfiguration getMsEncRuleConfiguration() {
-
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456abc");
- ShardingSphereAlgorithmConfiguration encryptAlgorithmConfiguration = new ShardingSphereAlgorithmConfiguration("aes", props);
-
- EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("c", "c", "", "c","aes");
- EncryptColumnRuleConfiguration columnConfigMd5 = new EncryptColumnRuleConfiguration("pad", "pad", "", "pad","md5");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration("sbtest", Arrays.asList(columnConfigMd5, columnConfigAes));
-
- return new EncryptRuleConfiguration(Collections.singleton(tableConfig), ImmutableMap.of("aes", encryptAlgorithmConfiguration));
-
- }
-
- private static Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_0", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.156",3306,""));
- result.put("ds_1", SJPerfDataSourceUtil.createDataSource("baitiao_test","10.222.16.97",3306,""));
- return result;
- }
- private static KeyGenerateStrategyConfiguration getKeyGeneratorConfiguration() {
-
- /**KeyGenerateAlgorithm keyGenerateAlgorithm = new SnowflakeKeyGenerateAlgorithm();
- Properties pros = new Properties();
- pros.setProperty("worker.id", "id");
- keyGenerateAlgorithm.setProperties(pros);
- return new KeyGeneratorConfiguration("id", keyGenerateAlgorithm);**/
-
- return new KeyGenerateStrategyConfiguration("id", "snowflake");
- }
-}
-
diff --git a/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceUtil.java b/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceUtil.java
deleted file mode 100644
index bf99f02..0000000
--- a/shardingsphere-benchmark/src/main/java/service/util/config/sjperf/SJPerfDataSourceUtil.java
+++ /dev/null
@@ -1,443 +0,0 @@
-package service.util.config.sjperf;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-import service.api.entity.Iou;
-import sjperf.v3.SQLStatement;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.LinkedList;
-import java.util.List;
-
-public class SJPerfDataSourceUtil {
- private static final String USER_NAME = "root";
- private static final String DEFAULT_SCHEMA = "test";
-
- public static DataSource createDataSource(final String dataSourceName, final String host, final int port, final String password) {
- HikariConfig config = new HikariConfig();
- config.setDriverClassName("com.mysql.jdbc.Driver");
- config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC", host, port, dataSourceName));
- config.setUsername(USER_NAME);
- config.setPassword(password);
- config.setMaximumPoolSize(200);
- config.setConnectionTimeout(30000);
- config.setIdleTimeout(60000);
- config.setMaxLifetime(1800000);
- config.addDataSourceProperty("useServerPrepStmts", Boolean.TRUE.toString());
- config.addDataSourceProperty("cachePrepStmts", "true");
- config.addDataSourceProperty("prepStmtCacheSize", 250);
- config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
- config.addDataSourceProperty("useLocalSessionState", Boolean.TRUE.toString());
- config.addDataSourceProperty("rewriteBatchedStatements", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheResultSetMetadata", Boolean.TRUE.toString());
- config.addDataSourceProperty("cacheServerConfiguration", Boolean.TRUE.toString());
- config.addDataSourceProperty("elideSetAutoCommits", Boolean.TRUE.toString());
- config.addDataSourceProperty("maintainTimeStats", Boolean.FALSE.toString());
- config.addDataSourceProperty("netTimeoutForStreamingResults", 0);
- DataSource dataSource = new HikariDataSource(config);
-
- return dataSource;
- }
-
- public void createSchema(final DataSource dataSource) {
- //TODO
- }
- public static void singleMsAll(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet result= null;
- try {
- connection = datasource.getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=1 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- sql = "select count(id) from sbtest3";
- preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- preparedStatement.executeQuery();
- sql = "select max(id) from sbtest3 ignore index(`PRIMARY`)";
- //sql = "select max(id) from sbtest3";
- preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- preparedStatement.executeQuery();
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- //sql = "update sbtest3 set c=?,pad =? where id=? and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setString(1,"new");
- //preparedStatement.setString(2,"new");
- //preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- //preparedStatement.executeUpdate();
- sql = "delete from sbtest3 where k=? and id=?";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- //sql = "select max(k) from sbtest3";
- //sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- //preparedStatement = connection.prepareStatement(sql);
- //preparedStatement.setLong(1,id);
- //preparedStatement.executeQuery();
- preparedStatement.close();
- result.close();
- }catch (final SQLException ex) {
- ex.printStackTrace();
- } finally {
- connection.close();
- }
- }
-
- public static void singleAll(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet result= null;
- try {
- connection = datasource.getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- sql = "update sbtest3 set c=?,pad =? where id=? and k=3";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- sql = "delete from sbtest3 where k=? and id=?";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- result.close();
- }catch (final SQLException ex) {
- ex.printStackTrace();
- } finally {
- connection.close();
- // preparedStatement.close();
- // resultSet.close();
- // connection=null;
- }
- }
- public static void singleAllnewbak(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
- preparedStatement.setInt(1, 1);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- }catch (final SQLException ex) {
- ex.printStackTrace();
- }
- sql = "update sbtest3 set c=?,pad =? where id=? and k=?";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1,"##-#####");
- preparedStatement.setString(2,"##-#####");
- preparedStatement.setLong(3,id);
- preparedStatement.setInt(4,1);
- preparedStatement.executeUpdate();
- }
- // sql = "TRUNCATE TABLE sbtest3";
- sql = "delete from sbtest3 where k=? and id=?";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,1);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- }
- }
-
- /**
- * operation
- */
- public static void singleAllbak(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest3 (k,c,pad) VALUES (?,?,?)";
- int id = 0;
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
- preparedStatement.setInt(1, 1);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getInt(1);
- }catch (final SQLException ex) {
- ex.printStackTrace();
- }
- //sql = "update sbtest3 set c=?,pad =? where id=? and k=?";
- sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=1 and k=3";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- // preparedStatement.setString(1,"##-#####");
- // preparedStatement.setString(2,"##-#####");
- // preparedStatement.setInt(3,id);
- // preparedStatement.setInt(4,1);
- // preparedStatement.executeUpdate();
- preparedStatement.executeQuery();
- }
-
- //sql = "select max(k) from sbtest3";
- sql = "select id,k from sbtest3 ignore index(`PRIMARY`) where id=2 and k=3";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- // preparedStatement.setString(1,"##-#####");
- // preparedStatement.setString(2,"##-#####");
- // preparedStatement.setInt(3,id);
- // preparedStatement.setInt(4,1);
- // preparedStatement.executeUpdate();
- preparedStatement.executeQuery();
- }
- sql = "delete from sbtest3 where k=? and id=?";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,1);
- preparedStatement.setInt(2,id);
- preparedStatement.executeUpdate();
- }
-
- sql = "select max(k) from sbtest3";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- // preparedStatement.setString(1,"##-#####");
- // preparedStatement.setString(2,"##-#####");
- // preparedStatement.setInt(3,id);
- // preparedStatement.setInt(4,1);
- // preparedStatement.executeUpdate();
- preparedStatement.executeQuery();
- }
- }
- public static void changeMsAll(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet resultSet= null;
- try {
- connection = datasource.getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- sql = "select id,k from sbtest ignore index(`PRIMARY`) where id=? and k=3";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setLong(1,id);
- preparedStatement.executeQuery();
- sql = "update sbtest set c=?,pad =? where id=? and k=3";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- sql = "delete from sbtest where k=? and id=?";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- result.close();
- }catch (final SQLException ex) {
- ex.printStackTrace();
- } finally {
- connection.close();
- }
- }
-
- public static void changeAll(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest (k,c,pad) VALUES (?,?,?)";
- Long id = Long.MIN_VALUE;
- Connection connection=null;
- PreparedStatement preparedStatement=null;
- ResultSet resultSet= null;
- try {
- connection = datasource.getConnection();
- preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- sql = "update sbtest set c=?,pad =? where id=? and k=3";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setString(1,"new");
- preparedStatement.setString(2,"new");
- preparedStatement.setLong(3,id);
- //preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- sql = "delete from sbtest where k=? and id=?";
- preparedStatement = connection.prepareStatement(sql);
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
- preparedStatement.executeUpdate();
- preparedStatement.close();
- result.close();
- }catch (final SQLException ex) {
- ex.printStackTrace();
- } finally {
- connection.close();
- // preparedStatement.close();
- // resultSet.close();
- // connection=null;
- }
- }
- /**
- * operation for sharindg
- */
- public static void changeAllbak(final DataSource datasource) throws SQLException {
- String sql = "INSERT INTO sbtest (k,c,pad) VALUES (?,?,?)";
- long id = Long.MIN_VALUE;
- //int id =0;
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS)) {
- preparedStatement.setInt(1, 3);
- preparedStatement.setString(2, "##-####");
- preparedStatement.setString(3, "##-####");
- preparedStatement.executeUpdate();
- ResultSet result = preparedStatement.getGeneratedKeys();
- result.next();
- id = result.getLong(1);
- }catch (final SQLException ex) {
- ex.printStackTrace();
- }
- sql = "update sbtest set c=?,pad =? where id=? and k=?";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setString(1,"##-#####");
- preparedStatement.setString(2,"##-#####");
- preparedStatement.setLong(3,id);
- preparedStatement.setInt(4,3);
- preparedStatement.executeUpdate();
- }
- // sql = "TRUNCATE TABLE sbtest";
- sql="delete from sbtest where k=? and id=?";
- try (Connection connection = datasource.getConnection();
- PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
- preparedStatement.setInt(1,3);
- preparedStatement.setLong(2,id);
... 13700 lines suppressed ...