This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8368e92 For code format (#10585)
8368e92 is described below
commit 8368e92712b7ebde8deeaa6abe14da46cc56ee27
Author: Liang Zhang <[email protected]>
AuthorDate: Mon May 31 16:16:00 2021 +0800
For code format (#10585)
* Remove useless dependency
* Remove useless dependency
* Remove useless dependencies for governance module
* Remove useless dependencies for governance module
* Add todo for DistSQLStatementParserEngineTest
* Refactor RQLStatement.g4
* For code format
* For code format
* For code format
* For code format
---
.../src/main/antlr4/imports/RQLStatement.g4 | 8 +--
.../distsql/parser/core/DistSQLVisitor.java | 66 ++++++++++----------
.../api/DistSQLStatementParserEngineTest.java | 1 +
.../segment/rdl/DatabaseDiscoveryRuleSegment.java | 8 +--
.../parser/segment/rdl/EncryptColumnSegment.java | 8 +--
.../parser/segment/rdl/EncryptRuleSegment.java | 6 +-
.../segment/rdl/ReadwriteSplittingRuleSegment.java | 4 +-
.../rdl/alter/AlterEncryptRuleStatement.java | 2 +-
.../AlterReadwriteSplittingRuleStatement.java | 2 +-
.../create/impl/CreateEncryptRuleStatement.java | 2 +-
.../show/ShowDatabaseDiscoveryRulesStatement.java | 2 +-
.../rql/show/ShowEncryptRulesStatement.java | 4 +-
.../show/ShowReadwriteSplittingRulesStatement.java | 2 +-
.../statement/rql/show/ShowRulesStatement.java | 4 +-
.../ShowShardingBindingTableRulesStatement.java | 2 +-
.../ShowShardingBroadcastTableRulesStatement.java | 2 +-
.../rql/show/ShowShardingTableRulesStatement.java | 4 +-
.../listener/impl/RuleChangedListenerTest.java | 70 ++++++++++++++++++++++
.../Dockerfile | 27 ---------
.../src/test/assembly/bin/stop.sh | 51 ----------------
.../src/test/resources/env/engine-env.properties | 27 ---------
21 files changed, 133 insertions(+), 169 deletions(-)
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
index 13ef0f6..5102803 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
@@ -23,6 +23,10 @@ showResources
: SHOW RESOURCES (FROM schemaName)?
;
+showShardingTableRules
+ : SHOW SHARDING TABLE (tableRule | RULES) (FROM schemaName)?
+ ;
+
showShardingBindingTableRules
: SHOW SHARDING BINDING TABLE RULES (FROM schemaName)?
;
@@ -43,10 +47,6 @@ showEncryptRules
: SHOW ENCRYPT (TABLE tableRule | RULES) (FROM schemaName)?
;
-showShardingTableRules
- : SHOW SHARDING TABLE (tableRule | RULES) (FROM schemaName)?
- ;
-
tableRule
: RULE tableName
;
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
index 5e2deb8..f35340c 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/DistSQLVisitor.java
@@ -104,7 +104,7 @@ import java.util.stream.Collectors;
* Dist SQL visitor.
*/
public final class DistSQLVisitor extends DistSQLStatementBaseVisitor<ASTNode>
{
-
+
@Override
public ASTNode visitAddResource(final AddResourceContext ctx) {
Collection<DataSourceSegment> connectionInfos = new LinkedList<>();
@@ -155,14 +155,14 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
}
return result;
}
-
+
@Override
public ASTNode visitCreateShardingBroadcastTableRules(final
CreateShardingBroadcastTableRulesContext ctx) {
CreateShardingBroadcastTableRulesStatement result = new
CreateShardingBroadcastTableRulesStatement();
result.getTables().addAll(ctx.IDENTIFIER().stream().map(ParseTree::getText).collect(Collectors.toList()));
return result;
}
-
+
@Override
public ASTNode visitAlterShardingTableRule(final
DistSQLStatementParser.AlterShardingTableRuleContext ctx) {
AlterShardingTableRuleStatement result = new
AlterShardingTableRuleStatement();
@@ -171,12 +171,12 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
}
return result;
}
-
+
@Override
public ASTNode visitShowShardingBroadcastTableRules(final
ShowShardingBroadcastTableRulesContext ctx) {
return new
ShowShardingBroadcastTableRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitAlterShardingBindingTableRules(final
DistSQLStatementParser.AlterShardingBindingTableRulesContext ctx) {
AlterShardingBindingTableRulesStatement result = new
AlterShardingBindingTableRulesStatement();
@@ -188,20 +188,20 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
}
return result;
}
-
+
@Override
public ASTNode visitAlterShardingBroadcastTableRules(final
DistSQLStatementParser.AlterShardingBroadcastTableRulesContext ctx) {
AlterShardingBroadcastTableRulesStatement result = new
AlterShardingBroadcastTableRulesStatement();
result.getTables().addAll(ctx.IDENTIFIER().stream().map(ParseTree::getText).collect(Collectors.toList()));
return result;
}
-
+
@Override
public ASTNode visitCreateReadwriteSplittingRule(final
DistSQLStatementParser.CreateReadwriteSplittingRuleContext ctx) {
return new
CreateReadwriteSplittingRuleStatement(ctx.readwriteSplittingRuleDefinition()
.stream().map(each -> (ReadwriteSplittingRuleSegment)
visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitReadwriteSplittingRuleDefinition(final
DistSQLStatementParser.ReadwriteSplittingRuleDefinitionContext ctx) {
ReadwriteSplittingRuleSegment result = (ReadwriteSplittingRuleSegment)
(null != ctx.dynamicReadwriteSplittingRuleDefinition()
@@ -217,7 +217,7 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
result.setProps(props);
return result;
}
-
+
@Override
public ASTNode visitStaticReadwriteSplittingRuleDefinition(final
DistSQLStatementParser.StaticReadwriteSplittingRuleDefinitionContext ctx) {
ReadwriteSplittingRuleSegment result = new
ReadwriteSplittingRuleSegment();
@@ -225,20 +225,20 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
result.setReadDataSources(ctx.resourceName().stream().map(each ->
each.getText()).collect(Collectors.toList()));
return result;
}
-
+
@Override
public ASTNode visitDynamicReadwriteSplittingRuleDefinition(final
DistSQLStatementParser.DynamicReadwriteSplittingRuleDefinitionContext ctx) {
ReadwriteSplittingRuleSegment result = new
ReadwriteSplittingRuleSegment();
result.setAutoAwareResource(ctx.IDENTIFIER().getText());
return result;
}
-
+
@Override
public ASTNode visitAlterReadwriteSplittingRule(final
DistSQLStatementParser.AlterReadwriteSplittingRuleContext ctx) {
return new
AlterReadwriteSplittingRuleStatement(ctx.readwriteSplittingRuleDefinition()
.stream().map(each -> (ReadwriteSplittingRuleSegment)
visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitDropShardingTableRule(final
DistSQLStatementParser.DropShardingTableRuleContext ctx) {
DropShardingTableRuleStatement result = new
DropShardingTableRuleStatement();
@@ -247,12 +247,12 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
}
return result;
}
-
+
@Override
public ASTNode visitDropShardingBindingTableRules(final
DistSQLStatementParser.DropShardingBindingTableRulesContext ctx) {
return new DropShardingBindingTableRulesStatement();
}
-
+
@Override
public ASTNode visitDropShardingBroadcastTableRules(final
DistSQLStatementParser.DropShardingBroadcastTableRulesContext ctx) {
return new DropShardingBroadcastTableRulesStatement();
@@ -293,12 +293,12 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
result.setAlgorithmProps(algorithmProps);
return result;
}
-
+
@Override
public ASTNode visitCreateDatabaseDiscoveryRule(final
DistSQLStatementParser.CreateDatabaseDiscoveryRuleContext ctx) {
return new
CreateDatabaseDiscoveryRuleStatement(ctx.databaseDiscoveryRuleDefinition().stream().map(each
-> (DatabaseDiscoveryRuleSegment) visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitDatabaseDiscoveryRuleDefinition(final
DistSQLStatementParser.DatabaseDiscoveryRuleDefinitionContext ctx) {
DatabaseDiscoveryRuleSegment result = new
DatabaseDiscoveryRuleSegment();
@@ -308,31 +308,31 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
result.setProps(buildAlgorithmProperties(ctx.functionDefinition().algorithmProperties()));
return result;
}
-
+
@Override
public ASTNode visitAlterDatabaseDiscoveryRule(final
DistSQLStatementParser.AlterDatabaseDiscoveryRuleContext ctx) {
return new
AlterDatabaseDiscoveryRuleStatement(ctx.databaseDiscoveryRuleDefinition().stream().map(each
-> (DatabaseDiscoveryRuleSegment) visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitDropDatabaseDiscoveryRule(final
DistSQLStatementParser.DropDatabaseDiscoveryRuleContext ctx) {
DropDatabaseDiscoveryRuleStatement result = new
DropDatabaseDiscoveryRuleStatement();
result.getRuleNames().addAll(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
return result;
}
-
+
@Override
public ASTNode visitCreateEncryptRule(final
DistSQLStatementParser.CreateEncryptRuleContext ctx) {
return new CreateEncryptRuleStatement(ctx.encryptRuleDefinition()
.stream().map(each -> (EncryptRuleSegment)
visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitEncryptRuleDefinition(final
DistSQLStatementParser.EncryptRuleDefinitionContext ctx) {
return new EncryptRuleSegment(ctx.tableName().getText(),
ctx.columnDefinition()
.stream().map(each -> (EncryptColumnSegment)
visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitColumnDefinition(final
DistSQLStatementParser.ColumnDefinitionContext ctx) {
EncryptColumnSegment result = new EncryptColumnSegment();
@@ -344,23 +344,23 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
result.setEncryptor((FunctionSegment) visit(ctx.functionDefinition()));
return result;
}
-
+
@Override
public ASTNode visitAlterEncryptRule(final
DistSQLStatementParser.AlterEncryptRuleContext ctx) {
return new AlterEncryptRuleStatement(ctx.encryptRuleDefinition()
.stream().map(each -> (EncryptRuleSegment)
visit(each)).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitDropEncryptRule(final
DistSQLStatementParser.DropEncryptRuleContext ctx) {
return new
DropEncryptRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
}
-
+
@Override
public ASTNode visitTableName(final TableNameContext ctx) {
return new TableNameSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
}
-
+
@Override
public ASTNode visitDropReadwriteSplittingRule(final
DistSQLStatementParser.DropReadwriteSplittingRuleContext ctx) {
DropReadwriteSplittingRuleStatement result = new
DropReadwriteSplittingRuleStatement();
@@ -372,12 +372,12 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
public ASTNode visitShowResources(final ShowResourcesContext ctx) {
return new ShowResourcesStatement(null == ctx.schemaName() ? null :
(SchemaSegment) visit(ctx.schemaName()));
}
-
+
@Override
public ASTNode visitShowShardingBindingTableRules(final
DistSQLStatementParser.ShowShardingBindingTableRulesContext ctx) {
return new
ShowShardingBindingTableRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitSchemaName(final SchemaNameContext ctx) {
return new SchemaSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
@@ -407,29 +407,29 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
public ASTNode visitDropScalingJob(final DropScalingJobContext ctx) {
return new
DropScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
}
-
+
@Override
public ASTNode visitShowReadwriteSplittingRules(final
ShowReadwriteSplittingRulesContext ctx) {
return new
ShowReadwriteSplittingRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitShowShardingTableRules(final
ShowShardingTableRulesContext ctx) {
return new
ShowShardingTableRulesStatement(Objects.nonNull(ctx.tableRule()) ?
ctx.tableRule().tableName().getText() : null,
Objects.nonNull(ctx.schemaName()) ? (SchemaSegment)
visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitShowDatabaseDiscoveryRules(final
ShowDatabaseDiscoveryRulesContext ctx) {
return new
ShowDatabaseDiscoveryRulesStatement(Objects.nonNull(ctx.schemaName()) ?
(SchemaSegment) visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitShowEncryptRules(final ShowEncryptRulesContext ctx) {
return new ShowEncryptRulesStatement(Objects.nonNull(ctx.tableRule())
? ctx.tableRule().tableName().getText() : null,
Objects.nonNull(ctx.schemaName()) ? (SchemaSegment)
visit(ctx.schemaName()) : null);
}
-
+
@Override
public ASTNode visitResetScalingJob(final ResetScalingJobContext ctx) {
return new
ResetScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
@@ -439,7 +439,7 @@ public final class DistSQLVisitor extends
DistSQLStatementBaseVisitor<ASTNode> {
public ASTNode visitCheckScalingJob(final CheckScalingJobContext ctx) {
return new
CheckScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
}
-
+
private Properties buildAlgorithmProperties(final
DistSQLStatementParser.AlgorithmPropertiesContext ctx) {
Properties result = new Properties();
for (AlgorithmPropertyContext each : ctx.algorithmProperty()) {
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/test/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngineTest.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/test/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngineTest.java
index 841d75d..675b3c2 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/test/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngineTest.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/test/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngineTest.java
@@ -62,6 +62,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+// TODO use Parameterized + XML instead of static test
public final class DistSQLStatementParserEngineTest {
private static final String RDL_ADD_RESOURCE_SINGLE_WITHOUT_PASSWORD =
"ADD RESOURCE ds_0(HOST=127.0.0.1,PORT=3306,DB=test0,USER=ROOT);";
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/DatabaseDiscoveryRuleSegment.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/DatabaseDiscoveryRuleSegment.java
index 0c37486..0d16832 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/DatabaseDiscoveryRuleSegment.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/DatabaseDiscoveryRuleSegment.java
@@ -30,12 +30,12 @@ import java.util.Properties;
@Getter
@Setter
public final class DatabaseDiscoveryRuleSegment implements ASTNode {
-
+
private String name;
-
+
private Collection<String> dataSources;
-
+
private String discoveryTypeName;
-
+
private Properties props;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptColumnSegment.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptColumnSegment.java
index df7e7f2..8195830 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptColumnSegment.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptColumnSegment.java
@@ -28,12 +28,12 @@ import
org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
@Getter
@Setter
public final class EncryptColumnSegment implements ASTNode {
-
+
private String name;
-
+
private String plainColumn;
-
+
private String cipherColumn;
-
+
private FunctionSegment encryptor;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptRuleSegment.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptRuleSegment.java
index 69806b8..8b6f497 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptRuleSegment.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/EncryptRuleSegment.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.distsql.parser.segment.rdl;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import lombok.Setter;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import java.util.Collection;
@@ -29,10 +28,9 @@ import java.util.Collection;
*/
@RequiredArgsConstructor
@Getter
-@Setter
public final class EncryptRuleSegment implements ASTNode {
-
+
private final String tableName;
-
+
private final Collection<EncryptColumnSegment> columns;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/ReadwriteSplittingRuleSegment.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/ReadwriteSplittingRuleSegment.java
index 5500afb..f9fc7bf 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/ReadwriteSplittingRuleSegment.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/rdl/ReadwriteSplittingRuleSegment.java
@@ -32,9 +32,9 @@ import java.util.Properties;
public final class ReadwriteSplittingRuleSegment implements ASTNode {
private String name;
-
+
private String autoAwareResource;
-
+
private String writeDataSource;
private Collection<String> readDataSources;
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterEncryptRuleStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterEncryptRuleStatement.java
index 75d9253..33b87dd 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterEncryptRuleStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterEncryptRuleStatement.java
@@ -30,6 +30,6 @@ import java.util.Collection;
@RequiredArgsConstructor
@Getter
public final class AlterEncryptRuleStatement extends RDLStatement {
-
+
private final Collection<EncryptRuleSegment> encryptRules;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterReadwriteSplittingRuleStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterReadwriteSplittingRuleStatement.java
index 207f5b2..c0f61d6 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterReadwriteSplittingRuleStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/alter/AlterReadwriteSplittingRuleStatement.java
@@ -30,6 +30,6 @@ import java.util.Collection;
@RequiredArgsConstructor
@Getter
public final class AlterReadwriteSplittingRuleStatement extends RDLStatement {
-
+
private final Collection<ReadwriteSplittingRuleSegment>
readwriteSplittingRules;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateEncryptRuleStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateEncryptRuleStatement.java
index 6b9c06f..0337f7c 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateEncryptRuleStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rdl/create/impl/CreateEncryptRuleStatement.java
@@ -30,6 +30,6 @@ import java.util.Collection;
@RequiredArgsConstructor
@Getter
public final class CreateEncryptRuleStatement extends CreateRDLStatement {
-
+
private final Collection<EncryptRuleSegment> encryptRules;
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowDatabaseDiscoveryRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowDatabaseDiscoveryRulesStatement.java
index 6f69c30..4ebea18 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowDatabaseDiscoveryRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowDatabaseDiscoveryRulesStatement.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
* Show database discovery rules statement.
*/
public final class ShowDatabaseDiscoveryRulesStatement extends
ShowRulesStatement {
-
+
public ShowDatabaseDiscoveryRulesStatement(final SchemaSegment schema) {
super(schema);
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowEncryptRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowEncryptRulesStatement.java
index ea84ae8..7932c28 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowEncryptRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowEncryptRulesStatement.java
@@ -25,9 +25,9 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
*/
@Getter
public final class ShowEncryptRulesStatement extends ShowRulesStatement {
-
+
private final String tableName;
-
+
public ShowEncryptRulesStatement(final String tableName, final
SchemaSegment schema) {
super(schema);
this.tableName = tableName;
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowReadwriteSplittingRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowReadwriteSplittingRulesStatement.java
index 44818ce..bddd03d 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowReadwriteSplittingRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowReadwriteSplittingRulesStatement.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
* Show readwrite splitting rules statement.
*/
public final class ShowReadwriteSplittingRulesStatement extends
ShowRulesStatement {
-
+
public ShowReadwriteSplittingRulesStatement(final SchemaSegment schema) {
super(schema);
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowRulesStatement.java
index 4e460d2..b389f7a 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowRulesStatement.java
@@ -29,11 +29,11 @@ import java.util.Optional;
*/
@RequiredArgsConstructor
public class ShowRulesStatement extends RQLStatement implements
FromSchemaAvailable {
-
+
private final SchemaSegment schema;
@Override
- public Optional<SchemaSegment> getSchema() {
+ public final Optional<SchemaSegment> getSchema() {
return Optional.ofNullable(schema);
}
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBindingTableRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBindingTableRulesStatement.java
index c085de7..bd2363b 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBindingTableRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBindingTableRulesStatement.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
* Show sharding binding table rules statement.
*/
public final class ShowShardingBindingTableRulesStatement extends
ShowRulesStatement {
-
+
public ShowShardingBindingTableRulesStatement(final SchemaSegment schema) {
super(schema);
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBroadcastTableRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBroadcastTableRulesStatement.java
index 0d07507..6f30477 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBroadcastTableRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingBroadcastTableRulesStatement.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
* Show sharding broadcast table rules statement.
*/
public final class ShowShardingBroadcastTableRulesStatement extends
ShowRulesStatement {
-
+
public ShowShardingBroadcastTableRulesStatement(final SchemaSegment
schema) {
super(schema);
}
diff --git
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingTableRulesStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingTableRulesStatement.java
index 717f3cd..526dd5f 100644
---
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingTableRulesStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowShardingTableRulesStatement.java
@@ -25,9 +25,9 @@ import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSeg
*/
@Getter
public final class ShowShardingTableRulesStatement extends ShowRulesStatement {
-
+
private final String tableName;
-
+
public ShowShardingTableRulesStatement(final String tableName, final
SchemaSegment schema) {
super(schema);
this.tableName = tableName;
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
new file mode 100644
index 0000000..a7a399f
--- /dev/null
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/listener/impl/RuleChangedListenerTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.governance.core.registry.listener.impl;
+
+import
org.apache.shardingsphere.governance.core.registry.listener.event.GovernanceEvent;
+import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
+import
org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent.Type;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+import static org.junit.Assert.assertFalse;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class RuleChangedListenerTest extends GovernanceListenerTest {
+
+ private static final String RULE_FILE = "yaml/rule.yaml";
+
+ private RuleChangedListener ruleChangedListener;
+
+ @Before
+ public void setUp() {
+ ruleChangedListener = new
RuleChangedListener(getRegistryCenterRepository(), Arrays.asList("foo_db",
"bar_db"));
+ }
+
+ @Test
+ public void assertCreateEventWithoutSchema() {
+ DataChangedEvent dataChangedEvent = new DataChangedEvent("/metadata",
readYAML(RULE_FILE), Type.UPDATED);
+ Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void assertCreateEventWithEmptyValue() {
+ DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/foo_db/rules", "", Type.UPDATED);
+ Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void assertCreateEventWithRule() {
+ // TODO use RuleConfigurationFixture instead of
ShardingRuleConfiguration for test case
+// DataChangedEvent dataChangedEvent = new
DataChangedEvent("/metadata/foo_db/rules", readYAML(RULE_FILE), Type.UPDATED);
+// Optional<GovernanceEvent> actual =
ruleChangedListener.createEvent(dataChangedEvent);
+// assertTrue(actual.isPresent());
+// assertThat(((RuleConfigurationsChangedEvent)
actual.get()).getSchemaName(), is("foo_db"));
+// Collection<RuleConfiguration> ruleConfigs =
((RuleConfigurationsChangedEvent) actual.get()).getRuleConfigurations();
+// assertThat(ruleConfigs.size(), is(1));
+// assertThat(((ShardingRuleConfiguration)
ruleConfigs.iterator().next()).getTables().size(), is(1));
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
deleted file mode 100644
index 8f60721..0000000
---
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-FROM openjdk:8-jdk-alpine
-
-ARG APP_NAME
-ENV WAIT_VERSION 2.7.2
-
-ADD
https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait
/wait
-RUN chmod +x /wait
-ADD target/${APP_NAME}.tar.gz /opt
-RUN mv /opt/${APP_NAME} /opt/shardingsphere-scaling
-ENTRYPOINT /wait && /opt/shardingsphere-scaling/bin/start.sh && tail -f
/opt/shardingsphere-scaling/logs/stdout.log
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
deleted file mode 100644
index 132e2f1..0000000
---
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-SERVER_NAME=ShardingSphere-Scaling
-
-cd `dirname $0`
-cd ..
-DEPLOY_DIR=`pwd`
-
-PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep |awk '{print $2}'`
-if [ -z "$PIDS" ]; then
- echo "ERROR: The $SERVER_NAME does not started!"
- exit 1
-fi
-
-echo -e "Stopping the $SERVER_NAME ...\c"
-for PID in ${PIDS} ; do
- kill ${PID} > /dev/null 2>&1
-done
-
-COUNT=0
-while [ ${COUNT} -lt 1 ]; do
- echo -e ".\c"
- sleep 1
- COUNT=1
- for PID in ${PIDS} ; do
- PID_EXIST=`ps -f -p ${PID} | grep java`
- if [ -n "$PID_EXIST" ]; then
- COUNT=0
- break
- fi
- done
-done
-
-echo "OK!"
-echo "PID: $PIDS"
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
deleted file mode 100644
index 5817727..0000000
---
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-it.env.type=${it.env}
-it.env.value=scaling
-
-db.host.docker=mysql:3306
-db.host.host=127.0.0.1:13306
-db.username=root
-db.password=123456
-scaling.url=http://127.0.0.1:18888
-scaling.retry=30
-scaling.waitMs=1000