You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/06/18 07:30:24 UTC
[shardingsphere] branch master updated: Split scaling ANTLR g4 file
and visitor (#10859)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 d18667f Split scaling ANTLR g4 file and visitor (#10859)
d18667f is described below
commit d18667f325f4d17a00a24431ed7a0c5ed9393578
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Jun 18 15:29:57 2021 +0800
Split scaling ANTLR g4 file and visitor (#10859)
* Add shardingsphere-scaling-distsql module
* Split scaling ANTLR g4 file and visitor
---
.../shardingsphere-distsql-parser-engine/pom.xml | 18 ++---
.../src/main/antlr4/imports/Keyword.g4 | 32 ---------
.../distsql/parser/autogen/ResourceStatement.g4 | 9 +--
.../resource/ResourceDistSQLStatementVisitor.java | 49 --------------
.../shardingsphere-proxy-backend/pom.xml | 10 +++
.../text/distsql/ral/RALBackendHandlerFactory.java | 14 ++--
.../ral/impl/CheckScalingJobBackendHandler.java | 2 +-
.../ral/impl/DropScalingJobBackendHandler.java | 2 +-
.../ral/impl/ResetScalingJobBackendHandler.java | 2 +-
.../impl/ShowScalingJobStatusBackendHandler.java | 2 +-
.../ral/impl/StartScalingJobBackendHandler.java | 2 +-
.../ral/impl/StopScalingJobBackendHandler.java | 2 +-
shardingsphere-scaling/pom.xml | 1 +
.../{ => shardingsphere-scaling-distsql}/pom.xml | 14 ++--
.../shardingsphere-scaling-distsql-parser}/pom.xml | 23 +++----
.../src/main/antlr4/imports/scaling/Alphabet.g4 | 42 ++++++++----
.../src/main/antlr4/imports/scaling}/Keyword.g4 | 40 -----------
.../src/main/antlr4/imports/scaling/Literals.g4 | 43 ++++++------
.../main/antlr4/imports/scaling}/RALStatement.g4 | 0
.../src/main/antlr4/imports/scaling/Symbol.g4 | 61 +++++++++++++++++
.../distsql/parser/autogen/ScalingStatement.g4 | 9 +--
.../scaling/distsql/parser/core/ScalingLexer.java | 18 ++---
.../scaling/distsql/parser/core/ScalingParser.java | 25 ++++---
.../parser/core/ScalingSQLStatementVisitor.java | 77 ++++++++++++++++++++++
.../facade/ScalingSQLStatementParserFacade.java | 52 +++++++++++++++
...distsql.parser.spi.RuleSQLStatementParserFacade | 18 +++++
.../core/ScalingStatementParserEngineTest.java | 41 ++++++++++++
.../pom.xml | 22 ++++---
.../statement}/CheckScalingJobStatement.java | 2 +-
.../statement}/DropScalingJobStatement.java | 2 +-
.../statement}/ResetScalingJobStatement.java | 2 +-
.../statement}/ShowScalingJobListStatement.java | 2 +-
.../statement}/ShowScalingJobStatusStatement.java | 2 +-
.../statement}/StartScalingJobStatement.java | 2 +-
.../statement}/StopScalingJobStatement.java | 2 +-
35 files changed, 397 insertions(+), 247 deletions(-)
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml
index bf893ed..cf08cac 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml
+++ b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml
@@ -29,15 +29,6 @@
<dependencies>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-distsql-parser-statement</artifactId>
<version>${project.version}</version>
@@ -47,6 +38,15 @@
<artifactId>shardingsphere-sql-parser-engine</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4 b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
index 2cecca7..3f7c491 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
+++ b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
@@ -35,22 +35,6 @@ SHOW
: S H O W
;
-START
- : S T A R T
- ;
-
-STOP
- : S T O P
- ;
-
-RESET
- : R E S E T
- ;
-
-CHECK
- : C H E C K
- ;
-
RESOURCE
: R E S O U R C E
;
@@ -63,22 +47,6 @@ FROM
: F R O M
;
-SCALING
- : S C A L I N G
- ;
-
-JOB
- : J O B
- ;
-
-LIST
- : L I S T
- ;
-
-STATUS
- : S T A T U S
- ;
-
HOST
: H O S T
;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4 b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
index 9d5424e..3a9e4c6 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
@@ -17,18 +17,11 @@
grammar ResourceStatement;
-import Symbol, RDLStatement, RQLStatement, RALStatement;
+import Symbol, RDLStatement, RQLStatement;
execute
: (addResource
| dropResource
| showResources
- | showScalingJobList
- | showScalingJobStatus
- | startScalingJob
- | stopScalingJob
- | dropScalingJob
- | resetScalingJob
- | checkScalingJob
) SEMI?
;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
index 157015d..9118aa3 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
+++ b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
@@ -20,25 +20,11 @@ package org.apache.shardingsphere.distsql.parser.core.resource;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementBaseVisitor;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.AddResourceContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.CheckScalingJobContext;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.DataSourceContext;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.DropResourceContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.DropScalingJobContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.ResetScalingJobContext;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.SchemaNameContext;
import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.ShowResourcesContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.ShowScalingJobListContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.ShowScalingJobStatusContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.StartScalingJobContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.StopScalingJobContext;
import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.CheckScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.DropScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ResetScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ShowScalingJobListStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ShowScalingJobStatusStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StartScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StopScalingJobStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
@@ -79,39 +65,4 @@ public final class ResourceDistSQLStatementVisitor extends ResourceStatementBase
public ASTNode visitSchemaName(final SchemaNameContext ctx) {
return new SchemaSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
}
-
- @Override
- public ASTNode visitShowScalingJobList(final ShowScalingJobListContext ctx) {
- return new ShowScalingJobListStatement();
- }
-
- @Override
- public ASTNode visitShowScalingJobStatus(final ShowScalingJobStatusContext ctx) {
- return new ShowScalingJobStatusStatement(Long.parseLong(ctx.jobId().getText()));
- }
-
- @Override
- public ASTNode visitStartScalingJob(final StartScalingJobContext ctx) {
- return new StartScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
- }
-
- @Override
- public ASTNode visitStopScalingJob(final StopScalingJobContext ctx) {
- return new StopScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
- }
-
- @Override
- public ASTNode visitDropScalingJob(final DropScalingJobContext ctx) {
- return new DropScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
- }
-
- @Override
- public ASTNode visitResetScalingJob(final ResetScalingJobContext ctx) {
- return new ResetScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
- }
-
- @Override
- public ASTNode visitCheckScalingJob(final CheckScalingJobContext ctx) {
- return new CheckScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/pom.xml b/shardingsphere-proxy/shardingsphere-proxy-backend/pom.xml
index 24745f8..470b19b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/pom.xml
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/pom.xml
@@ -104,6 +104,16 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-scaling-distsql-statement</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-scaling-distsql-parser</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-scaling-mysql</artifactId>
<version>${project.parent.version}</version>
</dependency>
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index 9bab535..09c7808 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.CheckScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.DropScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ResetScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ShowScalingJobListStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ShowScalingJobStatusStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StartScalingJobStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StopScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.CheckScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.DropScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ResetScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobListStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobStatusStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.StartScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.StopScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.CheckScalingJobBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.DropScalingJobBackendHandler;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobBackendHandler.java
index 001aba8..d97e2d2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobBackendHandler.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.CheckScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import org.apache.shardingsphere.scaling.distsql.statement.CheckScalingJobStatement;
import java.sql.Types;
import java.util.Collection;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobBackendHandler.java
index 05dc560..cea6334 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobBackendHandler.java
@@ -18,12 +18,12 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.DropScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import org.apache.shardingsphere.scaling.distsql.statement.DropScalingJobStatement;
/**
* Drop scaling job backend handler.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java
index 0cb1f12..802d321 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ResetScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ResetScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.exception.ScalingJobOperateException;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusBackendHandler.java
index 4067992..ba7117c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusBackendHandler.java
@@ -19,13 +19,13 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.ShowScalingJobStatusStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobStatusStatement;
import java.sql.Types;
import java.util.Collection;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobBackendHandler.java
index eefc210..1432eb9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobBackendHandler.java
@@ -18,12 +18,12 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StartScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import org.apache.shardingsphere.scaling.distsql.statement.StartScalingJobStatement;
/**
* Start scaling job backend handler.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java
index 8a11eb5..d8c739d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java
@@ -18,12 +18,12 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.impl.StopScalingJobStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import org.apache.shardingsphere.scaling.distsql.statement.StopScalingJobStatement;
/**
* Stop scaling job backend handler.
diff --git a/shardingsphere-scaling/pom.xml b/shardingsphere-scaling/pom.xml
index 0cc7e32..9313536 100755
--- a/shardingsphere-scaling/pom.xml
+++ b/shardingsphere-scaling/pom.xml
@@ -31,6 +31,7 @@
<modules>
<module>shardingsphere-scaling-bootstrap</module>
<module>shardingsphere-scaling-core</module>
+ <module>shardingsphere-scaling-distsql</module>
<module>shardingsphere-scaling-dialect</module>
</modules>
</project>
diff --git a/shardingsphere-scaling/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-distsql/pom.xml
old mode 100755
new mode 100644
similarity index 70%
copy from shardingsphere-scaling/pom.xml
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/pom.xml
index 0cc7e32..f6b66c4
--- a/shardingsphere-scaling/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/pom.xml
@@ -16,21 +16,21 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-scaling</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-scaling</artifactId>
+ <artifactId>shardingsphere-scaling-distsql</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-scaling-bootstrap</module>
- <module>shardingsphere-scaling-core</module>
- <module>shardingsphere-scaling-dialect</module>
+ <module>shardingsphere-scaling-distsql-statement</module>
+ <module>shardingsphere-scaling-distsql-parser</module>
</modules>
</project>
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/pom.xml
similarity index 81%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/pom.xml
index bf893ed..b58a1c0 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/pom.xml
@@ -19,32 +19,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>shardingsphere-distsql-parser</artifactId>
<groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-scaling-distsql</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>shardingsphere-distsql-parser-engine</artifactId>
+ <artifactId>shardingsphere-scaling-distsql-parser</artifactId>
+ <name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-parser-spi</artifactId>
+ <version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-distsql-parser-statement</artifactId>
+ <artifactId>shardingsphere-distsql-parser-engine</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sql-parser-engine</artifactId>
+ <artifactId>shardingsphere-scaling-distsql-statement</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
@@ -58,7 +55,7 @@
<execution>
<id>antlr</id>
<configuration>
- <libDirectory>src/main/antlr4/imports/</libDirectory>
+ <libDirectory>src/main/antlr4/imports/scaling/</libDirectory>
<listener>false</listener>
<visitor>true</visitor>
</configuration>
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Alphabet.g4
similarity index 56%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Alphabet.g4
index 4f1687f..f7603cc 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Alphabet.g4
@@ -15,18 +15,34 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+lexer grammar Alphabet;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+FOR_GENERATOR: 'DO NOT MATCH ANY THING, JUST FOR GENERATOR';
-/**
- * Check scaling job statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class CheckScalingJobStatement extends RALStatement {
-
- private final long jobId;
-}
+fragment A: [Aa];
+fragment B: [Bb];
+fragment C: [Cc];
+fragment D: [Dd];
+fragment E: [Ee];
+fragment F: [Ff];
+fragment G: [Gg];
+fragment H: [Hh];
+fragment I: [Ii];
+fragment J: [Jj];
+fragment K: [Kk];
+fragment L: [Ll];
+fragment M: [Mm];
+fragment N: [Nn];
+fragment O: [Oo];
+fragment P: [Pp];
+fragment Q: [Qq];
+fragment R: [Rr];
+fragment S: [Ss];
+fragment T: [Tt];
+fragment U: [Uu];
+fragment V: [Vv];
+fragment W: [Ww];
+fragment X: [Xx];
+fragment Y: [Yy];
+fragment Z: [Zz];
+fragment UL_: '_';
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4 b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Keyword.g4
similarity index 80%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Keyword.g4
index 2cecca7..571dbc7 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Keyword.g4
@@ -23,10 +23,6 @@ WS
: [ \t\r\n] + ->skip
;
-ADD
- : A D D
- ;
-
DROP
: D R O P
;
@@ -51,18 +47,6 @@ CHECK
: C H E C K
;
-RESOURCE
- : R E S O U R C E
- ;
-
-RESOURCES
- : R E S O U R C E S
- ;
-
-FROM
- : F R O M
- ;
-
SCALING
: S C A L I N G
;
@@ -78,27 +62,3 @@ LIST
STATUS
: S T A T U S
;
-
-HOST
- : H O S T
- ;
-
-PORT
- : P O R T
- ;
-
-DB
- : D B
- ;
-
-USER
- : U S E R
- ;
-
-PASSWORD
- : P A S S W O R D
- ;
-
-NAME
- : N A M E
- ;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4 b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Literals.g4
similarity index 65%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Literals.g4
index 2a5818f..e5f807b 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Literals.g4
@@ -15,38 +15,37 @@
* limitations under the License.
*/
-grammar RALStatement;
+lexer grammar Literals;
-import Keyword, Literals, Symbol;
+import Alphabet, Symbol;
-showScalingJobList
- : SHOW SCALING JOB LIST
+IDENTIFIER
+ : [A-Za-z_$0-9]*?[A-Za-z_$]+?[A-Za-z_$0-9]*
+ | BQ ~'`'+ BQ
+ | (DQ ( '\\'. | '""' | ~('"'| '\\') )* DQ)
;
-
-showScalingJobStatus
- : SHOW SCALING JOB STATUS jobId
- ;
-
-startScalingJob
- : START SCALING JOB jobId
+
+STRING
+ : (DQ ('""' | ~('"'| '\\') )* DQ)
+ | (SQ ('\'\'' | ~('\'' | '\\'))* SQ)
;
-stopScalingJob
- : STOP SCALING JOB jobId
+INT
+ : [0-9]+
;
-dropScalingJob
- : DROP SCALING JOB jobId
+HEX
+ : [0-9a-fA-F]
;
-resetScalingJob
- : RESET SCALING JOB jobId
+NUMBER
+ : INT? DOT? INT (E (PLUS | MINUS)? INT)?
;
-checkScalingJob
- : CHECK SCALING JOB jobId
+HEXDIGIT
+ : '0x' HEX+ | 'X' SQ HEX+ SQ
;
-
-jobId
- : INT
+
+BITNUM
+ : '0b' ('0' | '1')+ | B SQ ('0' | '1')+ SQ
;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4 b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/RALStatement.g4
similarity index 100%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/RALStatement.g4
diff --git a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Symbol.g4 b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Symbol.g4
new file mode 100644
index 0000000..a332bdd
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling/Symbol.g4
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Symbol;
+
+AND: '&&';
+OR: '||';
+NOT: '!';
+TILDE: '~';
+VERTICALBAR: '|';
+AMPERSAND: '&';
+SIGNEDLEFTSHIFT: '<<';
+SIGNEDRIGHTSHIFT: '>>';
+CARET: '^';
+MOD: '%';
+COLON: ':';
+PLUS: '+';
+MINUS: '-';
+ASTERISK: '*';
+SLASH: '/';
+BACKSLASH: '\\';
+DOT: '.';
+DOTASTERISK: '.*';
+SAFEEQ: '<=>';
+DEQ: '==';
+EQ: '=';
+NEQ: '<>' | '!=';
+GT: '>';
+GTE: '>=';
+LT: '<';
+LTE: '<=';
+POUND: '#';
+LP: '(';
+RP: ')';
+LBE: '{';
+RBE: '}';
+LBT: '[';
+RBT: ']';
+COMMA: ',';
+DQ: '"';
+SQ : '\'';
+BQ: '`';
+QUESTION: '?';
+AT: '@';
+SEMI: ';';
+JSONSEPARATOR: '->>';
+UL: '_';
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4 b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ScalingStatement.g4
similarity index 85%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ScalingStatement.g4
index 9d5424e..fda5039 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ScalingStatement.g4
@@ -15,15 +15,12 @@
* limitations under the License.
*/
-grammar ResourceStatement;
+grammar ScalingStatement;
-import Symbol, RDLStatement, RQLStatement, RALStatement;
+import Symbol, RALStatement;
execute
- : (addResource
- | dropResource
- | showResources
- | showScalingJobList
+ : (showScalingJobList
| showScalingJobStatus
| startScalingJob
| stopScalingJob
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingLexer.java
similarity index 65%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingLexer.java
index 4f1687f..07078be 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingLexer.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.parser.core;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.antlr.v4.runtime.CharStream;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementLexer;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
/**
- * Check scaling job statement.
+ * SQL lexer for scaling.
*/
-@RequiredArgsConstructor
-@Getter
-public final class CheckScalingJobStatement extends RALStatement {
+public final class ScalingLexer extends ScalingStatementLexer implements SQLLexer {
- private final long jobId;
+ public ScalingLexer(final CharStream input) {
+ super(input);
+ }
}
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingParser.java
similarity index 55%
copy from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingParser.java
index 4f1687f..435cf21 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingParser.java
@@ -15,18 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.parser.core;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.antlr.v4.runtime.TokenStream;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
/**
- * Check scaling job statement.
+ * SQL parser for scaling.
*/
-@RequiredArgsConstructor
-@Getter
-public final class CheckScalingJobStatement extends RALStatement {
+public final class ScalingParser extends ScalingStatementParser implements SQLParser {
- private final long jobId;
+ public ScalingParser(final TokenStream input) {
+ super(input);
+ }
+
+ @Override
+ public ASTNode parse() {
+ return new ParseASTNode(execute());
+ }
}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingSQLStatementVisitor.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingSQLStatementVisitor.java
new file mode 100644
index 0000000..4f888ca
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingSQLStatementVisitor.java
@@ -0,0 +1,77 @@
+/*
+ * 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.scaling.distsql.parser.core;
+
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementBaseVisitor;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.CheckScalingJobContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.DropScalingJobContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.ResetScalingJobContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.ShowScalingJobListContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.ShowScalingJobStatusContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.StartScalingJobContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ScalingStatementParser.StopScalingJobContext;
+import org.apache.shardingsphere.scaling.distsql.statement.CheckScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.DropScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ResetScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobListStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobStatusStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.StartScalingJobStatement;
+import org.apache.shardingsphere.scaling.distsql.statement.StopScalingJobStatement;
+import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
+
+/**
+ * SQL statement visitor for scaling.
+ */
+public final class ScalingSQLStatementVisitor extends ScalingStatementBaseVisitor<ASTNode> implements SQLVisitor {
+
+ @Override
+ public ASTNode visitShowScalingJobList(final ShowScalingJobListContext ctx) {
+ return new ShowScalingJobListStatement();
+ }
+
+ @Override
+ public ASTNode visitShowScalingJobStatus(final ShowScalingJobStatusContext ctx) {
+ return new ShowScalingJobStatusStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+
+ @Override
+ public ASTNode visitStartScalingJob(final StartScalingJobContext ctx) {
+ return new StartScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+
+ @Override
+ public ASTNode visitStopScalingJob(final StopScalingJobContext ctx) {
+ return new StopScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+
+ @Override
+ public ASTNode visitDropScalingJob(final DropScalingJobContext ctx) {
+ return new DropScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+
+ @Override
+ public ASTNode visitResetScalingJob(final ResetScalingJobContext ctx) {
+ return new ResetScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+
+ @Override
+ public ASTNode visitCheckScalingJob(final CheckScalingJobContext ctx) {
+ return new CheckScalingJobStatement(Long.parseLong(ctx.jobId().getText()));
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/facade/ScalingSQLStatementParserFacade.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/facade/ScalingSQLStatementParserFacade.java
new file mode 100644
index 0000000..53cacd2
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/facade/ScalingSQLStatementParserFacade.java
@@ -0,0 +1,52 @@
+/*
+ * 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.scaling.distsql.parser.facade;
+
+import org.apache.shardingsphere.distsql.parser.spi.RuleSQLStatementParserFacade;
+import org.apache.shardingsphere.scaling.distsql.parser.core.ScalingLexer;
+import org.apache.shardingsphere.scaling.distsql.parser.core.ScalingParser;
+import org.apache.shardingsphere.scaling.distsql.parser.core.ScalingSQLStatementVisitor;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
+
+/**
+ * SQL parser facade for scaling SQL statement.
+ */
+public final class ScalingSQLStatementParserFacade implements RuleSQLStatementParserFacade {
+
+ @Override
+ public Class<? extends SQLLexer> getLexerClass() {
+ return ScalingLexer.class;
+ }
+
+ @Override
+ public Class<? extends SQLParser> getParserClass() {
+ return ScalingParser.class;
+ }
+
+ @Override
+ public Class<? extends SQLVisitor> getVisitorClass() {
+ return ScalingSQLStatementVisitor.class;
+ }
+
+ @Override
+ public String getRuleType() {
+ return "scaling";
+ }
+}
diff --git a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.spi.RuleSQLStatementParserFacade b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.spi.RuleSQLStatementParserFacade
new file mode 100644
index 0000000..dc14e0e
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.spi.RuleSQLStatementParserFacade
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.scaling.distsql.parser.facade.ScalingSQLStatementParserFacade
diff --git a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/test/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingStatementParserEngineTest.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/test/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingStatementParserEngineTest.java
new file mode 100644
index 0000000..7d17486
--- /dev/null
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/test/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingStatementParserEngineTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.scaling.distsql.parser.core;
+
+import org.apache.shardingsphere.distsql.parser.api.DistSQLStatementParserEngine;
+import org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobListStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+// TODO use Parameterized + XML instead of static test
+public final class ScalingStatementParserEngineTest {
+
+ private static final String SHOW_SCALING_JOB_LIST = "SHOW SCALING JOB LIST;";
+
+ private final DistSQLStatementParserEngine engine = new DistSQLStatementParserEngine();
+
+ @Test
+ public void assertParseShowScalingJobList() {
+ SQLStatement sqlStatement = engine.parse(SHOW_SCALING_JOB_LIST);
+ assertTrue(sqlStatement instanceof ShowScalingJobListStatement);
+ }
+
+ // TODO add more test cases
+}
diff --git a/shardingsphere-scaling/pom.xml b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/pom.xml
old mode 100755
new mode 100644
similarity index 63%
copy from shardingsphere-scaling/pom.xml
copy to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/pom.xml
index 0cc7e32..dd042a9
--- a/shardingsphere-scaling/pom.xml
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/pom.xml
@@ -16,21 +16,23 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-scaling-distsql</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-scaling</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-scaling-distsql-statement</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-scaling-bootstrap</module>
- <module>shardingsphere-scaling-core</module>
- <module>shardingsphere-scaling-dialect</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-distsql-parser-statement</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
index 4f1687f..c84a763 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/CheckScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/DropScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/DropScalingJobStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
index deaced8..d03b618 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/DropScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ResetScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ResetScalingJobStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
index 502c677..b37dd06 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ResetScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobListStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
similarity index 93%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobListStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
index 09a08ad..d8d9530 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobListStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobStatusStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobStatusStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
index 3266049..127a114 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobStatusStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StartScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StartScalingJobStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
index 4f8ebcb..a694af5 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StartScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StopScalingJobStatement.java b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
similarity index 94%
rename from shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StopScalingJobStatement.java
rename to shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
index 9465f5b..5923318 100644
--- a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/StopScalingJobStatement.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.ral.impl;
+package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;