diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE
index b3da04059cc08..7fc62f0c5aac6 100644
--- a/.github/ISSUE_TEMPLATE
+++ b/.github/ISSUE_TEMPLATE
@@ -4,6 +4,8 @@ Please answer these questions before submitting your issue. Thanks!
### Which version of Sharding-Sphere do you using?
+### Which project do you using? Sharding-JDBC or Sharding-Proxy?
+
### Expected behavior
### Actual behavior
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000000000..e20541ac1d7e8
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,43 @@
+# Contributor Covenant Code of Conduct
+
+## Development idea
+
+ - Write extremely clean, simplify and graceful code. Fully agree with <Refactoring: Improving the Design of Existing Code> and <Clean Code: A Handbook of Agile Software Craftsma>.
+
+## Code push conventions
+
+ - Make sure all test cases passed.
+ - Make sure test coverage not lower than dev branch.
+ - Use checkstyle to check code style, provide special reason if rule violated. Find checkstyle template from `sharding-sphere/src/resources/sharding_checks.xml`, please use checkstyle 8.8 to run the rule.
+ - Make sure `mvn clean install` can be success.
+ - Delete unused code in time.
+
+## Code Conventions
+
+ - Use linux line seperator.
+ - Indent (including blank lines) is consistent with the previous line.
+ - No unnecessary blank line.
+ - All logs and java docs are in English.
+ - Commit allow javadoc, todo and fixme only.
+ - Give a meaningful variable name. The name of return value is result; The name of unit value is each in for each sentence, instead of entry for map iterator.
+ - Name of properties file is camel-case, first letter is lowercase.
+ - Constant on left and variable on right in conditional expression.
+ - The nested loop should extract to a new private method.
+ - Replace Nested Conditional with Guard Clauses.
+ - Access permissions for classes and methods should minimal as possible.
+ - Parameters and return value are not allowed to be null.
+ - If use comment to explain the code, try to split several small methods, and use method name to explain it.
+ - Use lombok instead of the constructor, getter, setter methods and log variable.
+ - keep style consistent with existed code.
+ - No duplicate code and configuration.
+
+## Unit Test Conventions
+
+ - Test code and production code equality, should follow the same code conventions.
+ - Test cases should fully covered if no special reason.
+ - Separate environment preparation codes and test codes.
+ - Only junit Assert, hamcrest CoreMatchers, Mockito related can use static import.
+ - For single parameter assert, should use `assertTrue`, `assertFalse`, `assertNull` and `assertNotNull`.
+ - For multiple parameters assert, should use `assertThat`.
+ - Assert accurately, do not use `not`, `containsString` and so on.
+ - Use actualXXX and expectedXXX to name related variable.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000000..8b33e89c67670
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,34 @@
+You can report a bug, submit a new feature enhancement recommendation, or commit codes by a pull request.
+
+## Reporting Bugs
+
+ - Before report a bug, please search from google to confirm you cannot find any hint on it.
+ - Look [issues List](https://github.com/sharding-sphere/sharding-sphere/issues) to confirm this issue is not a duplicated one.
+ - [Create](https://github.com/sharding-sphere/sharding-sphere/issues/new) a new issue.
+ - Define a clear and descriptive title for the issue.
+ - If bug reported, please provide information below:
+ - Details for reproduce bug step by step. Include SQL, configuration, expected results, actual results and tracing log.
+ - Sharding and Operation System version.
+ - Source code to reproduce bug on github cna copy the link here.
+ - Stack trace if exception thrown.
+ - Screenshot and animated gif to help bug reproduce if necessary.
+ - Screenshot for CPU, Memory, Network and IO stat if performance issue.
+ - If enhancement recommendation reported, please provide information below:
+ - Details for enhancement behaviour.
+ - Explain why this enhancement is general feature for most developers.
+ - List similar features which already available in other product if possible. Both open source and commercial software are available.
+ - Assign label after create issue. Label should be bug, enhancement, discussion and so on.
+ - Please pay attention on the issue and provide more information during discuss.
+ - Please close issue when it is resolved. If you don't close it, we will close it after 3 days。
+ - If this issue has new information, please reopen it again. Please note, issue can reopen which only closed by yourself. If the issue is closed by us, you have no permission to reopen any more.
+
+## Commit pull request
+
+ - Please choose a interested issue, or create a new issue and then settle a correct label.
+ - Reply a deadline message to pickup this issue.
+ - Find a mentor in [Core developers list](/en/organization/), he will give you feedback for design and implements.
+ - Fork to your github repo and begin to work.
+ - Please follow Sharding's [Development conventions](/en/contribute/convention/), and complete check before pull request submit.
+ - Submit a pull request to dev branch when finished, please do not submit pull request to master.
+ - Mentor will do code review and discuss some details, include design, implement, performance and code style. Code will be merged until mentor accepted.
+ - Finally, congratulations that you have become the official contributor for Sharding!
diff --git a/README.md b/README.md
index 0922a5f7cc837..da0a1dc54011b 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ It directly connects to databases to provide services in the form of jar, with n
### Sharding-Proxy
-[![Download](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/sharding-sphere/sharding-sphere-doc/raw/master/dist/sharding-proxy-3.0.0.M1.tar.gz)
+[![Download](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/sharding-sphere/sharding-sphere-doc/raw/master/dist/sharding-proxy-3.0.0.M2.tar.gz)
[![Docker Pulls](https://img.shields.io/docker/pulls/shardingsphere/sharding-proxy.svg)](https://store.docker.com/community/images/shardingsphere/sharding-proxy)
Sharding-Proxy is positioned as a transparent database proxy, providing a database server that encapsulates database binary protocol to support heterogeneous languages.
diff --git a/README_ZH.md b/README_ZH.md
index d9c55d2b09782..aa09eeaf3fd0d 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -38,7 +38,7 @@ Sharding-Sphere定位为关系型数据库中间件,旨在充分合理地在
### Sharding-Proxy
-[![Download](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/sharding-sphere/sharding-sphere-doc/raw/master/dist/sharding-proxy-3.0.0.M1.tar.gz)
+[![Download](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/sharding-sphere/sharding-sphere-doc/raw/master/dist/sharding-proxy-3.0.0.M2.tar.gz)
[![Docker Pulls](https://img.shields.io/docker/pulls/shardingsphere/sharding-proxy.svg)](https://store.docker.com/community/images/shardingsphere/sharding-proxy)
定位为透明化的数据库代理端,提供封装了数据库二进制协议的服务端版本,用于完成对异构语言的支持。
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index bc1e861db43da..d0377a569a19f 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -6,112 +6,155 @@
### New Features
-1. [ISSUE #290](https://github.com/sharding-sphere/sharding-sphere/issues/290) Support batch INSERT statements
-1. [ISSUE #501](https://github.com/sharding-sphere/sharding-sphere/issues/501) Support OR statement
-1. [ISSUE #862](https://github.com/sharding-sphere/sharding-sphere/issues/862) Support data orchestration in cloud side
-1. [ISSUE #980](https://github.com/sharding-sphere/sharding-sphere/issues/980) Support DCL statement
-1. [ISSUE #936](https://github.com/sharding-sphere/sharding-sphere/issues/936) Support the registry center for Proxy
+#### Core
+
+1. [ISSUE #290](https://github.com/sharding-sphere/sharding-sphere/issues/290) Support batch INSERT
+1. [ISSUE #501](https://github.com/sharding-sphere/sharding-sphere/issues/501) Support OR
+1. [ISSUE #980](https://github.com/sharding-sphere/sharding-sphere/issues/980) Support DCL
+1. [ISSUE #1111](https://github.com/sharding-sphere/sharding-sphere/issues/1111) SupportMySQL DAL
+
+#### Sharding-Proxy
+
+1. [ISSUE #916](https://github.com/sharding-sphere/sharding-sphere/issues/916) Support authorization
+1. [ISSUE #936](https://github.com/sharding-sphere/sharding-sphere/issues/936) Support registry center
### Enhancements
-1. [ISSUE #608](https://github.com/sharding-sphere/sharding-sphere/issues/608) Support the USE statement of MySQL
-1. [ISSUE #609](https://github.com/sharding-sphere/sharding-sphere/issues/609) Support the SHOW statement of MySQL
-1. [ISSUE #610](https://github.com/sharding-sphere/sharding-sphere/issues/610) Optimize the DQL that does not contain a table name
-1. [ISSUE #611](https://github.com/sharding-sphere/sharding-sphere/issues/611) Support the DESC statement of MySQL
-1. [ISSUE #652](https://github.com/sharding-sphere/sharding-sphere/issues/652) Support Spring Boot Starter 2.x
-1. [ISSUE #701](https://github.com/sharding-sphere/sharding-sphere/issues/701) Support caching parsing results of SQL to improve performance
-1. [ISSUE #702](https://github.com/sharding-sphere/sharding-sphere/issues/702) Support $->{..} as mark for inline expression
-1. [ISSUE #719](https://github.com/sharding-sphere/sharding-sphere/issues/719) Support Spring bean namespace to inject key generator objects
-1. [ISSUE #720](https://github.com/sharding-sphere/sharding-sphere/issues/720) Support Spring bean namespace to inject sharding algorithm objects
-1. [ISSUE #773](https://github.com/sharding-sphere/sharding-sphere/issues/773) Support sharding and autoincrement primary key of INSERT statements without column names
-1. [ISSUE #916](https://github.com/sharding-sphere/sharding-sphere/issues/916) Support authorization for Sharding Proxy
-1. [ISSUE #935](https://github.com/sharding-sphere/sharding-sphere/issues/935) Support to store configuration by using Yaml instead of JSON in registry center.
-1. [ISSUE #1004](https://github.com/sharding-sphere/sharding-sphere/issues/1004) Support props configuration for MasterSlave rule.
+#### Core
+
+1. [ISSUE #610](https://github.com/sharding-sphere/sharding-sphere/issues/610) Route unicast for DQL without table
+1. [ISSUE #701](https://github.com/sharding-sphere/sharding-sphere/issues/701) Caching parsed results to improve performance
+1. [ISSUE #773](https://github.com/sharding-sphere/sharding-sphere/issues/773) Support sharding and autoincrement key of INSERT without column names
+1. [ISSUE #935](https://github.com/sharding-sphere/sharding-sphere/issues/935) Use `YAML` instead of `JSON` to store configurations in registry center
+1. [ISSUE #1004](https://github.com/sharding-sphere/sharding-sphere/issues/1004) Properties can configure for Sharding and Master-slave independent
+
+#### Sharding-JDBC
+
+1. [ISSUE #652](https://github.com/sharding-sphere/sharding-sphere/issues/652) Support `Spring Boot Starter` 2.X
+1. [ISSUE #702](https://github.com/sharding-sphere/sharding-sphere/issues/702) Support `$->{..}` for inline expression
+1. [ISSUE #719](https://github.com/sharding-sphere/sharding-sphere/issues/719) Support inject key generator objects by spring namespace
+1. [ISSUE #720](https://github.com/sharding-sphere/sharding-sphere/issues/720) Support inject sharding algorithm objects by spring namespace
### Bug Fixes
-1. [ISSUE #372](https://github.com/sharding-sphere/sharding-sphere/issues/372) Reuse PreparedStatement cause cache of route result do not clean
+#### Core
+
1. [ISSUE #628](https://github.com/sharding-sphere/sharding-sphere/issues/628) Support data type jsonb for PostgreSQL
-1. [ISSUE #629](https://github.com/sharding-sphere/sharding-sphere/issues/629) Support transaction isolation on JDBC
-1. [ISSUE #646](https://github.com/sharding-sphere/sharding-sphere/issues/646) When aliases in SELECT ITEMS correspond to the real column names of GROUP BY or ORDER BY, there is no need to add columns
-1. [ISSUE #735](https://github.com/sharding-sphere/sharding-sphere/issues/735) Unexpected slave datasource routing result when using Round-robin load-balance algorithm in Mybatis
-1. [ISSUE #806](https://github.com/sharding-sphere/sharding-sphere/issues/806) SQL parse error with `NOT IN`
-1. [ISSUE #827](https://github.com/sharding-sphere/sharding-sphere/issues/827) Fix endless loop for bad SQL like `SELECT * FROM table WHERE id IN ()`
-1. [ISSUE #919](https://github.com/sharding-sphere/sharding-sphere/issues/919) Use groovy to parse inline expression may cause memory leak
+1. [ISSUE #646](https://github.com/sharding-sphere/sharding-sphere/issues/646) When aliases in `SELECT ITEMS` correspond to the real column names of `GROUP BY` or `ORDER BY`, there is no need to generate derived columns
+1. [ISSUE #806](https://github.com/sharding-sphere/sharding-sphere/issues/806) `NOT IN` parse exception
+1. [ISSUE #827](https://github.com/sharding-sphere/sharding-sphere/issues/827) Endless loop for bad SQL like `SELECT * FROM table WHERE id IN ()`
+1. [ISSUE #919](https://github.com/sharding-sphere/sharding-sphere/issues/919) Inline expression with groovy may cause memory leak
1. [ISSUE #993](https://github.com/sharding-sphere/sharding-sphere/issues/993) Fail to parsing PostgreSQL due to the quotation
-1. [ISSUE #1011](https://github.com/sharding-sphere/sharding-sphere/issues/1011) Can't resolve placeholder in spring boot configuration yaml
-1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) Support the statement of `SELECT id, COUNT(*) FROM table GROUP BY 1,2`
+1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) Support SQL like `SELECT id, COUNT(*) FROM table GROUP BY 1,2`
+
+#### Sharding-JDBC
+
+1. [ISSUE #372](https://github.com/sharding-sphere/sharding-sphere/issues/372) Reuse PreparedStatement cause cache of route result do not clean
+1. [ISSUE #629](https://github.com/sharding-sphere/sharding-sphere/issues/629) Support transaction isolation on JDBC
+1. [ISSUE #735](https://github.com/sharding-sphere/sharding-sphere/issues/735) Unexpected slave datasource routing result when using `Round-robin` load-balance algorithm in Mybatis
+1. [ISSUE #1011](https://github.com/sharding-sphere/sharding-sphere/issues/1011) Can't resolve placeholder in `Spring Boot YAML` configuration
+1. [ISSUE #1020](https://github.com/sharding-sphere/sharding-sphere/issues/1020) Derived columns of `GROUP BY / ORDER BY` appear in query result
## 2.0.3
-### Enhancements
+### New Features
+
+#### Core
1. [ISSUE #600](https://github.com/sharding-sphere/sharding-sphere/issues/600) Support TCL
### Bug Fixes
-1. [ISSUE #522](https://github.com/sharding-sphere/sharding-sphere/issues/522) The slave database does not need to execute the DDL statement for read-write separation
-1. [ISSUE #540](https://github.com/sharding-sphere/sharding-sphere/issues/540) Support SQLs that the alias is the keyword
-1. [ISSUE #577](https://github.com/sharding-sphere/sharding-sphere/issues/577) Support newline for YAML configuration
+#### Core
+
+1. [ISSUE #540](https://github.com/sharding-sphere/sharding-sphere/issues/540) Support SQL that alias is the keyword
+1. [ISSUE #577](https://github.com/sharding-sphere/sharding-sphere/issues/577) Support new line for `YAML` configuration
+
+#### Sharding-JDBC
+
+1. [ISSUE #522](https://github.com/sharding-sphere/sharding-sphere/issues/522) Slave database does not need to execute the DDL for read-write splitting
+
## 2.0.2
### Enhancements
-1. [ISSUE #475](https://github.com/sharding-sphere/sharding-sphere/issues/475) Support CREATE INDEX
-1. [ISSUE #525](https://github.com/sharding-sphere/sharding-sphere/issues/525) Support DROP INDEX
+#### Core
+
+1. [ISSUE #475](https://github.com/sharding-sphere/sharding-sphere/issues/475) Support `CREATE INDEX`
+1. [ISSUE #525](https://github.com/sharding-sphere/sharding-sphere/issues/525) Support `DROP INDEX`
### Bug Fixes
-1. [ISSUE #520](https://github.com/sharding-sphere/sharding-sphere/issues/520) When the partition table is introduced, the exception type is no longer DuplicateKeyException when the unique key conflict occurs
-1. [ISSUE #521](https://github.com/sharding-sphere/sharding-sphere/issues/521) ShardingProperties is invalid in YAML configuration
+#### Core
+
+1. [ISSUE #521](https://github.com/sharding-sphere/sharding-sphere/issues/521) `ShardingProperties` is invalid in `YAML` configuration
1. [ISSUE #529](https://github.com/sharding-sphere/sharding-sphere/issues/529) Table name capitalization cannot be queried
-1. [ISSUE #541](https://github.com/sharding-sphere/sharding-sphere/issues/541) Can't parse IS NOT NULL
-1. [ISSUE #557](https://github.com/sharding-sphere/sharding-sphere/issues/557) When GroupBy and OrderBy aliases are inconsistent, stream merging should be used
-1. [ISSUE #559](https://github.com/sharding-sphere/sharding-sphere/issues/559) Support parsing numbers beginning with minus and decimal (e.g. -.12).
-1. [ISSUE #567](https://github.com/sharding-sphere/sharding-sphere/issues/567) MySQL adds an escape character when columns are added to prevent errors caused by using keywords as column names or aliases
+1. [ISSUE #541](https://github.com/sharding-sphere/sharding-sphere/issues/541) `IS NOT NULL` parse error
+1. [ISSUE #557](https://github.com/sharding-sphere/sharding-sphere/issues/557) When `GROUP BY` and `ORDER BY` aliases are inconsistent, stream merging should be used
+1. [ISSUE #559](https://github.com/sharding-sphere/sharding-sphere/issues/559) Support parsing numbers beginning with minus and decimal (e.g. `-.12`)
+1. [ISSUE #567](https://github.com/sharding-sphere/sharding-sphere/issues/567) Add escape char for derived columns or alias when using MySQL
+
+#### Sharding-JDBC
+
+1. [ISSUE #520](https://github.com/sharding-sphere/sharding-sphere/issues/520) Exception is no longer `DuplicateKeyException` when the unique key conflict
+
## 2.0.1
### Enhancements
-1. [ISSUE #489](https://github.com/sharding-sphere/sharding-sphere/issues/489) SpringName uses RuntimeBeanReference to prevent the creation of InnerBean
+#### Core
+
+1. [ISSUE #490](https://github.com/sharding-sphere/sharding-sphere/issues/490) Using `rownum` greater than or equal to or less than or equal to the result of paging is incorrect in Oracle
1. [ISSUE #496](https://github.com/sharding-sphere/sharding-sphere/issues/496) Logical table names in sharding configuration can be case sensitive
-1. [ISSUE #497](https://github.com/sharding-sphere/sharding-sphere/issues/497) The registry center closes gracefully
+1. [ISSUE #497](https://github.com/sharding-sphere/sharding-sphere/issues/497) Close registry center gracefully
### Bug Fixes
-1. [ISSUE #490](https://github.com/sharding-sphere/sharding-sphere/issues/490) Oracle using rownum greater than or equal to or less than or equal to the result of paging is incorrect
-1. [ISSUE #491](https://github.com/sharding-sphere/sharding-sphere/issues/491) Can't close connection by ResultSet.getStatement().getConnection().close()
+#### Sharding-JDBC
+
+1. [ISSUE #489](https://github.com/sharding-sphere/sharding-sphere/issues/489) Uses `RuntimeBeanReference` to prevent the creation of `InnerBean` on spring namespace
+1. [ISSUE #491](https://github.com/sharding-sphere/sharding-sphere/issues/491) Can't close connection by `ResultSet.getStatement().getConnection().close()`
+
## 2.0.0
### Milestones
-1. API adjust. Brand new Maven coordinate name, package name and spring namespace name. Simplify and enhance API configuration, inline expression full configuration support
-1. Support spring-boot-starter of sharding-jdbc
-1. Dynamic configuration. Zookeeper and etcd can be used as registry to dynamically modify data sources and sharding configurations
-1. Data governance. Fusing database access procedures to access databases and disable access to slave databases
+1. API adjust. Brand new groupId and artifactId for `Maven`, package name and spring namespace name. Simplify and enhance API configuration, inline expression fully configuration support
+1. Support `spring-boot-starter` of `Sharding-JDBC`
+1. Dynamic configuration. `ZooKeeper` and `etcd` can be used as registry to dynamically modify data sources and sharding configurations
+1. Database orchestration. Fusing database access procedures to access databases and disable access to slave databases
1. ConfigMap support. Predefined metadata can be obtained in the sharding and read-write separation strategy
-1. Tracking system support. You can view the invocation chain of sharding-jdbc through sky-walking and other Opentracing based APM systems
+1. Tracking system support. You can view the invocation chain of `Sharding-JDBC` through `sky-walking` and other `Opentracing` based APM systems
### Enhancements
-1. [ISSUE #386](https://github.com/sharding-sphere/sharding-sphere/issues/386) Support for SELECT 1, a SQL that does not contain table names
-1. [ISSUE #407](https://github.com/sharding-sphere/sharding-sphere/issues/407) Sharding-jdbc's spring-boot-starter compatibility uses two ways of attribute configuration: minus sign and hump
+#### Core
+
+1. [ISSUE #386](https://github.com/sharding-sphere/sharding-sphere/issues/386) Support SQL that does not contain table names, such as `SELECT 1`
+
+#### Sharding-JDBC
+
+1. [ISSUE #407](https://github.com/sharding-sphere/sharding-sphere/issues/407) Support Hyphen properties for `sharding-jdbc-spring-boot-starter`
1. [ISSUE #424](https://github.com/sharding-sphere/sharding-sphere/issues/424) Providing SQL overall execution events
### Bug Fixes
+#### Core
+
1. [ISSUE #387](https://github.com/sharding-sphere/sharding-sphere/issues/387) Prevent errors from keywords process when '`' exists in function + column name
+1. [ISSUE #419](https://github.com/sharding-sphere/sharding-sphere/issues/419) When SQL is rewritten, it does not determine whether alias is a keyword without the escape character, which results in SQL exception
+1. [ISSUE #464](https://github.com/sharding-sphere/sharding-sphere/issues/464) SQL if the varchar type is not closed due to the absence of matching single quotes, and the next varchar in SQL is the wrong SQL of Chinese characters, it will lead to higher use of CPU
+
+#### Sharding-JDBC
+
1. [ISSUE #394](https://github.com/sharding-sphere/sharding-sphere/issues/394) Can't only close statement
1. [ISSUE #398](https://github.com/sharding-sphere/sharding-sphere/issues/398) Use Hint routing to shield case sensitivity
1. [ISSUE #404](https://github.com/sharding-sphere/sharding-sphere/issues/404) Sharding-jdbc's spring-boot-starter does not support HikariDataSource
-1. [ISSUE #419](https://github.com/sharding-sphere/sharding-sphere/issues/419) When SQL is rewritten, it does not determine whether alias is a keyword without the escape character, which results in SQL exception
-1. [ISSUE #436](https://github.com/sharding-sphere/sharding-sphere/issues/436) Read-write separation, when the RoundRobin algorithm is configured from the database and MyBatis is used, it can only be routed to the same slave library
+1. [ISSUE #436](https://github.com/sharding-sphere/sharding-sphere/issues/436) Read-write splitting, when the RoundRobin algorithm is configured from the database and MyBatis is used, it can only be routed to the same slave library
1. [ISSUE #452](https://github.com/sharding-sphere/sharding-sphere/issues/452) Sharding of DDL statements to more than one table causes a connection leak
-1. [ISSUE #453](https://github.com/sharding-sphere/sharding-sphere/issues/453) Orchestration datasource name is conflict with Druid datasource name
-1. [ISSUE #464](https://github.com/sharding-sphere/sharding-sphere/issues/464) SQL if the varchar type is not closed due to the absence of matching single quotes, and the next varchar in SQL is the wrong SQL of Chinese characters, it will lead to higher use of CPU
1. [ISSUE #472](https://github.com/sharding-sphere/sharding-sphere/issues/472) Before Connection executes createStatement, it calls getMetaData first and then setAutoCommit can not take effective connection to the database that was created later
## 1.5.4.1
diff --git a/RELEASE-NOTES_ZH.md b/RELEASE-NOTES_ZH.md
index 2a77985a1fed3..0f13a0cc00c2c 100644
--- a/RELEASE-NOTES_ZH.md
+++ b/RELEASE-NOTES_ZH.md
@@ -6,112 +6,154 @@
### 新功能
+#### 内核
+
1. [ISSUE #290](https://github.com/sharding-sphere/sharding-sphere/issues/290) 支持批量INSERT语句
1. [ISSUE #501](https://github.com/sharding-sphere/sharding-sphere/issues/501) 支持OR语句
-1. [ISSUE #862](https://github.com/sharding-sphere/sharding-sphere/issues/862) 支持在Cloud端进行数据治理
1. [ISSUE #980](https://github.com/sharding-sphere/sharding-sphere/issues/980) 支持DCL语句
-1. [ISSUE #936](https://github.com/sharding-sphere/sharding-sphere/issues/936) 支持Proxy使用注册中心
+1. [ISSUE #1111](https://github.com/sharding-sphere/sharding-sphere/issues/1111) 支持MySQL DAL语句
+
+#### Sharding-Proxy
+
+1. [ISSUE #916](https://github.com/sharding-sphere/sharding-sphere/issues/916) 支持登录认证
+1. [ISSUE #936](https://github.com/sharding-sphere/sharding-sphere/issues/936) 支持注册中心进行治理
+
### 功能提升
-1. [ISSUE #608](https://github.com/sharding-sphere/sharding-sphere/issues/608) 支持MySQL的USE语句
-1. [ISSUE #609](https://github.com/sharding-sphere/sharding-sphere/issues/609) 支持MySQL的SHOW语句
-1. [ISSUE #610](https://github.com/sharding-sphere/sharding-sphere/issues/610) 优化不包含表的DQL
-1. [ISSUE #611](https://github.com/sharding-sphere/sharding-sphere/issues/611) 支持MySQL的DESC语句
-1. [ISSUE #652](https://github.com/sharding-sphere/sharding-sphere/issues/652) Spring Boot Starter 2.x支持
-1. [ISSUE #701](https://github.com/sharding-sphere/sharding-sphere/issues/701) 支持缓存SQL解析结果以提升性能
-1. [ISSUE #702](https://github.com/sharding-sphere/sharding-sphere/issues/702) 支持以 $->{..} 作为inline表达式的标记
+#### 内核
+
+1. [ISSUE #610](https://github.com/sharding-sphere/sharding-sphere/issues/610) 无表名称的DQL采用单播路由
+1. [ISSUE #701](https://github.com/sharding-sphere/sharding-sphere/issues/701) 缓存SQL解析结果以提升性能
+1. [ISSUE #773](https://github.com/sharding-sphere/sharding-sphere/issues/773) 支持不包含列名的INSERT语句的分片与自增主键
+1. [ISSUE #935](https://github.com/sharding-sphere/sharding-sphere/issues/935) 取代`JSON`格式,而将`YAML`格式的配置文件存储在注册中心
+1. [ISSUE #1004](https://github.com/sharding-sphere/sharding-sphere/issues/1004) props属性可在分片和读写分离规则配置时独立使用
+
+#### Sharding-JDBC
+
+1. [ISSUE #652](https://github.com/sharding-sphere/sharding-sphere/issues/652) `Spring Boot Starter` 2.X支持
+1. [ISSUE #702](https://github.com/sharding-sphere/sharding-sphere/issues/702) 支持以 `$->{..}` 作为行表达式的标记
1. [ISSUE #719](https://github.com/sharding-sphere/sharding-sphere/issues/719) 支持Spring bean的方式在命名空间中注入自增序列生成器对象
1. [ISSUE #720](https://github.com/sharding-sphere/sharding-sphere/issues/720) 支持Spring bean的方式在命名空间中注入分片算法对象
-1. [ISSUE #773](https://github.com/sharding-sphere/sharding-sphere/issues/773) 支持不包含列名的INSERT语句的分片与自增主键
-1. [ISSUE #916](https://github.com/sharding-sphere/sharding-sphere/issues/916) 支持Sharding Proxy的登录权限认证
-1. [ISSUE #935](https://github.com/sharding-sphere/sharding-sphere/issues/935) 取代JSON格式,而将Yaml格式的配置文件存储在注册中心
-1. [ISSUE #1004](https://github.com/sharding-sphere/sharding-sphere/issues/1004) 支持在使用读写分离规则时,配置props属性
### 缺陷修正
-1. [ISSUE #372](https://github.com/sharding-sphere/sharding-sphere/issues/372) 同一PreparedStatement反复使用导致路由缓存未清理
+#### 内核
+
1. [ISSUE #628](https://github.com/sharding-sphere/sharding-sphere/issues/628) 支持PostgreSQL的数据类型jsonb
-1. [ISSUE #629](https://github.com/sharding-sphere/sharding-sphere/issues/629) 支持JDBC中设置事务隔离级别
-1. [ISSUE #646](https://github.com/sharding-sphere/sharding-sphere/issues/646) 当SELECT ITEMS中的别名与GROUP BY或ORDER BY的真实列名对应时,无需补列
-1. [ISSUE #735](https://github.com/sharding-sphere/sharding-sphere/issues/735) 在Mybatis中使用RoundRobinMasterSlaveLoadBalanceAlgorithm算法路由存在问题
+1. [ISSUE #646](https://github.com/sharding-sphere/sharding-sphere/issues/646) 当SELECT ITEMS中的别名与GROUP BY或ORDER BY的真实列名对应时无需补列
1. [ISSUE #806](https://github.com/sharding-sphere/sharding-sphere/issues/806) `NOT IN`解析异常
1. [ISSUE #827](https://github.com/sharding-sphere/sharding-sphere/issues/827) 将`SELECT * FROM table WHERE id IN ()`这种SQL跳出死循环
1. [ISSUE #919](https://github.com/sharding-sphere/sharding-sphere/issues/919) 使用Groovy解析行表达式可能导致内存泄漏
1. [ISSUE #993](https://github.com/sharding-sphere/sharding-sphere/issues/993) 无法解析PostgreSQL的双引号占位符
-1. [ISSUE #1011](https://github.com/sharding-sphere/sharding-sphere/issues/1011) 无法在Spring Boot的yaml中处理占位符
-1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) 支持使用`SELECT id, COUNT(*) FROM table GROUP BY 1,2`
+1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) 支持SQL `SELECT id, COUNT(*) FROM table GROUP BY 1,2`
+
+#### Sharding-JDBC
+
+1. [ISSUE #372](https://github.com/sharding-sphere/sharding-sphere/issues/372) 同一PreparedStatement反复使用导致路由缓存未清理
+1. [ISSUE #629](https://github.com/sharding-sphere/sharding-sphere/issues/629) 支持JDBC中设置事务隔离级别
+1. [ISSUE #735](https://github.com/sharding-sphere/sharding-sphere/issues/735) 在Mybatis中使用`Round-robin`的读写分离算法路由存在问题
+1. [ISSUE #1011](https://github.com/sharding-sphere/sharding-sphere/issues/1011) 无法在`Spring Boot`的`YAML`中处理占位符
+1. [ISSUE #1020](https://github.com/sharding-sphere/sharding-sphere/issues/1020) `GROUP BY / ORDER BY`产生的补列不应展现在查询结果中
## 2.0.3
-### 功能提升
+### 新功能
+
+#### 内核
1. [ISSUE #600](https://github.com/sharding-sphere/sharding-sphere/issues/600) 支持TCL
### 缺陷修正
-1. [ISSUE #522](https://github.com/sharding-sphere/sharding-sphere/issues/522) 读写分离Slave库不需要执行DDL语句
+#### 内核
+
1. [ISSUE #540](https://github.com/sharding-sphere/sharding-sphere/issues/540) 梳理并支持别名为关键字SQL
-1. [ISSUE #577](https://github.com/sharding-sphere/sharding-sphere/issues/577) 支持YAML配置换行
+1. [ISSUE #577](https://github.com/sharding-sphere/sharding-sphere/issues/577) 支持`YAML`配置换行
+
+#### Sharding-JDBC
+
+1. [ISSUE #522](https://github.com/sharding-sphere/sharding-sphere/issues/522) 读写分离的从库不需要执行DDL语句
+
## 2.0.2
### 功能提升
-1. [ISSUE #475](https://github.com/sharding-sphere/sharding-sphere/issues/475) 支持CREATE INDEX
-1. [ISSUE #525](https://github.com/sharding-sphere/sharding-sphere/issues/525) 支持DROP INDEX
+#### 内核
+1. [ISSUE #475](https://github.com/sharding-sphere/sharding-sphere/issues/475) 支持`CREATE INDEX`
+1. [ISSUE #525](https://github.com/sharding-sphere/sharding-sphere/issues/525) 支持`DROP INDEX`
### 缺陷修正
-1. [ISSUE #520](https://github.com/sharding-sphere/sharding-sphere/issues/520) 引入分表后,唯一键冲突时异常类型不再是DuplicateKeyException
-1. [ISSUE #521](https://github.com/sharding-sphere/sharding-sphere/issues/521) YAML文件中ShardingProperties设置无效
+#### 内核
+
+1. [ISSUE #521](https://github.com/sharding-sphere/sharding-sphere/issues/521) `YAML`文件中`ShardingProperties`设置无效
1. [ISSUE #529](https://github.com/sharding-sphere/sharding-sphere/issues/529) 表名大写无法查询
-1. [ISSUE #541](https://github.com/sharding-sphere/sharding-sphere/issues/541) 无法解析IS NOT NULL
-1. [ISSUE #557](https://github.com/sharding-sphere/sharding-sphere/issues/557) GroupBy和OrderBy仅别名不一致问题应使用流式归并
-1. [ISSUE #559](https://github.com/sharding-sphere/sharding-sphere/issues/559) 支持解析以负号和小数点开头的数字(如:-.12)
+1. [ISSUE #541](https://github.com/sharding-sphere/sharding-sphere/issues/541) 无法解析`IS NOT NULL`
+1. [ISSUE #557](https://github.com/sharding-sphere/sharding-sphere/issues/557) `GROUP BY`和`ORDER BY`仅别名不一致问题应使用流式归并
+1. [ISSUE #559](https://github.com/sharding-sphere/sharding-sphere/issues/559) 支持解析以负号和小数点开头的数字(如: `-.12`)
1. [ISSUE #567](https://github.com/sharding-sphere/sharding-sphere/issues/567) MySQL补列时增加转义符以防止使用关键字作为列名或别名导致错误
+#### Sharding-JDBC
+
+1. [ISSUE #520](https://github.com/sharding-sphere/sharding-sphere/issues/520) 唯一键冲突时异常类型不是`DuplicateKeyException`
+
+
## 2.0.1
### 功能提升
-1. [ISSUE #489](https://github.com/sharding-sphere/sharding-sphere/issues/489) SpringName使用RuntimeBeanReference防止创建InnerBean
+#### 内核
+
+1. [ISSUE #490](https://github.com/sharding-sphere/sharding-sphere/issues/490) Oracle使用`rownum`大于等于或小于等于分页结果不正确
1. [ISSUE #496](https://github.com/sharding-sphere/sharding-sphere/issues/496) 分片配置中逻辑表名可以大小写不敏感
1. [ISSUE #497](https://github.com/sharding-sphere/sharding-sphere/issues/497) 注册中心优雅关闭
### 缺陷修正
-1. [ISSUE #490](https://github.com/sharding-sphere/sharding-sphere/issues/490) Oracle使用rownum大于等于或小于等于分页结果不正确
-1. [ISSUE #491](https://github.com/sharding-sphere/sharding-sphere/issues/491) 通过ResultSet.getStatement().getConnection().close()无法释放连接
+#### Sharding-JDBC
+
+1. [ISSUE #489](https://github.com/sharding-sphere/sharding-sphere/issues/489) 在Spring namespace中使用`RuntimeBeanReference`防止创建`InnerBean`
+1. [ISSUE #491](https://github.com/sharding-sphere/sharding-sphere/issues/491) 通过`ResultSet.getStatement().getConnection().close()`无法释放连接
## 2.0.0
### 里程碑
-1. API调整. 全新的Maven坐标名称, 包名称和spring命名空间名称. 简化和提升API配置, inline表达式全配置支持
-1. 提供sharding-jdbc的spring-boot-starter
-1. 配置动态化. 可以通过zookeeper和etcd作为注册中心动态修改数据源以及分片配置
-1. 数据治理. 熔断数据库访问程序对数据库的访问和禁用从库的访问
+1. API调整. 全新的`Maven`坐标名称, 包名称和spring命名空间名称. 简化和提升API配置, 行表达式全配置支持
+1. 提供`Sharding-JDBC`的`spring-boot-starter`
+1. 配置动态化. 可以通过`ZooKeeper`和`etcd`作为注册中心动态修改数据源以及分片配置
+1. 数据库治理. 熔断数据库访问程序对数据库的访问和禁用从库的访问
1. ConfigMap支持. 可以在分片和读写分离策略中获取预定义的元数据
-1. 跟踪系统支持. 可以通过sky-walking等基于Opentracing协议的APM系统中查看sharding-jdbc的调用链
+1. 追踪系统支持. 可以通过`sky-walking`等基于`Opentracing`协议的APM系统中查看`Sharding-JDBC`的调用链
### 功能提升
-1. [ISSUE #386](https://github.com/sharding-sphere/sharding-sphere/issues/386) 支持SELECT 1这种不包含表名称的SQL
-1. [ISSUE #407](https://github.com/sharding-sphere/sharding-sphere/issues/407) sharding-jdbc的spring-boot-starter兼容使用减号和驼峰两种方式进行属性配置
+#### 内核
+
+1. [ISSUE #386](https://github.com/sharding-sphere/sharding-sphere/issues/386) 支持不包含表名称的SQL, 例如: `SELECT 1`
+
+#### Sharding-JDBC
+
+1. [ISSUE #407](https://github.com/sharding-sphere/sharding-sphere/issues/407) `sharding-jdbc-spring-boot-starter`兼容使用减号和驼峰两种方式进行属性配置
1. [ISSUE #424](https://github.com/sharding-sphere/sharding-sphere/issues/424) 提供SQL总体执行情况事件
### 缺陷修正
+#### 内核
+
1. [ISSUE #387](https://github.com/sharding-sphere/sharding-sphere/issues/387) 当函数 + 列名中存在'`'防止关键字时处理出错
+1. [ISSUE #419](https://github.com/sharding-sphere/sharding-sphere/issues/419) SQL改写时, 未判断别名是否为关键字未加转义符导致了SQL异常
+1. [ISSUE #464](https://github.com/sharding-sphere/sharding-sphere/issues/464) SQL如果varchar类型由于没有匹配单引号并未关闭, 而恰好sql中的下一个varchar又是汉字的错误SQL, 将导致CPU使用增高
+
+#### Sharding-JDBC
+
1. [ISSUE #394](https://github.com/sharding-sphere/sharding-sphere/issues/394) 无法单独close statement
1. [ISSUE #398](https://github.com/sharding-sphere/sharding-sphere/issues/398) 使用Hint路由屏蔽表和列名称的大小写区别
1. [ISSUE #404](https://github.com/sharding-sphere/sharding-sphere/issues/404) sharding-jdbc的spring-boot-starter不支持HikariDataSource
-1. [ISSUE #419](https://github.com/sharding-sphere/sharding-sphere/issues/419) SQL改写时, 未判断别名是否为关键字未加转义符导致了SQL异常
1. [ISSUE #436](https://github.com/sharding-sphere/sharding-sphere/issues/436) 读写分离当从库配置RoundRobin算法并使用MyBatis时,只能路由到同一从库
1. [ISSUE #452](https://github.com/sharding-sphere/sharding-sphere/issues/452) DDL语句分片至多个表会造成连接泄漏的问题
-1. [ISSUE #453](https://github.com/sharding-sphere/sharding-sphere/issues/453) 编排治理数据源配置name与Druid数据源name冲突
-1. [ISSUE #464](https://github.com/sharding-sphere/sharding-sphere/issues/464) SQL如果varchar类型由于没有匹配单引号并未关闭, 而恰好sql中的下一个varchar又是汉字的错误SQL, 将导致CPU使用增高
1. [ISSUE #472](https://github.com/sharding-sphere/sharding-sphere/issues/472) Connection执行createStatement之前, 先调用getMetaData再setAutoCommit无法对之后创建的数据库真实连接生效
## 1.5.4.1
diff --git a/pom.xml b/pom.xml
index f003acfabb4e5..d5fc5c543a407 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
pom
${project.artifactId}
@@ -16,6 +16,7 @@
sharding-opentracing
sharding-proxy
sharding-sql-test
+ sharding-transaction
diff --git a/sharding-core/pom.xml b/sharding-core/pom.xml
index be5b84acfbd10..806cd04176731 100644
--- a/sharding-core/pom.xml
+++ b/sharding-core/pom.xml
@@ -6,7 +6,7 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-core
${project.artifactId}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingConstant.java b/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingConstant.java
index baad5f89c2088..1376705c99091 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingConstant.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingConstant.java
@@ -17,12 +17,16 @@
package io.shardingsphere.core.constant;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* Sharding constant.
*
* @author zhangliang
*/
-public interface ShardingConstant {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShardingConstant {
/**
* Logic database schema name.
@@ -32,5 +36,5 @@ public interface ShardingConstant {
* Default: sharding_db
*
*/
- String LOGIC_SCHEMA_NAME = "sharding_db";
+ public static final String LOGIC_SCHEMA_NAME = "sharding_db";
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingPropertiesConstant.java b/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingPropertiesConstant.java
index d421c3593643e..75c7534d2d43c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingPropertiesConstant.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/constant/ShardingPropertiesConstant.java
@@ -42,16 +42,27 @@ public enum ShardingPropertiesConstant {
*/
SQL_SHOW("sql.show", Boolean.FALSE.toString(), boolean.class),
+ /**
+ * Worker group or user group thread max size.
+ *
+ *
+ * Worker group accept tcp connection.
+ * User group accept MySQL command.
+ * Default: CPU cores * 2.
+ *
+ */
+ ACCEPTOR_SIZE("acceptor.size", String.valueOf(Runtime.getRuntime().availableProcessors() * 2), int.class),
+
/**
* Worker thread max size.
*
*
* Execute SQL Statement and PrepareStatement will use this thread pool.
* One sharding data source will use a independent thread pool, it does not share thread pool even different data source in same JVM.
- * Default: same with CPU cores.
+ * Default: infinite.
*
*/
- EXECUTOR_SIZE("executor.size", String.valueOf(Runtime.getRuntime().availableProcessors()), int.class),
+ EXECUTOR_SIZE("executor.size", String.valueOf(0), int.class),
/**
* Connection mode of connected to databases.
@@ -70,7 +81,7 @@ public enum ShardingPropertiesConstant {
*/
CONNECTION_MODE("connection.mode", ConnectionMode.MEMORY_STRICTLY.name(), String.class),
- PROXY_TRANSACTION_MODE("proxy.transaction.mode", TransactionType.NONE.name(), String.class),
+ PROXY_TRANSACTION_MODE("proxy.transaction.mode", TransactionType.LOCAL.name(), String.class),
PROXY_BACKEND_USE_NIO("proxy.backend.use.nio", Boolean.FALSE.toString(), boolean.class),
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/constant/TransactionType.java b/sharding-core/src/main/java/io/shardingsphere/core/constant/TransactionType.java
index a6ccc77845371..d9ab457f10d17 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/constant/TransactionType.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/constant/TransactionType.java
@@ -17,52 +17,12 @@
package io.shardingsphere.core.constant;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
/**
- * TransactionType Enum.
+ * Transaction type.
*
* @author zhaojun
*/
-@RequiredArgsConstructor
-@Getter
public enum TransactionType {
- /**
- * Default local transaction.
- */
- NONE(""),
-
- /**
- * XA distribute transaction provided by RDBMS vendor.
- */
- XA("XA"),
-
- /**
- * B.A.S.E distribute transaction.
- */
- BASE("BASE"),
-
- /**
- * TCC (Try-Confirm-Cancel) distribute transaction mode.
- */
- TCC("TCC");
-
- private final String type;
-
- /**
- * Find enum by type value.
- *
- * @param type property type
- * @return value enum, return {@code NONE} if not found
- */
- public static TransactionType findByValue(final String type) {
- for (TransactionType each : TransactionType.values()) {
- if (each.getType().equals(type)) {
- return each;
- }
- }
- return NONE;
- }
+ LOCAL, XA, BASE
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/DALMergeEngine.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/DALMergeEngine.java
index dc6acaaca78ee..1f778f74af949 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/DALMergeEngine.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/DALMergeEngine.java
@@ -23,10 +23,12 @@
import io.shardingsphere.core.merger.dal.show.ShowCreateTableMergedResult;
import io.shardingsphere.core.merger.dal.show.ShowDatabasesMergedResult;
import io.shardingsphere.core.merger.dal.show.ShowOtherMergedResult;
+import io.shardingsphere.core.merger.dal.show.ShowTableStatusMergedResult;
import io.shardingsphere.core.merger.dal.show.ShowTablesMergedResult;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowCreateTableStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowDatabasesStatement;
+import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowTableStatusStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowTablesStatement;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.rule.ShardingRule;
@@ -57,11 +59,14 @@ public MergedResult merge() throws SQLException {
if (dalStatement instanceof ShowDatabasesStatement) {
return new ShowDatabasesMergedResult();
}
+ if (dalStatement instanceof ShowTableStatusStatement) {
+ return new ShowTableStatusMergedResult(shardingRule, queryResults, shardingTableMetaData);
+ }
if (dalStatement instanceof ShowTablesStatement) {
return new ShowTablesMergedResult(shardingRule, queryResults, shardingTableMetaData);
}
if (dalStatement instanceof ShowCreateTableStatement) {
- return new ShowCreateTableMergedResult(shardingRule, queryResults);
+ return new ShowCreateTableMergedResult(shardingRule, queryResults, shardingTableMetaData);
}
return new ShowOtherMergedResult(queryResults.get(0));
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/LogicTablesMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/LogicTablesMergedResult.java
new file mode 100644
index 0000000000000..ab0de00960887
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/LogicTablesMergedResult.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.merger.dal.show;
+
+import com.google.common.base.Optional;
+import io.shardingsphere.core.merger.QueryResult;
+import io.shardingsphere.core.merger.dql.common.MemoryMergedResult;
+import io.shardingsphere.core.merger.dql.common.MemoryQueryResultRow;
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
+import io.shardingsphere.core.rule.ShardingRule;
+import io.shardingsphere.core.rule.TableRule;
+
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Logic tables merged result.
+ *
+ * @author zhangliang
+ */
+public abstract class LogicTablesMergedResult extends MemoryMergedResult {
+
+ private final ShardingRule shardingRule;
+
+ private final Iterator memoryResultSetRows;
+
+ private final Set tableNames = new HashSet<>();
+
+ private final ShardingTableMetaData shardingTableMetaData;
+
+ public LogicTablesMergedResult(final Map labelAndIndexMap,
+ final ShardingRule shardingRule, final List queryResults, final ShardingTableMetaData shardingTableMetaData) throws SQLException {
+ super(labelAndIndexMap);
+ this.shardingRule = shardingRule;
+ this.shardingTableMetaData = shardingTableMetaData;
+ memoryResultSetRows = init(queryResults);
+ }
+
+ private Iterator init(final List queryResults) throws SQLException {
+ List result = new LinkedList<>();
+ for (QueryResult each : queryResults) {
+ while (each.next()) {
+ MemoryQueryResultRow memoryResultSetRow = new MemoryQueryResultRow(each);
+ String actualTableName = memoryResultSetRow.getCell(1).toString();
+ Optional tableRule = shardingRule.tryFindTableRuleByActualTable(actualTableName);
+ if (!tableRule.isPresent()) {
+ if (shardingRule.getTableRules().isEmpty() || shardingTableMetaData.containsTable(actualTableName) && tableNames.add(actualTableName)) {
+ result.add(memoryResultSetRow);
+ }
+ } else if (tableNames.add(tableRule.get().getLogicTable())) {
+ memoryResultSetRow.setCell(1, tableRule.get().getLogicTable());
+ setCellValue(memoryResultSetRow, tableRule.get().getLogicTable(), actualTableName);
+ result.add(memoryResultSetRow);
+ }
+ }
+ }
+ if (!result.isEmpty()) {
+ setCurrentResultSetRow(result.get(0));
+ }
+ return result.iterator();
+ }
+
+ protected void setCellValue(final MemoryQueryResultRow memoryResultSetRow, final String logicTableName, final String actualTableName) {
+ }
+
+ @Override
+ public final boolean next() {
+ if (memoryResultSetRows.hasNext()) {
+ setCurrentResultSetRow(memoryResultSetRows.next());
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResult.java
index a88698a964b2b..67a147176085a 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResult.java
@@ -17,18 +17,13 @@
package io.shardingsphere.core.merger.dal.show;
-import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.merger.dql.common.MemoryMergedResult;
import io.shardingsphere.core.merger.dql.common.MemoryQueryResultRow;
-import io.shardingsphere.core.parsing.SQLParsingEngine;
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.core.rule.TableRule;
import java.sql.SQLException;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -37,56 +32,20 @@
*
* @author zhangliang
*/
-public final class ShowCreateTableMergedResult extends MemoryMergedResult {
+public final class ShowCreateTableMergedResult extends LogicTablesMergedResult {
private static final Map LABEL_AND_INDEX_MAP = new HashMap<>(2, 1);
- private final ShardingRule shardingRule;
-
- private final Iterator memoryResultSetRows;
-
static {
LABEL_AND_INDEX_MAP.put("Table", 1);
LABEL_AND_INDEX_MAP.put("Create Table", 2);
}
- public ShowCreateTableMergedResult(final ShardingRule shardingRule, final List queryResults) throws SQLException {
- super(LABEL_AND_INDEX_MAP);
- this.shardingRule = shardingRule;
- memoryResultSetRows = init(queryResults);
- }
-
- private Iterator init(final List queryResults) throws SQLException {
- List result = new LinkedList<>();
- for (QueryResult each : queryResults) {
- while (each.next()) {
- MemoryQueryResultRow memoryResultSetRow = new MemoryQueryResultRow(each);
- String tableName = memoryResultSetRow.getCell(1).toString();
- TableRule tableRule = shardingRule.getTableRuleByActualTableName(tableName);
- String logicTableName = tableRule.getLogicTable();
- memoryResultSetRow.setCell(1, logicTableName);
- String createTableDDL = memoryResultSetRow.getCell(2).toString();
- SQLParsingEngine sqlParsingEngine = new SQLParsingEngine(DatabaseType.MySQL, createTableDDL, shardingRule, null);
- String actualTableName = sqlParsingEngine.parse(true).getTables().getSingleTableName();
- if (actualTableName.startsWith("`")) {
- logicTableName = "`" + logicTableName + "`";
- }
- memoryResultSetRow.setCell(2, createTableDDL.replaceFirst(actualTableName, logicTableName));
- result.add(memoryResultSetRow);
- }
- }
- if (!result.isEmpty()) {
- setCurrentResultSetRow(result.get(0));
- }
- return result.iterator();
+ public ShowCreateTableMergedResult(final ShardingRule shardingRule, final List queryResults, final ShardingTableMetaData shardingTableMetaData) throws SQLException {
+ super(LABEL_AND_INDEX_MAP, shardingRule, queryResults, shardingTableMetaData);
}
- @Override
- public boolean next() {
- if (memoryResultSetRows.hasNext()) {
- setCurrentResultSetRow(memoryResultSetRows.next());
- return true;
- }
- return false;
+ protected void setCellValue(final MemoryQueryResultRow memoryResultSetRow, final String logicTableName, final String actualTableName) {
+ memoryResultSetRow.setCell(2, memoryResultSetRow.getCell(2).toString().replaceFirst(actualTableName, logicTableName));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTableStatusMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTableStatusMergedResult.java
new file mode 100644
index 0000000000000..3f326a0470be2
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTableStatusMergedResult.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.merger.dal.show;
+
+import io.shardingsphere.core.merger.QueryResult;
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
+import io.shardingsphere.core.rule.ShardingRule;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Merged result for show table status.
+ *
+ * @author zhangliang
+ */
+public final class ShowTableStatusMergedResult extends LogicTablesMergedResult {
+
+ private static final Map LABEL_AND_INDEX_MAP = new HashMap<>(17, 1);
+
+ static {
+ LABEL_AND_INDEX_MAP.put("Name", 1);
+ LABEL_AND_INDEX_MAP.put("Engine", 2);
+ LABEL_AND_INDEX_MAP.put("Version", 3);
+ LABEL_AND_INDEX_MAP.put("Row_format", 4);
+ LABEL_AND_INDEX_MAP.put("Rows", 5);
+ LABEL_AND_INDEX_MAP.put("Avg_row_length", 6);
+ LABEL_AND_INDEX_MAP.put("Data_length", 7);
+ LABEL_AND_INDEX_MAP.put("Max_data_length", 8);
+ LABEL_AND_INDEX_MAP.put("Data_free", 9);
+ LABEL_AND_INDEX_MAP.put("Auto_increment", 10);
+ LABEL_AND_INDEX_MAP.put("Create_time", 11);
+ LABEL_AND_INDEX_MAP.put("Update_time", 12);
+ LABEL_AND_INDEX_MAP.put("Check_time", 13);
+ LABEL_AND_INDEX_MAP.put("Collation", 14);
+ LABEL_AND_INDEX_MAP.put("Checksum", 15);
+ LABEL_AND_INDEX_MAP.put("Create_options", 16);
+ LABEL_AND_INDEX_MAP.put("Comment", 17);
+ }
+
+ public ShowTableStatusMergedResult(final ShardingRule shardingRule, final List queryResults, final ShardingTableMetaData shardingTableMetaData) throws SQLException {
+ super(LABEL_AND_INDEX_MAP, shardingRule, queryResults, shardingTableMetaData);
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTablesMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTablesMergedResult.java
index 41d8ed32fddb6..64f6b8862a171 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTablesMergedResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dal/show/ShowTablesMergedResult.java
@@ -17,23 +17,15 @@
package io.shardingsphere.core.merger.dal.show;
-import com.google.common.base.Optional;
import io.shardingsphere.core.constant.ShardingConstant;
import io.shardingsphere.core.merger.QueryResult;
-import io.shardingsphere.core.merger.dql.common.MemoryMergedResult;
-import io.shardingsphere.core.merger.dql.common.MemoryQueryResultRow;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.core.rule.TableRule;
import java.sql.SQLException;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Merged result for show tables.
@@ -41,58 +33,15 @@
* @author zhangliang
* @author panjuan
*/
-public final class ShowTablesMergedResult extends MemoryMergedResult {
+public final class ShowTablesMergedResult extends LogicTablesMergedResult {
private static final Map LABEL_AND_INDEX_MAP = new HashMap<>(1, 1);
- private final ShardingRule shardingRule;
-
- private final Iterator memoryResultSetRows;
-
- private final Set tableNames = new HashSet<>();
-
- private final ShardingTableMetaData shardingTableMetaData;
-
static {
LABEL_AND_INDEX_MAP.put("Tables_in_" + ShardingConstant.LOGIC_SCHEMA_NAME, 1);
}
public ShowTablesMergedResult(final ShardingRule shardingRule, final List queryResults, final ShardingTableMetaData shardingTableMetaData) throws SQLException {
- super(LABEL_AND_INDEX_MAP);
- this.shardingRule = shardingRule;
- this.shardingTableMetaData = shardingTableMetaData;
- memoryResultSetRows = init(queryResults);
- }
-
- private Iterator init(final List queryResults) throws SQLException {
- List result = new LinkedList<>();
- for (QueryResult each : queryResults) {
- while (each.next()) {
- MemoryQueryResultRow memoryResultSetRow = new MemoryQueryResultRow(each);
- String actualTableName = memoryResultSetRow.getCell(1).toString();
- Optional tableRule = shardingRule.tryFindTableRuleByActualTable(actualTableName);
- if (!tableRule.isPresent()) {
- if (shardingRule.getTableRules().isEmpty() || shardingTableMetaData.containsTable(actualTableName) && tableNames.add(actualTableName)) {
- result.add(memoryResultSetRow);
- }
- } else if (tableNames.add(tableRule.get().getLogicTable())) {
- memoryResultSetRow.setCell(1, tableRule.get().getLogicTable());
- result.add(memoryResultSetRow);
- }
- }
- }
- if (!result.isEmpty()) {
- setCurrentResultSetRow(result.get(0));
- }
- return result.iterator();
- }
-
- @Override
- public boolean next() {
- if (memoryResultSetRows.hasNext()) {
- setCurrentResultSetRow(memoryResultSetRows.next());
- return true;
- }
- return false;
+ super(LABEL_AND_INDEX_MAP, shardingRule, queryResults, shardingTableMetaData);
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/DecoratorMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/DecoratorMergedResult.java
index 466b9ee5049e1..b4f55fb3d4b58 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/DecoratorMergedResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/DecoratorMergedResult.java
@@ -37,37 +37,37 @@ public abstract class DecoratorMergedResult implements MergedResult {
private final MergedResult mergedResult;
@Override
- public Object getValue(final int columnIndex, final Class> type) throws SQLException {
+ public final Object getValue(final int columnIndex, final Class> type) throws SQLException {
return mergedResult.getValue(columnIndex, type);
}
@Override
- public Object getValue(final String columnLabel, final Class> type) throws SQLException {
+ public final Object getValue(final String columnLabel, final Class> type) throws SQLException {
return mergedResult.getValue(columnLabel, type);
}
@Override
- public Object getCalendarValue(final int columnIndex, final Class> type, final Calendar calendar) throws SQLException {
+ public final Object getCalendarValue(final int columnIndex, final Class> type, final Calendar calendar) throws SQLException {
return mergedResult.getCalendarValue(columnIndex, type, calendar);
}
@Override
- public Object getCalendarValue(final String columnLabel, final Class> type, final Calendar calendar) throws SQLException {
+ public final Object getCalendarValue(final String columnLabel, final Class> type, final Calendar calendar) throws SQLException {
return mergedResult.getCalendarValue(columnLabel, type, calendar);
}
@Override
- public InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
+ public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
return mergedResult.getInputStream(columnIndex, type);
}
@Override
- public InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
+ public final InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
return mergedResult.getInputStream(columnLabel, type);
}
@Override
- public boolean wasNull() throws SQLException {
+ public final boolean wasNull() throws SQLException {
return mergedResult.wasNull();
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/MemoryMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/MemoryMergedResult.java
index 6493707081627..6ed1b76b7d2fa 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/MemoryMergedResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/MemoryMergedResult.java
@@ -48,7 +48,7 @@ public abstract class MemoryMergedResult implements MergedResult {
private boolean wasNull;
@Override
- public Object getValue(final int columnIndex, final Class> type) throws SQLException {
+ public final Object getValue(final int columnIndex, final Class> type) throws SQLException {
if (Blob.class == type || Clob.class == type || Reader.class == type || InputStream.class == type || SQLXML.class == type) {
throw new SQLFeatureNotSupportedException();
}
@@ -58,7 +58,7 @@ public Object getValue(final int columnIndex, final Class> type) throws SQLExc
}
@Override
- public Object getValue(final String columnLabel, final Class> type) throws SQLException {
+ public final Object getValue(final String columnLabel, final Class> type) throws SQLException {
if (Blob.class == type || Clob.class == type || Reader.class == type || InputStream.class == type || SQLXML.class == type) {
throw new SQLFeatureNotSupportedException();
}
@@ -68,7 +68,7 @@ public Object getValue(final String columnLabel, final Class> type) throws SQL
}
@Override
- public Object getCalendarValue(final int columnIndex, final Class> type, final Calendar calendar) {
+ public final Object getCalendarValue(final int columnIndex, final Class> type, final Calendar calendar) {
// TODO implement with calendar
Object result = currentResultSetRow.getCell(columnIndex);
wasNull = null == result;
@@ -76,7 +76,7 @@ public Object getCalendarValue(final int columnIndex, final Class> type, final
}
@Override
- public Object getCalendarValue(final String columnLabel, final Class> type, final Calendar calendar) {
+ public final Object getCalendarValue(final String columnLabel, final Class> type, final Calendar calendar) {
// TODO implement with calendar
Object result = currentResultSetRow.getCell(labelAndIndexMap.get(columnLabel));
wasNull = null == result;
@@ -84,17 +84,17 @@ public Object getCalendarValue(final String columnLabel, final Class> type, fi
}
@Override
- public InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
+ public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
- public InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
+ public final InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
- public boolean wasNull() {
+ public final boolean wasNull() {
return wasNull;
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/StreamMergedResult.java b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/StreamMergedResult.java
index 931ab8c89a4ae..572020e76c0e0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/StreamMergedResult.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/merger/dql/common/StreamMergedResult.java
@@ -37,7 +37,7 @@ public abstract class StreamMergedResult implements MergedResult {
private boolean wasNull;
- protected QueryResult getCurrentQueryResult() throws SQLException {
+ protected final QueryResult getCurrentQueryResult() throws SQLException {
if (null == currentQueryResult) {
throw new SQLException("Current ResultSet is null, ResultSet perhaps end of next.");
}
@@ -74,7 +74,7 @@ public Object getCalendarValue(final String columnLabel, final Class> type, fi
@SuppressWarnings("deprecation")
@Override
- public InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
+ public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
InputStream result = getCurrentQueryResult().getInputStream(columnIndex, type);
wasNull = getCurrentQueryResult().wasNull();
return result;
@@ -82,14 +82,14 @@ public InputStream getInputStream(final int columnIndex, final String type) thro
@SuppressWarnings("deprecation")
@Override
- public InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
+ public final InputStream getInputStream(final String columnLabel, final String type) throws SQLException {
InputStream result = getCurrentQueryResult().getInputStream(columnLabel, type);
wasNull = getCurrentQueryResult().wasNull();
return result;
}
@Override
- public boolean wasNull() {
+ public final boolean wasNull() {
return wasNull;
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/ShardingMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/ShardingMetaData.java
index 54a0701ac4a6e..e5239cfdf5d7f 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/ShardingMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/ShardingMetaData.java
@@ -17,21 +17,33 @@
package io.shardingsphere.core.metadata;
+import com.google.common.util.concurrent.MoreExecutors;
+import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
+import io.shardingsphere.core.metadata.table.executor.TableMetaDataConnectionManager;
+import io.shardingsphere.core.metadata.table.executor.TableMetaDataInitializer;
+import io.shardingsphere.core.rule.ShardingRule;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
/**
* Sharding meta data.
*
* @author zhangliang
*/
-@RequiredArgsConstructor
@Getter
public final class ShardingMetaData {
private final ShardingDataSourceMetaData dataSource;
private final ShardingTableMetaData table;
+
+ public ShardingMetaData(final Map dataSourceURLs, final ShardingRule shardingRule,
+ final DatabaseType databaseType, final ExecutorService executorService, final TableMetaDataConnectionManager connectionManager) {
+ dataSource = new ShardingDataSourceMetaData(dataSourceURLs, shardingRule, databaseType);
+ table = new ShardingTableMetaData(new TableMetaDataInitializer(dataSource, MoreExecutors.listeningDecorator(executorService), connectionManager).load(shardingRule));
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaData.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaData.java
index 3a1b61b0d55c6..1943c29df0a25 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaData.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaData.java
@@ -98,12 +98,12 @@ private boolean isExisted(final String dataSourceName, final Collection
}
/**
- * Get actual schema name.
- *
+ * Get data source meta data.
+ *
* @param actualDataSourceName actual data source name
- * @return actual schema name
+ * @return actual data source meta data
*/
- public String getActualSchemaName(final String actualDataSourceName) {
- return dataSourceMetaDataMap.get(actualDataSourceName).getSchemeName();
+ public DataSourceMetaData getActualDataSourceMetaData(final String actualDataSourceName) {
+ return dataSourceMetaDataMap.get(actualDataSourceName);
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataConnectionManager.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataConnectionManager.java
index 63d86a9197bb8..02c1cab6d557e 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataConnectionManager.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataConnectionManager.java
@@ -35,11 +35,4 @@ public interface TableMetaDataConnectionManager {
* @throws SQLException SQL exception
*/
Connection getConnection(String dataSourceName) throws SQLException;
-
- /**
- * Is auto close created connection or not.
- *
- * @return auto close or not
- */
- boolean isAutoClose();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
index 7b2099ff354d5..69362b7845f3d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataInitializer.java
@@ -20,6 +20,7 @@
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListeningExecutorService;
import io.shardingsphere.core.exception.ShardingException;
+import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.TableMetaData;
import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.core.rule.TableRule;
@@ -39,13 +40,14 @@
*/
public final class TableMetaDataInitializer {
- private final TableMetaDataConnectionManager executorAdapter;
+ private final TableMetaDataConnectionManager connectionManager;
private final TableMetaDataLoader tableMetaDataLoader;
- public TableMetaDataInitializer(final ListeningExecutorService executorService, final TableMetaDataConnectionManager executorAdapter) {
- this.executorAdapter = executorAdapter;
- tableMetaDataLoader = new TableMetaDataLoader(executorService, executorAdapter);
+ public TableMetaDataInitializer(
+ final ShardingDataSourceMetaData shardingDataSourceMetaData, final ListeningExecutorService executorService, final TableMetaDataConnectionManager connectionManager) {
+ this.connectionManager = connectionManager;
+ tableMetaDataLoader = new TableMetaDataLoader(shardingDataSourceMetaData, executorService, connectionManager);
}
/**
@@ -86,8 +88,8 @@ private Map loadDefaultTables(final ShardingRule sharding
private Collection getAllTableNames(final String dataSourceName) throws SQLException {
Collection result = new LinkedList<>();
- try (Connection connection = executorAdapter.getConnection(dataSourceName);
- ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null)) {
+ try (Connection connection = connectionManager.getConnection(dataSourceName);
+ ResultSet resultSet = connection.getMetaData().getTables(dataSourceName, null, null, null)) {
while (resultSet.next()) {
result.add(resultSet.getString("TABLE_NAME"));
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
index 55529d3ee60f0..e39f9a1d788c6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/metadata/table/executor/TableMetaDataLoader.java
@@ -21,12 +21,12 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import io.shardingsphere.core.exception.ShardingException;
+import io.shardingsphere.core.metadata.datasource.DataSourceMetaData;
+import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.ColumnMetaData;
import io.shardingsphere.core.metadata.table.TableMetaData;
-import io.shardingsphere.core.rule.DataNode;
import io.shardingsphere.core.rule.ShardingDataSourceNames;
import io.shardingsphere.core.rule.ShardingRule;
-import io.shardingsphere.core.rule.TableRule;
import lombok.RequiredArgsConstructor;
import java.sql.Connection;
@@ -37,6 +37,8 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -48,9 +50,11 @@
@RequiredArgsConstructor
public final class TableMetaDataLoader {
+ private final ShardingDataSourceMetaData shardingDataSourceMetaData;
+
private final ListeningExecutorService executorService;
- private final TableMetaDataConnectionManager executorAdapter;
+ private final TableMetaDataConnectionManager connectionManager;
/**
* Load table meta data.
@@ -60,38 +64,57 @@ public final class TableMetaDataLoader {
* @return table meta data
*/
public TableMetaData load(final String logicTableName, final ShardingRule shardingRule) {
- return load(shardingRule.getTableRuleByLogicTableName(logicTableName), shardingRule.getShardingDataSourceNames());
- }
-
- private TableMetaData load(final TableRule tableRule, final ShardingDataSourceNames shardingDataSourceNames) {
- List actualTableMetaDataList = loadActualTableMetaDataList(tableRule.getActualDataNodes(), shardingDataSourceNames);
- checkUniformed(tableRule.getLogicTable(), actualTableMetaDataList);
+ List actualTableMetaDataList = load(shardingRule.getTableRuleByLogicTableName(logicTableName).getDataNodeGroups(), shardingRule.getShardingDataSourceNames());
+ checkUniformed(logicTableName, actualTableMetaDataList);
return actualTableMetaDataList.iterator().next();
}
- private TableMetaData load(final DataNode dataNode) throws SQLException {
- if (executorAdapter.isAutoClose()) {
- try (Connection connection = executorAdapter.getConnection(dataNode.getDataSourceName())) {
- return load(connection, dataNode);
+ private List load(final Map> dataNodeGroups, final ShardingDataSourceNames shardingDataSourceNames) {
+ List>> futures = new LinkedList<>();
+ for (Entry> entry : dataNodeGroups.entrySet()) {
+ final String dataSourceName = shardingDataSourceNames.getRawMasterDataSourceName(entry.getKey());
+ DataSourceMetaData dataSourceMetaData = shardingDataSourceMetaData.getActualDataSourceMetaData(entry.getKey());
+ final String catalog = null == dataSourceMetaData ? null : dataSourceMetaData.getSchemeName();
+ final Collection actualTableNames = entry.getValue();
+ futures.add(executorService.submit(new Callable>() {
+
+ @Override
+ public Collection call() throws SQLException {
+ return load(dataSourceName, catalog, actualTableNames);
+ }
+ }));
+ }
+ List result = new LinkedList<>();
+ try {
+ for (Collection each : Futures.allAsList(futures).get()) {
+ result.addAll(each);
}
+ return result;
+ } catch (final InterruptedException | ExecutionException ex) {
+ throw new ShardingException(ex);
}
- return load(executorAdapter.getConnection(dataNode.getDataSourceName()), dataNode);
}
- private TableMetaData load(final Connection connection, final DataNode dataNode) throws SQLException {
- return new TableMetaData(isTableExist(connection, dataNode.getTableName()) ? getColumnMetaDataList(connection, dataNode.getTableName()) : Collections.emptyList());
+ private Collection load(final String dataSourceName, final String catalog, final Collection actualTableNames) throws SQLException {
+ Collection result = new LinkedList<>();
+ try (Connection connection = connectionManager.getConnection(dataSourceName)) {
+ for (String each : actualTableNames) {
+ result.add(new TableMetaData(isTableExist(connection, catalog, each) ? getColumnMetaDataList(connection, catalog, each) : Collections.emptyList()));
+ }
+ }
+ return result;
}
- private boolean isTableExist(final Connection connection, final String actualTableName) throws SQLException {
- try (ResultSet resultSet = connection.getMetaData().getTables(null, null, actualTableName, null)) {
+ private boolean isTableExist(final Connection connection, final String catalog, final String actualTableName) throws SQLException {
+ try (ResultSet resultSet = connection.getMetaData().getTables(catalog, null, actualTableName, null)) {
return resultSet.next();
}
}
- private List getColumnMetaDataList(final Connection connection, final String actualTableName) throws SQLException {
+ private List getColumnMetaDataList(final Connection connection, final String catalog, final String actualTableName) throws SQLException {
List result = new LinkedList<>();
- Collection primaryKeys = getPrimaryKeys(connection, actualTableName);
- try (ResultSet resultSet = connection.getMetaData().getColumns(null, null, actualTableName, null)) {
+ Collection primaryKeys = getPrimaryKeys(connection, catalog, actualTableName);
+ try (ResultSet resultSet = connection.getMetaData().getColumns(catalog, null, actualTableName, null)) {
while (resultSet.next()) {
String columnName = resultSet.getString("COLUMN_NAME");
String columnType = resultSet.getString("TYPE_NAME");
@@ -101,9 +124,9 @@ private List getColumnMetaDataList(final Connection connection,
return result;
}
- private Collection getPrimaryKeys(final Connection connection, final String actualTableName) throws SQLException {
+ private Collection getPrimaryKeys(final Connection connection, final String catalog, final String actualTableName) throws SQLException {
Collection result = new HashSet<>();
- try (ResultSet resultSet = connection.getMetaData().getPrimaryKeys(null, null, actualTableName)) {
+ try (ResultSet resultSet = connection.getMetaData().getPrimaryKeys(catalog, null, actualTableName)) {
while (resultSet.next()) {
result.add(resultSet.getString("COLUMN_NAME"));
}
@@ -111,24 +134,6 @@ private Collection getPrimaryKeys(final Connection connection, final Str
return result;
}
- private List loadActualTableMetaDataList(final List actualDataNodes, final ShardingDataSourceNames shardingDataSourceNames) {
- List> result = new LinkedList<>();
- for (final DataNode each : actualDataNodes) {
- result.add(executorService.submit(new Callable() {
-
- @Override
- public TableMetaData call() throws SQLException {
- return load(new DataNode(shardingDataSourceNames.getRawMasterDataSourceName(each.getDataSourceName()), each.getTableName()));
- }
- }));
- }
- try {
- return Futures.allAsList(result).get();
- } catch (final InterruptedException | ExecutionException ex) {
- throw new ShardingException(ex);
- }
- }
-
private void checkUniformed(final String logicTableName, final List actualTableMetaDataList) {
final TableMetaData sample = actualTableMetaDataList.iterator().next();
for (TableMetaData each : actualTableMetaDataList) {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/lexer/dialect/mysql/MySQLKeyword.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/lexer/dialect/mysql/MySQLKeyword.java
index fa4a73189fa58..8162c9eb3c521 100755
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/lexer/dialect/mysql/MySQLKeyword.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/lexer/dialect/mysql/MySQLKeyword.java
@@ -98,5 +98,10 @@ public enum MySQLKeyword implements Keyword {
STRAIGHT_JOIN,
REGEXP,
INDEXES,
- KEYS
+ KEYS,
+ STATUS,
+ GENERATED,
+ ALWAYS,
+ BTREE,
+ HASH
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/DistinctClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/DistinctClauseParser.java
index b4e4727d16ca1..9ee26ee4a9e9f 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/DistinctClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/DistinctClauseParser.java
@@ -32,7 +32,7 @@
* @author zhangliang
*/
@RequiredArgsConstructor
-public class DistinctClauseParser implements SQLClauseParser {
+public abstract class DistinctClauseParser implements SQLClauseParser {
private final LexerEngine lexerEngine;
@@ -47,7 +47,5 @@ public final void parse() {
lexerEngine.unsupportedIfEqual(distinctKeywords.toArray(new Keyword[distinctKeywords.size()]));
}
- protected Keyword[] getSynonymousKeywordsForDistinct() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSynonymousKeywordsForDistinct();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/GroupByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/GroupByClauseParser.java
index 4ffe8e38db2ea..f4a6b32a543b0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/GroupByClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/GroupByClauseParser.java
@@ -38,7 +38,7 @@
*
* @author zhangliang
*/
-public class GroupByClauseParser implements SQLClauseParser {
+public abstract class GroupByClauseParser implements SQLClauseParser {
private final LexerEngine lexerEngine;
@@ -98,11 +98,7 @@ private void addGroupByItem(final SQLExpression sqlExpression, final SelectState
selectStatement.getGroupByItems().add(orderItem);
}
- protected Keyword[] getUnsupportedKeywordBeforeGroupByItem() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getUnsupportedKeywordBeforeGroupByItem();
- protected Keyword[] getSkippedKeywordAfterGroupBy() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordAfterGroupBy();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertDuplicateKeyUpdateClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertDuplicateKeyUpdateClauseParser.java
index fadc54877118a..26a9e49d67eab 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertDuplicateKeyUpdateClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertDuplicateKeyUpdateClauseParser.java
@@ -34,7 +34,7 @@
*
* @author maxiaoguang
*/
-public class InsertDuplicateKeyUpdateClauseParser implements SQLClauseParser {
+public abstract class InsertDuplicateKeyUpdateClauseParser implements SQLClauseParser {
private final ShardingRule shardingRule;
@@ -78,7 +78,5 @@ public void parse(final InsertStatement insertStatement) {
} while (lexerEngine.skipIfEqual(Symbol.COMMA));
}
- protected Keyword[] getCustomizedInsertKeywords() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getCustomizedInsertKeywords();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertIntoClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertIntoClauseParser.java
index 8d5820f7fce78..76566a970ed58 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertIntoClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertIntoClauseParser.java
@@ -30,7 +30,7 @@
* @author zhangliang
*/
@RequiredArgsConstructor
-public class InsertIntoClauseParser implements SQLClauseParser {
+public abstract class InsertIntoClauseParser implements SQLClauseParser {
private final LexerEngine lexerEngine;
@@ -49,9 +49,7 @@ public void parse(final InsertStatement insertStatement) {
skipBetweenTableAndValues(insertStatement);
}
- protected Keyword[] getUnsupportedKeywordsBeforeInto() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getUnsupportedKeywordsBeforeInto();
private void skipBetweenTableAndValues(final InsertStatement insertStatement) {
while (lexerEngine.skipIfEqual(getSkippedKeywordsBetweenTableAndValues())) {
@@ -62,7 +60,5 @@ private void skipBetweenTableAndValues(final InsertStatement insertStatement) {
}
}
- protected Keyword[] getSkippedKeywordsBetweenTableAndValues() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenTableAndValues();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertSetClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertSetClauseParser.java
index 57685dc8d7f74..dd21f9186c637 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertSetClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertSetClauseParser.java
@@ -51,7 +51,7 @@
* @author zhangliang
* @author maxiaoguang
*/
-public class InsertSetClauseParser implements SQLClauseParser {
+public abstract class InsertSetClauseParser implements SQLClauseParser {
private final ShardingRule shardingRule;
@@ -120,7 +120,5 @@ private void removeUnnecessaryToken(final InsertStatement insertStatement) {
}
}
- protected Keyword[] getCustomizedInsertKeywords() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getCustomizedInsertKeywords();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertValuesClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertValuesClauseParser.java
index c70a286e7f7be..c5768bd7e80ab 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertValuesClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/InsertValuesClauseParser.java
@@ -50,7 +50,7 @@
* @author maxiaoguang
* @author panjuan
*/
-public class InsertValuesClauseParser implements SQLClauseParser {
+public abstract class InsertValuesClauseParser implements SQLClauseParser {
private final ShardingRule shardingRule;
@@ -78,9 +78,7 @@ public void parse(final InsertStatement insertStatement) {
}
}
- protected Keyword[] getSynonymousKeywordsForValues() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSynonymousKeywordsForValues();
/**
* Parse insert values.
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/OrderByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/OrderByClauseParser.java
index 1e65c5de13c14..f558a520e91c1 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/OrderByClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/OrderByClauseParser.java
@@ -43,7 +43,7 @@
*
* @author zhangliang
*/
-public class OrderByClauseParser implements SQLClauseParser {
+public abstract class OrderByClauseParser implements SQLClauseParser {
@Getter
private final LexerEngine lexerEngine;
@@ -100,7 +100,5 @@ private OrderItem parseSelectOrderByItem(final SelectStatement selectStatement)
throw new SQLParsingException(lexerEngine);
}
- protected OrderDirection getNullOrderDirection() {
- return OrderDirection.ASC;
- }
+ protected abstract OrderDirection getNullOrderDirection();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectListClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectListClauseParser.java
index f6a32868faaa5..a94a31cf3c90d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectListClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectListClauseParser.java
@@ -43,7 +43,7 @@
* @author zhangliang
*/
@Getter
-public class SelectListClauseParser implements SQLClauseParser {
+public abstract class SelectListClauseParser implements SQLClauseParser {
private final ShardingRule shardingRule;
@@ -88,17 +88,11 @@ private SelectItem parseSelectItem(final SelectStatement selectStatement) {
return result;
}
- protected Keyword[] getSkippedKeywordsBeforeSelectItem() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBeforeSelectItem();
- protected boolean isRowNumberSelectItem() {
- return false;
- }
+ protected abstract boolean isRowNumberSelectItem();
- protected SelectItem parseRowNumberSelectItem(final SelectStatement selectStatement) {
- throw new UnsupportedOperationException("Cannot support special select item.");
- }
+ protected abstract SelectItem parseRowNumberSelectItem(SelectStatement selectStatement);
private boolean isStarSelectItem() {
return Symbol.STAR.getLiterals().equals(SQLUtil.getExactlyValue(lexerEngine.getCurrentToken().getLiterals()));
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectRestClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectRestClauseParser.java
index e87f36fc8fddf..6432397b50b3b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectRestClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/SelectRestClauseParser.java
@@ -32,7 +32,7 @@
* @author zhangliang
*/
@RequiredArgsConstructor
-public class SelectRestClauseParser implements SQLClauseParser {
+public abstract class SelectRestClauseParser implements SQLClauseParser {
private final LexerEngine lexerEngine;
@@ -46,7 +46,5 @@ public final void parse() {
lexerEngine.unsupportedIfEqual(unsupportedRestKeywords.toArray(new Keyword[unsupportedRestKeywords.size()]));
}
- protected Keyword[] getUnsupportedKeywordsRest() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getUnsupportedKeywordsRest();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/WhereClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/WhereClauseParser.java
index 50e47e2b9f726..550dacb89f3be 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/WhereClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/WhereClauseParser.java
@@ -59,7 +59,7 @@
* @author zhangliang
* @author maxiaoguang
*/
-public class WhereClauseParser implements SQLClauseParser {
+public abstract class WhereClauseParser implements SQLClauseParser {
private final DatabaseType databaseType;
@@ -257,9 +257,7 @@ private boolean isRowNumberCondition(final List items, final SQLExpr
return null != columnLabel && isRowNumberCondition(items, columnLabel);
}
- protected boolean isRowNumberCondition(final List items, final String columnLabel) {
- return false;
- }
+ protected abstract boolean isRowNumberCondition(List items, String columnLabel);
private void parseRowCountCondition(final SelectStatement selectStatement, final boolean includeRowCount) {
SQLExpression sqlExpression = basicExpressionParser.parse(selectStatement);
@@ -291,9 +289,7 @@ private void parseOffsetCondition(final SelectStatement selectStatement, final b
}
}
- protected Keyword[] getCustomizedOtherConditionOperators() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getCustomizedOtherConditionOperators();
private void parseOtherCondition(final SQLStatement sqlStatement) {
basicExpressionParser.parse(sqlStatement);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/expression/AliasExpressionParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/expression/AliasExpressionParser.java
index 3e1fd68e305bf..f1daee035c9ef 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/expression/AliasExpressionParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/clause/expression/AliasExpressionParser.java
@@ -32,7 +32,7 @@
* @author zhangliang
*/
@RequiredArgsConstructor
-public class AliasExpressionParser {
+public abstract class AliasExpressionParser {
private final LexerEngine lexerEngine;
@@ -73,9 +73,7 @@ private TokenType[] getDefaultAvailableKeywordsForSelectItemAlias() {
};
}
- protected TokenType[] getCustomizedAvailableKeywordsForSelectItemAlias() {
- return new TokenType[0];
- }
+ protected abstract TokenType[] getCustomizedAvailableKeywordsForSelectItemAlias();
/**
* Parse alias for table.
@@ -103,7 +101,5 @@ private TokenType[] getDefaultAvailableKeywordsForTableAlias() {
};
}
- protected TokenType[] getCustomizedAvailableKeywordsForTableAlias() {
- return new TokenType[0];
- }
+ protected abstract TokenType[] getCustomizedAvailableKeywordsForTableAlias();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumn.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumn.java
new file mode 100644
index 0000000000000..50408632b6633
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumn.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.constant;
+
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * Derived column alias.
+ *
+ * @author zhangliang
+ */
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum DerivedColumn {
+
+ AVG_COUNT_ALIAS("AVG_DERIVED_COUNT_"),
+ AVG_SUM_ALIAS("AVG_DERIVED_SUM_"),
+ ORDER_BY_ALIAS("ORDER_BY_DERIVED_"),
+ GROUP_BY_ALIAS("GROUP_BY_DERIVED_");
+
+ private final String pattern;
+
+ /**
+ * Get alias of derived column.
+ *
+ * @param derivedColumnCount derived column count
+ * @return alias of derived column
+ */
+ public String getDerivedColumnAlias(final int derivedColumnCount) {
+ return String.format(pattern + "%s", derivedColumnCount);
+ }
+
+ /**
+ * Judge is derived column or not.
+ *
+ * @param columnName column name to be judged
+ * @return is derived column or not
+ */
+ public static boolean isDerivedColumn(final String columnName) {
+ for (DerivedColumn each : DerivedColumn.values()) {
+ if (columnName.startsWith(each.pattern)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLDistinctClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLDistinctClauseParser.java
index d525a292c5ea4..42ea804787c68 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLDistinctClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLDistinctClauseParser.java
@@ -27,7 +27,7 @@
*
* @author zhangliang
*/
-public class MySQLDistinctClauseParser extends DistinctClauseParser {
+public final class MySQLDistinctClauseParser extends DistinctClauseParser {
public MySQLDistinctClauseParser(final LexerEngine lexerEngine) {
super(lexerEngine);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLGroupByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLGroupByClauseParser.java
index e68a701c935fc..7c024086687fb 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLGroupByClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLGroupByClauseParser.java
@@ -34,6 +34,11 @@ public MySQLGroupByClauseParser(final LexerEngine lexerEngine) {
super(lexerEngine);
}
+ @Override
+ protected Keyword[] getUnsupportedKeywordBeforeGroupByItem() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getSkippedKeywordAfterGroupBy() {
return new Keyword[] {DefaultKeyword.WITH, MySQLKeyword.ROLLUP};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertIntoClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertIntoClauseParser.java
index 44996b6a99868..937ab979a493d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertIntoClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertIntoClauseParser.java
@@ -34,6 +34,11 @@ public MySQLInsertIntoClauseParser(final ShardingRule shardingRule, final LexerE
super(lexerEngine, new MySQLTableReferencesClauseParser(shardingRule, lexerEngine));
}
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBeforeInto() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getSkippedKeywordsBetweenTableAndValues() {
return new Keyword[] {MySQLKeyword.PARTITION};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertValuesClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertValuesClauseParser.java
index 547968504233b..ed813ebbfd691 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertValuesClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLInsertValuesClauseParser.java
@@ -28,7 +28,7 @@
*
* @author zhangliang
*/
-public class MySQLInsertValuesClauseParser extends InsertValuesClauseParser {
+public final class MySQLInsertValuesClauseParser extends InsertValuesClauseParser {
public MySQLInsertValuesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLOrderByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLOrderByClauseParser.java
new file mode 100644
index 0000000000000..ad775870ece94
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLOrderByClauseParser.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.mysql.clause;
+
+import io.shardingsphere.core.constant.OrderDirection;
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.parser.clause.OrderByClauseParser;
+
+/**
+ * Order by clause parser for MySQL.
+ *
+ * @author zhangliang
+ */
+public final class MySQLOrderByClauseParser extends OrderByClauseParser {
+
+ public MySQLOrderByClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected OrderDirection getNullOrderDirection() {
+ return OrderDirection.ASC;
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLSelectListClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLSelectListClauseParser.java
new file mode 100644
index 0000000000000..5b414930cc86b
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLSelectListClauseParser.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.mysql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
+import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
+import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Select list clause parser for MySQL.
+ *
+ * @author zhangliang
+ */
+public final class MySQLSelectListClauseParser extends SelectListClauseParser {
+
+ public MySQLSelectListClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeSelectItem() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected boolean isRowNumberSelectItem() {
+ return false;
+ }
+
+ @Override
+ protected SelectItem parseRowNumberSelectItem(final SelectStatement selectStatement) {
+ throw new UnsupportedOperationException("Cannot support special select item.");
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLWhereClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLWhereClauseParser.java
index 92c829ea20bf9..6cee31c2d2e0c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLWhereClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/MySQLWhereClauseParser.java
@@ -22,6 +22,9 @@
import io.shardingsphere.core.parsing.lexer.dialect.mysql.MySQLKeyword;
import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
+import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
+
+import java.util.List;
/**
* Where clause parser for MySQL.
@@ -34,6 +37,11 @@ public MySQLWhereClauseParser(final LexerEngine lexerEngine) {
super(DatabaseType.MySQL, lexerEngine);
}
+ @Override
+ protected boolean isRowNumberCondition(final List items, final String columnLabel) {
+ return false;
+ }
+
@Override
protected Keyword[] getCustomizedOtherConditionOperators() {
return new Keyword[] {MySQLKeyword.REGEXP};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/facade/MySQLSelectClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/facade/MySQLSelectClauseParserFacade.java
index a125c8e300ae2..634edc95e29f0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/facade/MySQLSelectClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/clause/facade/MySQLSelectClauseParserFacade.java
@@ -19,11 +19,11 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.HavingClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.OrderByClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractSelectClauseParserFacade;
import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLDistinctClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLGroupByClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLOrderByClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLSelectListClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLSelectRestClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLTableReferencesClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.mysql.clause.MySQLWhereClauseParser;
@@ -37,8 +37,8 @@
public final class MySQLSelectClauseParserFacade extends AbstractSelectClauseParserFacade {
public MySQLSelectClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new MySQLDistinctClauseParser(lexerEngine), new SelectListClauseParser(shardingRule, lexerEngine),
+ super(new MySQLDistinctClauseParser(lexerEngine), new MySQLSelectListClauseParser(shardingRule, lexerEngine),
new MySQLTableReferencesClauseParser(shardingRule, lexerEngine), new MySQLWhereClauseParser(lexerEngine), new MySQLGroupByClauseParser(lexerEngine),
- new HavingClauseParser(lexerEngine), new OrderByClauseParser(lexerEngine), new MySQLSelectRestClauseParser(lexerEngine));
+ new HavingClauseParser(lexerEngine), new MySQLOrderByClauseParser(lexerEngine), new MySQLSelectRestClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLAlterTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLAlterTableParser.java
index e9d94731ce5cf..215241f6fc819 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLAlterTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLAlterTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.mysql.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.alter.table.AbstractAlterTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class MySQLAlterTableParser extends AbstractAlterTableParser {
public MySQLAlterTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenAlterTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateIndexParser.java
index 1e100d632197b..fd5ac103c7e4f 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateIndexParser.java
@@ -45,4 +45,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateAndKeyword() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.FULLTEXT, MySQLKeyword.SPATIAL};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateTableParser.java
index 1ed5e513ee4a1..4db1dccfa6484 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLCreateTableParser.java
@@ -50,4 +50,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateTableAndTableName() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.FULLTEXT, MySQLKeyword.SPATIAL};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeTableConstraint() {
+ return new Keyword[] {DefaultKeyword.USING, MySQLKeyword.BTREE, MySQLKeyword.HASH};
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDeleteParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDeleteParser.java
index a26a2a701d65b..224576bc31ab4 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDeleteParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDeleteParser.java
@@ -40,4 +40,9 @@ public MySQLDeleteParser(final ShardingRule shardingRule, final LexerEngine lexe
protected Keyword[] getSkippedKeywordsBetweenDeleteAndTable() {
return new Keyword[] {MySQLKeyword.LOW_PRIORITY, MySQLKeyword.QUICK, MySQLKeyword.IGNORE, DefaultKeyword.FROM};
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenDeleteAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDropIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDropIndexParser.java
index 3e8971c16fe23..1bc76de30e0e3 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDropIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLDropIndexParser.java
@@ -39,4 +39,9 @@ public MySQLDropIndexParser(final ShardingRule shardingRule, final LexerEngine l
protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
return new Keyword[] {DefaultKeyword.TEMPORARY};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLShowParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLShowParser.java
index fb5e3fa7a8b1e..35a820556e726 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLShowParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLShowParser.java
@@ -26,6 +26,7 @@
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowDatabasesStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowIndexStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowOtherStatement;
+import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowTableStatusStatement;
import io.shardingsphere.core.parsing.parser.dialect.mysql.statement.ShowTablesStatement;
import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
import io.shardingsphere.core.parsing.parser.sql.dal.show.AbstractShowParser;
@@ -56,43 +57,70 @@ public DALStatement parse() {
lexerEngine.nextToken();
lexerEngine.skipIfEqual(DefaultKeyword.FULL);
if (lexerEngine.equalAny(MySQLKeyword.DATABASES)) {
- return new ShowDatabasesStatement();
+ return showDatabases();
+ }
+ if (lexerEngine.skipIfEqual(DefaultKeyword.TABLE, MySQLKeyword.STATUS)) {
+ return parseShowTableStatus();
}
if (lexerEngine.skipIfEqual(MySQLKeyword.TABLES)) {
- DALStatement result = new ShowTablesStatement();
- if (lexerEngine.equalAny(DefaultKeyword.FROM, DefaultKeyword.IN)) {
- int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
- lexerEngine.nextToken();
- lexerEngine.nextToken();
- result.getSqlTokens().add(new RemoveToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition()));
- }
- return result;
+ return parseShowTables();
}
if (lexerEngine.skipIfEqual(MySQLKeyword.COLUMNS, MySQLKeyword.FIELDS)) {
- DALStatement result = new ShowColumnsStatement();
- lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN);
- tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
- if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
- int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
- result.getSqlTokens().add(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getLiterals(), result.getTables().getSingleTableName()));
- }
- return result;
+ return parseShowColumnsFields();
}
if (lexerEngine.skipIfEqual(DefaultKeyword.CREATE) && lexerEngine.skipIfEqual(DefaultKeyword.TABLE)) {
- DALStatement result = new ShowCreateTableStatement();
- tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
- return result;
+ return parseShowCreateTable();
}
if (lexerEngine.skipIfEqual(DefaultKeyword.INDEX, MySQLKeyword.INDEXES, MySQLKeyword.KEYS)) {
- DALStatement result = new ShowIndexStatement();
- lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN);
- tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
- if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
- int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
- result.getSqlTokens().add(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getLiterals(), result.getTables().getSingleTableName()));
- }
- return result;
+ return parseShowIndex();
}
return new ShowOtherStatement();
}
+
+ private DALStatement showDatabases() {
+ return new ShowDatabasesStatement();
+ }
+
+ private DALStatement parseShowTableStatus() {
+ return new ShowTableStatusStatement();
+ }
+
+ private DALStatement parseShowTables() {
+ DALStatement result = new ShowTablesStatement();
+ if (lexerEngine.equalAny(DefaultKeyword.FROM, DefaultKeyword.IN)) {
+ int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
+ lexerEngine.nextToken();
+ lexerEngine.nextToken();
+ result.getSqlTokens().add(new RemoveToken(beginPosition, lexerEngine.getCurrentToken().getEndPosition()));
+ }
+ return result;
+ }
+
+ private DALStatement parseShowColumnsFields() {
+ DALStatement result = new ShowColumnsStatement();
+ lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN);
+ tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
+ if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
+ int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
+ result.getSqlTokens().add(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getLiterals(), result.getTables().getSingleTableName()));
+ }
+ return result;
+ }
+
+ private DALStatement parseShowCreateTable() {
+ DALStatement result = new ShowCreateTableStatement();
+ tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
+ return result;
+ }
+
+ private DALStatement parseShowIndex() {
+ DALStatement result = new ShowIndexStatement();
+ lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN);
+ tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
+ if (lexerEngine.skipIfEqual(DefaultKeyword.FROM, DefaultKeyword.IN)) {
+ int beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length();
+ result.getSqlTokens().add(new SchemaToken(beginPosition, lexerEngine.getCurrentToken().getLiterals(), result.getTables().getSingleTableName()));
+ }
+ return result;
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLTruncateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLTruncateTableParser.java
index 0a8ce40e58fa7..fa953200e5864 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLTruncateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLTruncateTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.mysql.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.truncate.table.AbstractTruncateTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class MySQLTruncateTableParser extends AbstractTruncateTableParser
public MySQLTruncateTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTruncateTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLUpdateParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLUpdateParser.java
index 2f8a69b4ec809..2a9eba9abf600 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLUpdateParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/sql/MySQLUpdateParser.java
@@ -39,4 +39,9 @@ public MySQLUpdateParser(final ShardingRule shardingRule, final LexerEngine lexe
protected Keyword[] getSkippedKeywordsBetweenUpdateAndTable() {
return new Keyword[] {MySQLKeyword.LOW_PRIORITY, MySQLKeyword.IGNORE};
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/constant/PacketHeader.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/statement/ShowTableStatusStatement.java
similarity index 66%
rename from sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/constant/PacketHeader.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/statement/ShowTableStatusStatement.java
index e59b7f11e12c6..98f6a021fbf90 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/transport/mysql/constant/PacketHeader.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/mysql/statement/ShowTableStatusStatement.java
@@ -15,25 +15,14 @@
*
*/
-package io.shardingsphere.proxy.transport.mysql.constant;
+package io.shardingsphere.core.parsing.parser.dialect.mysql.statement;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import io.shardingsphere.core.parsing.parser.sql.dal.DALStatement;
/**
- * Generic Packet Header.
+ * Show table status statement.
*
- * @author linjiaqi
+ * @author zhangliang
*/
-@RequiredArgsConstructor
-@Getter
-public enum PacketHeader {
-
- OK(0x00),
-
- EOF(0xfe),
-
- ERR(0xff);
-
- private final int value;
+public final class ShowTableStatusStatement extends DALStatement {
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleDistinctClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleDistinctClauseParser.java
index 045f616b148d9..6759b7fdc5b51 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleDistinctClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleDistinctClauseParser.java
@@ -27,7 +27,7 @@
*
* @author zhangliang
*/
-public class OracleDistinctClauseParser extends DistinctClauseParser {
+public final class OracleDistinctClauseParser extends DistinctClauseParser {
public OracleDistinctClauseParser(final LexerEngine lexerEngine) {
super(lexerEngine);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleGroupByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleGroupByClauseParser.java
index 9ae22c190972e..e94c2e21385ea 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleGroupByClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleGroupByClauseParser.java
@@ -37,4 +37,9 @@ public OracleGroupByClauseParser(final LexerEngine lexerEngine) {
protected Keyword[] getUnsupportedKeywordBeforeGroupByItem() {
return new Keyword[] {OracleKeyword.ROLLUP, OracleKeyword.CUBE, OracleKeyword.GROUPING};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordAfterGroupBy() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertDuplicateKeyUpdateClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertDuplicateKeyUpdateClauseParser.java
new file mode 100644
index 0000000000000..ccfe36e0cb162
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertDuplicateKeyUpdateClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.oracle.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert duplicate key update clause parser for Oracle.
+ *
+ * @author maxiaoguang
+ */
+public final class OracleInsertDuplicateKeyUpdateClauseParser extends InsertDuplicateKeyUpdateClauseParser {
+
+ public OracleInsertDuplicateKeyUpdateClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertIntoClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertIntoClauseParser.java
index 81c72b6ce604f..2461905a626ce 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertIntoClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertIntoClauseParser.java
@@ -39,4 +39,9 @@ public OracleInsertIntoClauseParser(final ShardingRule shardingRule, final Lexer
protected Keyword[] getUnsupportedKeywordsBeforeInto() {
return new Keyword[] {DefaultKeyword.ALL, OracleKeyword.FIRST};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTableAndValues() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertSetClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertSetClauseParser.java
new file mode 100644
index 0000000000000..055131979ab53
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertSetClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.oracle.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert set clause parser for Oracle.
+ *
+ * @author zhangliang
+ */
+public final class OracleInsertSetClauseParser extends InsertSetClauseParser {
+
+ public OracleInsertSetClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertValuesClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertValuesClauseParser.java
new file mode 100644
index 0000000000000..7838114ec813e
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleInsertValuesClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.oracle.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert values clause parser for Oracle.
+ *
+ * @author zhangliang
+ */
+public final class OracleInsertValuesClauseParser extends InsertValuesClauseParser {
+
+ public OracleInsertValuesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSynonymousKeywordsForValues() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectListClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectListClauseParser.java
index a0daf7e5d66e0..3241233b6a355 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectListClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectListClauseParser.java
@@ -21,6 +21,8 @@
import io.shardingsphere.core.parsing.lexer.dialect.oracle.OracleKeyword;
import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
+import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
+import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -38,4 +40,14 @@ public OracleSelectListClauseParser(final ShardingRule shardingRule, final Lexer
protected Keyword[] getSkippedKeywordsBeforeSelectItem() {
return new Keyword[] {OracleKeyword.CONNECT_BY_ROOT};
}
+
+ @Override
+ protected boolean isRowNumberSelectItem() {
+ return false;
+ }
+
+ @Override
+ protected SelectItem parseRowNumberSelectItem(final SelectStatement selectStatement) {
+ throw new UnsupportedOperationException("Cannot support special select item.");
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectRestClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectRestClauseParser.java
new file mode 100755
index 0000000000000..d7f7bb1cf4248
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleSelectRestClauseParser.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.oracle.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.SelectRestClauseParser;
+
+/**
+ * Select rest clause parser for Oracle.
+ *
+ * @author zhangliang
+ */
+public final class OracleSelectRestClauseParser extends SelectRestClauseParser {
+
+ public OracleSelectRestClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsRest() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleWhereClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleWhereClauseParser.java
index 715428598396a..62661b3c1d860 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleWhereClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/OracleWhereClauseParser.java
@@ -20,6 +20,7 @@
import com.google.common.base.Optional;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
@@ -47,4 +48,9 @@ protected boolean isRowNumberCondition(final List items, final Strin
}
return "rownum".equalsIgnoreCase(columnLabel) || columnLabel.equalsIgnoreCase(rowNumberAlias.orNull());
}
+
+ @Override
+ protected Keyword[] getCustomizedOtherConditionOperators() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleInsertClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleInsertClauseParserFacade.java
index 136ea0e8f5666..325d71a0e6fcf 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleInsertClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleInsertClauseParserFacade.java
@@ -19,11 +19,11 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.InsertColumnsClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractInsertClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleInsertDuplicateKeyUpdateClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleInsertIntoClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleInsertSetClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleInsertValuesClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -34,7 +34,7 @@
public final class OracleInsertClauseParserFacade extends AbstractInsertClauseParserFacade {
public OracleInsertClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new OracleInsertIntoClauseParser(shardingRule, lexerEngine), new InsertColumnsClauseParser(shardingRule, lexerEngine),
- new InsertValuesClauseParser(shardingRule, lexerEngine), new InsertSetClauseParser(shardingRule, lexerEngine), new InsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
+ super(new OracleInsertIntoClauseParser(shardingRule, lexerEngine), new InsertColumnsClauseParser(shardingRule, lexerEngine), new OracleInsertValuesClauseParser(shardingRule, lexerEngine),
+ new OracleInsertSetClauseParser(shardingRule, lexerEngine), new OracleInsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleSelectClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleSelectClauseParserFacade.java
index aac24014fc29d..b3ab7eb1e150f 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleSelectClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/clause/facade/OracleSelectClauseParserFacade.java
@@ -19,12 +19,12 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.HavingClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.SelectRestClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractSelectClauseParserFacade;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleDistinctClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleGroupByClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleOrderByClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleSelectListClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleSelectRestClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleTableReferencesClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.OracleWhereClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -39,6 +39,6 @@ public final class OracleSelectClauseParserFacade extends AbstractSelectClausePa
public OracleSelectClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(new OracleDistinctClauseParser(lexerEngine), new OracleSelectListClauseParser(shardingRule, lexerEngine),
new OracleTableReferencesClauseParser(shardingRule, lexerEngine), new OracleWhereClauseParser(lexerEngine), new OracleGroupByClauseParser(lexerEngine),
- new HavingClauseParser(lexerEngine), new OracleOrderByClauseParser(lexerEngine), new SelectRestClauseParser(lexerEngine));
+ new HavingClauseParser(lexerEngine), new OracleOrderByClauseParser(lexerEngine), new OracleSelectRestClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleAlterTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleAlterTableParser.java
index e80663d0d835b..a2535f5fce172 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleAlterTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleAlterTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.oracle.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.alter.table.AbstractAlterTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class OracleAlterTableParser extends AbstractAlterTableParser {
public OracleAlterTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenAlterTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateIndexParser.java
index 7ccfc07e781f4..6bdd904dc6e98 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateIndexParser.java
@@ -44,4 +44,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateAndKeyword() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.BITMAP};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateTableParser.java
index 0985718f234cb..74b0b58d4e1d1 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleCreateTableParser.java
@@ -49,4 +49,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateTableAndTableName() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.BITMAP};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeTableConstraint() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDeleteParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDeleteParser.java
index d3c0699453652..4a34c0bb071a0 100755
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDeleteParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDeleteParser.java
@@ -29,7 +29,7 @@
*
* @author zhangliang
*/
-public class OracleDeleteParser extends AbstractDeleteParser {
+public final class OracleDeleteParser extends AbstractDeleteParser {
public OracleDeleteParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine, new OracleDeleteClauseParserFacade(shardingRule, lexerEngine));
@@ -39,4 +39,9 @@ public OracleDeleteParser(final ShardingRule shardingRule, final LexerEngine lex
protected Keyword[] getSkippedKeywordsBetweenDeleteAndTable() {
return new Keyword[] {DefaultKeyword.FROM};
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenDeleteAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropIndexParser.java
index 42a2f36e15d6c..fecafc3bf4dd9 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropIndexParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.oracle.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.drop.index.AbstractDropIndexParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,14 @@ public final class OracleDropIndexParser extends AbstractDropIndexParser {
public OracleDropIndexParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropTableParser.java
index 08fb1c4caafa6..707df23819c3e 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleDropTableParser.java
@@ -34,6 +34,11 @@ public OracleDropTableParser(final ShardingRule shardingRule, final LexerEngine
super(shardingRule, lexerEngine);
}
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getSkippedKeywordsBetweenDropTableAndTableName() {
return new Keyword[] {};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleTruncateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleTruncateTableParser.java
index 00ffacb34d5f7..0a11ac43fef04 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleTruncateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleTruncateTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.oracle.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.truncate.table.AbstractTruncateTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class OracleTruncateTableParser extends AbstractTruncateTableParser
public OracleTruncateTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTruncateTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleUpdateParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleUpdateParser.java
index 291868c108701..b55d0e07c63eb 100755
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleUpdateParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/oracle/sql/OracleUpdateParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.oracle.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.dialect.oracle.clause.facade.OracleUpdateClauseParserFacade;
import io.shardingsphere.core.parsing.parser.sql.dml.update.AbstractUpdateParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -27,9 +28,19 @@
*
* @author zhangliang
*/
-public class OracleUpdateParser extends AbstractUpdateParser {
+public final class OracleUpdateParser extends AbstractUpdateParser {
public OracleUpdateParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine, new OracleUpdateClauseParserFacade(shardingRule, lexerEngine));
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenUpdateAndTable() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLDistinctClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLDistinctClauseParser.java
new file mode 100644
index 0000000000000..ca0fc18f12ae6
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLDistinctClauseParser.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.DistinctClauseParser;
+
+/**
+ * Distinct clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLDistinctClauseParser extends DistinctClauseParser {
+
+ public PostgreSQLDistinctClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSynonymousKeywordsForDistinct() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLGroupByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLGroupByClauseParser.java
new file mode 100644
index 0000000000000..ba0a5310d59f7
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLGroupByClauseParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.GroupByClauseParser;
+
+/**
+ * Group by clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLGroupByClauseParser extends GroupByClauseParser {
+
+ public PostgreSQLGroupByClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordBeforeGroupByItem() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordAfterGroupBy() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertDuplicateKeyUpdateClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertDuplicateKeyUpdateClauseParser.java
new file mode 100644
index 0000000000000..7925874eab4b1
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertDuplicateKeyUpdateClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert duplicate key update clause parser for SQLServer.
+ *
+ * @author maxiaoguang
+ */
+public final class PostgreSQLInsertDuplicateKeyUpdateClauseParser extends InsertDuplicateKeyUpdateClauseParser {
+
+ public PostgreSQLInsertDuplicateKeyUpdateClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertIntoClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertIntoClauseParser.java
index 78e327b4b4e6f..cd4ce0f4b08cf 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertIntoClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertIntoClauseParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.InsertIntoClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -31,4 +32,14 @@ public final class PostgreSQLInsertIntoClauseParser extends InsertIntoClausePars
public PostgreSQLInsertIntoClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(lexerEngine, new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine));
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBeforeInto() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTableAndValues() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertSetClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertSetClauseParser.java
new file mode 100644
index 0000000000000..b326f8e36e247
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertSetClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert set clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLInsertSetClauseParser extends InsertSetClauseParser {
+
+ public PostgreSQLInsertSetClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertValuesClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertValuesClauseParser.java
new file mode 100644
index 0000000000000..ba4a073629ce7
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLInsertValuesClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert values clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLInsertValuesClauseParser extends InsertValuesClauseParser {
+
+ public PostgreSQLInsertValuesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSynonymousKeywordsForValues() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLSelectListClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLSelectListClauseParser.java
new file mode 100644
index 0000000000000..212df85372d74
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLSelectListClauseParser.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
+import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
+import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Select list clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLSelectListClauseParser extends SelectListClauseParser {
+
+ public PostgreSQLSelectListClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeSelectItem() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected boolean isRowNumberSelectItem() {
+ return false;
+ }
+
+ @Override
+ protected SelectItem parseRowNumberSelectItem(final SelectStatement selectStatement) {
+ throw new UnsupportedOperationException("Cannot support special select item.");
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLWhereClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLWhereClauseParser.java
new file mode 100644
index 0000000000000..2b941611f1299
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/PostgreSQLWhereClauseParser.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause;
+
+import io.shardingsphere.core.constant.DatabaseType;
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
+import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
+
+import java.util.List;
+
+/**
+ * Where clause parser for PostgreSQL.
+ *
+ * @author zhangliang
+ */
+public final class PostgreSQLWhereClauseParser extends WhereClauseParser {
+
+ public PostgreSQLWhereClauseParser(final LexerEngine lexerEngine) {
+ super(DatabaseType.PostgreSQL, lexerEngine);
+ }
+
+ @Override
+ protected boolean isRowNumberCondition(final List items, final String columnLabel) {
+ return false;
+ }
+
+ @Override
+ protected Keyword[] getCustomizedOtherConditionOperators() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLDeleteClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLDeleteClauseParserFacade.java
index 0f2866a46fef1..9c9b55603530b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLDeleteClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLDeleteClauseParserFacade.java
@@ -17,11 +17,10 @@
package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.facade;
-import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
-import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractDeleteClauseParserFacade;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLTableReferencesClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLWhereClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -32,6 +31,6 @@
public final class PostgreSQLDeleteClauseParserFacade extends AbstractDeleteClauseParserFacade {
public PostgreSQLDeleteClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine), new WhereClauseParser(DatabaseType.PostgreSQL, lexerEngine));
+ super(new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine), new PostgreSQLWhereClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLInsertClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLInsertClauseParserFacade.java
index bc04c3e52d42a..bb098af2cf4a0 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLInsertClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLInsertClauseParserFacade.java
@@ -19,11 +19,11 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.InsertColumnsClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractInsertClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLInsertDuplicateKeyUpdateClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLInsertIntoClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLInsertSetClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLInsertValuesClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -35,6 +35,7 @@ public final class PostgreSQLInsertClauseParserFacade extends AbstractInsertClau
public PostgreSQLInsertClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(new PostgreSQLInsertIntoClauseParser(shardingRule, lexerEngine), new InsertColumnsClauseParser(shardingRule, lexerEngine),
- new InsertValuesClauseParser(shardingRule, lexerEngine), new InsertSetClauseParser(shardingRule, lexerEngine), new InsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
+ new PostgreSQLInsertValuesClauseParser(shardingRule, lexerEngine), new PostgreSQLInsertSetClauseParser(shardingRule, lexerEngine),
+ new PostgreSQLInsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLSelectClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLSelectClauseParserFacade.java
index 7c81407f4da41..e3917f6b10708 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLSelectClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLSelectClauseParserFacade.java
@@ -17,17 +17,16 @@
package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.facade;
-import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
-import io.shardingsphere.core.parsing.parser.clause.DistinctClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.GroupByClauseParser;
import io.shardingsphere.core.parsing.parser.clause.HavingClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractSelectClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLDistinctClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLGroupByClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLOrderByClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLSelectListClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLSelectRestClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLTableReferencesClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLWhereClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -38,9 +37,9 @@
public final class PostgreSQLSelectClauseParserFacade extends AbstractSelectClauseParserFacade {
public PostgreSQLSelectClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new DistinctClauseParser(lexerEngine), new SelectListClauseParser(shardingRule, lexerEngine),
+ super(new PostgreSQLDistinctClauseParser(lexerEngine), new PostgreSQLSelectListClauseParser(shardingRule, lexerEngine),
new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine),
- new WhereClauseParser(DatabaseType.PostgreSQL, lexerEngine), new GroupByClauseParser(lexerEngine), new HavingClauseParser(lexerEngine),
+ new PostgreSQLWhereClauseParser(lexerEngine), new PostgreSQLGroupByClauseParser(lexerEngine), new HavingClauseParser(lexerEngine),
new PostgreSQLOrderByClauseParser(lexerEngine), new PostgreSQLSelectRestClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLUpdateClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLUpdateClauseParserFacade.java
index 779524a2f19f8..3b26736d03f60 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLUpdateClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/clause/facade/PostgreSQLUpdateClauseParserFacade.java
@@ -17,12 +17,11 @@
package io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.facade;
-import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.UpdateSetItemsClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractUpdateClauseParserFacade;
import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLTableReferencesClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.postgresql.clause.PostgreSQLWhereClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -33,6 +32,6 @@
public final class PostgreSQLUpdateClauseParserFacade extends AbstractUpdateClauseParserFacade {
public PostgreSQLUpdateClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine), new UpdateSetItemsClauseParser(lexerEngine), new WhereClauseParser(DatabaseType.PostgreSQL, lexerEngine));
+ super(new PostgreSQLTableReferencesClauseParser(shardingRule, lexerEngine), new UpdateSetItemsClauseParser(lexerEngine), new PostgreSQLWhereClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLCreateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLCreateTableParser.java
index 700a6e484d4f7..90e2d9d52da05 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLCreateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLCreateTableParser.java
@@ -50,4 +50,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateTableAndTableName() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeTableConstraint() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDeleteParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDeleteParser.java
index 8277137a603a7..f2b21c524e0ac 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDeleteParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDeleteParser.java
@@ -40,4 +40,9 @@ public PostgreSQLDeleteParser(final ShardingRule shardingRule, final LexerEngine
protected Keyword[] getSkippedKeywordsBetweenDeleteAndTable() {
return new Keyword[] {DefaultKeyword.FROM, PostgreSQLKeyword.ONLY};
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenDeleteAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropIndexParser.java
index 489dcca85c099..0a6c4596ef724 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropIndexParser.java
@@ -39,4 +39,9 @@ public PostgreSQLDropIndexParser(final ShardingRule shardingRule, final LexerEng
protected Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName() {
return new Keyword[] {DefaultKeyword.IF, DefaultKeyword.EXISTS};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropTableParser.java
index 984cc84317f00..69da3feee7b2c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLDropTableParser.java
@@ -34,7 +34,12 @@ public final class PostgreSQLDropTableParser extends AbstractDropTableParser {
public PostgreSQLDropTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
-
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getSkippedKeywordsBetweenDropTableAndTableName() {
return new Keyword[] {DefaultKeyword.IF, DefaultKeyword.EXISTS};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLUpdateParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLUpdateParser.java
index 3ce45e3ae72b9..be56f937dd2c6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLUpdateParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/postgresql/sql/PostgreSQLUpdateParser.java
@@ -39,4 +39,9 @@ public PostgreSQLUpdateParser(final ShardingRule shardingRule, final LexerEngine
protected Keyword[] getSkippedKeywordsBetweenUpdateAndTable() {
return new Keyword[] {PostgreSQLKeyword.ONLY};
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerDistinctClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerDistinctClauseParser.java
new file mode 100644
index 0000000000000..b9e28b8852c62
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerDistinctClauseParser.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.DistinctClauseParser;
+
+/**
+ * Distinct clause parser for SQLServer.
+ *
+ * @author zhangliang
+ */
+public final class SQLServerDistinctClauseParser extends DistinctClauseParser {
+
+ public SQLServerDistinctClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSynonymousKeywordsForDistinct() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerGroupByClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerGroupByClauseParser.java
new file mode 100644
index 0000000000000..578c5bdea3dfa
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerGroupByClauseParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.GroupByClauseParser;
+
+/**
+ * Group by clause parser for SQLServer.
+ *
+ * @author zhangliang
+ */
+public final class SQLServerGroupByClauseParser extends GroupByClauseParser {
+
+ public SQLServerGroupByClauseParser(final LexerEngine lexerEngine) {
+ super(lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordBeforeGroupByItem() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordAfterGroupBy() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertDuplicateKeyUpdateClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertDuplicateKeyUpdateClauseParser.java
new file mode 100644
index 0000000000000..761e50b57eb00
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertDuplicateKeyUpdateClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert duplicate key update clause parser for PostgreSQL.
+ *
+ * @author maxiaoguang
+ */
+public final class SQLServerInsertDuplicateKeyUpdateClauseParser extends InsertDuplicateKeyUpdateClauseParser {
+
+ public SQLServerInsertDuplicateKeyUpdateClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertIntoClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertIntoClauseParser.java
index 9ee12b7a4c44f..0738a6e21d50e 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertIntoClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertIntoClauseParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.InsertIntoClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -31,4 +32,14 @@ public final class SQLServerInsertIntoClauseParser extends InsertIntoClauseParse
public SQLServerInsertIntoClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(lexerEngine, new SQLServerTableReferencesClauseParser(shardingRule, lexerEngine));
}
+
+ @Override
+ protected Keyword[] getUnsupportedKeywordsBeforeInto() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTableAndValues() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertSetClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertSetClauseParser.java
new file mode 100644
index 0000000000000..d4cec92cadcd1
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertSetClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert set clause parser for SQLServer.
+ *
+ * @author zhangliang
+ */
+public final class SQLServerInsertSetClauseParser extends InsertSetClauseParser {
+
+ public SQLServerInsertSetClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getCustomizedInsertKeywords() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertValuesClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertValuesClauseParser.java
new file mode 100644
index 0000000000000..c252033e8ca39
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerInsertValuesClauseParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause;
+
+import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Insert values clause parser for SQLServer.
+ *
+ * @author zhangliang
+ */
+public final class SQLServerInsertValuesClauseParser extends InsertValuesClauseParser {
+
+ public SQLServerInsertValuesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
+ super(shardingRule, lexerEngine);
+ }
+
+ @Override
+ protected Keyword[] getSynonymousKeywordsForValues() {
+ return new Keyword[0];
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java
index 9100d5ee1a58a..1b03f1b537dd3 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java
@@ -20,6 +20,7 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.lexer.dialect.sqlserver.SQLServerKeyword;
import io.shardingsphere.core.parsing.lexer.token.DefaultKeyword;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.lexer.token.Symbol;
import io.shardingsphere.core.parsing.parser.clause.OrderByClauseParser;
import io.shardingsphere.core.parsing.parser.clause.SelectListClauseParser;
@@ -42,6 +43,11 @@ public SQLServerSelectListClauseParser(final ShardingRule shardingRule, final Le
orderByClauseParser = new SQLServerOrderByClauseParser(lexerEngine);
}
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeSelectItem() {
+ return new Keyword[0];
+ }
+
@Override
protected boolean isRowNumberSelectItem() {
return getLexerEngine().skipIfEqual(SQLServerKeyword.ROW_NUMBER);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerWhereClauseParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerWhereClauseParser.java
index ea67383990b37..8ec78b8e26c5c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerWhereClauseParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/SQLServerWhereClauseParser.java
@@ -20,6 +20,7 @@
import com.google.common.base.Optional;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.clause.WhereClauseParser;
import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
@@ -47,4 +48,9 @@ protected boolean isRowNumberCondition(final List items, final Strin
}
return columnLabel.equalsIgnoreCase(rowNumberAlias.orNull());
}
+
+ @Override
+ protected Keyword[] getCustomizedOtherConditionOperators() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerInsertClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerInsertClauseParserFacade.java
index a1ed3d91c3644..fa891fbd6ff90 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerInsertClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerInsertClauseParserFacade.java
@@ -19,11 +19,11 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.parser.clause.InsertColumnsClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertDuplicateKeyUpdateClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertSetClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.InsertValuesClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractInsertClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerInsertDuplicateKeyUpdateClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerInsertIntoClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerInsertSetClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerInsertValuesClauseParser;
import io.shardingsphere.core.rule.ShardingRule;
/**
@@ -35,6 +35,7 @@ public final class SQLServerInsertClauseParserFacade extends AbstractInsertClaus
public SQLServerInsertClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(new SQLServerInsertIntoClauseParser(shardingRule, lexerEngine), new InsertColumnsClauseParser(shardingRule, lexerEngine),
- new InsertValuesClauseParser(shardingRule, lexerEngine), new InsertSetClauseParser(shardingRule, lexerEngine), new InsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
+ new SQLServerInsertValuesClauseParser(shardingRule, lexerEngine), new SQLServerInsertSetClauseParser(shardingRule, lexerEngine),
+ new SQLServerInsertDuplicateKeyUpdateClauseParser(shardingRule, lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerSelectClauseParserFacade.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerSelectClauseParserFacade.java
index 8744a721e3a5f..62250eec91218 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerSelectClauseParserFacade.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/clause/facade/SQLServerSelectClauseParserFacade.java
@@ -18,10 +18,10 @@
package io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.facade;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
-import io.shardingsphere.core.parsing.parser.clause.DistinctClauseParser;
-import io.shardingsphere.core.parsing.parser.clause.GroupByClauseParser;
import io.shardingsphere.core.parsing.parser.clause.HavingClauseParser;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractSelectClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerDistinctClauseParser;
+import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerGroupByClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerOrderByClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerSelectListClauseParser;
import io.shardingsphere.core.parsing.parser.dialect.sqlserver.clause.SQLServerSelectRestClauseParser;
@@ -37,8 +37,8 @@
public final class SQLServerSelectClauseParserFacade extends AbstractSelectClauseParserFacade {
public SQLServerSelectClauseParserFacade(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
- super(new DistinctClauseParser(lexerEngine), new SQLServerSelectListClauseParser(shardingRule, lexerEngine),
- new SQLServerTableReferencesClauseParser(shardingRule, lexerEngine), new SQLServerWhereClauseParser(lexerEngine), new GroupByClauseParser(lexerEngine),
+ super(new SQLServerDistinctClauseParser(lexerEngine), new SQLServerSelectListClauseParser(shardingRule, lexerEngine),
+ new SQLServerTableReferencesClauseParser(shardingRule, lexerEngine), new SQLServerWhereClauseParser(lexerEngine), new SQLServerGroupByClauseParser(lexerEngine),
new HavingClauseParser(lexerEngine), new SQLServerOrderByClauseParser(lexerEngine), new SQLServerSelectRestClauseParser(lexerEngine));
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerAlterTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerAlterTableParser.java
index 961b0d4227395..bbfdab6cf7005 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerAlterTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerAlterTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.sqlserver.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.alter.table.AbstractAlterTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class SQLServerAlterTableParser extends AbstractAlterTableParser {
public SQLServerAlterTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenAlterTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateIndexParser.java
index a6074dad18392..c929c72e5186a 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateIndexParser.java
@@ -44,4 +44,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateAndKeyword() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.FULLTEXT};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateTableParser.java
index d65ccdb351176..62225f364ff43 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerCreateTableParser.java
@@ -49,4 +49,9 @@ protected Keyword[] getSkippedKeywordsBetweenCreateTableAndTableName() {
protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndKeyword() {
return new Keyword[] {DefaultKeyword.UNIQUE, DefaultKeyword.FULLTEXT};
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBeforeTableConstraint() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropIndexParser.java
index 75c79fa735869..0cd17fa06a029 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropIndexParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.sqlserver.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.drop.index.AbstractDropIndexParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,14 @@ public final class SQLServerDropIndexParser extends AbstractDropIndexParser {
public SQLServerDropIndexParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropTableParser.java
index aa64aacfcf4ee..83bdcb432d47f 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerDropTableParser.java
@@ -35,6 +35,11 @@ public SQLServerDropTableParser(final ShardingRule shardingRule, final LexerEngi
super(shardingRule, lexerEngine);
}
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getSkippedKeywordsBetweenDropTableAndTableName() {
return new Keyword[] {DefaultKeyword.IF, DefaultKeyword.EXISTS};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerTruncateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerTruncateTableParser.java
index 8f4a1a93db1c8..800b01ccf83c9 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerTruncateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerTruncateTableParser.java
@@ -18,6 +18,7 @@
package io.shardingsphere.core.parsing.parser.dialect.sqlserver.sql;
import io.shardingsphere.core.parsing.lexer.LexerEngine;
+import io.shardingsphere.core.parsing.lexer.token.Keyword;
import io.shardingsphere.core.parsing.parser.sql.ddl.truncate.table.AbstractTruncateTableParser;
import io.shardingsphere.core.rule.ShardingRule;
@@ -32,4 +33,9 @@ public final class SQLServerTruncateTableParser extends AbstractTruncateTablePar
public SQLServerTruncateTableParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) {
super(shardingRule, lexerEngine);
}
+
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenTruncateTableAndTableName() {
+ return new Keyword[0];
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerUpdateParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerUpdateParser.java
index f73b7b6638dbf..6738705c9209b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerUpdateParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/dialect/sqlserver/sql/SQLServerUpdateParser.java
@@ -35,6 +35,11 @@ public SQLServerUpdateParser(final ShardingRule shardingRule, final LexerEngine
super(shardingRule, lexerEngine, new SQLServerUpdateClauseParserFacade(shardingRule, lexerEngine));
}
+ @Override
+ protected Keyword[] getSkippedKeywordsBetweenUpdateAndTable() {
+ return new Keyword[0];
+ }
+
@Override
protected Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable() {
return new Keyword[] {SQLServerKeyword.TOP};
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/AbstractSQLStatement.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/AbstractSQLStatement.java
index 54239daaed50b..82b1ce137984c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/AbstractSQLStatement.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/AbstractSQLStatement.java
@@ -56,7 +56,7 @@ public final SQLType getType() {
}
@Override
- public int increaseParametersIndex() {
+ public final int increaseParametersIndex() {
return ++parametersIndex;
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/alter/AlterUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/alter/AlterUserParser.java
index daa60d75728d3..9b43f3d7505a1 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/alter/AlterUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/alter/AlterUserParser.java
@@ -35,7 +35,7 @@ public class AlterUserParser implements SQLParser {
private final LexerEngine lexerEngine;
@Override
- public DCLStatement parse() {
+ public final DCLStatement parse() {
if (lexerEngine.skipIfEqual(DefaultKeyword.USER) || lexerEngine.skipIfEqual(DefaultKeyword.ROLE) || lexerEngine.skipIfEqual(DefaultKeyword.LOGIN)) {
return new DCLStatement();
} else {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/create/CreateUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/create/CreateUserParser.java
index 68d2da0ff4654..cb69b6ff9d3b3 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/create/CreateUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/create/CreateUserParser.java
@@ -35,7 +35,7 @@ public class CreateUserParser implements SQLParser {
private final LexerEngine lexerEngine;
@Override
- public DCLStatement parse() {
+ public final DCLStatement parse() {
if (lexerEngine.skipIfEqual(DefaultKeyword.USER) || lexerEngine.skipIfEqual(DefaultKeyword.ROLE) || lexerEngine.skipIfEqual(DefaultKeyword.LOGIN)) {
return new DCLStatement();
} else {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/deny/DenyUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/deny/DenyUserParser.java
index ff8aaf7f3a4d2..946c639ddbae5 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/deny/DenyUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/deny/DenyUserParser.java
@@ -29,7 +29,7 @@
*
* @author panjuan
*/
-public class DenyUserParser implements SQLParser {
+public final class DenyUserParser implements SQLParser {
private final LexerEngine lexerEngine;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/drop/DropUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/drop/DropUserParser.java
index c88dac0b775a0..d52c2672249d8 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/drop/DropUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/drop/DropUserParser.java
@@ -35,7 +35,7 @@ public class DropUserParser implements SQLParser {
private final LexerEngine lexerEngine;
@Override
- public DCLStatement parse() {
+ public final DCLStatement parse() {
if (lexerEngine.skipIfEqual(DefaultKeyword.USER) || lexerEngine.skipIfEqual(DefaultKeyword.ROLE) || lexerEngine.skipIfEqual(DefaultKeyword.LOGIN)) {
return new DCLStatement();
} else {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/grant/GrantUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/grant/GrantUserParser.java
index 7aca37b00e1d4..45c8cb6db9715 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/grant/GrantUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/grant/GrantUserParser.java
@@ -29,7 +29,7 @@
*
* @author panjuan
*/
-public class GrantUserParser implements SQLParser {
+public final class GrantUserParser implements SQLParser {
private final LexerEngine lexerEngine;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/rename/RenameUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/rename/RenameUserParser.java
index 82f9fda3b6a7e..126eafed4e36a 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/rename/RenameUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/rename/RenameUserParser.java
@@ -30,7 +30,7 @@
* @author panjuan
*/
@RequiredArgsConstructor
-public class RenameUserParser implements SQLParser {
+public final class RenameUserParser implements SQLParser {
private final LexerEngine lexerEngine;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/revoke/RevokeUserParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/revoke/RevokeUserParser.java
index 6afcf1bc107c8..85e83a326b5fb 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/revoke/RevokeUserParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dcl/revoke/RevokeUserParser.java
@@ -29,7 +29,7 @@
*
* @author panjuan
*/
-public class RevokeUserParser implements SQLParser {
+public final class RevokeUserParser implements SQLParser {
private final LexerEngine lexerEngine;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/DDLStatement.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/DDLStatement.java
index 5e04f42432725..a96c929ecdb47 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/DDLStatement.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/DDLStatement.java
@@ -33,7 +33,7 @@
* @author zhangliang
*/
@ToString(callSuper = true)
-public final class DDLStatement extends AbstractSQLStatement {
+public class DDLStatement extends AbstractSQLStatement {
private static final Collection PRIMARY_STATEMENT_PREFIX = Arrays.asList(DefaultKeyword.CREATE, DefaultKeyword.ALTER, DefaultKeyword.DROP, DefaultKeyword.TRUNCATE);
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/alter/table/AbstractAlterTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/alter/table/AbstractAlterTableParser.java
index d0695e3068f89..13bac516e209c 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/alter/table/AbstractAlterTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/alter/table/AbstractAlterTableParser.java
@@ -49,7 +49,7 @@ public AbstractAlterTableParser(final ShardingRule shardingRule, final LexerEngi
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.unsupportedIfNotSkip(DefaultKeyword.TABLE);
lexerEngine.skipAll(getSkippedKeywordsBetweenAlterTableAndTableName());
DDLStatement result = new DDLStatement();
@@ -57,7 +57,5 @@ public DDLStatement parse() {
return result;
}
- protected Keyword[] getSkippedKeywordsBetweenAlterTableAndTableName() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenAlterTableAndTableName();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/index/AbstractCreateIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/index/AbstractCreateIndexParser.java
index ffc8d80499718..8282df1aa7e93 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/index/AbstractCreateIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/index/AbstractCreateIndexParser.java
@@ -52,7 +52,7 @@ public AbstractCreateIndexParser(final ShardingRule shardingRule, final LexerEng
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.skipAll(getSkippedKeywordsBetweenCreateIndexAndKeyword());
lexerEngine.skipAll(getSkippedKeywordsBetweenCreateAndKeyword());
DDLStatement result = new DDLStatement();
@@ -70,9 +70,7 @@ public DDLStatement parse() {
protected abstract Keyword[] getSkippedKeywordsBetweenCreateAndKeyword();
- protected Keyword[] getSkippedKeywordsBetweenCreateIndexAndIndexName() {
- return new Keyword[] {};
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenCreateIndexAndIndexName();
private void parseIndex(final DDLStatement ddlStatement) {
Token currentToken = lexerEngine.getCurrentToken();
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/AbstractCreateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/AbstractCreateTableParser.java
index f9e5d76ae9d6a..ea32cf684a4a8 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/AbstractCreateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/AbstractCreateTableParser.java
@@ -20,6 +20,7 @@
import io.shardingsphere.core.parsing.lexer.LexerEngine;
import io.shardingsphere.core.parsing.lexer.token.DefaultKeyword;
import io.shardingsphere.core.parsing.lexer.token.Keyword;
+import io.shardingsphere.core.parsing.lexer.token.Symbol;
import io.shardingsphere.core.parsing.parser.clause.TableReferencesClauseParser;
import io.shardingsphere.core.parsing.parser.exception.SQLParsingException;
import io.shardingsphere.core.parsing.parser.sql.SQLParser;
@@ -28,6 +29,9 @@
import lombok.AccessLevel;
import lombok.Getter;
+import java.util.Collection;
+import java.util.LinkedList;
+
/**
* Create parser.
*
@@ -50,16 +54,21 @@ public AbstractCreateTableParser(final ShardingRule shardingRule, final LexerEng
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.skipAll(getSkippedKeywordsBetweenCreateIndexAndKeyword());
lexerEngine.skipAll(getSkippedKeywordsBetweenCreateAndKeyword());
- DDLStatement result = new DDLStatement();
+ CreateTableStatement result = new CreateTableStatement();
if (lexerEngine.skipIfEqual(DefaultKeyword.TABLE)) {
lexerEngine.skipAll(getSkippedKeywordsBetweenCreateTableAndTableName());
} else {
throw new SQLParsingException("Can't support other CREATE grammar unless CREATE TABLE.");
}
tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
+ lexerEngine.accept(Symbol.LEFT_PAREN);
+ do {
+ parseCreateDefinition(result);
+ } while (lexerEngine.skipIfEqual(Symbol.COMMA));
+ lexerEngine.accept(Symbol.RIGHT_PAREN);
return result;
}
@@ -68,4 +77,53 @@ public DDLStatement parse() {
protected abstract Keyword[] getSkippedKeywordsBetweenCreateAndKeyword();
protected abstract Keyword[] getSkippedKeywordsBetweenCreateTableAndTableName();
+
+ private void parseCreateDefinition(final CreateTableStatement statement) {
+ String columnName = parseColumnName(statement);
+ parseColumnDefinition(columnName, statement);
+ }
+
+ private String parseColumnName(final CreateTableStatement statement) {
+ String result = lexerEngine.getCurrentToken().getLiterals();
+ statement.getColumnNames().add(result);
+ return result;
+ }
+
+ private void parseColumnDefinition(final String columnName, final CreateTableStatement statement) {
+ parseDataType(statement);
+ lexerEngine.skipUntil(DefaultKeyword.PRIMARY, Symbol.COMMA, Symbol.RIGHT_PAREN);
+ if (lexerEngine.skipIfEqual(DefaultKeyword.PRIMARY)) {
+ lexerEngine.accept(DefaultKeyword.KEY);
+ lexerEngine.skipAll(getSkippedKeywordsBeforeTableConstraint());
+ if (lexerEngine.skipIfEqual(Symbol.LEFT_PAREN)) {
+ parseTableConstraint(statement);
+ } else {
+ parseInlineConstraint(columnName, statement);
+ }
+ }
+ }
+
+ private void parseDataType(final CreateTableStatement statement) {
+ lexerEngine.nextToken();
+ statement.getColumnTypes().add(lexerEngine.getCurrentToken().getLiterals());
+ lexerEngine.skipParentheses(statement);
+ }
+
+ protected abstract Keyword[] getSkippedKeywordsBeforeTableConstraint();
+
+ private void parseTableConstraint(final CreateTableStatement statement) {
+ Collection columnNames = new LinkedList<>();
+ do {
+ columnNames.add(lexerEngine.getCurrentToken().getLiterals());
+ lexerEngine.nextToken();
+ lexerEngine.skipParentheses(statement);
+ lexerEngine.skipUntil(Symbol.COMMA, Symbol.RIGHT_PAREN);
+ } while (lexerEngine.skipIfEqual(Symbol.COMMA));
+ statement.getPrimaryKeyColumns().addAll(columnNames);
+ }
+
+ private void parseInlineConstraint(final String columnName, final CreateTableStatement statement) {
+ statement.getPrimaryKeyColumns().add(columnName);
+ lexerEngine.skipUntil(Symbol.COMMA, Symbol.RIGHT_PAREN);
+ }
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/CreateTableStatement.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/CreateTableStatement.java
new file mode 100644
index 0000000000000..d4740a5769983
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/create/table/CreateTableStatement.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.sql.ddl.create.table;
+
+import io.shardingsphere.core.parsing.parser.sql.ddl.DDLStatement;
+import lombok.Getter;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Create table statement.
+ *
+ * @author zhangliang
+ */
+@Getter
+public final class CreateTableStatement extends DDLStatement {
+
+ private final List columnNames = new LinkedList<>();
+
+ private final List columnTypes = new LinkedList<>();
+
+ private final List primaryKeyColumns = new LinkedList<>();
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/index/AbstractDropIndexParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/index/AbstractDropIndexParser.java
index 12fcab6c58b6a..cad59726011e8 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/index/AbstractDropIndexParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/index/AbstractDropIndexParser.java
@@ -52,7 +52,7 @@ public AbstractDropIndexParser(final ShardingRule shardingRule, final LexerEngin
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.skipAll(getSkippedKeywordsBetweenDropAndTable());
DDLStatement result = new DDLStatement();
if (lexerEngine.skipIfEqual(DefaultKeyword.INDEX)) {
@@ -64,13 +64,9 @@ public DDLStatement parse() {
return result;
}
- protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenDropAndTable();
- protected Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName() {
- return new Keyword[] {};
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenDropIndexAndIndexName();
private void parseIndex(final DDLStatement ddlStatement) {
Token currentToken = lexerEngine.getCurrentToken();
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/AbstractDropTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/AbstractDropTableParser.java
index f7518b8f013ba..bcd8d169153f6 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/AbstractDropTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/AbstractDropTableParser.java
@@ -50,9 +50,9 @@ public AbstractDropTableParser(final ShardingRule shardingRule, final LexerEngin
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.skipAll(getSkippedKeywordsBetweenDropAndTable());
- DDLStatement result = new DDLStatement();
+ DropTableStatement result = new DropTableStatement();
if (lexerEngine.skipIfEqual(DefaultKeyword.TABLE)) {
lexerEngine.skipAll(getSkippedKeywordsBetweenDropTableAndTableName());
tableReferencesClauseParser.parseSingleTableWithoutAlias(result);
@@ -62,9 +62,7 @@ public DDLStatement parse() {
return result;
}
- protected Keyword[] getSkippedKeywordsBetweenDropAndTable() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenDropAndTable();
protected abstract Keyword[] getSkippedKeywordsBetweenDropTableAndTableName();
}
diff --git a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/constant/AuthType.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/DropTableStatement.java
similarity index 61%
rename from sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/constant/AuthType.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/DropTableStatement.java
index 3d64dbe50c6f0..10fbdea41da21 100644
--- a/sharding-proxy/src/main/java/io/shardingsphere/proxy/backend/constant/AuthType.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/drop/table/DropTableStatement.java
@@ -15,36 +15,14 @@
*
*/
-package io.shardingsphere.proxy.backend.constant;
+package io.shardingsphere.core.parsing.parser.sql.ddl.drop.table;
+
+import io.shardingsphere.core.parsing.parser.sql.ddl.DDLStatement;
/**
- * Auth Type.
- *
- * @author linjiaqi
+ * Drop table statement.
+ *
+ * @author zhangliang
*/
-public enum AuthType {
-
- /**
- * Database UN_AUTH.
- *
- */
- UN_AUTH,
-
- /**
- * Database AUTHING.
- *
- */
- AUTHING,
-
- /**
- * Database AUTH_SUCCESS.
- *
- */
- AUTH_SUCCESS,
-
- /**
- * Database AUTH_FAILED.
- *
- */
- AUTH_FAILED
+public final class DropTableStatement extends DDLStatement {
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/truncate/table/AbstractTruncateTableParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/truncate/table/AbstractTruncateTableParser.java
index 4c1bf99d417b6..d3c86a7117c7b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/truncate/table/AbstractTruncateTableParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/ddl/truncate/table/AbstractTruncateTableParser.java
@@ -49,7 +49,7 @@ public AbstractTruncateTableParser(final ShardingRule shardingRule, final LexerE
}
@Override
- public DDLStatement parse() {
+ public final DDLStatement parse() {
lexerEngine.skipIfEqual(DefaultKeyword.TABLE);
lexerEngine.skipAll(getSkippedKeywordsBetweenTruncateTableAndTableName());
DDLStatement result = new DDLStatement();
@@ -57,7 +57,5 @@ public DDLStatement parse() {
return result;
}
- protected Keyword[] getSkippedKeywordsBetweenTruncateTableAndTableName() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenTruncateTableAndTableName();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/delete/AbstractDeleteParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/delete/AbstractDeleteParser.java
index 34dc5a9853ff6..68ec76580b680 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/delete/AbstractDeleteParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/delete/AbstractDeleteParser.java
@@ -44,7 +44,7 @@ public abstract class AbstractDeleteParser implements SQLParser {
private final AbstractDeleteClauseParserFacade deleteClauseParserFacade;
@Override
- public DMLStatement parse() {
+ public final DMLStatement parse() {
lexerEngine.nextToken();
lexerEngine.skipAll(getSkippedKeywordsBetweenDeleteAndTable());
lexerEngine.unsupportedIfEqual(getUnsupportedKeywordsBetweenDeleteAndTable());
@@ -57,7 +57,5 @@ public DMLStatement parse() {
protected abstract Keyword[] getSkippedKeywordsBetweenDeleteAndTable();
- protected Keyword[] getUnsupportedKeywordsBetweenDeleteAndTable() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getUnsupportedKeywordsBetweenDeleteAndTable();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/update/AbstractUpdateParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/update/AbstractUpdateParser.java
index 8badbf2c42a08..b0a6c270ccb3d 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/update/AbstractUpdateParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dml/update/AbstractUpdateParser.java
@@ -44,7 +44,7 @@ public abstract class AbstractUpdateParser implements SQLParser {
private final AbstractUpdateClauseParserFacade updateClauseParserFacade;
@Override
- public DMLStatement parse() {
+ public final DMLStatement parse() {
lexerEngine.nextToken();
lexerEngine.skipAll(getSkippedKeywordsBetweenUpdateAndTable());
lexerEngine.unsupportedIfEqual(getUnsupportedKeywordsBetweenUpdateAndTable());
@@ -56,11 +56,7 @@ public DMLStatement parse() {
return result;
}
- protected Keyword[] getSkippedKeywordsBetweenUpdateAndTable() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getSkippedKeywordsBetweenUpdateAndTable();
- protected Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable() {
- return new Keyword[0];
- }
+ protected abstract Keyword[] getUnsupportedKeywordsBetweenUpdateAndTable();
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dql/select/AbstractSelectParser.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dql/select/AbstractSelectParser.java
index 4ae7b6d77716b..4ae74504dd468 100755
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dql/select/AbstractSelectParser.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/parser/sql/dql/select/AbstractSelectParser.java
@@ -26,6 +26,7 @@
import io.shardingsphere.core.parsing.lexer.token.DefaultKeyword;
import io.shardingsphere.core.parsing.lexer.token.Symbol;
import io.shardingsphere.core.parsing.parser.clause.facade.AbstractSelectClauseParserFacade;
+import io.shardingsphere.core.parsing.parser.constant.DerivedColumn;
import io.shardingsphere.core.parsing.parser.context.OrderItem;
import io.shardingsphere.core.parsing.parser.context.selectitem.AggregationSelectItem;
import io.shardingsphere.core.parsing.parser.context.selectitem.SelectItem;
@@ -51,14 +52,6 @@
@Getter(AccessLevel.PROTECTED)
public abstract class AbstractSelectParser implements SQLParser {
- private static final String DERIVED_COUNT_ALIAS = "AVG_DERIVED_COUNT_%s";
-
- private static final String DERIVED_SUM_ALIAS = "AVG_DERIVED_SUM_%s";
-
- private static final String ORDER_BY_DERIVED_ALIAS = "ORDER_BY_DERIVED_%s";
-
- private static final String GROUP_BY_DERIVED_ALIAS = "GROUP_BY_DERIVED_%s";
-
private final ShardingRule shardingRule;
private final LexerEngine lexerEngine;
@@ -138,8 +131,8 @@ protected final void parseSelectRest() {
private void appendDerivedColumns(final SelectStatement selectStatement) {
ItemsToken itemsToken = new ItemsToken(selectStatement.getSelectListLastPosition());
appendAvgDerivedColumns(itemsToken, selectStatement);
- appendDerivedOrderColumns(itemsToken, selectStatement.getOrderByItems(), ORDER_BY_DERIVED_ALIAS, selectStatement);
- appendDerivedOrderColumns(itemsToken, selectStatement.getGroupByItems(), GROUP_BY_DERIVED_ALIAS, selectStatement);
+ appendDerivedOrderColumns(itemsToken, selectStatement.getOrderByItems(), selectStatement);
+ appendDerivedGroupColumns(itemsToken, selectStatement.getGroupByItems(), selectStatement);
if (!itemsToken.getItems().isEmpty()) {
selectStatement.getSqlTokens().add(itemsToken);
}
@@ -152,9 +145,9 @@ private void appendAvgDerivedColumns(final ItemsToken itemsToken, final SelectSt
continue;
}
AggregationSelectItem avgItem = (AggregationSelectItem) each;
- String countAlias = String.format(DERIVED_COUNT_ALIAS, derivedColumnOffset);
+ String countAlias = DerivedColumn.AVG_COUNT_ALIAS.getDerivedColumnAlias(derivedColumnOffset);
AggregationSelectItem countItem = new AggregationSelectItem(AggregationType.COUNT, avgItem.getInnerExpression(), Optional.of(countAlias));
- String sumAlias = String.format(DERIVED_SUM_ALIAS, derivedColumnOffset);
+ String sumAlias = DerivedColumn.AVG_SUM_ALIAS.getDerivedColumnAlias(derivedColumnOffset);
AggregationSelectItem sumItem = new AggregationSelectItem(AggregationType.SUM, avgItem.getInnerExpression(), Optional.of(sumAlias));
avgItem.getDerivedAggregationSelectItems().add(countItem);
avgItem.getDerivedAggregationSelectItems().add(sumItem);
@@ -165,11 +158,22 @@ private void appendAvgDerivedColumns(final ItemsToken itemsToken, final SelectSt
}
}
- private void appendDerivedOrderColumns(final ItemsToken itemsToken, final List orderItems, final String aliasPattern, final SelectStatement selectStatement) {
+ private void appendDerivedOrderColumns(final ItemsToken itemsToken, final List orderItems, final SelectStatement selectStatement) {
+ int derivedColumnOffset = 0;
+ for (OrderItem each : orderItems) {
+ if (!containsItem(selectStatement, each)) {
+ String alias = DerivedColumn.ORDER_BY_ALIAS.getDerivedColumnAlias(derivedColumnOffset++);
+ each.setAlias(Optional.of(alias));
+ itemsToken.getItems().add(each.getQualifiedName().get() + " AS " + alias + " ");
+ }
+ }
+ }
+
+ private void appendDerivedGroupColumns(final ItemsToken itemsToken, final List orderItems, final SelectStatement selectStatement) {
int derivedColumnOffset = 0;
for (OrderItem each : orderItems) {
if (!containsItem(selectStatement, each)) {
- String alias = String.format(aliasPattern, derivedColumnOffset++);
+ String alias = DerivedColumn.GROUP_BY_ALIAS.getDerivedColumnAlias(derivedColumnOffset++);
each.setAlias(Optional.of(alias));
itemsToken.getItems().add(each.getQualifiedName().get() + " AS " + alias + " ");
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rewrite/SQLBuilder.java b/sharding-core/src/main/java/io/shardingsphere/core/rewrite/SQLBuilder.java
index ef1709b8767a7..a2c24c05bb92b 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rewrite/SQLBuilder.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rewrite/SQLBuilder.java
@@ -131,7 +131,7 @@ private void appendTablePlaceholder(final TablePlaceholder tablePlaceholder, fin
private void appendSchemaPlaceholder(final ShardingRule shardingRule, final ShardingDataSourceMetaData shardingDataSourceMetaData,
final String actualTableName, final StringBuilder stringBuilder) {
- stringBuilder.append(shardingDataSourceMetaData.getActualSchemaName(shardingRule.getActualDataSourceNameByActualTableName(actualTableName)));
+ stringBuilder.append(shardingDataSourceMetaData.getActualDataSourceMetaData(shardingRule.getActualDataSourceNameByActualTableName(actualTableName)).getSchemeName());
}
private void appendIndexPlaceholder(final IndexPlaceholder indexPlaceholder, final String actualTableName, final StringBuilder stringBuilder) {
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
index 2116015adad56..1114f15583b01 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/ShardingRule.java
@@ -121,23 +121,6 @@ public Optional tryFindTableRuleByActualTable(final String actualTabl
return Optional.absent();
}
- /**
- * Find table rule though actual table name.
- *
- * @param actualTableName actual table name
- * @return table rule
- */
- public TableRule getTableRuleByActualTableName(final String actualTableName) {
- Optional tableRule = tryFindTableRuleByActualTable(actualTableName.toLowerCase());
- if (tableRule.isPresent()) {
- return tableRule.get();
- }
- if (!Strings.isNullOrEmpty(shardingDataSourceNames.getDefaultDataSourceName())) {
- return createTableRuleWithDefaultDataSource(actualTableName.toLowerCase());
- }
- throw new ShardingConfigurationException("Cannot find table rule and default data source with actual table: '%s'", actualTableName);
- }
-
/**
* Find table rule though logic table name.
*
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java b/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
index 9e5eb49ccd60f..f2cd56f4b9cac 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/rule/TableRule.java
@@ -28,9 +28,11 @@
import lombok.ToString;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
/**
* Table rule configuration.
@@ -92,6 +94,23 @@ private List generateDataNodes(final List actualDataNodes, fin
return result;
}
+ /**
+ * Get data node groups.
+ *
+ * @return data node groups, key is data source name, value is tables belong to this data source
+ */
+ public Map> getDataNodeGroups() {
+ Map> result = new LinkedHashMap<>(actualDataNodes.size(), 1);
+ for (DataNode each : actualDataNodes) {
+ String dataSourceName = each.getDataSourceName();
+ if (!result.containsKey(dataSourceName)) {
+ result.put(dataSourceName, new LinkedList());
+ }
+ result.get(dataSourceName).add(each.getTableName());
+ }
+ return result;
+ }
+
/**
* Get actual data source names.
*
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/transaction/spi/TransactionEventHolder.java b/sharding-core/src/main/java/io/shardingsphere/core/transaction/spi/TransactionEventHolder.java
deleted file mode 100644
index 098d89812a029..0000000000000
--- a/sharding-core/src/main/java/io/shardingsphere/core/transaction/spi/TransactionEventHolder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2016-2018 shardingsphere.io.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package io.shardingsphere.core.transaction.spi;
-
-import io.shardingsphere.core.transaction.event.TransactionEvent;
-
-/**
- * Hold transaction event for current thread.
- *
- * @author zhaojun
- */
-public class TransactionEventHolder {
-
- private static Class extends TransactionEvent> transactionEvent;
-
- /**
- * Set transactionEvent.
- *
- * @param clazz class type of TransactionEvent
- */
- public static synchronized void set(final Class extends TransactionEvent> clazz) {
- transactionEvent = clazz;
- }
-
- /**
- * Get transactionEvent class type.
- *
- * @return transactionEvent class type
- */
- public static Class extends TransactionEvent> get() {
- return transactionEvent;
- }
-}
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/util/EventBusInstance.java b/sharding-core/src/main/java/io/shardingsphere/core/util/EventBusInstance.java
similarity index 100%
rename from sharding-jdbc/src/main/java/io/shardingsphere/core/util/EventBusInstance.java
rename to sharding-core/src/main/java/io/shardingsphere/core/util/EventBusInstance.java
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/yaml/sharding/YamlTableRuleConfiguration.java b/sharding-core/src/main/java/io/shardingsphere/core/yaml/sharding/YamlTableRuleConfiguration.java
index f3da6b79f472a..301574e757fa1 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/yaml/sharding/YamlTableRuleConfiguration.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/yaml/sharding/YamlTableRuleConfiguration.java
@@ -58,7 +58,6 @@ public YamlTableRuleConfiguration(final TableRuleConfiguration tableRuleConfigur
keyGeneratorColumnName = tableRuleConfiguration.getKeyGeneratorColumnName();
keyGeneratorClassName = null == tableRuleConfiguration.getKeyGenerator()
? null : tableRuleConfiguration.getKeyGenerator().getClass().getName();
- logicTable = tableRuleConfiguration.getLogicTable();
}
/**
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/AllTests.java b/sharding-core/src/test/java/io/shardingsphere/core/AllTests.java
index aef122d001746..09afb23ad2356 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/AllTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/AllTests.java
@@ -46,5 +46,5 @@
AllHintTests.class,
AllYamlTests.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/api/AllApiTests.java b/sharding-core/src/test/java/io/shardingsphere/core/api/AllApiTests.java
index 207c5272ed9ef..2fdd3e97ceab9 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/api/AllApiTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/api/AllApiTests.java
@@ -34,5 +34,5 @@
RandomMasterSlaveLoadBalanceAlgorithmTest.class,
HintManagerTest.class
})
-public class AllApiTests {
+public final class AllApiTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/constant/AllConstantsTests.java b/sharding-core/src/test/java/io/shardingsphere/core/constant/AllConstantsTests.java
index 5ed4ac0c68980..62223d688932e 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/constant/AllConstantsTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/constant/AllConstantsTests.java
@@ -26,5 +26,5 @@
ShardingPropertiesConstantTest.class,
ShardingPropertiesTest.class
})
-public class AllConstantsTests {
+public final class AllConstantsTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/fixture/OrderDatabaseHintShardingAlgorithm.java b/sharding-core/src/test/java/io/shardingsphere/core/fixture/OrderDatabaseHintShardingAlgorithm.java
index 8777ccf5a5d36..a6e212ad2910d 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/fixture/OrderDatabaseHintShardingAlgorithm.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/fixture/OrderDatabaseHintShardingAlgorithm.java
@@ -24,7 +24,7 @@
import java.util.Collection;
import java.util.Collections;
-public class OrderDatabaseHintShardingAlgorithm implements HintShardingAlgorithm {
+public final class OrderDatabaseHintShardingAlgorithm implements HintShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final ShardingValue shardingValue) {
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/hint/AllHintTests.java b/sharding-core/src/test/java/io/shardingsphere/core/hint/AllHintTests.java
index 26a6f9e885bfb..043b2dc4e4827 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/hint/AllHintTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/hint/AllHintTests.java
@@ -22,5 +22,5 @@
@RunWith(Suite.class)
@Suite.SuiteClasses(HintManagerHolderTest.class)
-public class AllHintTests {
+public final class AllHintTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/keygen/AllKeygenTests.java b/sharding-core/src/test/java/io/shardingsphere/core/keygen/AllKeygenTests.java
index 9646615f7f259..9469fae09217b 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/keygen/AllKeygenTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/keygen/AllKeygenTests.java
@@ -25,5 +25,5 @@
DefaultKeyGeneratorTest.class,
KeyGeneratorFactoryTest.class
})
-public class AllKeygenTests {
+public final class AllKeygenTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/keygen/KeyGeneratorFactoryTest.java b/sharding-core/src/test/java/io/shardingsphere/core/keygen/KeyGeneratorFactoryTest.java
index a38b1376d3c6d..8bb7eceb177fd 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/keygen/KeyGeneratorFactoryTest.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/keygen/KeyGeneratorFactoryTest.java
@@ -43,7 +43,7 @@ public void assertCreateKeyGeneratorFailureWithIllegalAccess() {
}
@RequiredArgsConstructor
- public static class InstantiationKeyGenerator implements KeyGenerator {
+ public static final class InstantiationKeyGenerator implements KeyGenerator {
private final int field;
@@ -54,7 +54,7 @@ public Number generateKey() {
}
@NoArgsConstructor(access = AccessLevel.PRIVATE)
- public static class IllegalAccessKeyGenerator implements KeyGenerator {
+ public static final class IllegalAccessKeyGenerator implements KeyGenerator {
@Override
public Number generateKey() {
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/keygen/fixture/IncrementKeyGenerator.java b/sharding-core/src/test/java/io/shardingsphere/core/keygen/fixture/IncrementKeyGenerator.java
index e871ceeed7228..225ddfb7aedfc 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/keygen/fixture/IncrementKeyGenerator.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/keygen/fixture/IncrementKeyGenerator.java
@@ -21,7 +21,7 @@
import java.util.concurrent.atomic.AtomicInteger;
-public class IncrementKeyGenerator implements KeyGenerator {
+public final class IncrementKeyGenerator implements KeyGenerator {
private final AtomicInteger count = new AtomicInteger();
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/merger/AllMergerTests.java b/sharding-core/src/test/java/io/shardingsphere/core/merger/AllMergerTests.java
index 8a39f0f08effa..6363db9d401c3 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/merger/AllMergerTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/merger/AllMergerTests.java
@@ -68,5 +68,5 @@
ShowTablesMergedResultTest.class,
MergeEngineFactoryTest.class
})
-public class AllMergerTests {
+public final class AllMergerTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResultTest.java b/sharding-core/src/test/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResultTest.java
index 416e58b473811..2e3ef1a882546 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResultTest.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/merger/dal/show/ShowCreateTableMergedResultTest.java
@@ -24,6 +24,9 @@
import io.shardingsphere.core.api.config.strategy.ComplexShardingStrategyConfiguration;
import io.shardingsphere.core.merger.QueryResult;
import io.shardingsphere.core.merger.fixture.TestQueryResult;
+import io.shardingsphere.core.metadata.table.ColumnMetaData;
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
+import io.shardingsphere.core.metadata.table.TableMetaData;
import io.shardingsphere.core.rule.ShardingRule;
import org.junit.Before;
import org.junit.Test;
@@ -32,10 +35,13 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,6 +53,8 @@ public final class ShowCreateTableMergedResultTest {
private ResultSet resultSet;
+ private ShardingTableMetaData shardingTableMetaData;
+
@Before
public void setUp() throws SQLException {
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration();
@@ -56,7 +64,9 @@ public void setUp() throws SQLException {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRule = new ShardingRule(shardingRuleConfig, Lists.newArrayList("ds"));
-
+ Map tableMetaDataMap = new HashMap<>(1, 1);
+ tableMetaDataMap.put("table", new TableMetaData(Collections.emptyList()));
+ shardingTableMetaData = new ShardingTableMetaData(tableMetaDataMap);
resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
@@ -73,7 +83,7 @@ public void setUp() throws SQLException {
@Test
public void assertNextForEmptyQueryResult() throws SQLException {
- ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, new ArrayList());
+ ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, new ArrayList(), shardingTableMetaData);
assertFalse(showCreateTableMergedResult.next());
}
@@ -88,7 +98,7 @@ public void assertNextForTableRuleIsPresentForBackQuotes() throws SQLException {
+ " `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n"
+ " PRIMARY KEY (`id`)\n"
+ ") ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8 COLLATE=utf8_bin");
- ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, queryResults);
+ ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, queryResults, shardingTableMetaData);
assertTrue(showCreateTableMergedResult.next());
}
@@ -103,7 +113,7 @@ public void assertNextForTableRuleIsPresentForNoBackQuotes() throws SQLException
+ " `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n"
+ " PRIMARY KEY (`id`)\n"
+ ") ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8 COLLATE=utf8_bin");
- ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, queryResults);
+ ShowCreateTableMergedResult showCreateTableMergedResult = new ShowCreateTableMergedResult(shardingRule, queryResults, shardingTableMetaData);
assertTrue(showCreateTableMergedResult.next());
}
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/merger/dql/groupby/aggregation/AllAggregationTests.java b/sharding-core/src/test/java/io/shardingsphere/core/merger/dql/groupby/aggregation/AllAggregationTests.java
index 64735b0f888dc..c54076dd7c8d7 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/merger/dql/groupby/aggregation/AllAggregationTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/merger/dql/groupby/aggregation/AllAggregationTests.java
@@ -27,5 +27,5 @@
AccumulationAggregationUnitTest.class,
AverageAggregationUnitTest.class
})
-public class AllAggregationTests {
+public final class AllAggregationTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/metadata/AllMetaDataTests.java b/sharding-core/src/test/java/io/shardingsphere/core/metadata/AllMetaDataTests.java
index 7b93141885c92..a5dc7d0435774 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/metadata/AllMetaDataTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/metadata/AllMetaDataTests.java
@@ -37,5 +37,5 @@
DataSourceMetaDataFactoryTest.class,
ShardingDataSourceMetaDataTest.class
})
-public class AllMetaDataTests {
+public final class AllMetaDataTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaDataTest.java b/sharding-core/src/test/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaDataTest.java
index b1258cebf35c2..0cdec1e94084d 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaDataTest.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/metadata/datasource/ShardingDataSourceMetaDataTest.java
@@ -93,11 +93,11 @@ public void assertGetAllInstanceDataSourceNamesForShardingRule() {
@Test
public void assertGetActualSchemaNameForMasterSlaveShardingRule() {
- assertEquals(masterSlaveShardingDataSourceMetaData.getActualSchemaName("ms_0"), "master_0");
+ assertEquals(masterSlaveShardingDataSourceMetaData.getActualDataSourceMetaData("ms_0").getSchemeName(), "master_0");
}
@Test
public void assertGetActualSchemaNameForShardingRule() {
- assertEquals(shardingDataSourceMetaData.getActualSchemaName("ds_0"), "db_0");
+ assertEquals(shardingDataSourceMetaData.getActualDataSourceMetaData("ds_0").getSchemeName(), "db_0");
}
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/optimizer/AllOptimizerTests.java b/sharding-core/src/test/java/io/shardingsphere/core/optimizer/AllOptimizerTests.java
index f1028e9331c61..add2f259e4bee 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/optimizer/AllOptimizerTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/optimizer/AllOptimizerTests.java
@@ -25,5 +25,5 @@
InsertOptimizeEngineTest.class,
QueryOptimizeEngineTest.class
})
-public class AllOptimizerTests {
+public final class AllOptimizerTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/AllParsingTests.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/AllParsingTests.java
index ed872f102741d..1aef878b517dd 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/AllParsingTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/AllParsingTests.java
@@ -19,6 +19,7 @@
import io.shardingsphere.core.parsing.integrate.AllParsingIntegrateTests;
import io.shardingsphere.core.parsing.lexer.AllLexerTests;
+import io.shardingsphere.core.parsing.parser.constant.DerivedColumnTest;
import io.shardingsphere.core.parsing.parser.context.OrderItemTest;
import io.shardingsphere.core.parsing.parser.sql.AllSQLTests;
import io.shardingsphere.core.parsing.parser.sql.AllStatementParserTests;
@@ -31,8 +32,9 @@
AllStatementParserTests.class,
AllSQLTests.class,
SQLJudgeEngineTest.class,
- OrderItemTest.class,
+ OrderItemTest.class,
+ DerivedColumnTest.class,
AllParsingIntegrateTests.class
})
-public class AllParsingTests {
+public final class AllParsingTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/AllParsingIntegrateTests.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/AllParsingIntegrateTests.java
index 7008dabba4cad..ab777b782f48c 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/AllParsingIntegrateTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/AllParsingIntegrateTests.java
@@ -27,5 +27,5 @@
IntegrateSupportedSQLParsingTest.class,
IntegrateUnsupportedSQLParsingTest.class
})
-public class AllParsingIntegrateTests {
+public final class AllParsingIntegrateTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/SQLStatementAssert.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/SQLStatementAssert.java
index cb1e608c8a897..23d508d030d9d 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/SQLStatementAssert.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/SQLStatementAssert.java
@@ -22,11 +22,13 @@
import io.shardingsphere.core.parsing.integrate.asserts.index.IndexAssert;
import io.shardingsphere.core.parsing.integrate.asserts.item.ItemAssert;
import io.shardingsphere.core.parsing.integrate.asserts.limit.LimitAssert;
+import io.shardingsphere.core.parsing.integrate.asserts.meta.TableMetaDataAssert;
import io.shardingsphere.core.parsing.integrate.asserts.orderby.OrderByAssert;
import io.shardingsphere.core.parsing.integrate.asserts.table.TableAssert;
import io.shardingsphere.core.parsing.integrate.asserts.token.TokenAssert;
import io.shardingsphere.core.parsing.integrate.jaxb.root.ParserResult;
import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
+import io.shardingsphere.core.parsing.parser.sql.ddl.create.table.CreateTableStatement;
import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingsphere.test.sql.SQLCaseType;
@@ -57,6 +59,8 @@ public final class SQLStatementAssert {
private final LimitAssert limitAssert;
+ private final TableMetaDataAssert metaAssert;
+
public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, final SQLCaseType sqlCaseType) {
SQLStatementAssertMessage assertMessage = new SQLStatementAssertMessage(sqlCaseId, sqlCaseType);
this.actual = actual;
@@ -70,6 +74,7 @@ public SQLStatementAssert(final SQLStatement actual, final String sqlCaseId, fin
groupByAssert = new GroupByAssert(assertMessage);
orderByAssert = new OrderByAssert(assertMessage);
limitAssert = new LimitAssert(sqlCaseType, assertMessage);
+ metaAssert = new TableMetaDataAssert(assertMessage);
}
/**
@@ -83,6 +88,9 @@ public void assertSQLStatement() {
if (actual instanceof SelectStatement) {
assertSelectStatement((SelectStatement) actual);
}
+ if (actual instanceof CreateTableStatement) {
+ assertCreateTableStatement((CreateTableStatement) actual);
+ }
}
private void assertSelectStatement(final SelectStatement actual) {
@@ -91,4 +99,8 @@ private void assertSelectStatement(final SelectStatement actual) {
orderByAssert.assertOrderByItems(actual.getOrderByItems(), expected.getOrderByColumns());
limitAssert.assertLimit(actual.getLimit(), expected.getLimit());
}
+
+ private void assertCreateTableStatement(final CreateTableStatement actual) {
+ metaAssert.assertMeta(actual.getColumnNames(), actual.getColumnTypes(), actual.getPrimaryKeyColumns(), expected.getMeta());
+ }
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/meta/TableMetaDataAssert.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/meta/TableMetaDataAssert.java
new file mode 100644
index 0000000000000..27e618209506b
--- /dev/null
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/asserts/meta/TableMetaDataAssert.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.integrate.asserts.meta;
+
+import com.google.common.base.Joiner;
+import io.shardingsphere.core.parsing.integrate.asserts.SQLStatementAssertMessage;
+import io.shardingsphere.core.parsing.integrate.jaxb.meta.ExpectedTableMetaData;
+import lombok.RequiredArgsConstructor;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Table meta data assert.
+ *
+ * @author zhangliang
+ */
+@RequiredArgsConstructor
+public final class TableMetaDataAssert {
+
+ private final SQLStatementAssertMessage assertMessage;
+
+ /**
+ * Assert table meta data.
+ *
+ * @param actualColumnNames actual column names
+ * @param actualColumnTypes actual column types
+ * @param actualPrimaryKeyColumns actual primary key columns
+ * @param expected expected meta data
+ */
+ public void assertMeta(final List actualColumnNames, final List actualColumnTypes, final List actualPrimaryKeyColumns, final ExpectedTableMetaData expected) {
+ assertFalse(assertMessage.getFullAssertMessage("Column names should exist: "), actualColumnNames.isEmpty());
+ assertThat(assertMessage.getFullAssertMessage("Column names assertion error: "), Joiner.on(",").join(actualColumnNames), is(expected.getColumnNames()));
+ assertFalse(assertMessage.getFullAssertMessage("Column types should exist: "), actualColumnTypes.isEmpty());
+ assertThat(assertMessage.getFullAssertMessage("Column types assertion error: "), Joiner.on(",").join(actualColumnTypes), is(expected.getColumnTypes()));
+ assertThat(assertMessage.getFullAssertMessage("Column primary key columns assertion error: "), Joiner.on(",").join(actualPrimaryKeyColumns), is(expected.getPrimaryKeyColumns()));
+ }
+}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/meta/ExpectedTableMetaData.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/meta/ExpectedTableMetaData.java
new file mode 100644
index 0000000000000..865064088c057
--- /dev/null
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/meta/ExpectedTableMetaData.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.integrate.jaxb.meta;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+
+@Getter
+@Setter
+@XmlAccessorType(XmlAccessType.FIELD)
+public final class ExpectedTableMetaData {
+
+ @XmlAttribute(name = "column-names")
+ private String columnNames = "";
+
+ @XmlAttribute(name = "column-types")
+ private String columnTypes = "";
+
+ @XmlAttribute(name = "primary-key-columns")
+ private String primaryKeyColumns = "";
+}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/root/ParserResult.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/root/ParserResult.java
index 331d4a42d5e35..86f0ed57ef324 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/root/ParserResult.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/integrate/jaxb/root/ParserResult.java
@@ -22,6 +22,7 @@
import io.shardingsphere.core.parsing.integrate.jaxb.groupby.ExpectedGroupByColumn;
import io.shardingsphere.core.parsing.integrate.jaxb.item.ExpectedAggregationSelectItem;
import io.shardingsphere.core.parsing.integrate.jaxb.limit.ExpectedLimit;
+import io.shardingsphere.core.parsing.integrate.jaxb.meta.ExpectedTableMetaData;
import io.shardingsphere.core.parsing.integrate.jaxb.orderby.ExpectedOrderByColumn;
import io.shardingsphere.core.parsing.integrate.jaxb.table.ExpectedTable;
import io.shardingsphere.core.parsing.integrate.jaxb.token.ExpectedTokens;
@@ -77,6 +78,9 @@ public final class ParserResult {
@XmlElement
private ExpectedLimit limit;
+ @XmlElement
+ private ExpectedTableMetaData meta;
+
/**
* Get parameters.
*
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/lexer/AllLexerTests.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/lexer/AllLexerTests.java
index 31d8330b9f397..b9bb2b9e48002 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/lexer/AllLexerTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/lexer/AllLexerTests.java
@@ -36,5 +36,5 @@
SQLServerLexerTest.class,
PostgreSQLLexerTest.class
})
-public class AllLexerTests {
+public final class AllLexerTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumnTest.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumnTest.java
new file mode 100644
index 0000000000000..13df5e9f1c4e6
--- /dev/null
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/constant/DerivedColumnTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.parser.constant;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class DerivedColumnTest {
+
+ @Test
+ public void assertGetDerivedColumnAlias() {
+ assertThat(DerivedColumn.AVG_COUNT_ALIAS.getDerivedColumnAlias(0), is("AVG_DERIVED_COUNT_0"));
+ assertThat(DerivedColumn.AVG_SUM_ALIAS.getDerivedColumnAlias(1), is("AVG_DERIVED_SUM_1"));
+ assertThat(DerivedColumn.ORDER_BY_ALIAS.getDerivedColumnAlias(0), is("ORDER_BY_DERIVED_0"));
+ assertThat(DerivedColumn.GROUP_BY_ALIAS.getDerivedColumnAlias(1), is("GROUP_BY_DERIVED_1"));
+ }
+
+ @Test
+ public void assertIsDerivedColumn() {
+ assertTrue(DerivedColumn.isDerivedColumn("AVG_DERIVED_COUNT_0"));
+ assertTrue(DerivedColumn.isDerivedColumn("AVG_DERIVED_SUM_1"));
+ assertTrue(DerivedColumn.isDerivedColumn("ORDER_BY_DERIVED_0"));
+ assertTrue(DerivedColumn.isDerivedColumn("GROUP_BY_DERIVED_1"));
+ }
+
+ @Test
+ public void assertIsNotDerivedColumn() {
+ assertFalse(DerivedColumn.isDerivedColumn("OTHER_DERIVED_COLUMN_0"));
+ }
+}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllSQLTests.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllSQLTests.java
index ccdbfa51081df..7cc2abcb5b110 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllSQLTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllSQLTests.java
@@ -35,5 +35,5 @@
TCLStatementTest.class,
DALStatementTest.class
})
-public class AllSQLTests {
+public final class AllSQLTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllStatementParserTests.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllStatementParserTests.java
index 6c8e08079f0b1..b170d4a5de66b 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllStatementParserTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/AllStatementParserTests.java
@@ -27,5 +27,5 @@
UpdateStatementParserTest.class,
DeleteStatementParserTest.class
})
-public class AllStatementParserTests {
+public final class AllStatementParserTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/DeleteStatementParserTest.java b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/DeleteStatementParserTest.java
index 3059064157ecf..d52e480e95fff 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/DeleteStatementParserTest.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/parsing/parser/sql/DeleteStatementParserTest.java
@@ -17,9 +17,7 @@
package io.shardingsphere.core.parsing.parser.sql;
-import com.google.common.collect.Range;
import io.shardingsphere.core.api.algorithm.sharding.ListShardingValue;
-import io.shardingsphere.core.api.algorithm.sharding.RangeShardingValue;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.ShardingOperator;
import io.shardingsphere.core.parsing.SQLParsingEngine;
@@ -27,84 +25,16 @@
import io.shardingsphere.core.parsing.parser.context.condition.Condition;
import io.shardingsphere.core.parsing.parser.sql.dml.DMLStatement;
import io.shardingsphere.core.rule.ShardingRule;
-import org.hamcrest.CoreMatchers;
import org.junit.Test;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
public final class DeleteStatementParserTest extends AbstractStatementParserTest {
-
- @Test
- public void parseWithoutCondition() {
- ShardingRule shardingRule = createShardingRule();
- SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL, "DELETE FROM TABLE_XXX", shardingRule, null);
- DMLStatement deleteStatement = (DMLStatement) statementParser.parse(false);
- assertThat(deleteStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
- }
-
- @Test
- public void parseWithoutParameter() {
- ShardingRule shardingRule = createShardingRule();
- SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL,
- "DELETE FROM TABLE_XXX xxx WHERE field4<10 AND TABLE_XXX.field1=1 AND field5>10 AND xxx.field2 IN (1,3) AND field6<=10 AND field3 BETWEEN 5 AND 20 AND field7>=10", shardingRule, null);
- DMLStatement deleteStatement = (DMLStatement) statementParser.parse(false);
- assertDeleteStatementWithoutParameter(deleteStatement);
- }
-
- private void assertDeleteStatementWithoutParameter(final DMLStatement deleteStatement) {
- assertThat(deleteStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
- assertThat(deleteStatement.getTables().find("xxx").get().getAlias().get(), is("xxx"));
- Condition condition1 = deleteStatement.getConditions().find(new Column("field1", "TABLE_XXX")).get();
- assertThat(condition1.getOperator(), CoreMatchers.is(ShardingOperator.EQUAL));
- assertThat(((ListShardingValue) condition1.getShardingValue(Collections.emptyList())).getValues().iterator().next(), is((Object) 1));
- Condition condition2 = deleteStatement.getConditions().find(new Column("field2", "TABLE_XXX")).get();
- assertThat(condition2.getOperator(), is(ShardingOperator.IN));
- Iterator> shardingValues2 = ((ListShardingValue) condition2.getShardingValue(Collections.emptyList())).getValues().iterator();
- assertThat(shardingValues2.next(), is((Object) 1));
- assertThat(shardingValues2.next(), is((Object) 3));
- assertFalse(shardingValues2.hasNext());
- Condition condition3 = deleteStatement.getConditions().find(new Column("field3", "TABLE_XXX")).get();
- assertThat(condition3.getOperator(), is(ShardingOperator.BETWEEN));
- Range shardingValues3 = ((RangeShardingValue) condition3.getShardingValue(Collections.emptyList())).getValueRange();
- assertThat(shardingValues3.lowerEndpoint(), is((Comparable) 5));
- assertThat(shardingValues3.upperEndpoint(), is((Comparable) 20));
- }
-
- @Test
- public void parseWithParameter() {
- ShardingRule shardingRule = createShardingRule();
- SQLParsingEngine statementParser = new SQLParsingEngine(DatabaseType.MySQL,
- "DELETE FROM TABLE_XXX xxx WHERE field4 AND field1=? AND field5>? AND field2 IN (?,?) AND field6<=? AND field3 BETWEEN ? AND ? AND field7>=?", shardingRule, null);
- DMLStatement deleteStatement = (DMLStatement) statementParser.parse(false);
- assertDeleteStatementWithParameter(deleteStatement);
- }
-
- private void assertDeleteStatementWithParameter(final DMLStatement deleteStatement) {
- assertThat(deleteStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
- assertThat(deleteStatement.getTables().find("xxx").get().getAlias().get(), is("xxx"));
- List actualParameters = Arrays.asList(0, 10, 20, 30, 40, 50, 60, 70, 80);
- Condition condition1 = deleteStatement.getConditions().find(new Column("field1", "TABLE_XXX")).get();
- assertThat(condition1.getOperator(), is(ShardingOperator.EQUAL));
- assertThat(((ListShardingValue) condition1.getShardingValue(actualParameters)).getValues().iterator().next(), is((Object) 10));
- Condition condition2 = deleteStatement.getConditions().find(new Column("field2", "TABLE_XXX")).get();
- assertThat(condition2.getOperator(), is(ShardingOperator.IN));
- Iterator> shardingValues2 = ((ListShardingValue) condition2.getShardingValue(actualParameters)).getValues().iterator();
- assertThat(shardingValues2.next(), is((Object) 30));
- assertThat(shardingValues2.next(), is((Object) 40));
- Condition condition3 = deleteStatement.getConditions().find(new Column("field3", "TABLE_XXX")).get();
- assertThat(condition3.getOperator(), is(ShardingOperator.BETWEEN));
- Range shardingValues3 = ((RangeShardingValue) condition3.getShardingValue(actualParameters)).getValueRange();
- assertThat(shardingValues3.lowerEndpoint(), is((Comparable) 60));
- assertThat(shardingValues3.upperEndpoint(), is((Comparable) 70));
- }
-
+
@Test(expected = UnsupportedOperationException.class)
public void parseStatementWithDeleteMultipleTable() {
ShardingRule shardingRule = createShardingRule();
@@ -119,7 +49,7 @@ public void parseStatementWithDeleteMultipleTableWithUsing() {
@Test
public void parseWithSpecialSyntax() {
-// parseWithSpecialSyntax(DatabaseType.MySQL, "DELETE `TABLE_XXX` WHERE `field1`=1");
+ parseWithSpecialSyntax(DatabaseType.MySQL, "DELETE `TABLE_XXX` WHERE `field1`=1");
parseWithSpecialSyntax(DatabaseType.Oracle, "DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(DatabaseType.Oracle, "DELETE /*+ index(field1) */ ONLY (TABLE_XXX) WHERE field1=1 RETURNING *");
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/rewrite/AllRewriteTests.java b/sharding-core/src/test/java/io/shardingsphere/core/rewrite/AllRewriteTests.java
index 462ec70c67b0a..c4ed871881185 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/rewrite/AllRewriteTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/rewrite/AllRewriteTests.java
@@ -26,5 +26,5 @@
SQLBuilderTest.class,
SQLRewriteEngineTest.class
})
-public class AllRewriteTests {
+public final class AllRewriteTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/routing/AllRoutingTests.java b/sharding-core/src/test/java/io/shardingsphere/core/routing/AllRoutingTests.java
index 582dbe40b62d0..3b4eb24ab8dbe 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/routing/AllRoutingTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/routing/AllRoutingTests.java
@@ -26,5 +26,5 @@
DatabaseTest.class,
DatabaseHintSQLRouterTest.class
})
-public class AllRoutingTests {
+public final class AllRoutingTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/rule/AllRuleTests.java b/sharding-core/src/test/java/io/shardingsphere/core/rule/AllRuleTests.java
index 996db729ed204..de9aaf417a2ae 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/rule/AllRuleTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/rule/AllRuleTests.java
@@ -29,5 +29,5 @@
BindingTableRuleTest.class,
MasterSlaveRuleTest.class
})
-public class AllRuleTests {
+public final class AllRuleTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/util/AllUtilTests.java b/sharding-core/src/test/java/io/shardingsphere/core/util/AllUtilTests.java
index 673260ef66d64..36d01b4c1a8c6 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/util/AllUtilTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/util/AllUtilTests.java
@@ -27,5 +27,5 @@
InlineExpressionParserTest.class,
SQLUtilTest.class
})
-public class AllUtilTests {
+public final class AllUtilTests {
}
diff --git a/sharding-core/src/test/java/io/shardingsphere/core/yaml/AllYamlTests.java b/sharding-core/src/test/java/io/shardingsphere/core/yaml/AllYamlTests.java
index cdaa848040a12..1f9f238aa9b96 100644
--- a/sharding-core/src/test/java/io/shardingsphere/core/yaml/AllYamlTests.java
+++ b/sharding-core/src/test/java/io/shardingsphere/core/yaml/AllYamlTests.java
@@ -36,5 +36,5 @@
YamlMasterSlaveConfigurationTest.class,
YamlMasterSlaveRuleConfigurationTest.class
})
-public class AllYamlTests {
+public final class AllYamlTests {
}
diff --git a/sharding-core/src/test/resources/parser/create.xml b/sharding-core/src/test/resources/parser/create.xml
index edf63dfea9f66..572ae14715956 100644
--- a/sharding-core/src/test/resources/parser/create.xml
+++ b/sharding-core/src/test/resources/parser/create.xml
@@ -7,6 +7,7 @@
+
@@ -16,6 +17,7 @@
+
@@ -25,6 +27,7 @@
+
@@ -34,6 +37,7 @@
+
@@ -43,6 +47,7 @@
+
@@ -52,6 +57,7 @@
+
diff --git a/sharding-core/src/test/resources/parser/show.xml b/sharding-core/src/test/resources/parser/show.xml
index aa16008ebabc2..82c529ac6a80d 100644
--- a/sharding-core/src/test/resources/parser/show.xml
+++ b/sharding-core/src/test/resources/parser/show.xml
@@ -1,6 +1,5 @@
-
@@ -66,5 +65,6 @@
-
+
+
diff --git a/sharding-jdbc-orchestration-spring/pom.xml b/sharding-jdbc-orchestration-spring/pom.xml
index 6f16c4d089108..7ef3b7b555fb8 100644
--- a/sharding-jdbc-orchestration-spring/pom.xml
+++ b/sharding-jdbc-orchestration-spring/pom.xml
@@ -6,7 +6,7 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-orchestration-spring
pom
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/pom.xml b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/pom.xml
index b22894a9bdea4..9caa30775e111 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/pom.xml
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-orchestration-spring
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-orchestration-spring-boot-starter
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
index e64bc185b692c..e7fb96c507a39 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
@@ -78,7 +78,7 @@ public DataSource dataSource() throws SQLException {
}
@Override
- public void setEnvironment(final Environment environment) {
+ public final void setEnvironment(final Environment environment) {
setDataSourceMap(environment);
}
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/util/PropertyUtil.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/util/PropertyUtil.java
index adc74df4ca0e4..700841b6c4820 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/util/PropertyUtil.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/orchestration/spring/boot/util/PropertyUtil.java
@@ -17,6 +17,13 @@
package io.shardingsphere.jdbc.orchestration.spring.boot.util;
+import io.shardingsphere.core.exception.ShardingException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.PropertyResolver;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -24,13 +31,8 @@
import java.util.HashMap;
import java.util.Map;
-import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.PropertyResolver;
-
-import io.shardingsphere.core.exception.ShardingException;
-
-public class PropertyUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PropertyUtil {
private static int springBootVersion = 1;
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
index 987f6c5f190af..36bf5b3bbe5db 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
@@ -28,5 +28,5 @@
OrchestrationSpringBootMasterSlaveTest.class,
OrchestrationSpringBootShardingTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/pom.xml b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/pom.xml
index 25265aef3aa6e..d56e3ba8de08d 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/pom.xml
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-orchestration-spring
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-orchestration-spring-namespace
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationMasterSlaveDataSourceFactoryBean.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationMasterSlaveDataSourceFactoryBean.java
index 73be2ba394096..8fc2e4b868f4c 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationMasterSlaveDataSourceFactoryBean.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationMasterSlaveDataSourceFactoryBean.java
@@ -36,7 +36,7 @@
* @author zhangliang
* @author panjuan
*/
-public class OrchestrationMasterSlaveDataSourceFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
+public final class OrchestrationMasterSlaveDataSourceFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
private OrchestrationMasterSlaveDataSource orchestrationMasterSlaveDataSource;
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationShardingDataSourceFactoryBean.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationShardingDataSourceFactoryBean.java
index d86980b1405e3..963e0cbcd2747 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationShardingDataSourceFactoryBean.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/datasource/OrchestrationShardingDataSourceFactoryBean.java
@@ -35,7 +35,7 @@
*
* @author zhangliang
*/
-public class OrchestrationShardingDataSourceFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
+public final class OrchestrationShardingDataSourceFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
private OrchestrationShardingDataSource orchestrationShardingDataSource;
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/AbstractOrchestrationBeanDefinitionParser.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/AbstractOrchestrationBeanDefinitionParser.java
index 394e86ad07aaf..5c05c70215ce1 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/AbstractOrchestrationBeanDefinitionParser.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/AbstractOrchestrationBeanDefinitionParser.java
@@ -31,11 +31,11 @@
*/
public abstract class AbstractOrchestrationBeanDefinitionParser extends AbstractBeanDefinitionParser {
- protected String parseRegistryCenterRef(final Element element) {
+ protected final String parseRegistryCenterRef(final Element element) {
return element.getAttribute("registry-center-ref");
}
- protected BeanDefinition parseOrchestrationConfiguration(final Element element, final OrchestrationType type) {
+ protected final BeanDefinition parseOrchestrationConfiguration(final Element element, final OrchestrationType type) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(OrchestrationConfiguration.class);
factory.addConstructorArgValue(element.getAttribute("id"));
factory.addConstructorArgReference(element.getAttribute("registry-center-ref"));
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationMasterSlaveDataSourceBeanDefinitionParser.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationMasterSlaveDataSourceBeanDefinitionParser.java
index 9af4eda3da0bf..797cb115754e1 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationMasterSlaveDataSourceBeanDefinitionParser.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationMasterSlaveDataSourceBeanDefinitionParser.java
@@ -48,7 +48,7 @@
* @author caohao
* @author zhangliang
*/
-public class OrchestrationMasterSlaveDataSourceBeanDefinitionParser extends AbstractOrchestrationBeanDefinitionParser {
+public final class OrchestrationMasterSlaveDataSourceBeanDefinitionParser extends AbstractOrchestrationBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationShardingDataSourceBeanDefinitionParser.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationShardingDataSourceBeanDefinitionParser.java
index 2152d429a2c06..995017a1b2109 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationShardingDataSourceBeanDefinitionParser.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/OrchestrationShardingDataSourceBeanDefinitionParser.java
@@ -47,7 +47,7 @@
* @author caohao
* @author zhangliang
*/
-public class OrchestrationShardingDataSourceBeanDefinitionParser extends AbstractOrchestrationBeanDefinitionParser {
+public final class OrchestrationShardingDataSourceBeanDefinitionParser extends AbstractOrchestrationBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinition.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinition.java
index 5177eef3cc7f3..a991c002372dc 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinition.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinition.java
@@ -37,7 +37,7 @@
* @author caohao
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class ShardingStrategyBeanDefinition {
+public final class ShardingStrategyBeanDefinition {
static AbstractBeanDefinition getBeanDefinitionByElement(final Element element) {
String type = element.getLocalName();
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
index 5523ebea99bca..d9ddf646479bc 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/main/java/io/shardingsphere/jdbc/orchestration/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
@@ -27,7 +27,7 @@
*®
* @author caohao
*/
-public class ShardingStrategyBeanDefinitionParser extends AbstractBeanDefinitionParser {
+public final class ShardingStrategyBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/AllTests.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/AllTests.java
index 84b208f8e53fd..4dc103e791370 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/AllTests.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/AllTests.java
@@ -27,5 +27,5 @@
OrchestrationShardingNamespaceTest.class,
OrchestrationShardingMasterSlaveNamespaceTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
index 35708a9d76047..4baf9008f57ee 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/OrchestrationShardingMasterSlaveNamespaceTest.java
@@ -58,13 +58,13 @@ public void assertDefaultShardingDataSource() {
@SuppressWarnings("unchecked")
private Map getDataSourceMap() {
- ShardingDataSource shardingDataSource = this.applicationContext.getBean("defaultShardingDataSource", ShardingDataSource.class);
+ ShardingDataSource shardingDataSource = applicationContext.getBean("defaultShardingDataSource", ShardingDataSource.class);
Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
return (Map) FieldValueUtil.getFieldValue(shardingContext, "dataSourceMap");
}
private ShardingRule getShardingRule() {
- ShardingDataSource shardingDataSource = this.applicationContext.getBean("defaultShardingDataSource", ShardingDataSource.class);
+ ShardingDataSource shardingDataSource = applicationContext.getBean("defaultShardingDataSource", ShardingDataSource.class);
Object shardingContext = FieldValueUtil.getFieldValue(shardingDataSource, "shardingContext", true);
return (ShardingRule) FieldValueUtil.getFieldValue(shardingContext, "shardingRule");
}
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
index 6910b3afd8bdc..924ca94023d8f 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class DefaultComplexKeysShardingAlgorithm implements ComplexKeysShardingAlgorithm {
+public final class DefaultComplexKeysShardingAlgorithm implements ComplexKeysShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final Collection shardingValues) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultHintShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultHintShardingAlgorithm.java
index 8f2b430aed929..3f001493040bf 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultHintShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/DefaultHintShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class DefaultHintShardingAlgorithm implements HintShardingAlgorithm {
+public final class DefaultHintShardingAlgorithm implements HintShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final ShardingValue shardingValue) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
index 0db78329bf378..fba073419f555 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class PreciseModuloDatabaseShardingAlgorithm implements PreciseShardingAlgorithm {
+public final class PreciseModuloDatabaseShardingAlgorithm implements PreciseShardingAlgorithm {
@Override
public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloTableShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
index 7b15dea133bb4..00cb113be3cb2 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class PreciseModuloTableShardingAlgorithm implements PreciseShardingAlgorithm {
+public final class PreciseModuloTableShardingAlgorithm implements PreciseShardingAlgorithm {
@Override
public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
index 329da016d3c3a..4591ffec5c683 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
@@ -24,7 +24,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-public class RangeModuloDatabaseShardingAlgorithm implements RangeShardingAlgorithm {
+public final class RangeModuloDatabaseShardingAlgorithm implements RangeShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) {
diff --git a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloTableShardingAlgorithm.java b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloTableShardingAlgorithm.java
index de4df2bc35bec..7459896cce821 100644
--- a/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloTableShardingAlgorithm.java
+++ b/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-namespace/src/test/java/io/shardingsphere/jdbc/orchestration/spring/algorithm/RangeModuloTableShardingAlgorithm.java
@@ -24,7 +24,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-public class RangeModuloTableShardingAlgorithm implements RangeShardingAlgorithm {
+public final class RangeModuloTableShardingAlgorithm implements RangeShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) {
diff --git a/sharding-jdbc-orchestration/pom.xml b/sharding-jdbc-orchestration/pom.xml
index 5067a4d7ffe04..bf58bf8835eb8 100644
--- a/sharding-jdbc-orchestration/pom.xml
+++ b/sharding-jdbc-orchestration/pom.xml
@@ -5,14 +5,14 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
4.0.0
sharding-jdbc-orchestration
${project.artifactId}
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationMasterSlaveDataSource.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationMasterSlaveDataSource.java
index fe50cbbb2fe06..8f4b4b7d42f1e 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationMasterSlaveDataSource.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationMasterSlaveDataSource.java
@@ -33,7 +33,7 @@
* @author panjuan
*/
@Slf4j
-public class OrchestrationMasterSlaveDataSource extends MasterSlaveDataSource implements AutoCloseable {
+public final class OrchestrationMasterSlaveDataSource extends MasterSlaveDataSource implements AutoCloseable {
private final OrchestrationFacade orchestrationFacade;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationShardingDataSource.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationShardingDataSource.java
index 5791833574de4..a21d15b256bf8 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationShardingDataSource.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/OrchestrationShardingDataSource.java
@@ -33,7 +33,7 @@
* @author caohao
*/
@Slf4j
-public class OrchestrationShardingDataSource extends ShardingDataSource {
+public final class OrchestrationShardingDataSource extends ShardingDataSource {
private final OrchestrationFacade orchestrationFacade;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/statement/CircuitBreakerStatement.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/statement/CircuitBreakerStatement.java
index 4048a63989e7b..01042aafad933 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/statement/CircuitBreakerStatement.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/statement/CircuitBreakerStatement.java
@@ -31,11 +31,10 @@
* @author caohao
*/
@Getter
-public class CircuitBreakerStatement extends AbstractUnsupportedOperationStatement {
+public final class CircuitBreakerStatement extends AbstractUnsupportedOperationStatement {
@Override
public void close() {
-
}
@Override
@@ -45,7 +44,6 @@ public int getMaxFieldSize() {
@Override
public void setMaxFieldSize(final int max) {
-
}
@Override
@@ -55,12 +53,10 @@ public int getMaxRows() {
@Override
public void setMaxRows(final int max) {
-
}
@Override
public void setEscapeProcessing(final boolean enable) {
-
}
@Override
@@ -70,12 +66,10 @@ public int getQueryTimeout() {
@Override
public void setQueryTimeout(final int seconds) {
-
}
@Override
public void cancel() {
-
}
@Override
@@ -85,7 +79,6 @@ public SQLWarning getWarnings() {
@Override
public void clearWarnings() {
-
}
@Override
@@ -100,7 +93,6 @@ public int getUpdateCount() {
@Override
public void setFetchSize(final int rows) {
-
}
@Override
@@ -195,7 +187,6 @@ public boolean isClosed() {
@Override
public void setPoolable(final boolean poolable) {
-
}
@Override
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/converter/ShardingConfigurationConverter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/converter/ShardingConfigurationConverter.java
index 23160eb84fbd9..771f7e844ad23 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/converter/ShardingConfigurationConverter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/converter/ShardingConfigurationConverter.java
@@ -35,7 +35,7 @@
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class ShardingConfigurationConverter {
+public final class ShardingConfigurationConverter {
private static final Yaml YAML = new Yaml(new DefaultConfigurationRepresenter());
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/DataSourceRepresenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/DataSourceRepresenter.java
index caecaf0e8b958..96839a45b48aa 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/DataSourceRepresenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/DataSourceRepresenter.java
@@ -36,7 +36,7 @@
*
* @author panjuan
*/
-public class DataSourceRepresenter extends Representer {
+public final class DataSourceRepresenter extends Representer {
private static Collection> generalClassType;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/MasterSlaveConfigurationRepresenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/MasterSlaveConfigurationRepresenter.java
index ff1959ed8da87..6045ffaf009f9 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/MasterSlaveConfigurationRepresenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/MasterSlaveConfigurationRepresenter.java
@@ -35,7 +35,7 @@
*
* @author panjuan
*/
-public class MasterSlaveConfigurationRepresenter extends Representer {
+public final class MasterSlaveConfigurationRepresenter extends Representer {
private static Collection eliminatedPropertyNames = new HashSet<>();
@@ -67,6 +67,8 @@ protected Set getProperties(final Class> type) {
}
private class NullRepresent implements Represent {
+
+ @Override
public Node representData(final Object data) {
return representScalar(Tag.NULL, "");
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ProxyConfigurationRepresenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ProxyConfigurationRepresenter.java
index bbe462c7d5e31..2e486a62c53c6 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ProxyConfigurationRepresenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ProxyConfigurationRepresenter.java
@@ -35,7 +35,7 @@
*
* @author panjuan
*/
-public class ProxyConfigurationRepresenter extends Representer {
+public final class ProxyConfigurationRepresenter extends Representer {
private static Collection eliminatedPropertyNames = new HashSet<>();
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ShardingConfigurationRepresenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ShardingConfigurationRepresenter.java
index bf875a999602d..2e8f124f901c4 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ShardingConfigurationRepresenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/internal/yaml/representer/ShardingConfigurationRepresenter.java
@@ -35,7 +35,7 @@
*
* @author panjuan
*/
-public class ShardingConfigurationRepresenter extends Representer {
+public final class ShardingConfigurationRepresenter extends Representer {
private static Collection eliminatedPropertyNames = new HashSet<>();
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/NewZookeeperRegistryCenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/NewZookeeperRegistryCenter.java
index 2c7167513db96..0e18f5e568f7b 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/NewZookeeperRegistryCenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/NewZookeeperRegistryCenter.java
@@ -18,6 +18,7 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk;
import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
import com.google.common.base.Strings;
import io.shardingsphere.jdbc.orchestration.reg.api.RegistryCenter;
import io.shardingsphere.jdbc.orchestration.reg.exception.RegExceptionHandler;
@@ -31,6 +32,11 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.StrategyType;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
import io.shardingsphere.jdbc.orchestration.reg.zookeeper.ZookeeperConfiguration;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.ZooDefs;
+
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
@@ -39,10 +45,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.ZooDefs;
/**
* Zookeeper native based registry center.
@@ -53,62 +55,60 @@ public final class NewZookeeperRegistryCenter implements RegistryCenter {
private final IClient client;
- private final Map caches = new HashMap<>();
+ private final Map caches;
public NewZookeeperRegistryCenter(final ZookeeperConfiguration zkConfig) {
- final ClientFactory creator = buildCreator(zkConfig);
- client = initClient(creator, zkConfig);
+ client = initClient(buildClientFactory(zkConfig), zkConfig);
+ caches = new HashMap<>();
}
- private ClientFactory buildCreator(final ZookeeperConfiguration zkConfig) {
- final ClientFactory creator = new ClientFactory();
- creator.setClientNamespace(zkConfig.getNamespace())
- .newClient(zkConfig.getServerLists(), zkConfig.getSessionTimeoutMilliseconds())
+ private ClientFactory buildClientFactory(final ZookeeperConfiguration zkConfig) {
+ ClientFactory result = new ClientFactory();
+ result.setClientNamespace(zkConfig.getNamespace()).newClient(zkConfig.getServerLists(), zkConfig.getSessionTimeoutMilliseconds())
.setRetryPolicy(new DelayRetryPolicy(zkConfig.getBaseSleepTimeMilliseconds(), zkConfig.getMaxRetries(), zkConfig.getMaxSleepTimeMilliseconds()));
if (!Strings.isNullOrEmpty(zkConfig.getDigest())) {
- creator.authorization("digest", zkConfig.getDigest().getBytes(Charsets.UTF_8), ZooDefs.Ids.CREATOR_ALL_ACL);
+ result.authorization("digest", zkConfig.getDigest().getBytes(Charsets.UTF_8), ZooDefs.Ids.CREATOR_ALL_ACL);
}
- return creator;
+ return result;
}
- private IClient initClient(final ClientFactory creator, final ZookeeperConfiguration zkConfig) {
- IClient newClient = null;
+ private IClient initClient(final ClientFactory clientFactory, final ZookeeperConfiguration zkConfig) {
+ IClient result = null;
try {
- // todo There is a bug when the start time is very short, and I haven't found the reason yet
- // newClient = creator.start(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS);
- newClient = creator.start();
- if (!newClient.blockUntilConnected(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS)) {
- newClient.close();
+ // TODO There is a bug when the start time is very short, and I haven't found the reason yet
+ // result = clientFactory.start(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS);
+ result = clientFactory.start();
+ if (!result.blockUntilConnected(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS)) {
+ result.close();
throw new KeeperException.OperationTimeoutException();
}
-
- newClient.useExecStrategy(StrategyType.SYNC_RETRY);
+ result.useExecStrategy(StrategyType.SYNC_RETRY);
} catch (final KeeperException.OperationTimeoutException | IOException | InterruptedException ex) {
RegExceptionHandler.handleException(ex);
}
- return newClient;
+ return result;
}
@Override
public String get(final String key) {
- final PathTree cache = findTreeCache(key);
- if (null == cache) {
+ Optional cache = findTreeCache(key);
+ if (!cache.isPresent()) {
return getDirectly(key);
}
- byte[] resultInCache = cache.getValue(key);
+ byte[] resultInCache = cache.get().getValue(key);
if (null != resultInCache) {
- return null == resultInCache ? null : new String(resultInCache, Charsets.UTF_8);
+ return new String(resultInCache, Charsets.UTF_8);
}
return getDirectly(key);
}
- private PathTree findTreeCache(final String key) {
+ private Optional findTreeCache(final String key) {
for (Entry entry : caches.entrySet()) {
if (key.startsWith(entry.getKey())) {
- return entry.getValue();
+ return Optional.of(entry.getValue());
}
}
- return null;
+ return Optional.absent();
}
@Override
@@ -185,23 +185,19 @@ public void persistEphemeral(final String key, final String value) {
@Override
public void watch(final String key, final EventListener eventListener) {
- final String path = key + "/";
+ String path = key + "/";
if (!caches.containsKey(path)) {
addCacheData(key);
}
- final PathTree cache = caches.get(path);
+ PathTree cache = caches.get(path);
cache.watch(new ZookeeperEventListener() {
@Override
public void process(final WatchedEvent event) {
if (!Strings.isNullOrEmpty(event.getPath())) {
- eventListener.onChange(new DataChangedEvent(getEventType(event), event.getPath(), getWithoutCache(event.getPath())));
+ eventListener.onChange(new DataChangedEvent(extractEventType(event), event.getPath(), getWithoutCache(event.getPath())));
}
}
-
- private DataChangedEvent.Type getEventType(final WatchedEvent event) {
- return extractEventType(event);
- }
});
}
@@ -230,7 +226,7 @@ private synchronized String getWithoutCache(final String key) {
}
private void addCacheData(final String cachePath) {
- final PathTree cache = new PathTree(cachePath, client);
+ PathTree cache = new PathTree(cachePath, client);
try {
cache.load();
cache.watch();
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ContentionCallback.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ContentionCallback.java
index 105941acaf45d..23d942b2a0d02 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ContentionCallback.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ContentionCallback.java
@@ -17,7 +17,7 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.action;
-/*
+/**
* Callback on contention has not reached.
*
* @author lidongbo
@@ -25,7 +25,7 @@
public interface ContentionCallback {
/**
- * Process callback result.
- */
+ * Process callback result.
+ */
void processResult();
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IAction.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IAction.java
index 905961e92bd13..a20d3433f632c 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IAction.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IAction.java
@@ -24,7 +24,7 @@
import java.util.List;
-/*
+/**
* The basic actions of the client.
*
* @author lidongbo
@@ -36,8 +36,8 @@ public interface IAction {
*
* @param key key
* @return data String
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
String getDataString(String key) throws KeeperException, InterruptedException;
@@ -46,8 +46,8 @@ public interface IAction {
*
* @param key key
* @return data
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
byte[] getData(String key) throws KeeperException, InterruptedException;
@@ -56,9 +56,9 @@ public interface IAction {
*
* @param key key
* @param callback callback
- * @param ctx ctx
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @param ctx context
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void getData(String key, AsyncCallback.DataCallback callback, Object ctx) throws KeeperException, InterruptedException;
@@ -66,9 +66,9 @@ public interface IAction {
* Check exist.
*
* @param key key
- * @return exist
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @return exist or not
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
boolean checkExists(String key) throws KeeperException, InterruptedException;
@@ -77,9 +77,9 @@ public interface IAction {
*
* @param key key
* @param watcher watcher
- * @return exist
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @return exist or not
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
boolean checkExists(String key, Watcher watcher) throws KeeperException, InterruptedException;
@@ -88,8 +88,8 @@ public interface IAction {
*
* @param key key
* @return children keys
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
List getChildren(String key) throws KeeperException, InterruptedException;
@@ -99,8 +99,8 @@ public interface IAction {
* @param key key
* @param value value
* @param createMode createMode
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void createCurrentOnly(String key, String value, CreateMode createMode) throws KeeperException, InterruptedException;
@@ -109,8 +109,8 @@ public interface IAction {
*
* @param key key
* @param value value
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void update(String key, String value) throws KeeperException, InterruptedException;
@@ -118,8 +118,8 @@ public interface IAction {
* Only delete target node..
*
* @param key key
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void deleteOnlyCurrent(String key) throws KeeperException, InterruptedException;
@@ -128,9 +128,9 @@ public interface IAction {
*
* @param key key
* @param callback callback
- * @param ctx ctx
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @param ctx context
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void deleteOnlyCurrent(String key, AsyncCallback.VoidCallback callback, Object ctx) throws KeeperException, InterruptedException;
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IClient.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IClient.java
index 9706f14bb5725..f897dafab9c6e 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IClient.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IClient.java
@@ -24,8 +24,8 @@
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-/*
- * Client api.
+/**
+ * Client API.
*
* @author lidongbo
*/
@@ -34,42 +34,37 @@ public interface IClient extends IAction, IGroupAction {
/**
* Start.
*
- * @throws IOException IO Exception
- * @throws InterruptedException InterruptedException
+ * @throws IOException IO exception
+ * @throws InterruptedException interrupted exception
*/
void start() throws IOException, InterruptedException;
/**
* Start until out.
*
- * @param wait wait
- * @param units units
- * @return connected
- * @throws IOException IO Exception
- * @throws InterruptedException InterruptedException
+ * @param waitingTime waiting time
+ * @param timeUnit time unit
+ * @return connected or not
+ * @throws IOException IO exception
+ * @throws InterruptedException interrupted exception
*/
- boolean start(int wait, TimeUnit units) throws IOException, InterruptedException;
+ boolean start(int waitingTime, TimeUnit timeUnit) throws IOException, InterruptedException;
/**
* Block until connected.
*
- * @param wait wait
- * @param units units
- * @return connected
- * @throws InterruptedException InterruptedException
- */
- boolean blockUntilConnected(int wait, TimeUnit units) throws InterruptedException;
-
- /**
- * Close.
+ * @param waitingTime waiting time
+ * @param timeUnit time unit
+ * @return connected or not
+ * @throws InterruptedException interrupted exception
*/
- void close();
+ boolean blockUntilConnected(int waitingTime, TimeUnit timeUnit) throws InterruptedException;
/**
* Register watcher.
*
* @param key key
- * @param zookeeperEventListener listener
+ * @param zookeeperEventListener zookeeper event listener
*/
void registerWatch(String key, ZookeeperEventListener zookeeperEventListener);
@@ -88,9 +83,21 @@ public interface IClient extends IAction, IGroupAction {
void useExecStrategy(StrategyType strategyType);
/**
- * Create transaction.
+ * Get execution strategy.
*
- * @return ZKTransaction
+ * @return execution strategy
+ */
+ IExecStrategy getExecStrategy();
+
+ /**
+ * Create zookeeper transaction.
+ *
+ * @return zookeeper transaction
*/
BaseTransaction transaction();
+
+ /**
+ * Close.
+ */
+ void close();
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IExecStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IExecStrategy.java
index 012172bcfdc45..d7f587ad9efe8 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IExecStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IExecStrategy.java
@@ -19,7 +19,7 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.BaseTransaction;
-/*
+/**
* Client 's execution strategy.
*
* @author lidongbo
@@ -29,14 +29,14 @@ public interface IExecStrategy extends IAction, IGroupAction {
/**
* Get provider.
*
- * @return IProvider
+ * @return provider
*/
IProvider getProvider();
/**
- * Create transaction.
+ * Create zookeeper transaction.
*
- * @return BaseTransaction
+ * @return zookeeper transaction
*/
BaseTransaction transaction();
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IGroupAction.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IGroupAction.java
index 75e2b1aaf1bc3..03a79e49a2f64 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IGroupAction.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IGroupAction.java
@@ -20,7 +20,7 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
-/*
+/**
* One action contains a group operation.
*
* @author lidongbo
@@ -32,9 +32,9 @@ public interface IGroupAction {
*
* @param key key
* @param value value
- * @param createMode createMode
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @param createMode create mode
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void createAllNeedPath(String key, String value, CreateMode createMode) throws KeeperException, InterruptedException;
@@ -42,8 +42,8 @@ public interface IGroupAction {
* Delete target node and children nodes.
*
* @param key key
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void deleteAllChildren(String key) throws KeeperException, InterruptedException;
@@ -51,8 +51,8 @@ public interface IGroupAction {
* Delete the current node with force and delete the super node whose only child node is current node recursively.
*
* @param key key
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void deleteCurrentBranch(String key) throws KeeperException, InterruptedException;
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IProvider.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IProvider.java
index 845603eab686e..c2414251b0da2 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IProvider.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/IProvider.java
@@ -27,8 +27,8 @@
import java.util.List;
import java.util.Stack;
-/*
- * Provider api.
+/**
+ * Provider API.
*
* @author lidongbo
*/
@@ -39,8 +39,8 @@ public interface IProvider {
*
* @param key key
* @return data String
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
String getDataString(String key) throws KeeperException, InterruptedException;
@@ -49,8 +49,8 @@ public interface IProvider {
*
* @param key key
* @return data
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
byte[] getData(String key) throws KeeperException, InterruptedException;
@@ -60,8 +60,8 @@ public interface IProvider {
* @param key key
* @param callback callback
* @param ctx ctx
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void getData(String key, AsyncCallback.DataCallback callback, Object ctx) throws KeeperException, InterruptedException;
@@ -70,8 +70,8 @@ public interface IProvider {
*
* @param key key
* @return exist
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
boolean exists(String key) throws KeeperException, InterruptedException;
@@ -81,8 +81,8 @@ public interface IProvider {
* @param key key
* @param watcher watcher
* @return exist
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
boolean exists(String key, Watcher watcher) throws KeeperException, InterruptedException;
@@ -91,8 +91,8 @@ public interface IProvider {
*
* @param key key
* @return exist
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
List getChildren(String key) throws KeeperException, InterruptedException;
@@ -101,9 +101,9 @@ public interface IProvider {
*
* @param key key
* @param value value
- * @param createMode createMode
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @param createMode create mode
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void create(String key, String value, CreateMode createMode) throws KeeperException, InterruptedException;
@@ -113,8 +113,8 @@ public interface IProvider {
* @param key key
* @param value value
* @return is success
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
boolean update(String key, String value) throws KeeperException, InterruptedException;
@@ -122,19 +122,19 @@ public interface IProvider {
* Only delete target node..
*
* @param key key
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void delete(String key) throws KeeperException, InterruptedException;
/**
- * Only delete target node..
+ * Only delete target node.
*
* @param key key
* @param callback callback
* @param ctx ctx
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
void delete(String key, AsyncCallback.VoidCallback callback, Object ctx) throws KeeperException, InterruptedException;
@@ -166,7 +166,7 @@ public interface IProvider {
* Contention exec.
*
* @param election election
- * @throws KeeperException Zookeeper Exception
+ * @throws KeeperException zookeeper exception
* @throws InterruptedException InterruptedException
*/
void executeContention(LeaderElection election) throws KeeperException, InterruptedException;
@@ -177,9 +177,9 @@ public interface IProvider {
void resetConnection();
/**
- * Create transaction.
+ * Create zookeeper transaction.
*
- * @return BaseTransaction
+ * @return zookeeper transaction
*/
BaseTransaction transaction();
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ITransactionProvider.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ITransactionProvider.java
index 6acb30d5c1716..fe53483e4becb 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ITransactionProvider.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/action/ITransactionProvider.java
@@ -20,7 +20,7 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.BaseTransaction;
import org.apache.zookeeper.CreateMode;
-/*
+/**
* Provider with transaction.
*
* @author lidongbo
@@ -32,8 +32,8 @@ public interface ITransactionProvider extends IProvider {
*
* @param key key
* @param value value
- * @param createMode createMode
- * @param transaction transaction
+ * @param createMode create mode
+ * @param transaction zookeeper transaction
*/
void createInTransaction(String key, String value, CreateMode createMode, BaseTransaction transaction);
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/CacheStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/CacheStrategy.java
index 9a43f0790b651..2e3260d6f2f90 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/CacheStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/CacheStrategy.java
@@ -17,14 +17,12 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.cache;
-/*
+/**
* Cache strategy.
*
* @author lidongbo
*/
public enum CacheStrategy {
- NONE,
- WATCH,
- ALL
+ NONE, WATCH, ALL
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java
index e13fc41f7df23..22ecbbc5376a2 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java
@@ -19,31 +19,29 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.PathUtil;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
-/*
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
* Zookeeper node cache.
*
* @author lidongbo
*/
+@Getter
+@Setter
@Slf4j
public final class PathNode {
private final Map children = new ConcurrentHashMap<>();
-
+
private final String nodeKey;
- @Getter(value = AccessLevel.PACKAGE)
- @Setter(value = AccessLevel.PACKAGE)
private String path;
-
- @Getter(value = AccessLevel.PACKAGE)
- @Setter(value = AccessLevel.PACKAGE)
+
private byte[] value;
PathNode(final String key) {
@@ -56,32 +54,9 @@ public final class PathNode {
this.path = key;
}
- /**
- * Get children.
- *
- * @return children
- */
- public Map getChildren() {
- return children;
- }
-
- /**
- * Get key.
- *
- * @return node key
- */
- public String getKey() {
- return this.nodeKey;
- }
-
- /**
- * Attach child node.
- *
- * @param node node
- */
- public void attachChild(final PathNode node) {
- this.children.put(node.nodeKey, node);
- node.setPath(PathUtil.getRealPath(path, node.getKey()));
+ void attachChild(final PathNode node) {
+ children.put(node.nodeKey, node);
+ node.setPath(PathUtil.getRealPath(path, node.getNodeKey()));
}
PathNode set(final PathResolve pathResolve, final String value) {
@@ -90,7 +65,7 @@ PathNode set(final PathResolve pathResolve, final String value) {
return this;
}
pathResolve.next();
- log.debug("PathNode set:{},value:{}", pathResolve.getCurrent(), value);
+ log.debug("PathNode set: {}, value: {}", pathResolve.getCurrent(), value);
if (children.containsKey(pathResolve.getCurrent())) {
return children.get(pathResolve.getCurrent()).set(pathResolve, value);
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathResolve.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathResolve.java
index 322f971ae6c96..1f04fde02ccf2 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathResolve.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathResolve.java
@@ -21,14 +21,14 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-/*
+/**
* Path hierarchy resolve.
*
* @author lidongbo
*/
@Slf4j
@RequiredArgsConstructor
-class PathResolve {
+final class PathResolve {
@Getter
private final String path;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathStatus.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathStatus.java
index 029d0db8d8eda..5768454450c24 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathStatus.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathStatus.java
@@ -17,13 +17,12 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.cache;
-/*
+/**
* Path status.
*
* @author lidongbo
*/
public enum PathStatus {
- CHANGING,
- RELEASE
+ CHANGING, RELEASE
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java
index 10f54af0627c0..651831c4c6938 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java
@@ -23,44 +23,43 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.action.IProvider;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.PathUtil;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
-import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.UsualClient;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-/*
+/**
* Zookeeper cache tree.
*
* @author lidongbo
*/
@Slf4j
-public final class PathTree {
+public final class PathTree implements AutoCloseable {
- private final transient ReentrantLock lock = new ReentrantLock();
+ private final IClient client;
+
+ private final IProvider provider;
private final AtomicReference rootNode = new AtomicReference<>();
private final List watcherKeys = new ArrayList<>();
+ private final transient ReentrantLock lock = new ReentrantLock();
+
private boolean executorStart;
private ScheduledExecutorService cacheService;
- private final IClient client;
-
- private final IProvider provider;
-
@Getter
@Setter
private PathStatus status;
@@ -68,11 +67,11 @@ public final class PathTree {
private boolean closed;
public PathTree(final String root, final IClient client) {
- this.rootNode.set(new PathNode(root));
- this.status = PathStatus.RELEASE;
+ rootNode.set(new PathNode(root));
+ status = PathStatus.RELEASE;
+ // TODO consider whether to use a new client alternative to the current
this.client = client;
- // todo It looks unpleasant
- this.provider = ((UsualClient) client).getStrategy().getProvider();
+ provider = client.getExecStrategy().getProvider();
}
/**
@@ -82,30 +81,28 @@ public PathTree(final String root, final IClient client) {
* @throws InterruptedException InterruptedException
*/
public void load() throws KeeperException, InterruptedException {
- final ReentrantLock lock = this.lock;
+ ReentrantLock lock = this.lock;
lock.lockInterruptibly();
if (closed) {
return;
}
try {
if (status == PathStatus.RELEASE) {
- log.debug("loading status:{}", status);
+ log.debug("loading status: {}", status);
status = PathStatus.CHANGING;
-
- final PathNode newRoot = new PathNode(rootNode.get().getKey());
- final List children = provider.getChildren(PathUtil.checkPath(rootNode.get().getKey()));
+ PathNode newRoot = new PathNode(rootNode.get().getNodeKey());
+ List children = provider.getChildren(PathUtil.checkPath(rootNode.get().getNodeKey()));
children.remove(ZookeeperConstants.CHANGING_KEY);
attachIntoNode(children, newRoot);
rootNode.set(newRoot);
-
status = PathStatus.RELEASE;
- log.debug("loading release:{}", status);
+ log.debug("loading release: {}", status);
} else {
log.info("loading but cache status not release");
try {
Thread.sleep(10L);
} catch (final InterruptedException ex) {
- log.error("loading sleep error:{}", ex.getMessage(), ex);
+ log.error("loading sleep error: {}", ex.getMessage(), ex);
}
load();
}
@@ -118,16 +115,16 @@ private void attachIntoNode(final List children, final PathNode pathNode
if (closed) {
return;
}
- log.debug("attechIntoNode children:{}", children);
+ log.debug("attachIntoNode children: {}", children);
if (children.isEmpty()) {
- log.info("attechIntoNode there are no children");
+ log.info("attachIntoNode there are no children");
return;
}
for (String each : children) {
- final String childPath = PathUtil.getRealPath(pathNode.getPath(), each);
- final PathNode current = new PathNode(each, provider.getData(childPath));
+ String childPath = PathUtil.getRealPath(pathNode.getPath(), each);
+ PathNode current = new PathNode(each, provider.getData(childPath));
pathNode.attachChild(current);
- final List subs = provider.getChildren(childPath);
+ List subs = provider.getChildren(childPath);
attachIntoNode(subs, current);
}
}
@@ -138,7 +135,7 @@ private void attachIntoNode(final List children, final PathNode pathNode
* @param period period
*/
public void refreshPeriodic(final long period) {
- final ReentrantLock lock = this.lock;
+ ReentrantLock lock = this.lock;
lock.lock();
if (closed) {
return;
@@ -149,12 +146,13 @@ public void refreshPeriodic(final long period) {
if (threadPeriod < 1) {
threadPeriod = ZookeeperConstants.THREAD_PERIOD;
}
- log.debug("refreshPeriodic:{}", period);
+ log.debug("refreshPeriodic: {}", period);
cacheService = Executors.newSingleThreadScheduledExecutor();
cacheService.scheduleAtFixedRate(new Runnable() {
+
@Override
public void run() {
- log.debug("cacheService run:{}", getStatus());
+ log.debug("cacheService run: {}", getStatus());
if (PathStatus.RELEASE == getStatus()) {
try {
load();
@@ -166,6 +164,7 @@ public void run() {
}, ZookeeperConstants.THREAD_INITIAL_DELAY, threadPeriod, TimeUnit.MILLISECONDS);
executorStart = true;
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+
@Override
public void run() {
log.debug("cacheService stop");
@@ -183,18 +182,19 @@ public void run() {
public void stopRefresh() {
cacheService.shutdown();
executorStart = false;
- log.debug("stopRefresh");
+ log.debug("stop refresh");
}
/**
* Watch data change.
*/
public void watch() {
- watch(new ZookeeperEventListener(rootNode.get().getKey()) {
+ watch(new ZookeeperEventListener(rootNode.get().getNodeKey()) {
+
@Override
public void process(final WatchedEvent event) {
String path = event.getPath();
- log.debug("PathTree Watch event:{}", event.toString());
+ log.debug("PathTree Watch event: {}", event.toString());
switch (event.getType()) {
case NodeCreated:
case NodeDataChanged:
@@ -220,15 +220,15 @@ public void watch(final ZookeeperEventListener zookeeperEventListener) {
if (closed) {
return;
}
- final String key = zookeeperEventListener.getKey();
- log.debug("PathTree Watch:{}", key);
- client.registerWatch(rootNode.get().getKey(), zookeeperEventListener);
+ String key = zookeeperEventListener.getKey();
+ log.debug("PathTree Watch: {}", key);
+ client.registerWatch(rootNode.get().getNodeKey(), zookeeperEventListener);
watcherKeys.add(key);
}
private void processNodeChange(final String path) {
try {
- final String value = provider.getDataString(path);
+ String value = provider.getDataString(path);
put(path, value);
} catch (final KeeperException | InterruptedException ex) {
if (ex instanceof KeeperException.NoNodeException || ex instanceof KeeperException.ConnectionLossException) {
@@ -239,15 +239,6 @@ private void processNodeChange(final String path) {
}
}
- /**
- * Get root node.
- *
- * @return root node
- */
- public PathNode getRootNode() {
- return rootNode.get();
- }
-
/**
* Get node value.
*
@@ -258,7 +249,7 @@ public byte[] getValue(final String path) {
if (closed) {
return null;
}
- final PathNode node = get(path);
+ PathNode node = get(path);
return null == node ? null : node.getValue();
}
@@ -272,8 +263,8 @@ public List getChildren(final String path) {
if (closed) {
return null;
}
- final PathNode node = get(path);
- final List result = new ArrayList<>();
+ PathNode node = get(path);
+ List result = new ArrayList<>();
if (node == null) {
log.info("getChildren null");
return result;
@@ -282,20 +273,19 @@ public List getChildren(final String path) {
log.info("getChildren no child");
return result;
}
- final Iterator children = node.getChildren().values().iterator();
- while (children.hasNext()) {
- result.add(new String(children.next().getValue()));
+ for (final PathNode pathNode : node.getChildren().values()) {
+ result.add(new String(pathNode.getValue()));
}
return result;
}
private PathNode get(final String path) {
- log.debug("PathTree get:{}", path);
+ log.debug("PathTree get: {}", path);
if (Strings.isNullOrEmpty(path) || path.equals(ZookeeperConstants.PATH_SEPARATOR)) {
return rootNode.get();
}
- final String realPath = provider.getRealPath(path);
- final PathResolve pathResolve = new PathResolve(realPath);
+ String realPath = provider.getRealPath(path);
+ PathResolve pathResolve = new PathResolve(realPath);
pathResolve.next();
if (pathResolve.isEnd()) {
log.info("path node get() hit root!");
@@ -311,7 +301,7 @@ private PathNode get(final String path) {
* @param value value
*/
public void put(final String path, final String value) {
- final ReentrantLock lock = this.lock;
+ ReentrantLock lock = this.lock;
lock.lock();
if (closed) {
return;
@@ -319,12 +309,12 @@ public void put(final String path, final String value) {
try {
log.debug("cache put:{},value:{},status:{}", path, value, status);
if (status == PathStatus.RELEASE) {
- this.setStatus(PathStatus.CHANGING);
- final String realPath = provider.getRealPath(path);
- final PathResolve pathResolve = new PathResolve(realPath);
+ setStatus(PathStatus.CHANGING);
+ String realPath = provider.getRealPath(path);
+ PathResolve pathResolve = new PathResolve(realPath);
pathResolve.next();
rootNode.get().set(pathResolve, value);
- this.setStatus(PathStatus.RELEASE);
+ setStatus(PathStatus.RELEASE);
} else {
try {
log.debug("put but cache status not release");
@@ -346,19 +336,18 @@ public void put(final String path, final String value) {
*/
public void delete(final String path) {
log.debug("PathTree begin delete:{}", path);
- final ReentrantLock lock = this.lock;
+ ReentrantLock lock = this.lock;
lock.lock();
if (closed) {
return;
}
-
try {
if (rootNode.get().getChildren().containsKey(path)) {
rootNode.get().getChildren().remove(path);
return;
}
- final String realPath = provider.getRealPath(path);
- final PathResolve pathResolve = new PathResolve(realPath);
+ String realPath = provider.getRealPath(path);
+ PathResolve pathResolve = new PathResolve(realPath);
pathResolve.next();
rootNode.get().delete(pathResolve);
log.debug("PathTree end delete:{}", path);
@@ -367,13 +356,11 @@ public void delete(final String path) {
}
}
- /**
- * Close.
- */
+ @Override
public void close() {
- final ReentrantLock lock = this.lock;
+ ReentrantLock lock = this.lock;
lock.lock();
- this.closed = true;
+ closed = true;
try {
if (executorStart) {
stopRefresh();
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/election/LeaderElection.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/election/LeaderElection.java
index 1702e54226fa2..598d89b588c12 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/election/LeaderElection.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/election/LeaderElection.java
@@ -27,7 +27,7 @@
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
-/*
+/**
* Competition of node write permission.
* It is not recommended to be used as a global variable.
*
@@ -36,41 +36,24 @@
@Slf4j
public abstract class LeaderElection {
- private boolean done;
-
- private int retryCount;
+ private int retryCount = ZookeeperConstants.NODE_ELECTION_RETRY;
- public LeaderElection() {
- retryCount = ZookeeperConstants.NODE_ELECTION_RETRY;
- }
-
- private boolean contend(final String node, final IProvider provider, final ZookeeperEventListener zookeeperEventListener) throws KeeperException, InterruptedException {
- boolean success = false;
- try {
- // todo EPHEMERAL_SEQUENTIAL check index value
- provider.create(node, ZookeeperConstants.CLIENT_ID, CreateMode.EPHEMERAL);
- success = true;
- } catch (final KeeperException.NodeExistsException ex) {
- log.info("contend not success");
- // TODO or changing_key node value == current client id
- provider.exists(node, WatcherCreator.deleteWatcher(zookeeperEventListener));
- }
- return success;
- }
+ private boolean done;
/**
* Listener will be register when the contention of the path is unsuccessful.
*
- * @param nodeBeContend nodeBeContend
+ * @param nodeBeContend node be contend
* @param provider provider
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public void executeContention(final String nodeBeContend, final IProvider provider) throws KeeperException, InterruptedException {
boolean canBegin;
final String realNode = provider.getRealPath(nodeBeContend);
- final String contendNode = PathUtil.getRealPath(realNode, ZookeeperConstants.CHANGING_KEY);
- canBegin = this.contend(contendNode, provider, new ZookeeperEventListener(contendNode) {
+ String contendNode = PathUtil.getRealPath(realNode, ZookeeperConstants.CHANGING_KEY);
+ canBegin = contend(contendNode, provider, new ZookeeperEventListener(contendNode) {
+
@Override
public void process(final WatchedEvent event) {
try {
@@ -85,7 +68,6 @@ public void process(final WatchedEvent event) {
}
}
});
-
if (canBegin) {
try {
action();
@@ -98,6 +80,20 @@ public void process(final WatchedEvent event) {
}
}
+ private boolean contend(final String node, final IProvider provider, final ZookeeperEventListener zookeeperEventListener) throws KeeperException, InterruptedException {
+ boolean result = false;
+ try {
+ // TODO EPHEMERAL_SEQUENTIAL check index value
+ provider.create(node, ZookeeperConstants.CLIENT_ID, CreateMode.EPHEMERAL);
+ result = true;
+ } catch (final KeeperException.NodeExistsException ex) {
+ log.info("contend not result");
+ // TODO or changing_key node value == current client id
+ provider.exists(node, WatcherCreator.deleteWatcher(zookeeperEventListener));
+ }
+ return result;
+ }
+
/**
* Wait done.
*/
@@ -112,10 +108,10 @@ public void waitDone() {
}
/**
- * Contend exec.
+ * Contend execute.
*
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public abstract void action() throws KeeperException, InterruptedException;
@@ -123,6 +119,5 @@ public void waitDone() {
* Callback.
*/
public void callback() {
-
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/AsyncRetryCenter.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/AsyncRetryCenter.java
index 2276006edd6b4..d6e9afe619d2e 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/AsyncRetryCenter.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/AsyncRetryCenter.java
@@ -22,7 +22,7 @@
import java.util.concurrent.DelayQueue;
-/*
+/**
* Async retry center.
*
* @author lidongbo
@@ -41,13 +41,13 @@ public enum AsyncRetryCenter {
private DelayRetryPolicy delayRetryPolicy;
/**
- * init.
+ * Initialize.
*
- * @param delayRetryPolicy delayRetryPolicy
+ * @param delayRetryPolicy delay retry policy
*/
public void init(final DelayRetryPolicy delayRetryPolicy) {
log.debug("delayRetryPolicy init");
- if (delayRetryPolicy == null) {
+ if (null == delayRetryPolicy) {
log.warn("delayRetryPolicy is null and auto init with DelayRetryPolicy.defaultDelayPolicy");
this.delayRetryPolicy = DelayRetryPolicy.defaultDelayPolicy();
return;
@@ -64,7 +64,7 @@ public synchronized void start() {
}
retryThread.setName("retry-thread");
retryThread.start();
- this.started = true;
+ started = true;
}
/**
@@ -73,12 +73,12 @@ public synchronized void start() {
* @param operation operation
*/
public void add(final BaseOperation operation) {
- if (delayRetryPolicy == null) {
+ if (null == delayRetryPolicy) {
log.warn("delayRetryPolicy no init and auto init with DelayRetryPolicy.defaultDelayPolicy");
delayRetryPolicy = DelayRetryPolicy.defaultDelayPolicy();
}
operation.setDelayPolicyExecutor(new DelayPolicyExecutor(delayRetryPolicy));
queue.offer(operation);
- log.debug("enqueue operation:{}", operation.toString());
+ log.debug("enqueue operation: {}", operation.toString());
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayPolicyExecutor.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayPolicyExecutor.java
index 481c58ddfafba..a254a9a202f1a 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayPolicyExecutor.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayPolicyExecutor.java
@@ -17,35 +17,27 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.Random;
-/*
+/**
* Delay policy executor.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
@Slf4j
-public class DelayPolicyExecutor {
+public final class DelayPolicyExecutor {
private final DelayRetryPolicy delayRetryPolicy;
- private final Random random;
+ private final Random random = new Random();
private int executeCount;
- private long executeTick;
-
- public DelayPolicyExecutor() {
- this(DelayRetryPolicy.defaultDelayPolicy());
- }
-
- public DelayPolicyExecutor(final DelayRetryPolicy delayRetryPolicy) {
- this.delayRetryPolicy = delayRetryPolicy;
- this.executeTick = System.currentTimeMillis();
- this.random = new Random();
- }
+ private long executeTick = System.currentTimeMillis();
/**
* Has next.
@@ -57,9 +49,9 @@ public boolean hasNext() {
}
/**
- * Next exec tick.
+ * Next execute tick.
*
- * @return next exec tick
+ * @return next execute tick
*/
public long getNextTick() {
return executeTick;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayRetryPolicy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayRetryPolicy.java
index 05d245387a50e..1297501fc8e80 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayRetryPolicy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/DelayRetryPolicy.java
@@ -18,12 +18,15 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
-/*
- * Delay policy
+/**
+ * Delay policy.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
+@Getter
public class DelayRetryPolicy {
private static final long BASE_DELAY = 10;
@@ -32,32 +35,20 @@ public class DelayRetryPolicy {
private static final int RETRY_COUNT_BOUND = 29;
- @Getter
private final int retryCount;
- @Getter
private final long baseDelay;
- @Getter
private final long delayUpperBound;
- /*
- * Millis
- */
public DelayRetryPolicy(final long baseDelay) {
this(RETRY_COUNT_BOUND, baseDelay, Integer.MAX_VALUE);
}
- public DelayRetryPolicy(final int retryCount, final long baseDelay, final long delayUpperBound) {
- this.retryCount = retryCount;
- this.baseDelay = baseDelay;
- this.delayUpperBound = delayUpperBound;
- }
-
/**
- * Default DelayPolicy.
+ * Default delay policy.
*
- * @return DelayPolicy
+ * @return delay policy
*/
public static DelayRetryPolicy defaultDelayPolicy() {
return new DelayRetryPolicy(BASE_COUNT, BASE_DELAY, Integer.MAX_VALUE);
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryCallable.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryCallable.java
index 32f9ac79c9337..39170dd4ff5bb 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryCallable.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryCallable.java
@@ -24,44 +24,43 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.KeeperException;
-/*
+/**
* Sync retry call.
*
* @author lidongbo
*/
@Slf4j
+@Getter(value = AccessLevel.PROTECTED)
public abstract class RetryCallable {
- @Getter(value = AccessLevel.PROTECTED)
- private final DelayPolicyExecutor delayPolicyExecutor;
-
- @Getter(value = AccessLevel.PROTECTED)
private final IProvider provider;
+ private final DelayPolicyExecutor delayPolicyExecutor;
+
public RetryCallable(final IProvider provider, final DelayRetryPolicy delayRetryPolicy) {
- this.delayPolicyExecutor = new DelayPolicyExecutor(delayRetryPolicy);
this.provider = provider;
+ delayPolicyExecutor = new DelayPolicyExecutor(delayRetryPolicy);
}
/**
* Call the action.
*
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public abstract void call() throws KeeperException, InterruptedException;
/**
* Call without result.
*
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public void exec() throws KeeperException, InterruptedException {
try {
call();
} catch (final KeeperException ex) {
- log.warn("exec KeeperException:{}", ex.getMessage());
+ log.warn("exec KeeperException: {}", ex.getMessage());
delayPolicyExecutor.next();
if (Connection.needReset(ex)) {
provider.resetConnection();
@@ -74,7 +73,7 @@ private void execDelay() throws KeeperException, InterruptedException {
for (;;) {
long delay = delayPolicyExecutor.getNextTick() - System.currentTimeMillis();
if (delay > 0) {
- log.debug("exec delay:{}", delay);
+ log.debug("exec delay: {}", delay);
Thread.sleep(delay);
} else {
if (delayPolicyExecutor.hasNext()) {
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryResultCallable.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryResultCallable.java
index 8cc889d8d1f78..ca06dc8507426 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryResultCallable.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryResultCallable.java
@@ -22,8 +22,8 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.KeeperException;
-/*
- * Sync retry call with Result.
+/**
+ * Sync retry call with result.
*
* @author lidongbo
*/
@@ -41,14 +41,14 @@ public RetryResultCallable(final IProvider provider, final DelayRetryPolicy dela
* Get result.
*
* @return result
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public T getResult() throws KeeperException, InterruptedException {
- if (result == null) {
+ if (null == result) {
exec();
}
- log.debug("result:{}", result);
+ log.debug("result: {}", result);
return result;
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryThread.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryThread.java
index ac8209ef90eff..e84a5e8a7c0c9 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryThread.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/RetryThread.java
@@ -19,6 +19,7 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.BaseOperation;
import lombok.extern.slf4j.Slf4j;
+import org.apache.zookeeper.KeeperException;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.ExecutorService;
@@ -27,9 +28,8 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.zookeeper.KeeperException;
-/*
+/**
* Async retry.
*
* @author lidongbo
@@ -39,8 +39,6 @@ public final class RetryThread extends Thread {
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
- private final ThreadPoolExecutor retryExecutor;
-
private final int maximumPoolSize = corePoolSize;
private final long keepAliveTime = 0;
@@ -49,6 +47,8 @@ public final class RetryThread extends Thread {
private final DelayQueue queue;
+ private final ThreadPoolExecutor retryExecutor;
+
public RetryThread(final DelayQueue queue) {
this.queue = queue;
retryExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(10), new ThreadFactory() {
@@ -56,11 +56,11 @@ public RetryThread(final DelayQueue queue) {
private final AtomicInteger threadIndex = new AtomicInteger(0);
@Override
- public Thread newThread(final Runnable r) {
- Thread thread = new Thread(r);
+ public Thread newThread(final Runnable runnable) {
+ Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.setName("zk-retry-" + threadIndex.incrementAndGet());
- log.debug("new thread:{}", thread.getName());
+ log.debug("new thread: {}", thread.getName());
return thread;
}
});
@@ -74,9 +74,9 @@ public void run() {
final BaseOperation operation;
try {
operation = queue.take();
- log.debug("take operation:{}", operation.toString());
+ log.debug("take operation: {}", operation.toString());
} catch (final InterruptedException ex) {
- log.error("retry interrupt ex:{}", ex.getMessage());
+ log.error("retry interrupt ex: {}", ex.getMessage());
continue;
}
retryExecutor.submit(new Runnable() {
@@ -88,11 +88,11 @@ public void run() {
result = operation.executeOperation();
} catch (final KeeperException | InterruptedException ex) {
result = false;
- log.error("retry disrupt operation:{}, ex:{}", operation.toString(), ex.getMessage());
+ log.error("retry disrupt operation: {}, ex: {}", operation.toString(), ex.getMessage());
}
if (result) {
queue.offer(operation);
- log.debug("enqueue again operation:{}", operation.toString());
+ log.debug("enqueue again operation: {}", operation.toString());
}
}
});
@@ -110,7 +110,6 @@ public void run() {
service.shutdown();
service.awaitTermination(terminationTimeout, timeUnit);
} catch (final InterruptedException ignored) {
- // shutting down anyway, just ignore.
}
}
});
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/PathUtil.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/PathUtil.java
index 9ea8be75d0534..34f41978b31c1 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/PathUtil.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/PathUtil.java
@@ -19,16 +19,20 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
-/*
+/**
* Path util.
*
* @author lidongbo
*/
-public class PathUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PathUtil {
/**
* Get real path.
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/ZookeeperConstants.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/ZookeeperConstants.java
index bbd21297766b1..775bf50a4c702 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/ZookeeperConstants.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/utility/ZookeeperConstants.java
@@ -17,13 +17,17 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
import java.nio.charset.Charset;
-/*
+/**
* Zookeeper client constants.
*
* @author lidongbo
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ZookeeperConstants {
public static final int VERSION = -1;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/CacheClient.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/CacheClient.java
index 2e02745c61e5b..7e9bc54bef129 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/CacheClient.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/CacheClient.java
@@ -30,12 +30,12 @@
import java.io.IOException;
import java.util.List;
-/*
+/**
* Cache Client.
*
- * // todo Partially prepared product
* @author lidongbo
*/
+// TODO Partially prepared product
@Slf4j
public final class CacheClient extends UsualClient {
@@ -58,7 +58,7 @@ public void start() throws IOException, InterruptedException {
@Override
public void close() {
super.close();
- this.pathTree.close();
+ pathTree.close();
}
//todo put it here?
@@ -83,11 +83,11 @@ private PathTree loadPathTree() throws KeeperException, InterruptedException {
}
private PathTree loadPathTree(final String treeRoot) throws KeeperException, InterruptedException {
- PathTree tree = new PathTree(treeRoot, this);
- log.debug("load path tree:{}", treeRoot);
- tree.load();
- tree.watch();
- return tree;
+ PathTree result = new PathTree(treeRoot, this);
+ log.debug("load path result: {}", treeRoot);
+ result.load();
+ result.watch();
+ return result;
}
@Override
@@ -112,23 +112,23 @@ public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback
public byte[] getData(final String key) throws KeeperException, InterruptedException {
String path = PathUtil.getRealPath(getRootNode(), key);
byte[] data = pathTree.getValue(path);
- if (data != null) {
- log.debug("getData cache hit:{}", data);
+ if (null != data) {
+ log.debug("getData cache hit: {}", key);
return data;
}
- log.debug("getData cache not hit:{}", data);
- return getStrategy().getData(key);
+ log.debug("getData cache not hit: {}", key);
+ return getExecStrategy().getData(key);
}
@Override
public List getChildren(final String key) throws KeeperException, InterruptedException {
String path = PathUtil.getRealPath(getRootNode(), key);
List keys = pathTree.getChildren(path);
- if (!keys.isEmpty()) {
- log.debug("getChildren cache hit:{}", keys);
+ if (keys != null && !keys.isEmpty()) {
+ log.debug("getChildren cache hit: {}", keys);
return keys;
}
- log.debug("getChildren cache not hit:{}", keys);
- return getStrategy().getChildren(PathUtil.getRealPath(getRootNode(), key));
+ log.debug("getChildren cache not hit: {}", keys);
+ return getExecStrategy().getChildren(PathUtil.getRealPath(getRootNode(), key));
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/ClientFactory.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/ClientFactory.java
index 8abef6e2bc48e..62c0728b2daba 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/ClientFactory.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/ClientFactory.java
@@ -30,13 +30,13 @@
import java.io.IOException;
import java.util.List;
-/*
+/**
* Client factory.
*
* @author lidongbo
*/
@Slf4j
-public class ClientFactory extends BaseClientFactory {
+public final class ClientFactory extends BaseClientFactory {
private DelayRetryPolicy delayRetryPolicy;
@@ -44,7 +44,7 @@ public class ClientFactory extends BaseClientFactory {
* Create a new client.
*
* @param servers servers
- * @param sessionTimeoutMilliseconds sessionTimeoutMilliseconds
+ * @param sessionTimeoutMilliseconds session timeout milliseconds
* @return ClientFactory this
*/
public ClientFactory newClient(final String servers, final int sessionTimeoutMilliseconds) {
@@ -82,8 +82,8 @@ ClientFactory newCacheClient(final String servers, final int sessionTimeoutMilli
/**
* Wait to register global listener.
*
- * @param globalZookeeperEventListener globalListener
- * @return ClientFactory this
+ * @param globalZookeeperEventListener global listener
+ * @return client factory
*/
public ClientFactory watch(final ZookeeperEventListener globalZookeeperEventListener) {
setGlobalZookeeperEventListener(globalZookeeperEventListener);
@@ -94,7 +94,7 @@ public ClientFactory watch(final ZookeeperEventListener globalZookeeperEventList
* Set client namespace.
*
* @param namespace namespace
- * @return ClientFactory this
+ * @return client factory
*/
public ClientFactory setClientNamespace(final String namespace) {
setNamespace(PathUtil.checkPath(namespace));
@@ -107,7 +107,7 @@ public ClientFactory setClientNamespace(final String namespace) {
* @param scheme scheme
* @param auth auth
* @param authorities authorities
- * @return ClientFactory this
+ * @return client factory
*/
public ClientFactory authorization(final String scheme, final byte[] auth, final List authorities) {
setScheme(scheme);
@@ -119,8 +119,8 @@ public ClientFactory authorization(final String scheme, final byte[] auth, final
/**
* Set delay retry policy.
*
- * @param delayRetryPolicy delayRetryPolicy
- * @return ClientFactory this
+ * @param delayRetryPolicy delay retry policy
+ * @return client factory
*/
public ClientFactory setRetryPolicy(final DelayRetryPolicy delayRetryPolicy) {
this.delayRetryPolicy = delayRetryPolicy;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/UsualClient.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/UsualClient.java
index ea4415f245e04..1d45a411068ab 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/UsualClient.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/UsualClient.java
@@ -42,7 +42,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-/*
+/**
* Usually use client.
*
* @author lidongbo
@@ -53,7 +53,7 @@ public class UsualClient extends BaseClient {
private final Map strategies = new ConcurrentHashMap<>();
@Getter
- private IExecStrategy strategy;
+ private IExecStrategy execStrategy;
protected UsualClient(final BaseContext context) {
super(context);
@@ -61,7 +61,7 @@ protected UsualClient(final BaseContext context) {
@Override
public void close() {
- this.strategies.clear();
+ strategies.clear();
super.close();
}
@@ -69,86 +69,86 @@ public void close() {
public synchronized void useExecStrategy(final StrategyType strategyType) {
log.debug("useExecStrategy:{}", strategyType);
if (strategies.containsKey(strategyType)) {
- strategy = strategies.get(strategyType);
+ execStrategy = strategies.get(strategyType);
return;
}
ITransactionProvider provider = new TransactionProvider(getRootNode(), getHolder(), ZookeeperConstants.WATCHED, getAuthorities());
switch (strategyType) {
case USUAL:
- strategy = new UsualStrategy(provider);
+ execStrategy = new UsualStrategy(provider);
break;
case CONTEND:
- strategy = new ContentionStrategy(provider);
+ execStrategy = new ContentionStrategy(provider);
break;
case TRANSACTION_CONTEND:
- strategy = new TransactionContendStrategy(provider);
+ execStrategy = new TransactionContendStrategy(provider);
break;
case SYNC_RETRY:
- strategy = new SyncRetryStrategy(provider, ((ClientContext) getContext()).getDelayRetryPolicy());
+ execStrategy = new SyncRetryStrategy(provider, ((ClientContext) getContext()).getDelayRetryPolicy());
break;
case ASYNC_RETRY:
- strategy = new AsyncRetryStrategy(provider, ((ClientContext) getContext()).getDelayRetryPolicy());
+ execStrategy = new AsyncRetryStrategy(provider, ((ClientContext) getContext()).getDelayRetryPolicy());
break;
default:
- strategy = new UsualStrategy(provider);
+ execStrategy = new UsualStrategy(provider);
break;
}
- strategies.put(strategyType, strategy);
+ strategies.put(strategyType, execStrategy);
}
@Override
public String getDataString(final String key) throws KeeperException, InterruptedException {
- return strategy.getDataString(key);
+ return execStrategy.getDataString(key);
}
@Override
public byte[] getData(final String key) throws KeeperException, InterruptedException {
- return strategy.getData(key);
+ return execStrategy.getData(key);
}
@Override
public void getData(final String key, final AsyncCallback.DataCallback callback, final Object ctx) throws KeeperException, InterruptedException {
- strategy.getData(key, callback, ctx);
+ execStrategy.getData(key, callback, ctx);
}
@Override
public boolean checkExists(final String key) throws KeeperException, InterruptedException {
- return strategy.checkExists(key);
+ return execStrategy.checkExists(key);
}
@Override
public boolean checkExists(final String key, final Watcher watcher) throws KeeperException, InterruptedException {
- return strategy.checkExists(key, watcher);
+ return execStrategy.checkExists(key, watcher);
}
@Override
public List getChildren(final String key) throws KeeperException, InterruptedException {
- return strategy.getChildren(key);
+ return execStrategy.getChildren(key);
}
@Override
public void createCurrentOnly(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
- this.createNamespace();
+ createNamespace();
if (getRootNode().equals(key)) {
return;
}
- strategy.createCurrentOnly(key, value, createMode);
+ execStrategy.createCurrentOnly(key, value, createMode);
}
@Override
public void createAllNeedPath(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
- this.createNamespace();
+ createNamespace();
if (getRootNode().equals(key)) {
return;
}
- strategy.createAllNeedPath(key, value, createMode);
+ execStrategy.createAllNeedPath(key, value, createMode);
}
@Override
public void update(final String key, final String value) throws KeeperException, InterruptedException {
- strategy.update(key, value);
+ execStrategy.update(key, value);
}
@Override
@@ -157,7 +157,7 @@ public void deleteOnlyCurrent(final String key) throws KeeperException, Interrup
deleteNamespace();
return;
}
- strategy.deleteOnlyCurrent(key);
+ execStrategy.deleteOnlyCurrent(key);
}
@Override
@@ -166,29 +166,29 @@ public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback
deleteNamespace();
return;
}
- strategy.deleteOnlyCurrent(key, callback, ctx);
+ execStrategy.deleteOnlyCurrent(key, callback, ctx);
}
@Override
public void deleteAllChildren(final String key) throws KeeperException, InterruptedException {
- strategy.deleteAllChildren(key);
+ execStrategy.deleteAllChildren(key);
if (getRootNode().equals(key)) {
setRootExist(false);
- log.debug("deleteAllChildren delete root:{}", getRootNode());
+ log.debug("deleteAllChildren delete root: {}", getRootNode());
}
}
@Override
public void deleteCurrentBranch(final String key) throws KeeperException, InterruptedException {
- strategy.deleteCurrentBranch(key);
- if (!strategy.checkExists(getRootNode())) {
+ execStrategy.deleteCurrentBranch(key);
+ if (!execStrategy.checkExists(getRootNode())) {
setRootExist(false);
- log.debug("deleteCurrentBranch delete root:{}", getRootNode());
+ log.debug("deleteCurrentBranch delete root: {}", getRootNode());
}
}
@Override
public BaseTransaction transaction() {
- return strategy.transaction();
+ return execStrategy.transaction();
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClient.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClient.java
index 94e1498ce942e..fb3924e036842 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClient.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClient.java
@@ -24,9 +24,6 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.StrategyType;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.WatcherCreator;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@@ -36,7 +33,11 @@
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.data.ACL;
-/*
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
* Base client.
*
* @author lidongbo
@@ -75,10 +76,10 @@ public void start() throws IOException, InterruptedException {
}
@Override
- public synchronized boolean start(final int wait, final TimeUnit units) throws InterruptedException, IOException {
- log.debug("start wait:{}, units:{}", wait, units);
+ public synchronized boolean start(final int waitingTime, final TimeUnit timeUnit) throws InterruptedException, IOException {
+ log.debug("start wait:{}, units:{}", waitingTime, timeUnit);
prepareStart();
- holder.start(wait, units);
+ holder.start(waitingTime, timeUnit);
return holder.isConnected();
}
@@ -88,8 +89,8 @@ private void prepareStart() {
}
@Override
- public synchronized boolean blockUntilConnected(final int wait, final TimeUnit units) throws InterruptedException {
- long maxWait = units != null ? TimeUnit.MILLISECONDS.convert(wait, units) : 0;
+ public synchronized boolean blockUntilConnected(final int waitingTime, final TimeUnit timeUnit) throws InterruptedException {
+ long maxWait = timeUnit != null ? TimeUnit.MILLISECONDS.convert(waitingTime, timeUnit) : 0;
while (!holder.isConnected()) {
long waitTime = maxWait - CIRCLE_WAIT;
if (waitTime <= 0) {
@@ -123,7 +124,7 @@ void registerWatch(final ZookeeperEventListener globalZookeeperEventListener) {
}
@Override
- public void registerWatch(final String key, final ZookeeperEventListener zookeeperEventListener) {
+ public final void registerWatch(final String key, final ZookeeperEventListener zookeeperEventListener) {
final String path = PathUtil.getRealPath(rootNode, key);
zookeeperEventListener.setPath(path);
context.getWatchers().put(zookeeperEventListener.getKey(), zookeeperEventListener);
@@ -131,7 +132,7 @@ public void registerWatch(final String key, final ZookeeperEventListener zookeep
}
@Override
- public void unregisterWatch(final String key) {
+ public final void unregisterWatch(final String key) {
if (Strings.isNullOrEmpty(key)) {
throw new IllegalArgumentException("key should not be blank");
}
@@ -171,7 +172,7 @@ public void process(final WatchedEvent event) {
log.debug("created root:{}", rootNode);
}
- protected void deleteNamespace() throws KeeperException, InterruptedException {
+ protected final void deleteNamespace() throws KeeperException, InterruptedException {
try {
holder.getZooKeeper().delete(rootNode, ZookeeperConstants.VERSION);
} catch (final KeeperException.NodeExistsException | KeeperException.NotEmptyException ex) {
@@ -181,7 +182,7 @@ protected void deleteNamespace() throws KeeperException, InterruptedException {
log.debug("delete root:{}", rootNode);
}
- void setAuthorities(final String scheme, final byte[] auth, final List authorities) {
+ final void setAuthorities(final String scheme, final byte[] auth, final List authorities) {
context.setScheme(scheme);
context.setAuth(auth);
this.authorities = authorities;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientFactory.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientFactory.java
index daf1256c8cdc1..0f6393d17cf07 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientFactory.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientFactory.java
@@ -30,7 +30,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
-/*
+/**
* Base client factory.
*
* @author lidongbo
@@ -69,16 +69,16 @@ public IClient start() throws IOException, InterruptedException {
/**
* Start until Timeout.
*
- * @param wait wait
- * @param units units
- * @return connected
+ * @param waitingTime waiting time
+ * @param timeUnit time unit
+ * @return connected or not
* @throws IOException IO Exception
- * @throws InterruptedException InterruptedException
- * @throws KeeperException OperationTimeoutException
+ * @throws InterruptedException interrupted exception
+ * @throws KeeperException operation timeout exception
*/
- public IClient start(final int wait, final TimeUnit units) throws IOException, InterruptedException, KeeperException {
+ public IClient start(final int waitingTime, final TimeUnit timeUnit) throws IOException, InterruptedException, KeeperException {
prepareClient();
- if (!client.start(wait, units)) {
+ if (!client.start(waitingTime, timeUnit)) {
client.close();
throw new KeeperException.OperationTimeoutException();
}
@@ -87,11 +87,11 @@ public IClient start(final int wait, final TimeUnit units) throws IOException, I
private void prepareClient() {
client.setRootNode(namespace);
- if (scheme == null) {
+ if (null == scheme) {
authorities = ZooDefs.Ids.OPEN_ACL_UNSAFE;
}
client.setAuthorities(scheme, auth, authorities);
- if (globalZookeeperEventListener != null) {
+ if (null != globalZookeeperEventListener) {
client.registerWatch(globalZookeeperEventListener);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseContext.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseContext.java
index c66d0536d1135..c5b7cde3d40ce 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseContext.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseContext.java
@@ -18,13 +18,14 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
-/*
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
* Base context.
*
* @author lidongbo
@@ -49,6 +50,6 @@ public abstract class BaseContext {
* Close.
*/
public void close() {
- this.watchers.clear();
+ watchers.clear();
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseOperation.java
index 3cb6f72631b86..57d98c8b0c0eb 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseOperation.java
@@ -21,6 +21,7 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.retry.DelayPolicyExecutor;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.Connection;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.KeeperException;
@@ -28,11 +29,12 @@
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
-/*
+/**
* Base async retry operation.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
@Slf4j
public abstract class BaseOperation implements Delayed {
@@ -42,22 +44,15 @@ public abstract class BaseOperation implements Delayed {
@Setter
private DelayPolicyExecutor delayPolicyExecutor;
- protected BaseOperation(final IProvider provider) {
- this.provider = provider;
- }
-
@Override
- public long getDelay(final TimeUnit unit) {
+ public final long getDelay(final TimeUnit timeUnit) {
long absoluteBlock = this.delayPolicyExecutor.getNextTick() - System.currentTimeMillis();
- log.debug("queue getDelay block:{}", absoluteBlock);
- return unit.convert(absoluteBlock, TimeUnit.MILLISECONDS);
+ log.debug("queue getDelay block: {}", absoluteBlock);
+ return timeUnit.convert(absoluteBlock, TimeUnit.MILLISECONDS);
}
- /**
- * Queue precedence.
- */
@Override
- public int compareTo(final Delayed delayed) {
+ public final int compareTo(final Delayed delayed) {
return (int) (this.getDelay(TimeUnit.MILLISECONDS) - delayed.getDelay(TimeUnit.MILLISECONDS));
}
@@ -67,8 +62,8 @@ public int compareTo(final Delayed delayed) {
* Queue precedence.
*
* @return whether or not continue enqueue
- * @throws KeeperException Keeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException keeper exception
+ * @throws InterruptedException interrupted exception
*/
public boolean executeOperation() throws KeeperException, InterruptedException {
boolean result;
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/Holder.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/Holder.java
index bda6177be91fe..90fac561e8e47 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/Holder.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/Holder.java
@@ -20,11 +20,9 @@
import com.google.common.base.Strings;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.KeeperException;
@@ -32,11 +30,17 @@
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
-/*
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
* Zookeeper connection holder.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
+@Getter
@Slf4j
public class Holder {
@@ -45,22 +49,16 @@ public class Holder {
@Getter(value = AccessLevel.PROTECTED)
private final BaseContext context;
- @Getter
private ZooKeeper zooKeeper;
- @Getter
@Setter(value = AccessLevel.PROTECTED)
private boolean connected;
- Holder(final BaseContext context) {
- this.context = context;
- }
-
/**
* Start.
*
- * @throws IOException IO Exception
- * @throws InterruptedException InterruptedException
+ * @throws IOException IO exception
+ * @throws InterruptedException interrupted exception
*/
public void start() throws IOException, InterruptedException {
initZookeeper();
@@ -73,25 +71,25 @@ protected void start(final int wait, final TimeUnit units) throws IOException, I
}
protected void initZookeeper() throws IOException {
- log.debug("Holder servers:{},sessionTimeOut:{}", context.getServers(), context.getSessionTimeOut());
+ log.debug("Holder servers: {}, sessionTimeOut: {}", context.getServers(), context.getSessionTimeOut());
zooKeeper = new ZooKeeper(context.getServers(), context.getSessionTimeOut(), startWatcher());
if (!Strings.isNullOrEmpty(context.getScheme())) {
zooKeeper.addAuthInfo(context.getScheme(), context.getAuth());
- log.debug("Holder scheme:{},auth:{}", context.getScheme(), context.getAuth());
+ log.debug("Holder scheme: {}, auth: {}", context.getScheme(), context.getAuth());
}
}
private Watcher startWatcher() {
return new Watcher() {
+ @Override
public void process(final WatchedEvent event) {
- log.debug("event-----------:" + event.toString());
processConnection(event);
if (!isConnected()) {
return;
}
processGlobalListener(event);
- // todo filter event type or path
+ // TODO filter event type or path
if (event.getType() == Event.EventType.None) {
return;
}
@@ -103,7 +101,7 @@ public void process(final WatchedEvent event) {
}
protected void processConnection(final WatchedEvent event) {
- log.debug("BaseClient process event:{}", event.toString());
+ log.debug("BaseClient process event: {}", event.toString());
if (Watcher.Event.EventType.None == event.getType()) {
if (Watcher.Event.KeeperState.SyncConnected == event.getState()) {
connectLatch.countDown();
@@ -115,7 +113,7 @@ protected void processConnection(final WatchedEvent event) {
log.warn("startWatcher Event.KeeperState.Expired");
reset();
} catch (final IOException | InterruptedException ex) {
- log.error("event state Expired:{}", ex.getMessage(), ex);
+ log.error("event state Expired: {}", ex.getMessage(), ex);
}
} else if (Watcher.Event.KeeperState.Disconnected == event.getState()) {
connected = false;
@@ -124,7 +122,7 @@ protected void processConnection(final WatchedEvent event) {
}
private void processGlobalListener(final WatchedEvent event) {
- if (context.getGlobalZookeeperEventListener() != null) {
+ if (null != context.getGlobalZookeeperEventListener()) {
context.getGlobalZookeeperEventListener().process(event);
log.debug("Holder {} process", ZookeeperConstants.GLOBAL_LISTENER_KEY);
}
@@ -133,8 +131,8 @@ private void processGlobalListener(final WatchedEvent event) {
private void processUsualListener(final WatchedEvent event) {
if (!context.getWatchers().isEmpty()) {
for (ZookeeperEventListener zookeeperEventListener : context.getWatchers().values()) {
- if (zookeeperEventListener.getPath() == null || event.getPath().startsWith(zookeeperEventListener.getPath())) {
- log.debug("listener process:{}, listener:{}", zookeeperEventListener.getPath(), zookeeperEventListener.getKey());
+ if (null == zookeeperEventListener.getPath() || event.getPath().startsWith(zookeeperEventListener.getPath())) {
+ log.debug("listener process: {}, listener: {}", zookeeperEventListener.getPath(), zookeeperEventListener.getKey());
zookeeperEventListener.process(event);
}
}
@@ -143,23 +141,21 @@ private void processUsualListener(final WatchedEvent event) {
private boolean checkPath(final String path) {
try {
- return zooKeeper.exists(path, true) != null;
+ return null != zooKeeper.exists(path, true);
} catch (final KeeperException | InterruptedException ignore) {
+ return false;
}
- return false;
}
/**
* Reset connection.
*
- * @throws IOException IO Exception
- * @throws InterruptedException InterruptedException
+ * @throws IOException IO exception
+ * @throws InterruptedException interrupted exception
*/
public void reset() throws IOException, InterruptedException {
- log.debug("zk reset....................................");
close();
start();
- log.debug("....................................zk reset");
}
/**
@@ -177,7 +173,7 @@ public void process(final WatchedEvent watchedEvent) {
zooKeeper.close();
connected = false;
log.debug("zk closed");
- this.context.close();
+ context.close();
} catch (final InterruptedException ex) {
log.warn("Holder close:{}", ex.getMessage());
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateAllNeedOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateAllNeedOperation.java
index 20b83352e61df..85d36f8b35824 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateAllNeedOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateAllNeedOperation.java
@@ -23,12 +23,12 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which CreateAllNeed action.
+/**
+ * Async retry operation which create all need action.
*
* @author lidongbo
*/
-public class CreateAllNeedOperation extends BaseOperation {
+public final class CreateAllNeedOperation extends BaseOperation {
private final String key;
@@ -50,6 +50,6 @@ protected void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("CreateAllNeedOperation key:%s,value:%s,createMode:%s", key, value, createMode.name());
+ return String.format("CreateAllNeedOperation key: %s,value: %s, createMode: %s", key, value, createMode.name());
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateCurrentOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateCurrentOperation.java
index dff46ade9dac8..d41a400d0d5ea 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateCurrentOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/CreateCurrentOperation.java
@@ -22,12 +22,12 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which CreateCurrent action.
+/**
+ * Async retry operation which create current action.
*
* @author lidongbo
*/
-public class CreateCurrentOperation extends BaseOperation {
+public final class CreateCurrentOperation extends BaseOperation {
private final String key;
@@ -49,6 +49,6 @@ public void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("CreateCurrentOperation key:%s,value:%s,createMode:%s", key, value, createMode.name());
+ return String.format("CreateCurrentOperation key: %s, value: %s, createMode: %s", key, value, createMode.name());
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteAllChildrenOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteAllChildrenOperation.java
index bb718c6aeb926..d323b7b8683bb 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteAllChildrenOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteAllChildrenOperation.java
@@ -22,12 +22,12 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.strategy.UsualStrategy;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which DeleteAllChildren action.
+/**
+ * Async retry operation which delete all children action.
*
* @author lidongbo
*/
-public class DeleteAllChildrenOperation extends BaseOperation {
+public final class DeleteAllChildrenOperation extends BaseOperation {
private final String key;
@@ -43,6 +43,6 @@ protected void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("DeleteAllChildrenOperation key:%s", key);
+ return String.format("DeleteAllChildrenOperation key: %s", key);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentBranchOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentBranchOperation.java
index bfa2d9aa032f4..1a13533d39124 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentBranchOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentBranchOperation.java
@@ -22,12 +22,12 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.strategy.UsualStrategy;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which DeleteCurrentBranch action.
+/**
+ * Async retry operation which delete current branch action.
*
* @author lidongbo
*/
-public class DeleteCurrentBranchOperation extends BaseOperation {
+public final class DeleteCurrentBranchOperation extends BaseOperation {
private final String key;
@@ -43,6 +43,6 @@ protected void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("DeleteCurrentBranchOperation key:%s", key);
+ return String.format("DeleteCurrentBranchOperation key: %s", key);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentOperation.java
index bdf59b4e413e2..04afe73bdb78b 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/DeleteCurrentOperation.java
@@ -21,12 +21,12 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.BaseOperation;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which DeleteCurrent action.
+/**
+ * Async retry operation which delete current action.
*
* @author lidongbo
*/
-public class DeleteCurrentOperation extends BaseOperation {
+public final class DeleteCurrentOperation extends BaseOperation {
private final String key;
@@ -42,6 +42,6 @@ protected void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("DeleteCurrentOperation key:%s", key);
+ return String.format("DeleteCurrentOperation key: %s", key);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/UpdateOperation.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/UpdateOperation.java
index c46ec5fc1fb61..52b486d16ac44 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/UpdateOperation.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/operation/UpdateOperation.java
@@ -21,12 +21,12 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.BaseOperation;
import org.apache.zookeeper.KeeperException;
-/*
- * Async retry operation which Update action.
+/**
+ * Async retry operation which update action.
*
* @author lidongbo
*/
-public class UpdateOperation extends BaseOperation {
+public final class UpdateOperation extends BaseOperation {
private final String key;
@@ -45,6 +45,6 @@ protected void execute() throws KeeperException, InterruptedException {
@Override
public String toString() {
- return String.format("UpdateOperation key:%s,value:%s", key, value);
+ return String.format("UpdateOperation key: %s, value: %s", key, value);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/BaseProvider.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/BaseProvider.java
index 89c8a4ce5f39f..c94858be9b889 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/BaseProvider.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/BaseProvider.java
@@ -23,11 +23,9 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.Holder;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.BaseTransaction;
-import java.io.IOException;
-import java.util.List;
-import java.util.Stack;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.CreateMode;
@@ -35,19 +33,24 @@
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.ACL;
-/*
+import java.io.IOException;
+import java.util.List;
+import java.util.Stack;
+
+/**
* Base provider.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
@Slf4j
public class BaseProvider implements IProvider {
@Getter
- private final Holder holder;
+ private final String rootNode;
@Getter
- private final String rootNode;
+ private final Holder holder;
@Getter(value = AccessLevel.PROTECTED)
private final boolean watched;
@@ -55,55 +58,48 @@ public class BaseProvider implements IProvider {
@Getter(value = AccessLevel.PROTECTED)
private final List authorities;
- public BaseProvider(final String rootNode, final Holder holder, final boolean watched, final List authorities) {
- this.rootNode = rootNode;
- this.holder = holder;
- this.watched = watched;
- this.authorities = authorities;
- }
-
@Override
- public String getDataString(final String key) throws KeeperException, InterruptedException {
+ public final String getDataString(final String key) throws KeeperException, InterruptedException {
return new String(getData(key));
}
@Override
- public byte[] getData(final String key) throws KeeperException, InterruptedException {
+ public final byte[] getData(final String key) throws KeeperException, InterruptedException {
return holder.getZooKeeper().getData(key, watched, null);
}
@Override
- public void getData(final String key, final AsyncCallback.DataCallback callback, final Object ctx) {
+ public final void getData(final String key, final AsyncCallback.DataCallback callback, final Object ctx) {
holder.getZooKeeper().getData(key, watched, callback, ctx);
}
@Override
- public boolean exists(final String key) throws KeeperException, InterruptedException {
+ public final boolean exists(final String key) throws KeeperException, InterruptedException {
return null != holder.getZooKeeper().exists(key, watched);
}
@Override
- public boolean exists(final String key, final Watcher watcher) throws KeeperException, InterruptedException {
+ public final boolean exists(final String key, final Watcher watcher) throws KeeperException, InterruptedException {
return null != holder.getZooKeeper().exists(key, watcher);
}
@Override
- public List getChildren(final String key) throws KeeperException, InterruptedException {
+ public final List getChildren(final String key) throws KeeperException, InterruptedException {
return holder.getZooKeeper().getChildren(key, watched);
}
@Override
- public void create(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
+ public final void create(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
if (exists(key)) {
- log.debug("node exist:{}", key);
+ log.debug("node exist: {}", key);
return;
}
holder.getZooKeeper().create(key, value.getBytes(ZookeeperConstants.UTF_8), authorities, createMode);
- log.debug("BaseProvider createCurrentOnly:{}", key);
+ log.debug("BaseProvider createCurrentOnly: {}", key);
}
@Override
- public boolean update(final String key, final String value) throws KeeperException, InterruptedException {
+ public final boolean update(final String key, final String value) throws KeeperException, InterruptedException {
if (exists(key)) {
holder.getZooKeeper().setData(key, value.getBytes(ZookeeperConstants.UTF_8), ZookeeperConstants.VERSION);
return true;
@@ -112,36 +108,36 @@ public boolean update(final String key, final String value) throws KeeperExcepti
}
@Override
- public void delete(final String key) throws KeeperException, InterruptedException {
+ public final void delete(final String key) throws KeeperException, InterruptedException {
holder.getZooKeeper().delete(key, ZookeeperConstants.VERSION);
- log.debug("BaseProvider deleteOnlyCurrent:{}", key);
+ log.debug("BaseProvider deleteOnlyCurrent: {}", key);
}
@Override
- public void delete(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) {
+ public final void delete(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) {
holder.getZooKeeper().delete(key, ZookeeperConstants.VERSION, callback, ctx);
- log.debug("BaseProvider deleteOnlyCurrent:{},ctx:{}", key, ctx);
+ log.debug("BaseProvider deleteOnlyCurrent: {}, ctx: {}", key, ctx);
}
@Override
- public String getRealPath(final String path) {
+ public final String getRealPath(final String path) {
return PathUtil.getRealPath(rootNode, path);
}
@Override
- public List getNecessaryPaths(final String key) {
+ public final List getNecessaryPaths(final String key) {
List nodes = PathUtil.getPathOrderNodes(rootNode, key);
nodes.remove(rootNode);
return nodes;
}
@Override
- public Stack getDeletingPaths(final String key) {
+ public final Stack getDeletingPaths(final String key) {
return PathUtil.getPathReverseNodes(rootNode, key);
}
@Override
- public void executeContention(final LeaderElection election) throws KeeperException, InterruptedException {
+ public final void executeContention(final LeaderElection election) throws KeeperException, InterruptedException {
this.executeContention(rootNode, election);
}
@@ -150,11 +146,11 @@ private void executeContention(final String nodeBeCompete, final LeaderElection
}
@Override
- public void resetConnection() {
+ public final void resetConnection() {
try {
holder.reset();
} catch (final InterruptedException | IOException ex) {
- log.error("resetConnection Exception:{}", ex.getMessage(), ex);
+ log.error("resetConnection Exception: {}", ex.getMessage(), ex);
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/TransactionProvider.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/TransactionProvider.java
index 591e8180a5ccd..89a2d679ed04b 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/TransactionProvider.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/provider/TransactionProvider.java
@@ -21,18 +21,18 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.Holder;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.BaseTransaction;
-import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.ZKTransaction;
+import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.ZooKeeperTransaction;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.ACL;
import java.util.List;
-/*
+/**
* Provider with transaction.
*
* @author lidongbo
*/
-public class TransactionProvider extends BaseProvider implements ITransactionProvider {
+public final class TransactionProvider extends BaseProvider implements ITransactionProvider {
public TransactionProvider(final String rootNode, final Holder holder, final boolean watched, final List authorities) {
super(rootNode, holder, watched, authorities);
@@ -45,6 +45,6 @@ public void createInTransaction(final String key, final String value, final Crea
@Override
public BaseTransaction transaction() {
- return new ZKTransaction(getRootNode(), getHolder());
+ return new ZooKeeperTransaction(getRootNode(), getHolder());
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientContext.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientContext.java
index 58aaf274c7700..5e190b45a21ed 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientContext.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientContext.java
@@ -23,7 +23,7 @@
import lombok.Getter;
import lombok.Setter;
-/*
+/**
* Client context.
*
* @author lidongbo
@@ -37,29 +37,26 @@ public final class ClientContext extends BaseContext {
private BaseClientFactory clientFactory;
public ClientContext(final String servers, final int sessionTimeoutMilliseconds) {
- super();
setServers(servers);
setSessionTimeOut(sessionTimeoutMilliseconds);
}
- /**
- * Close.
- */
- public void close() {
- super.close();
- this.delayRetryPolicy = null;
- this.clientFactory = null;
- }
-
/**
* Update context.
*
* @param context context
*/
public void updateContext(final ClientContext context) {
- this.delayRetryPolicy = context.getDelayRetryPolicy();
- this.clientFactory = context.clientFactory;
+ delayRetryPolicy = context.getDelayRetryPolicy();
+ clientFactory = context.clientFactory;
getWatchers().clear();
getWatchers().putAll(context.getWatchers());
}
+
+ @Override
+ public void close() {
+ super.close();
+ delayRetryPolicy = null;
+ clientFactory = null;
+ }
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientTask.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientTask.java
index b42bca471806b..62016a191af0a 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientTask.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ClientTask.java
@@ -22,7 +22,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.KeeperException;
-/*
+/**
* Client task.
*
* @author lidongbo
@@ -37,13 +37,13 @@ public abstract class ClientTask implements Runnable {
* Run.
*
* @param provider provider
- * @throws KeeperException Zookeeper Exception
- * @throws InterruptedException InterruptedException
+ * @throws KeeperException zookeeper exception
+ * @throws InterruptedException interrupted exception
*/
public abstract void run(IProvider provider) throws KeeperException, InterruptedException;
@Override
- public void run() {
+ public final void run() {
try {
run(provider);
} catch (final KeeperException | InterruptedException ex) {
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/Connection.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/Connection.java
index 896a563d8c959..6e67b89f76383 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/Connection.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/Connection.java
@@ -17,17 +17,20 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.zookeeper.KeeperException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-/*
+/**
* Zookeeper connection check.
*
* @author lidongbo
*/
-public class Connection {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class Connection {
//is need reset
private static final Map EXCEPTION_RESETS = new ConcurrentHashMap<>();
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/StrategyType.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/StrategyType.java
index ddec170caf048..f0e7573b0501c 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/StrategyType.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/StrategyType.java
@@ -17,7 +17,7 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section;
-/*
+/**
* Exec strategy type.
*
* @author lidongbo
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/WatcherCreator.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/WatcherCreator.java
index dd96d2c3e7e12..17ec47f1adb79 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/WatcherCreator.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/WatcherCreator.java
@@ -17,17 +17,20 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
-/*
+/**
* Build public watcher.
*
* @author lidongbo
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Slf4j
-public class WatcherCreator {
+public final class WatcherCreator {
/**
* Get string type data.
@@ -42,7 +45,7 @@ public static Watcher deleteWatcher(final ZookeeperEventListener zookeeperEventL
public void process(final WatchedEvent event) {
if (zookeeperEventListener.getPath().equals(event.getPath()) && Event.EventType.NodeDeleted.equals(event.getType())) {
zookeeperEventListener.process(event);
- log.debug("delete node event:{}", event.toString());
+ log.debug("delete node event: {}", event.toString());
}
}
};
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ZookeeperEventListener.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ZookeeperEventListener.java
index 80629a6776d81..a57a7816a328d 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ZookeeperEventListener.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/section/ZookeeperEventListener.java
@@ -21,7 +21,7 @@
import lombok.Setter;
import org.apache.zookeeper.WatchedEvent;
-/*
+/**
* Watch event listener.
*
* @author lidongbo
@@ -39,8 +39,8 @@ public ZookeeperEventListener() {
}
public ZookeeperEventListener(final String path) {
- this.path = path;
this.key = path + System.currentTimeMillis();
+ this.path = path;
}
/**
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/AsyncRetryStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/AsyncRetryStrategy.java
index 57a9793b09ced..f7607a4a75fb7 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/AsyncRetryStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/AsyncRetryStrategy.java
@@ -31,13 +31,13 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
-/*
+/**
* Async retry strategy.
*
* @author lidongbo
*/
@Slf4j
-public class AsyncRetryStrategy extends SyncRetryStrategy {
+public final class AsyncRetryStrategy extends SyncRetryStrategy {
public AsyncRetryStrategy(final IProvider provider, final DelayRetryPolicy delayRetryPolicy) {
super(provider, delayRetryPolicy);
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/BaseStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/BaseStrategy.java
index 6963b9baf1ad1..0b29da0ca9911 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/BaseStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/BaseStrategy.java
@@ -21,29 +21,27 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.action.IProvider;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.BaseTransaction;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import org.apache.zookeeper.KeeperException;
-/*
- * Base exec strategy.
+/**
+ * Base execute strategy.
*
* @author lidongbo
*/
+@RequiredArgsConstructor
public abstract class BaseStrategy implements IExecStrategy {
@Getter
private final IProvider provider;
- public BaseStrategy(final IProvider provider) {
- this.provider = provider;
- }
-
@Override
- public String getDataString(final String key) throws KeeperException, InterruptedException {
+ public final String getDataString(final String key) throws KeeperException, InterruptedException {
return new String(getData(key));
}
@Override
- public BaseTransaction transaction() {
+ public final BaseTransaction transaction() {
return provider.transaction();
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/ContentionStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/ContentionStrategy.java
index 8f39f50d7cd2d..b98e145e62281 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/ContentionStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/ContentionStrategy.java
@@ -30,8 +30,8 @@
import java.util.List;
import java.util.Stack;
-/*
- * The ContentionStrategy is effective only when all the clients of the node which be competitive are using ContentionStrategy.
+/**
+ * The contention strategy is effective only when all the clients of the node which be competitive are using contention strategy.
*
* @author lidongbo
*/
@@ -46,20 +46,20 @@ public ContentionStrategy(final IProvider provider) {
* Don't use this if you don't have to use it.
*/
@Override
- public void getData(final String key, final AsyncCallback.DataCallback callback, final Object ctx) throws KeeperException, InterruptedException {
- LeaderElection election = new LeaderElection() {
+ public final void getData(final String key, final AsyncCallback.DataCallback callback, final Object ctx) throws KeeperException, InterruptedException {
+ getProvider().executeContention(new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
getProvider().getData(getProvider().getRealPath(key), callback, ctx);
- log.debug("ContentionStrategy getData action:{}", key);
+ log.debug("ContentionStrategy getData action: {}", key);
}
- };
- getProvider().executeContention(election);
+ });
log.debug("ContentionStrategy getData executeContention");
}
@Override
- public void createCurrentOnly(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
+ public final void createCurrentOnly(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
LeaderElection election = buildCreateElection(key, value, createMode, null);
getProvider().executeContention(election);
log.debug("ContentionStrategy createCurrentOnly executeContention");
@@ -68,6 +68,7 @@ public void createCurrentOnly(final String key, final String value, final Create
private LeaderElection buildCreateElection(final String key, final String value, final CreateMode createMode, final ContentionCallback contentionCallback) {
return new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
getProvider().create(getProvider().getRealPath(key), value, createMode);
@@ -75,7 +76,7 @@ public void action() throws KeeperException, InterruptedException {
@Override
public void callback() {
- if (contentionCallback != null) {
+ if (null != contentionCallback) {
contentionCallback.processResult();
}
}
@@ -83,7 +84,7 @@ public void callback() {
}
@Override
- public void update(final String key, final String value) throws KeeperException, InterruptedException {
+ public final void update(final String key, final String value) throws KeeperException, InterruptedException {
LeaderElection election = buildUpdateElection(key, value, null);
getProvider().executeContention(election);
log.debug("ContentionStrategy update executeContention");
@@ -92,15 +93,16 @@ public void update(final String key, final String value) throws KeeperException,
private LeaderElection buildUpdateElection(final String key, final String value, final ContentionCallback contentionCallback) {
return new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
getProvider().update(getProvider().getRealPath(key), value);
- log.debug("ContentionStrategy update action:{},value:{}", key, value);
+ log.debug("ContentionStrategy update action: {}, value: {}", key, value);
}
@Override
public void callback() {
- if (contentionCallback != null) {
+ if (null != contentionCallback) {
contentionCallback.processResult();
}
}
@@ -108,7 +110,7 @@ public void callback() {
}
@Override
- public void deleteOnlyCurrent(final String key) throws KeeperException, InterruptedException {
+ public final void deleteOnlyCurrent(final String key) throws KeeperException, InterruptedException {
LeaderElection election = buildDeleteElection(key, null);
getProvider().executeContention(election);
log.debug("ContentionStrategy deleteOnlyCurrent executeContention");
@@ -116,18 +118,20 @@ public void deleteOnlyCurrent(final String key) throws KeeperException, Interrup
}
@Override
- public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
+ public final void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
getProvider().executeContention(new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
getProvider().delete(getProvider().getRealPath(key), callback, ctx);
- log.debug("ContentionStrategy deleteOnlyCurrent action:{},ctx:{}", key, ctx);
+ log.debug("ContentionStrategy deleteOnlyCurrent action: {}, ctx: {}", key, ctx);
}
});
}
private LeaderElection buildDeleteElection(final String key, final ContentionCallback contentionCallback) {
return new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
getProvider().delete(getProvider().getRealPath(key));
@@ -135,7 +139,7 @@ public void action() throws KeeperException, InterruptedException {
@Override
public void callback() {
- if (contentionCallback != null) {
+ if (null != contentionCallback) {
contentionCallback.processResult();
}
}
@@ -152,15 +156,16 @@ public void createAllNeedPath(final String key, final String value, final Create
private LeaderElection buildCreateAllNeedElection(final String key, final String value, final CreateMode createMode, final ContentionCallback contentionCallback) {
return new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
- log.debug("ContentionStrategy createAllNeedPath action:{}", key);
+ log.debug("ContentionStrategy createAllNeedPath action: {}", key);
createBegin(getProvider().getRealPath(key), value, createMode);
}
@Override
public void callback() {
- if (contentionCallback != null) {
+ if (null != contentionCallback) {
contentionCallback.processResult();
}
}
@@ -168,7 +173,7 @@ public void callback() {
}
private void createBegin(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
- // todo start with /
+ // TODO start with /
if (!key.contains(ZookeeperConstants.PATH_SEPARATOR)) {
getProvider().create(key, value, createMode);
return;
@@ -176,10 +181,10 @@ private void createBegin(final String key, final String value, final CreateMode
List nodes = getProvider().getNecessaryPaths(key);
for (int i = 0; i < nodes.size(); i++) {
if (getProvider().exists(nodes.get(i))) {
- log.info("create node exist:{}", nodes.get(i));
+ log.info("create node exist: {}", nodes.get(i));
continue;
}
- log.debug("create node not exist:", nodes.get(i));
+ log.debug("create node not exist: {}", nodes.get(i));
if (i == nodes.size() - 1) {
getProvider().create(nodes.get(i), value, createMode);
} else {
@@ -191,6 +196,7 @@ private void createBegin(final String key, final String value, final CreateMode
@Override
public void deleteAllChildren(final String key) throws KeeperException, InterruptedException {
getProvider().executeContention(new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
deleteChildren(getProvider().getRealPath(key), true);
@@ -202,13 +208,13 @@ public void action() throws KeeperException, InterruptedException {
private void deleteChildren(final String key, final boolean deleteCurrentNode) throws KeeperException, InterruptedException {
List children = getProvider().getChildren(key);
log.debug("deleteChildren:{}", children);
- for (int i = 0; i < children.size(); i++) {
- String child = PathUtil.getRealPath(key, children.get(i));
+ for (String aChildren : children) {
+ String child = PathUtil.getRealPath(key, aChildren);
if (!getProvider().exists(child)) {
- log.info("delete not exist:{}", child);
+ log.info("delete not exist: {}", child);
continue;
}
- log.debug("deleteChildren:{}", child);
+ log.debug("deleteChildren: {}", child);
deleteChildren(child, true);
}
if (deleteCurrentNode) {
@@ -219,6 +225,7 @@ private void deleteChildren(final String key, final boolean deleteCurrentNode) t
@Override
public void deleteCurrentBranch(final String key) throws KeeperException, InterruptedException {
getProvider().executeContention(new LeaderElection() {
+
@Override
public void action() throws KeeperException, InterruptedException {
deleteBranch(getProvider().getRealPath(key));
@@ -237,16 +244,16 @@ private void deleteBranch(final String key) throws KeeperException, InterruptedE
try {
getProvider().delete(node);
} catch (KeeperException.NotEmptyException e) {
- log.warn("deleteBranch {} exist other children:{}", node, this.getChildren(node));
+ log.warn("deleteBranch {} exist other children: {}", node, this.getChildren(node));
log.debug(e.getMessage());
return;
}
}
- log.info("deleteBranch node not exist:{}", node);
+ log.info("deleteBranch node not exist: {}", node);
}
}
- //todo Use arbitrary competitive nodes
+ //TODO Use arbitrary competitive nodes
//IExecStrategy convert to ContentionStrategy
/*public void createCurrentOnly(final String key, final String value, final CreateMode createMode, final ContentionCallback callback) throws KeeperException, InterruptedException {
getProvider().executeContention(buildCreateElection(key, value, createMode, callback));
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/SyncRetryStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/SyncRetryStrategy.java
index 07def3bbbc677..9781ad0ded5e5 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/SyncRetryStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/SyncRetryStrategy.java
@@ -30,20 +30,20 @@
import java.util.List;
-/*
+/**
* Sync retry strategy.
*
* @author lidongbo
*/
+@Getter(value = AccessLevel.PROTECTED)
@Slf4j
public class SyncRetryStrategy extends UsualStrategy {
- @Getter(value = AccessLevel.PROTECTED)
private final DelayRetryPolicy delayRetryPolicy;
public SyncRetryStrategy(final IProvider provider, final DelayRetryPolicy delayRetryPolicy) {
super(provider);
- if (delayRetryPolicy == null) {
+ if (null == delayRetryPolicy) {
log.info("RetryCallable constructor context's delayRetryPolicy is null");
this.delayRetryPolicy = DelayRetryPolicy.defaultDelayPolicy();
} else {
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/TransactionContendStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/TransactionContendStrategy.java
index e4734edd0297a..ba832f67c19ec 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/TransactionContendStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/TransactionContendStrategy.java
@@ -23,7 +23,7 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.PathUtil;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.utility.ZookeeperConstants;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.provider.BaseProvider;
-import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.ZKTransaction;
+import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.transaction.ZooKeeperTransaction;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -31,14 +31,14 @@
import java.util.List;
import java.util.Stack;
-/*
+/**
* ContentionStrategy with transaction.
*
* @author lidongbo
* @since zookeeper 3.4.0
*/
@Slf4j
-public class TransactionContendStrategy extends ContentionStrategy {
+public final class TransactionContendStrategy extends ContentionStrategy {
public TransactionContendStrategy(final ITransactionProvider provider) {
super(provider);
@@ -57,8 +57,8 @@ private LeaderElection buildCreateAllNeedElection(final String key, final String
@Override
public void action() throws KeeperException, InterruptedException {
- log.debug("ContentionStrategy createAllNeedPath action:{}", key);
- ZKTransaction transaction = new ZKTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
+ log.debug("ContentionStrategy createAllNeedPath action: {}", key);
+ ZooKeeperTransaction transaction = new ZooKeeperTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
createBegin(key, value, createMode, transaction);
transaction.commit();
}
@@ -72,7 +72,7 @@ public void callback() {
};
}
- private void createBegin(final String key, final String value, final CreateMode createMode, final ZKTransaction transaction) throws KeeperException, InterruptedException {
+ private void createBegin(final String key, final String value, final CreateMode createMode, final ZooKeeperTransaction transaction) throws KeeperException, InterruptedException {
if (!key.contains(ZookeeperConstants.PATH_SEPARATOR)) {
((ITransactionProvider) getProvider()).createInTransaction(key, value, createMode, transaction);
return;
@@ -80,10 +80,10 @@ private void createBegin(final String key, final String value, final CreateMode
List nodes = getProvider().getNecessaryPaths(key);
for (int i = 0; i < nodes.size(); i++) {
if (getProvider().exists(nodes.get(i))) {
- log.info("create node exist:{}", nodes.get(i));
+ log.info("create node exist: {}", nodes.get(i));
continue;
}
- log.debug("node not exist and create:", nodes.get(i));
+ log.debug("node not exist and create: {}", nodes.get(i));
if (i == nodes.size() - 1) {
((ITransactionProvider) getProvider()).createInTransaction(nodes.get(i), value, createMode, transaction);
} else {
@@ -98,7 +98,7 @@ public void deleteAllChildren(final String key) throws KeeperException, Interrup
@Override
public void action() throws KeeperException, InterruptedException {
- ZKTransaction transaction = new ZKTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
+ ZooKeeperTransaction transaction = new ZooKeeperTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
deleteChildren(getProvider().getRealPath(key), true, transaction);
transaction.commit();
}
@@ -106,15 +106,15 @@ public void action() throws KeeperException, InterruptedException {
log.debug("ContentionStrategy deleteAllChildren executeContention");
}
- private void deleteChildren(final String key, final boolean deleteCurrentNode, final ZKTransaction transaction) throws KeeperException, InterruptedException {
+ private void deleteChildren(final String key, final boolean deleteCurrentNode, final ZooKeeperTransaction transaction) throws KeeperException, InterruptedException {
List children = getProvider().getChildren(key);
- for (int i = 0; i < children.size(); i++) {
- String child = PathUtil.getRealPath(key, children.get(i));
+ for (String each : children) {
+ String child = PathUtil.getRealPath(key, each);
if (!getProvider().exists(child)) {
- log.info("delete not exist:{}", child);
+ log.info("delete not exist: {}", child);
continue;
}
- log.debug("deleteChildren:{}", child);
+ log.debug("deleteChildren: {}", child);
deleteChildren(child, true, transaction);
}
if (deleteCurrentNode) {
@@ -128,7 +128,7 @@ public void deleteCurrentBranch(final String key) throws KeeperException, Interr
@Override
public void action() throws KeeperException, InterruptedException {
- ZKTransaction transaction = new ZKTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
+ ZooKeeperTransaction transaction = new ZooKeeperTransaction(((BaseProvider) getProvider()).getRootNode(), ((BaseProvider) getProvider()).getHolder());
deleteBranch(getProvider().getRealPath(key), transaction);
transaction.commit();
}
@@ -136,7 +136,7 @@ public void action() throws KeeperException, InterruptedException {
log.debug("ContentionStrategy deleteCurrentBranch executeContention");
}
- private void deleteBranch(final String key, final ZKTransaction transaction) throws KeeperException, InterruptedException {
+ private void deleteBranch(final String key, final ZooKeeperTransaction transaction) throws KeeperException, InterruptedException {
deleteChildren(key, false, transaction);
Stack pathStack = getProvider().getDeletingPaths(key);
String prePath = key;
@@ -145,8 +145,8 @@ private void deleteBranch(final String key, final ZKTransaction transaction) thr
// contrast cache
// Performance needs testing
List children = getProvider().getChildren(node);
- boolean canDelete = children.size() == 0 || children.size() == 1;
- if (children.size() == 1) {
+ boolean canDelete = children.isEmpty() || 1 == children.size();
+ if (1 == children.size()) {
if (!PathUtil.getRealPath(node, children.get(0)).equals(prePath)) {
canDelete = false;
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/UsualStrategy.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/UsualStrategy.java
index 27677a6911135..ae1654fa94c18 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/UsualStrategy.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/strategy/UsualStrategy.java
@@ -28,7 +28,7 @@
import java.util.List;
-/*
+/**
* Usual strategy.
*
* @author lidongbo
@@ -88,37 +88,37 @@ public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback
@Override
public void createAllNeedPath(final String key, final String value, final CreateMode createMode) throws KeeperException, InterruptedException {
if (!key.contains(ZookeeperConstants.PATH_SEPARATOR)) {
- this.createCurrentOnly(key, value, createMode);
+ createCurrentOnly(key, value, createMode);
return;
}
List nodes = getProvider().getNecessaryPaths(key);
for (int i = 0; i < nodes.size(); i++) {
try {
if (i == nodes.size() - 1) {
- this.createCurrentOnly(nodes.get(i), value, createMode);
+ createCurrentOnly(nodes.get(i), value, createMode);
} else {
- this.createCurrentOnly(nodes.get(i), ZookeeperConstants.NOTHING_VALUE, CreateMode.PERSISTENT);
+ createCurrentOnly(nodes.get(i), ZookeeperConstants.NOTHING_VALUE, CreateMode.PERSISTENT);
}
- log.debug("node not exist and create:", nodes.get(i));
+ log.debug("node not exist and create: {}", nodes.get(i));
} catch (final KeeperException.NodeExistsException ex) {
- log.debug("create node exist:{}", nodes.get(i));
+ log.debug("create node exist: {}", nodes.get(i));
}
}
}
@Override
public void deleteAllChildren(final String key) throws KeeperException, InterruptedException {
- log.debug("deleteAllChildren:{}", key);
- this.deleteChildren(getProvider().getRealPath(key), true);
+ log.debug("deleteAllChildren: {}", key);
+ deleteChildren(getProvider().getRealPath(key), true);
}
private void deleteChildren(final String path, final boolean deleteCurrentNode) throws KeeperException, InterruptedException {
- log.debug("deleteChildren:{}", path);
+ log.debug("deleteChildren: {}", path);
List children;
try {
children = getProvider().getChildren(path);
} catch (final KeeperException.NoNodeException ex) {
- log.warn("deleteChildren node not exist:{},ex:{}", path, ex.getMessage());
+ log.warn("deleteChildren node not exist: {}, ex: {}", path, ex.getMessage());
return;
}
for (String each : children) {
@@ -126,12 +126,12 @@ private void deleteChildren(final String path, final boolean deleteCurrentNode)
}
if (deleteCurrentNode) {
try {
- this.deleteOnlyCurrent(path);
+ deleteOnlyCurrent(path);
} catch (final KeeperException.NotEmptyException ex) {
- log.warn("deleteCurrentNode exist children:{},ex:{}", path, ex.getMessage());
+ log.warn("deleteCurrentNode exist children: {}, ex: {}", path, ex.getMessage());
deleteChildren(path, true);
} catch (final KeeperException.NoNodeException ex) {
- log.warn("deleteCurrentNode node not exist:{},ex:{}", path, ex.getMessage());
+ log.warn("deleteCurrentNode node not exist: {}, ex: {}", path, ex.getMessage());
}
}
}
@@ -141,43 +141,43 @@ private void deleteChildren(final String path, final boolean deleteCurrentNode)
*/
@Override
public void deleteCurrentBranch(final String key) throws KeeperException, InterruptedException {
- log.debug("deleteCurrentBranch:{}", key);
+ log.debug("deleteCurrentBranch: {}", key);
String path = getProvider().getRealPath(key);
try {
- this.deleteOnlyCurrent(path);
+ deleteOnlyCurrent(path);
} catch (final KeeperException | InterruptedException ex) {
if (ex instanceof KeeperException.NotEmptyException) {
- this.deleteChildren(path, true);
+ deleteChildren(path, true);
} else if (ex instanceof KeeperException.NoNodeException) {
- log.debug("path:{},ex:{}", path, ex.getMessage());
+ log.debug("path: {}, ex: {}", path, ex.getMessage());
} else {
throw ex;
}
}
String superPath = path.substring(0, path.lastIndexOf(ZookeeperConstants.PATH_SEPARATOR));
try {
- this.deleteRecursively(superPath);
+ deleteRecursively(superPath);
} catch (final KeeperException.NotEmptyException ex) {
- log.warn("deleteCurrentBranch exist children:{},ex:{}", path, ex.getMessage());
+ log.warn("deleteCurrentBranch exist children: {}, ex: {}", path, ex.getMessage());
} catch (final KeeperException.NoNodeException ex) {
- log.debug("deleteCurrentBranch:{},ex:{}", superPath, ex.getMessage());
+ log.debug("deleteCurrentBranch: {}, ex: {}", superPath, ex.getMessage());
}
}
private void deleteRecursively(final String path) throws KeeperException, InterruptedException {
- log.debug("deleteRecursively:{}", path);
+ log.debug("deleteRecursively: {}", path);
int index = path.lastIndexOf(ZookeeperConstants.PATH_SEPARATOR);
if (index == 0) {
- this.deleteOnlyCurrent(path);
+ deleteOnlyCurrent(path);
return;
}
String superPath = path.substring(0, index);
try {
- this.deleteOnlyCurrent(path);
- this.deleteRecursively(superPath);
+ deleteOnlyCurrent(path);
+ deleteRecursively(superPath);
} catch (final KeeperException.NotEmptyException ex) {
- log.info("deleteRecursively exist children:{},ex:{}", path, ex.getMessage());
- log.debug("deleteRecursively {} exist other children:{}", path, this.getChildren(path));
+ log.info("deleteRecursively exist children: {}, ex: {}", path, ex.getMessage());
+ log.debug("deleteRecursively {} exist other children: {}", path, getChildren(path));
}
}
}
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/BaseTransaction.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/BaseTransaction.java
index ee57474f6a729..facbf6e8f1b28 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/BaseTransaction.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/BaseTransaction.java
@@ -24,7 +24,7 @@
import java.util.List;
-/*
+/**
* Base transaction.
*
* @author lidongbo
@@ -37,10 +37,10 @@ public class BaseTransaction {
* @param path key
* @param data value
* @param acl acl
- * @param createMode createMode
- * @return ZKTransaction
+ * @param createMode create mode
+ * @return zookeeper transaction
*/
- public ZKTransaction create(final String path, final byte[] data, final List acl, final CreateMode createMode) {
+ public ZooKeeperTransaction create(final String path, final byte[] data, final List acl, final CreateMode createMode) {
throw new UnsupportedOperationException("check zk version!");
}
@@ -48,9 +48,9 @@ public ZKTransaction create(final String path, final byte[] data, final List commit() throws InterruptedException, KeeperException {
throw new UnsupportedOperationException("check zk version!");
diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZKTransaction.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZooKeeperTransaction.java
similarity index 67%
rename from sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZKTransaction.java
rename to sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZooKeeperTransaction.java
index c0a6eaadd6544..c453a7a0ab189 100644
--- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZKTransaction.java
+++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/transaction/ZooKeeperTransaction.java
@@ -29,64 +29,64 @@
import java.util.List;
-/*
+/**
* Zookeeper transaction support.
*
* @author lidongbo
* @since zookeeper 3.4.0
*/
@Slf4j
-public class ZKTransaction extends BaseTransaction {
-
- private final Transaction transaction;
+public final class ZooKeeperTransaction extends BaseTransaction {
private final String rootNode;
+
+ private final Transaction transaction;
- public ZKTransaction(final String root, final Holder holder) {
- transaction = holder.getZooKeeper().transaction();
+ public ZooKeeperTransaction(final String root, final Holder holder) {
rootNode = root;
- log.debug("ZKTransaction root:{}", rootNode);
+ transaction = holder.getZooKeeper().transaction();
+ log.debug("ZKTransaction root: {}", rootNode);
}
@Override
- public ZKTransaction create(final String path, final byte[] data, final List acl, final CreateMode createMode) {
- this.transaction.create(PathUtil.getRealPath(rootNode, path), data, acl, createMode);
+ public ZooKeeperTransaction create(final String path, final byte[] data, final List acl, final CreateMode createMode) {
+ transaction.create(PathUtil.getRealPath(rootNode, path), data, acl, createMode);
log.debug("wait create:{},data:{},acl:{},createMode:{}", path, data, acl, createMode);
return this;
}
@Override
- public ZKTransaction delete(final String path) {
+ public ZooKeeperTransaction delete(final String path) {
return delete(path, ZookeeperConstants.VERSION);
}
@Override
- public ZKTransaction delete(final String path, final int version) {
- this.transaction.delete(PathUtil.getRealPath(rootNode, path), version);
+ public ZooKeeperTransaction delete(final String path, final int version) {
+ transaction.delete(PathUtil.getRealPath(rootNode, path), version);
log.debug("wait delete:{}", path);
return this;
}
@Override
- public ZKTransaction check(final String path) {
+ public ZooKeeperTransaction check(final String path) {
return check(path, ZookeeperConstants.VERSION);
}
@Override
- public ZKTransaction check(final String path, final int version) {
- this.transaction.check(PathUtil.getRealPath(rootNode, path), version);
+ public ZooKeeperTransaction check(final String path, final int version) {
+ transaction.check(PathUtil.getRealPath(rootNode, path), version);
log.debug("wait check:{}", path);
return this;
}
@Override
- public ZKTransaction setData(final String path, final byte[] data) {
+ public ZooKeeperTransaction setData(final String path, final byte[] data) {
return setData(path, data, ZookeeperConstants.VERSION);
}
@Override
- public ZKTransaction setData(final String path, final byte[] data, final int version) {
- this.transaction.setData(PathUtil.getRealPath(rootNode, path), data, version);
+ public ZooKeeperTransaction setData(final String path, final byte[] data, final int version) {
+ transaction.setData(PathUtil.getRealPath(rootNode, path), data, version);
log.debug("wait setData:{},data:{}", path, data);
return this;
}
@@ -94,6 +94,6 @@ public ZKTransaction setData(final String path, final byte[] data, final int ver
@Override
public List commit() throws InterruptedException, KeeperException {
log.debug("ZKTransaction commit");
- return this.transaction.commit();
+ return transaction.commit();
}
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/AllTests.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/AllTests.java
index 32d3333885458..b4d7371d9be1b 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/AllTests.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/AllTests.java
@@ -28,5 +28,5 @@
AllYamlTests.class,
AllInternalTests.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/AllInternalTests.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/AllInternalTests.java
index 9ab08b24299f0..ebdff181976b8 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/AllInternalTests.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/AllInternalTests.java
@@ -23,5 +23,5 @@
@RunWith(Suite.class)
@Suite.SuiteClasses(AllJdbcTests.class)
-public class AllInternalTests {
+public final class AllInternalTests {
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/AllJdbcTests.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/AllJdbcTests.java
index cdfc59ecfc0bf..7b4820cbaa0d9 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/AllJdbcTests.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/internal/jdbc/AllJdbcTests.java
@@ -29,5 +29,5 @@
CircuitBreakerDataSourceTest.class,
CircuitBreakerDatabaseMetaDataTest.class
})
-public class AllJdbcTests {
+public final class AllJdbcTests {
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestCallable.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestCallable.java
index 9330020a13907..0056ed3576f95 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestCallable.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestCallable.java
@@ -30,7 +30,7 @@ public TestCallable(final IProvider provider, final DelayRetryPolicy delayRetryP
}
@Override
- public void call() throws KeeperException, InterruptedException {
+ public final void call() throws KeeperException, InterruptedException {
if (count < 2) {
count++;
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestResultCallable.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestResultCallable.java
index ec5f77c73e014..e96e504b269a2 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestResultCallable.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/retry/TestResultCallable.java
@@ -30,7 +30,7 @@ public TestResultCallable(final IProvider provider, final DelayRetryPolicy delay
}
@Override
- public void call() throws KeeperException, InterruptedException {
+ public final void call() throws KeeperException, InterruptedException {
if (count < 2) {
count++;
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/SyncRetryStrategyTest.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/SyncRetryStrategyTest.java
index f9ee5ed67d8d1..9e3d58a33a1e7 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/SyncRetryStrategyTest.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/SyncRetryStrategyTest.java
@@ -26,25 +26,26 @@
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base.TestSupport;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.StrategyType;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.strategy.UsualStrategy;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.junit.Test;
-import static junit.framework.TestCase.assertFalse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@Slf4j
-public class SyncRetryStrategyTest extends UsualClientTest {
+public final class SyncRetryStrategyTest extends UsualClientTest {
private IProvider provider;
@@ -53,7 +54,7 @@ protected IClient createClient(final ClientFactory creator) throws IOException,
final IClient client = creator.setClientNamespace(TestSupport.ROOT).authorization(TestSupport.AUTH, TestSupport.AUTH.getBytes(), ZooDefs.Ids.CREATOR_ALL_ACL)
.newClient(TestSupport.SERVERS, TestSupport.SESSION_TIMEOUT).watch(TestSupport.buildListener()).start();
client.useExecStrategy(StrategyType.SYNC_RETRY);
- provider = ((UsualClient) client).getStrategy().getProvider();
+ provider = client.getExecStrategy().getProvider();
return client;
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientTest.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientTest.java
index 3a60bd623e6e6..201c344517130 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientTest.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseClientTest.java
@@ -65,7 +65,7 @@ public void start() throws IOException, InterruptedException {
getZooKeeper(testClient);
}
- protected ZooKeeper getZooKeeper(final IClient client) {
+ protected final ZooKeeper getZooKeeper(final IClient client) {
return ((BaseClient) client).getHolder().getZooKeeper();
}
@@ -84,14 +84,14 @@ public void assertDeleteRoot() throws KeeperException, InterruptedException {
assertNull(getZooKeeper(testClient).exists(ZookeeperConstants.PATH_SEPARATOR + TestSupport.ROOT, false));
}
- protected void createRoot(final IClient client) throws KeeperException, InterruptedException {
+ protected final void createRoot(final IClient client) throws KeeperException, InterruptedException {
((BaseClient) client).createNamespace();
assertNotNull(getZooKeeper(client).exists(ZookeeperConstants.PATH_SEPARATOR + TestSupport.ROOT, false));
((BaseClient) client).deleteNamespace();
assertNull(getZooKeeper(client).exists(ZookeeperConstants.PATH_SEPARATOR + TestSupport.ROOT, false));
}
- protected void createChild(final IClient client) throws KeeperException, InterruptedException {
+ protected final void createChild(final IClient client) throws KeeperException, InterruptedException {
String key = "a/b/bb";
client.createAllNeedPath(key, "bbb11", CreateMode.PERSISTENT);
assertNotNull(getZooKeeper(client).exists(PathUtil.getRealPath(TestSupport.ROOT, key), false));
@@ -99,7 +99,7 @@ protected void createChild(final IClient client) throws KeeperException, Interru
assertNull(getZooKeeper(client).exists(PathUtil.getRealPath(TestSupport.ROOT, key), false));
}
- protected void deleteBranch(final IClient client) throws KeeperException, InterruptedException {
+ protected final void deleteBranch(final IClient client) throws KeeperException, InterruptedException {
String keyB = "a/b/bb";
String valueB = "bbb11";
client.createAllNeedPath(keyB, valueB, CreateMode.PERSISTENT);
@@ -119,7 +119,7 @@ protected void deleteBranch(final IClient client) throws KeeperException, Interr
assertNull(getZooKeeper(client).exists(PathUtil.checkPath(TestSupport.ROOT), false));
}
- protected void isExisted(final IClient client) throws KeeperException, InterruptedException {
+ protected final void isExisted(final IClient client) throws KeeperException, InterruptedException {
String key = "a/b/bb";
client.createAllNeedPath(key, "", CreateMode.PERSISTENT);
assertTrue(isExisted(key, client));
@@ -130,7 +130,7 @@ private boolean isExisted(final String key, final IClient client) throws KeeperE
return client.checkExists(key);
}
- protected void get(final IClient client) throws KeeperException, InterruptedException {
+ protected final void get(final IClient client) throws KeeperException, InterruptedException {
String value = "bbb11";
client.createAllNeedPath("a/b", value, CreateMode.PERSISTENT);
String key = "a";
@@ -140,7 +140,7 @@ protected void get(final IClient client) throws KeeperException, InterruptedExce
client.deleteCurrentBranch("a/b");
}
- protected void asyncGet(final IClient client) throws KeeperException, InterruptedException {
+ protected final void asyncGet(final IClient client) throws KeeperException, InterruptedException {
final CountDownLatch ready = new CountDownLatch(1);
String key = "a/b";
String value = "bbb11";
@@ -163,7 +163,7 @@ private String getDirectly(final String key, final IClient client) throws Keeper
return new String(client.getData(key));
}
- protected void getChildrenKeys(final IClient client) throws KeeperException, InterruptedException {
+ protected final void getChildrenKeys(final IClient client) throws KeeperException, InterruptedException {
String key = "a/b";
String current = "a";
client.createAllNeedPath(key, "", CreateMode.PERSISTENT);
@@ -178,7 +178,7 @@ public int compare(final String o1, final String o2) {
client.deleteCurrentBranch(key);
}
- protected void persist(final IClient client) throws KeeperException, InterruptedException {
+ protected final void persist(final IClient client) throws KeeperException, InterruptedException {
String key = "a";
String value = "aa";
String newValue = "aaa";
@@ -199,7 +199,7 @@ private void updateWithCheck(final String key, final String value, final IClient
client.update(key, value);
}
- protected void persistEphemeral(final IClient client) throws KeeperException, InterruptedException {
+ protected final void persistEphemeral(final IClient client) throws KeeperException, InterruptedException {
String key = "a/b/bb";
String value = "b1b";
client.createAllNeedPath(key, value, CreateMode.PERSISTENT);
@@ -215,7 +215,7 @@ protected void persistEphemeral(final IClient client) throws KeeperException, In
client.deleteCurrentBranch(key);
}
- protected void delAllChildren(final IClient client) throws KeeperException, InterruptedException {
+ protected final void delAllChildren(final IClient client) throws KeeperException, InterruptedException {
String key = "a/b/bb";
client.createAllNeedPath(key, "bb", CreateMode.PERSISTENT);
key = "a/c/cc";
@@ -228,7 +228,7 @@ protected void delAllChildren(final IClient client) throws KeeperException, Inte
((BaseClient) client).deleteNamespace();
}
- protected void watch(final IClient client) throws KeeperException, InterruptedException {
+ protected final void watch(final IClient client) throws KeeperException, InterruptedException {
List actual = new ArrayList<>();
final ZookeeperEventListener zookeeperEventListener = buildListener(client, actual);
@@ -266,7 +266,7 @@ public void process(final WatchedEvent event) {
client.unregisterWatch(zookeeperEventListener.getKey());
}
- protected void watchRegister(final IClient client) throws KeeperException, InterruptedException {
+ protected final void watchRegister(final IClient client) throws KeeperException, InterruptedException {
List actual = new ArrayList<>();
final ZookeeperEventListener zookeeperEventListener = buildListener(client, actual);
@@ -320,7 +320,7 @@ public void process(final WatchedEvent event) {
};
}
- protected void close(final IClient client) {
+ protected final void close(final IClient client) {
client.close();
assertThat(getZooKeeper(client).getState(), is(ZooKeeper.States.CLOSED));
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseTest.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseTest.java
index 48018b026b9b7..7cf32726b3263 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseTest.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/BaseTest.java
@@ -22,15 +22,15 @@
public class BaseTest {
- protected void createRootOnly(final IClient client) throws KeeperException, InterruptedException {
+ protected final void createRootOnly(final IClient client) throws KeeperException, InterruptedException {
((BaseClient) client).createNamespace();
}
- protected void deleteRoot(final IClient client) throws KeeperException, InterruptedException {
+ protected final void deleteRoot(final IClient client) throws KeeperException, InterruptedException {
((BaseClient) client).deleteNamespace();
}
- protected void sleep(final long tick) {
+ protected final void sleep(final long tick) {
try {
Thread.sleep(tick);
} catch (final InterruptedException ignore) {
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestClient.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestClient.java
index 1a9f13df60129..c282df851d385 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestClient.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestClient.java
@@ -23,16 +23,16 @@
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-public class TestClient extends UsualClient {
+public final class TestClient extends UsualClient {
TestClient(final BaseContext context) {
super(context);
}
@Override
- public synchronized boolean start(final int wait, final TimeUnit units) throws InterruptedException, IOException {
+ public synchronized boolean start(final int waitingTime, final TimeUnit timeUnit) throws InterruptedException, IOException {
setHolder(new TestHolder(getContext()));
- getHolder().start(wait, units);
+ getHolder().start(waitingTime, timeUnit);
return getHolder().isConnected();
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestHolder.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestHolder.java
index 0c100858b9433..8dc7f3375a3f7 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestHolder.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestHolder.java
@@ -24,7 +24,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-public class TestHolder extends Holder {
+public final class TestHolder extends Holder {
private final CountDownLatch connecting = new CountDownLatch(1);
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestSupport.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestSupport.java
index 72753f1111f70..f4fdf081c1c22 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestSupport.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/zookeeper/base/TestSupport.java
@@ -18,11 +18,14 @@
package io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.base;
import io.shardingsphere.jdbc.orchestration.reg.newzk.client.zookeeper.section.ZookeeperEventListener;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.WatchedEvent;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Slf4j
-public class TestSupport {
+public final class TestSupport {
public static final String AUTH = "digest";
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/AllYamlTests.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/AllYamlTests.java
index 92e7243c96c0c..23e9746489628 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/AllYamlTests.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/AllYamlTests.java
@@ -29,5 +29,5 @@
YamlOrchestrationMasterSlaveIntegrateTest.class,
YamlOrchestrationShardingWithMasterSlaveIntegrateTest.class
})
-public class AllYamlTests {
+public final class AllYamlTests {
}
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/MultiAlgorithm.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/MultiAlgorithm.java
index 166b9a9583073..486fa19842b69 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/MultiAlgorithm.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/MultiAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class MultiAlgorithm implements ComplexKeysShardingAlgorithm {
+public final class MultiAlgorithm implements ComplexKeysShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final Collection shardingValues) {
diff --git a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/SingleAlgorithm.java b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/SingleAlgorithm.java
index 9abdc33b1d622..a1974b2c78461 100644
--- a/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/SingleAlgorithm.java
+++ b/sharding-jdbc-orchestration/src/test/java/io/shardingsphere/jdbc/orchestration/yaml/fixture/SingleAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class SingleAlgorithm implements PreciseShardingAlgorithm {
+public final class SingleAlgorithm implements PreciseShardingAlgorithm {
@Override
public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {
diff --git a/sharding-jdbc-plugin/pom.xml b/sharding-jdbc-plugin/pom.xml
index ad19ebcbbe870..7fbc8c4efa02a 100644
--- a/sharding-jdbc-plugin/pom.xml
+++ b/sharding-jdbc-plugin/pom.xml
@@ -5,11 +5,11 @@
4.0.0
io.shardingsphere
sharding-jdbc-plugin
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
pom
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
4.12
1.6.6
1.7
diff --git a/sharding-jdbc-plugin/src/test/java/io/shardingsphere/plugin/keygen/AllTests.java b/sharding-jdbc-plugin/src/test/java/io/shardingsphere/plugin/keygen/AllTests.java
index bd79ab87971fe..da06a5cf84b7d 100644
--- a/sharding-jdbc-plugin/src/test/java/io/shardingsphere/plugin/keygen/AllTests.java
+++ b/sharding-jdbc-plugin/src/test/java/io/shardingsphere/plugin/keygen/AllTests.java
@@ -25,5 +25,5 @@
HostNameKeyGeneratorTest.class,
IPKeyGeneratorTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-spring/pom.xml b/sharding-jdbc-spring/pom.xml
index 233cb061c502c..4c99a74254c3e 100644
--- a/sharding-jdbc-spring/pom.xml
+++ b/sharding-jdbc-spring/pom.xml
@@ -6,7 +6,7 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-spring
pom
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/pom.xml b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/pom.xml
index c34c7a7053db6..1d7f853ef3eb2 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/pom.xml
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-spring
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-spring-boot-starter
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/SpringBootConfiguration.java b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/SpringBootConfiguration.java
index 3ef8ae5dd8ad2..c42114c0819af 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/SpringBootConfiguration.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/SpringBootConfiguration.java
@@ -69,7 +69,7 @@ public DataSource dataSource() throws SQLException {
}
@Override
- public void setEnvironment(final Environment environment) {
+ public final void setEnvironment(final Environment environment) {
setDataSourceMap(environment);
}
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/util/PropertyUtil.java b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/util/PropertyUtil.java
index e6943dc5cb889..2d2979f7abd3a 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/util/PropertyUtil.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingsphere/jdbc/spring/boot/util/PropertyUtil.java
@@ -17,6 +17,13 @@
package io.shardingsphere.jdbc.spring.boot.util;
+import io.shardingsphere.core.exception.ShardingException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.PropertyResolver;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -24,13 +31,8 @@
import java.util.HashMap;
import java.util.Map;
-import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.PropertyResolver;
-
-import io.shardingsphere.core.exception.ShardingException;
-
-public class PropertyUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PropertyUtil {
private static int springBootVersion = 1;
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
index 05a5e83f31447..c62fba9e54b17 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/AllTests.java
@@ -28,5 +28,5 @@
SpringBootMasterSlaveTest.class,
SpringBootShardingTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootMasterSlaveTest.java b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootMasterSlaveTest.java
index 69b0b8a513a6e..fd6871647ee3e 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootMasterSlaveTest.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootMasterSlaveTest.java
@@ -49,7 +49,7 @@ public class SpringBootMasterSlaveTest {
public void assertWithMasterSlaveDataSource() {
assertTrue(dataSource instanceof MasterSlaveDataSource);
for (DataSource each : ((MasterSlaveDataSource) dataSource).getAllDataSources().values()) {
- assertThat(((BasicDataSource) each).getMaxTotal(), is(16));
+ assertThat(((BasicDataSource) each).getMaxTotal(), is(100));
}
Map configMap = new ConcurrentHashMap<>();
configMap.put("key1", "value1");
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootShardingTest.java b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootShardingTest.java
index bd07561ec5061..ad9ed895a1f9e 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootShardingTest.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/java/io/shardingsphere/jdbc/spring/boot/type/SpringBootShardingTest.java
@@ -56,7 +56,7 @@ public void assertWithShardingDataSource() throws NoSuchFieldException, IllegalA
field.setAccessible(true);
ShardingContext shardingContext = (ShardingContext) field.get(dataSource);
for (DataSource each : shardingContext.getDataSourceMap().values()) {
- assertThat(((BasicDataSource) each).getMaxTotal(), is(16));
+ assertThat(((BasicDataSource) each).getMaxTotal(), is(100));
}
assertTrue(shardingContext.isShowSQL());
Map configMap = new ConcurrentHashMap<>();
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-masterslave.properties b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-masterslave.properties
index ddaba089af31a..baca2af0b0e0b 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-masterslave.properties
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-masterslave.properties
@@ -5,21 +5,21 @@ sharding.jdbc.datasource.ds_master.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds_master.url=jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds_master.username=root
sharding.jdbc.datasource.ds_master.password=
-sharding.jdbc.datasource.ds_master.max-total=16
+sharding.jdbc.datasource.ds_master.max-total=100
sharding.jdbc.datasource.ds_slave_0.type=org.apache.commons.dbcp2.BasicDataSource
sharding.jdbc.datasource.ds_slave_0.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds_slave_0.url=jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds_slave_0.username=${sharding.jdbc.config.masterslave.config-map.username}
sharding.jdbc.datasource.ds_slave_0.password=
-sharding.jdbc.datasource.ds_slave_0.max-total=16
+sharding.jdbc.datasource.ds_slave_0.max-total=100
sharding.jdbc.datasource.ds_slave_1.type=org.apache.commons.dbcp2.BasicDataSource
sharding.jdbc.datasource.ds_slave_1.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds_slave_1.url=jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds_slave_1.username=root
sharding.jdbc.datasource.ds_slave_1.password=
-sharding.jdbc.datasource.ds_slave_1.max-total=16
+sharding.jdbc.datasource.ds_slave_1.max-total=100
sharding.jdbc.config.masterslave.name=ds_ms
sharding.jdbc.config.masterslave.master-data-source-name=ds_master
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-sharding.properties b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-sharding.properties
index dffdb83506cfc..7c45fb034f5a2 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-sharding.properties
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/test/resources/application-sharding.properties
@@ -4,21 +4,21 @@ sharding.jdbc.datasource.ds.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds.url=jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds.username=sa
sharding.jdbc.datasource.ds.password=
-sharding.jdbc.datasource.ds.max-total=16
+sharding.jdbc.datasource.ds.max-total=100
sharding.jdbc.datasource.ds_0.type=org.apache.commons.dbcp2.BasicDataSource
sharding.jdbc.datasource.ds_0.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds_0.url=jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds_0.username=sa
sharding.jdbc.datasource.ds_0.password=
-sharding.jdbc.datasource.ds_0.max-total=16
+sharding.jdbc.datasource.ds_0.max-total=100
sharding.jdbc.datasource.ds_1.type=org.apache.commons.dbcp2.BasicDataSource
sharding.jdbc.datasource.ds_1.driver-class-name=org.h2.Driver
sharding.jdbc.datasource.ds_1.url=jdbc:h2:mem:ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
sharding.jdbc.datasource.ds_1.username=sa
sharding.jdbc.datasource.ds_1.password=
-sharding.jdbc.datasource.ds_1.max-total=16
+sharding.jdbc.datasource.ds_1.max-total=100
sharding.jdbc.config.sharding.default-data-source-name=ds
sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column=user_id
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/pom.xml b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/pom.xml
index ceccaabeceabc..103ae461000b1 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/pom.xml
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-spring
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-spring-namespace
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/MasterSlaveDataSourceBeanDefinitionParser.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/MasterSlaveDataSourceBeanDefinitionParser.java
index 515f6da51446e..850dc5a4d3710 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/MasterSlaveDataSourceBeanDefinitionParser.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/MasterSlaveDataSourceBeanDefinitionParser.java
@@ -45,7 +45,7 @@
*
* @author zhangliang
*/
-public class MasterSlaveDataSourceBeanDefinitionParser extends AbstractBeanDefinitionParser {
+public final class MasterSlaveDataSourceBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java
index 3c79dd5aa1a2e..82ed1202dd671 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingDataSourceBeanDefinitionParser.java
@@ -45,7 +45,7 @@
*
* @author caohao
*/
-public class ShardingDataSourceBeanDefinitionParser extends AbstractBeanDefinitionParser {
+public final class ShardingDataSourceBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinition.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinition.java
index 6e013dd5c705e..d73409870080a 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinition.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinition.java
@@ -37,7 +37,7 @@
* @author caohao
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class ShardingStrategyBeanDefinition {
+public final class ShardingStrategyBeanDefinition {
static AbstractBeanDefinition getBeanDefinitionByElement(final Element element) {
String type = element.getLocalName();
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
index 774d598eeab94..ed1db84f49a9a 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/main/java/io/shardingsphere/jdbc/spring/namespace/parser/ShardingStrategyBeanDefinitionParser.java
@@ -27,7 +27,7 @@
*®
* @author caohao
*/
-public class ShardingStrategyBeanDefinitionParser extends AbstractBeanDefinitionParser {
+public final class ShardingStrategyBeanDefinitionParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/AllTests.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/AllTests.java
index 0849507daa87e..4ed6f7f1b141d 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/AllTests.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/AllTests.java
@@ -44,5 +44,5 @@
MasterSlaveNamespaceTest.class,
ShardingNamespaceTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
index 5e51db9f3d574..e6eb74294d3f5 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultComplexKeysShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class DefaultComplexKeysShardingAlgorithm implements ComplexKeysShardingAlgorithm {
+public final class DefaultComplexKeysShardingAlgorithm implements ComplexKeysShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final Collection shardingValues) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultHintShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultHintShardingAlgorithm.java
index 0f9378b8a6776..67b14503d9069 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultHintShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/DefaultHintShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class DefaultHintShardingAlgorithm implements HintShardingAlgorithm {
+public final class DefaultHintShardingAlgorithm implements HintShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final ShardingValue shardingValue) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
index 2d9620e9bbc79..a209509f4e5fc 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloDatabaseShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class PreciseModuloDatabaseShardingAlgorithm implements PreciseShardingAlgorithm {
+public final class PreciseModuloDatabaseShardingAlgorithm implements PreciseShardingAlgorithm {
@Override
public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloTableShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
index df7d36096e837..4d99eb4ffc065 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/PreciseModuloTableShardingAlgorithm.java
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class PreciseModuloTableShardingAlgorithm implements PreciseShardingAlgorithm {
+public final class PreciseModuloTableShardingAlgorithm implements PreciseShardingAlgorithm {
@Override
public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
index c697639039e2a..b11b727334705 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloDatabaseShardingAlgorithm.java
@@ -24,7 +24,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-public class RangeModuloDatabaseShardingAlgorithm implements RangeShardingAlgorithm {
+public final class RangeModuloDatabaseShardingAlgorithm implements RangeShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloTableShardingAlgorithm.java b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloTableShardingAlgorithm.java
index a6b6bd9dd696e..e26bd6d9acf1d 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloTableShardingAlgorithm.java
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/java/io/shardingsphere/jdbc/spring/algorithm/RangeModuloTableShardingAlgorithm.java
@@ -24,7 +24,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-public class RangeModuloTableShardingAlgorithm implements RangeShardingAlgorithm {
+public final class RangeModuloTableShardingAlgorithm implements RangeShardingAlgorithm {
@Override
public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) {
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/dataSource.xml b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/dataSource.xml
index 26f417882c2d2..141d074d3719a 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/dataSource.xml
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/dataSource.xml
@@ -14,6 +14,7 @@
+
@@ -21,5 +22,6 @@
+
diff --git a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/masterSlaveDataSource.xml b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/masterSlaveDataSource.xml
index 409aa1090e599..4766f2002c65e 100644
--- a/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/masterSlaveDataSource.xml
+++ b/sharding-jdbc-spring/sharding-jdbc-spring-namespace/src/test/resources/META-INF/rdb/datasource/masterSlaveDataSource.xml
@@ -14,6 +14,7 @@
+
@@ -21,6 +22,7 @@
+
@@ -28,6 +30,7 @@
+
@@ -36,6 +39,7 @@
+
@@ -43,6 +47,7 @@
+
@@ -50,5 +55,6 @@
+
diff --git a/sharding-jdbc-transaction-parent/pom.xml b/sharding-jdbc-transaction-parent/pom.xml
index 0af233cee31df..c93b37da4430e 100644
--- a/sharding-jdbc-transaction-parent/pom.xml
+++ b/sharding-jdbc-transaction-parent/pom.xml
@@ -6,7 +6,7 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-transaction-parent
pom
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/pom.xml b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/pom.xml
index 55d0d0568efaa..52fd0cd92ec3a 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/pom.xml
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-transaction-parent
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-transaction-async-job
${project.artifactId}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingsphere/transaction/job/BASETransactionJobBootStrap.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingsphere/transaction/job/BASETransactionJobBootStrap.java
index f3ab3055f2c06..d1214ca1d6372 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingsphere/transaction/job/BASETransactionJobBootStrap.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingsphere/transaction/job/BASETransactionJobBootStrap.java
@@ -17,6 +17,8 @@
package io.shardingsphere.transaction.job;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.quartz.SchedulerException;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
@@ -31,6 +33,7 @@
* @author caohao
* @author wangkai
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class BASETransactionJobBootStrap {
/**
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/pom.xml b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/pom.xml
index 9bc391997ea8a..83c6493c45621 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/pom.xml
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-transaction-parent
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-transaction-storage
${project.artifactId}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/MemoryTransactionLogDataSource.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/MemoryTransactionLogDataSource.java
index f2a34302fd01b..2656102aa667c 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/MemoryTransactionLogDataSource.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/MemoryTransactionLogDataSource.java
@@ -27,7 +27,7 @@
*
* @author caohao
*/
-public class MemoryTransactionLogDataSource implements TransactionLogDataSource {
+public final class MemoryTransactionLogDataSource implements TransactionLogDataSource {
@Override
public TransactionLogDataSourceType getType() {
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/RdbTransactionLogDataSource.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/RdbTransactionLogDataSource.java
index 0744175035962..abf2d01a7e720 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/RdbTransactionLogDataSource.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/main/java/io/shardingsphere/transaction/datasource/impl/RdbTransactionLogDataSource.java
@@ -29,7 +29,7 @@
* @author caohao
*/
@RequiredArgsConstructor
-public class RdbTransactionLogDataSource implements TransactionLogDataSource {
+public final class RdbTransactionLogDataSource implements TransactionLogDataSource {
private final DataSource dataSource;
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/AllTests.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/AllTests.java
index 2552552600cfa..dc08fccb3d456 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/AllTests.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/AllTests.java
@@ -28,5 +28,5 @@
AllStorageTest.class,
AllIntegrateTests.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/AllIntegrateTests.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/AllIntegrateTests.java
index 52de21a92b86e..43d6f438bbdb6 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/AllIntegrateTests.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/AllIntegrateTests.java
@@ -28,5 +28,5 @@
MemoryTransactionLogStorageOperationsTest.class,
RdbTransactionLogStorageOperationsTest.class
})
-public class AllIntegrateTests {
+public final class AllIntegrateTests {
}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/AbstractTransactionLogStorageOperationsTest.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/AbstractTransactionLogStorageOperationsTest.java
index 4bb4ac03363eb..c2f5bfd534d71 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/AbstractTransactionLogStorageOperationsTest.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/AbstractTransactionLogStorageOperationsTest.java
@@ -29,7 +29,7 @@
public abstract class AbstractTransactionLogStorageOperationsTest {
- protected void assertTransactionLogStorageOperations(final TransactionLogStorage storage) {
+ protected final void assertTransactionLogStorageOperations(final TransactionLogStorage storage) {
String id = UUID.randomUUID().toString();
String transactionId = UUID.randomUUID().toString();
TransactionLog transactionLog = new TransactionLog(id, transactionId, SoftTransactionType.BestEffortsDelivery,
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/RdbTransactionLogStorageOperationsTest.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/RdbTransactionLogStorageOperationsTest.java
index 74cf013e112ea..814facb811bce 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/RdbTransactionLogStorageOperationsTest.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/integrate/storage/RdbTransactionLogStorageOperationsTest.java
@@ -51,8 +51,7 @@ private void createTable(final DataSource dataSource) throws SQLException {
+ "`creation_time` LONG NOT NULL, "
+ "`async_delivery_try_times` INT NOT NULL DEFAULT 0, "
+ "PRIMARY KEY (`id`));";
- try (
- Connection conn = dataSource.getConnection();
+ try (Connection conn = dataSource.getConnection();
PreparedStatement preparedStatement = conn.prepareStatement(dbSchema)) {
preparedStatement.executeUpdate();
}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/storage/AllStorageTest.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/storage/AllStorageTest.java
index 45fa15ef42720..14dd960bc3234 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/storage/AllStorageTest.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction-storage/src/test/java/io/shardingsphere/transaction/storage/AllStorageTest.java
@@ -28,5 +28,5 @@
MemoryTransactionLogStorageTest.class,
RdbTransactionLogStorageTest.class
})
-public class AllStorageTest {
+public final class AllStorageTest {
}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/pom.xml b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/pom.xml
index b604b82c937a3..63ece54f29a77 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/pom.xml
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/pom.xml
@@ -3,7 +3,7 @@
io.shardingsphere
sharding-jdbc-transaction-parent
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc-transaction
${project.artifactId}
diff --git a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/test/java/io/shardingsphere/transaction/AllTests.java b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/test/java/io/shardingsphere/transaction/AllTests.java
index 0050411a4dd8f..96a3123546bce 100644
--- a/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/test/java/io/shardingsphere/transaction/AllTests.java
+++ b/sharding-jdbc-transaction-parent/sharding-jdbc-transaction/src/test/java/io/shardingsphere/transaction/AllTests.java
@@ -29,5 +29,5 @@
BEDSoftTransactionTest.class,
SoftTransactionTest.class
})
-public class AllTests {
+public final class AllTests {
}
diff --git a/sharding-jdbc/pom.xml b/sharding-jdbc/pom.xml
index faa93cefd5368..70d34ed310ffd 100644
--- a/sharding-jdbc/pom.xml
+++ b/sharding-jdbc/pom.xml
@@ -4,7 +4,7 @@
io.shardingsphere
sharding-sphere
- 3.0.0.M2-SNAPSHOT
+ 3.0.0.M3-SNAPSHOT
sharding-jdbc
${project.artifactId}
@@ -14,6 +14,11 @@
sharding-core
${project.version}
+
+ io.shardingsphere
+ sharding-transaction
+ ${project.version}
+
org.projectlombok
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
index 2e066f42257e4..caa7c06872c57 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/ExecutorEngine.java
@@ -17,8 +17,6 @@
package io.shardingsphere.core.executor;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
@@ -35,16 +33,13 @@
import lombok.extern.slf4j.Slf4j;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -57,7 +52,7 @@
* @author panjuan
*/
@Slf4j
-public final class ExecutorEngine implements AutoCloseable {
+public abstract class ExecutorEngine implements AutoCloseable {
private static final ThreadPoolExecutor SHUTDOWN_EXECUTOR = new ThreadPoolExecutor(
0, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(10), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Sharding-JDBC-ExecutorEngineCloseTimer").build());
@@ -66,8 +61,13 @@ public final class ExecutorEngine implements AutoCloseable {
private final ListeningExecutorService executorService;
public ExecutorEngine(final int executorSize) {
- executorService = MoreExecutors.listeningDecorator(new ThreadPoolExecutor(
+ if (0 == executorSize) {
+ executorService = MoreExecutors.listeningDecorator(new ThreadPoolExecutor(
+ 0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Sharding-JDBC-%d").build()));
+ } else {
+ executorService = MoreExecutors.listeningDecorator(new ThreadPoolExecutor(
executorSize, executorSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Sharding-JDBC-%d").build()));
+ }
MoreExecutors.addDelayedShutdownHook(executorService, 60, TimeUnit.SECONDS);
}
@@ -88,11 +88,8 @@ public List execute(
}
OverallExecutionEvent event = new OverallExecutionEvent(sqlType, baseStatementUnits.size());
EventBusInstance.getInstance().post(event);
- Iterator extends BaseStatementUnit> iterator = baseStatementUnits.iterator();
try {
- T firstOutput = syncExecute(sqlType, iterator.next(), executeCallback);
- List> restFutures = asyncExecute(sqlType, Lists.newArrayList(iterator), executeCallback);
- List result = buildResultList(firstOutput, restFutures);
+ List result = getExecuteResults(sqlType, baseStatementUnits, executeCallback);
event.setEventExecutionType(EventExecutionType.EXECUTE_SUCCESS);
EventBusInstance.getInstance().post(event);
return result;
@@ -107,64 +104,34 @@ public List execute(
}
}
- private List> asyncExecute(
- final SQLType sqlType, final Collection baseStatementUnits, final ExecuteCallback executeCallback) {
- List> result = new ArrayList<>(baseStatementUnits.size());
- final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
- final Map dataMap = ExecutorDataMap.getDataMap();
- for (final BaseStatementUnit each : baseStatementUnits) {
- result.add(executorService.submit(new Callable() {
-
- @Override
- public T call() throws Exception {
- return executeInternal(sqlType, each, executeCallback, isExceptionThrown, dataMap);
- }
- }));
- }
- return result;
- }
-
- private T syncExecute(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final ExecuteCallback executeCallback) throws Exception {
- return executeInternal(sqlType, baseStatementUnit, executeCallback, ExecutorExceptionHandler.isExceptionThrown(), ExecutorDataMap.getDataMap());
- }
+ protected abstract List getExecuteResults(SQLType sqlType, Collection extends BaseStatementUnit> baseStatementUnits, ExecuteCallback executeCallback) throws Exception;
- private T executeInternal(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final ExecuteCallback executeCallback,
+ protected T executeInternal(final SQLType sqlType, final BaseStatementUnit baseStatementUnit, final ExecuteCallback