This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 f637dd5 Use SPI to refactor RALBackendHandlerFactory (#11178)
f637dd5 is described below
commit f637dd5384e8fb247dda2c24da2c7547133fe67e
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jul 6 19:01:37 2021 +0800
Use SPI to refactor RALBackendHandlerFactory (#11178)
* Abstract ShowRulesStatement
* Add CheckScalingJobQueryResultSet
* Refactor CheckScalingJobQueryResultSet
* Add ShowScalingJobListQueryResultSet
* Add ShowScalingJobStatusQueryResultSet
* Refactor RALBackendHandlerFactory
* Add UpdatableRALBackendHandlerFactory
* Move RALUpdater to infra module
---
.../statement/ral/QueryableRALStatement.java | 8 +-
.../statement/ral/UpdatableRALStatement.java | 8 +-
.../statement/rql/show/ShowRulesStatement.java | 2 +-
.../infra/distsql/update/RALUpdater.java | 22 +++--
.../text/distsql/DistSQLBackendHandlerFactory.java | 2 +-
.../distsql/ral/QueryableRALBackendHandler.java | 65 ++++++++++++++
.../ral/QueryableRALBackendHandlerFactory.java | 52 +++++++++++
.../text/distsql/ral/RALBackendHandlerFactory.java | 43 ++-------
...andler.java => UpdatableRALBackendHandler.java} | 34 +++----
...java => UpdatableRALBackendHandlerFactory.java} | 39 ++++----
.../ral/impl/CheckScalingJobBackendHandler.java | 98 --------------------
.../ral/impl/CheckScalingJobQueryResultSet.java | 72 +++++++++++++++
...kendHandler.java => DropScalingJobUpdater.java} | 20 ++---
...endHandler.java => ResetScalingJobUpdater.java} | 22 +++--
.../ral/impl/ShowScalingJobListBackendHandler.java | 96 --------------------
.../ral/impl/ShowScalingJobListQueryResultSet.java | 73 +++++++++++++++
.../impl/ShowScalingJobStatusBackendHandler.java | 100 ---------------------
.../impl/ShowScalingJobStatusQueryResultSet.java | 75 ++++++++++++++++
...endHandler.java => StartScalingJobUpdater.java} | 20 ++---
...kendHandler.java => StopScalingJobUpdater.java} | 20 ++---
...shardingsphere.infra.distsql.query.RQLResultSet | 3 +
...shardingsphere.infra.distsql.update.RALUpdater} | 5 +-
.../statement/CheckScalingJobStatement.java | 4 +-
.../distsql/statement/DropScalingJobStatement.java | 4 +-
.../statement/ResetScalingJobStatement.java | 4 +-
.../statement/ShowScalingJobListStatement.java | 4 +-
.../statement/ShowScalingJobStatusStatement.java | 4 +-
.../statement/StartScalingJobStatement.java | 4 +-
.../distsql/statement/StopScalingJobStatement.java | 4 +-
29 files changed, 464 insertions(+), 443 deletions(-)
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/QueryableRALStatement.java
similarity index 76%
copy from
shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
copy to
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/QueryableRALStatement.java
index d8d9530..093c18c 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/QueryableRALStatement.java
@@ -15,12 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.distsql.statement;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral;
/**
- * Show scaling job list statement.
+ * Queryable RAL statement.
*/
-public final class ShowScalingJobListStatement extends RALStatement {
+public abstract class QueryableRALStatement extends RALStatement {
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/UpdatableRALStatement.java
similarity index 76%
copy from
shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
copy to
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/UpdatableRALStatement.java
index d8d9530..f1e54cc 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
+++
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/UpdatableRALStatement.java
@@ -15,12 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.distsql.statement;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral;
/**
- * Show scaling job list statement.
+ * Updatable RAL statement.
*/
-public final class ShowScalingJobListStatement extends RALStatement {
+public abstract class UpdatableRALStatement extends RALStatement {
}
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 b389f7a..66a0b51 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
@@ -28,7 +28,7 @@ import java.util.Optional;
* Show rules statement.
*/
@RequiredArgsConstructor
-public class ShowRulesStatement extends RQLStatement implements
FromSchemaAvailable {
+public abstract class ShowRulesStatement extends RQLStatement implements
FromSchemaAvailable {
private final SchemaSegment schema;
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
similarity index 63%
copy from
shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
copy to
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
index 127a114..611b553 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
@@ -15,18 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.scaling.distsql.statement;
+package org.apache.shardingsphere.infra.distsql.update;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.apache.shardingsphere.infra.spi.typed.TypedSPI;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
/**
- * Show scaling job status statement.
+ * RAL updater.
+ *
+ * @param <T> type of updatable RAL statement
*/
-@RequiredArgsConstructor
-@Getter
-public final class ShowScalingJobStatusStatement extends RALStatement {
+public interface RALUpdater<T extends SQLStatement> extends TypedSPI {
- private final long jobId;
+ /**
+ * Execute update.
+ *
+ * @param sqlStatement updatable RAL statement
+ */
+ void executeUpdate(T sqlStatement);
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
index 7ff6dfc..69a4700 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactory.java
@@ -56,7 +56,7 @@ public final class DistSQLBackendHandlerFactory {
return RDLBackendHandlerFactory.newInstance(databaseType,
(RDLStatement) sqlStatement, backendConnection);
}
if (sqlStatement instanceof RALStatement) {
- return RALBackendHandlerFactory.newInstance((RALStatement)
sqlStatement);
+ return RALBackendHandlerFactory.newInstance((RALStatement)
sqlStatement, backendConnection);
}
throw new
UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java
new file mode 100644
index 0000000..487739d
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandler.java
@@ -0,0 +1,65 @@
+/*
+ * 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.proxy.backend.text.distsql.ral;
+
+import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import org.apache.shardingsphere.infra.distsql.query.RQLResultSet;
+import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+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.SchemaRequiredBackendHandler;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Queryable RAL backend handler.
+ */
+public final class QueryableRALBackendHandler extends
SchemaRequiredBackendHandler<RALStatement> {
+
+ private final RQLResultSet resultSet;
+
+ public QueryableRALBackendHandler(final RALStatement sqlStatement, final
BackendConnection backendConnection, final RQLResultSet resultSet) {
+ super(sqlStatement, backendConnection);
+ this.resultSet = resultSet;
+ }
+
+ @Override
+ protected ResponseHeader execute(final String schemaName, final
RALStatement sqlStatement) {
+ resultSet.init(ProxyContext.getInstance().getMetaData(schemaName),
sqlStatement);
+ List<QueryHeader> queryHeaders = new ArrayList<>();
+ for (String each : resultSet.getColumnNames()) {
+ queryHeaders.add(new QueryHeader(schemaName, "", each, each,
Types.CHAR, "CHAR", 255, 0, false, false, false, false));
+ }
+ return new QueryResponseHeader(queryHeaders);
+ }
+
+ @Override
+ public boolean next() {
+ return resultSet.next();
+ }
+
+ @Override
+ public Collection<Object> getRowData() {
+ return resultSet.getRowData();
+ }
+}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandlerFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandlerFactory.java
new file mode 100644
index 0000000..d850a3f
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/QueryableRALBackendHandlerFactory.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.proxy.backend.text.distsql.ral;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
+import org.apache.shardingsphere.infra.distsql.query.RQLResultSet;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
+import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+import java.util.Properties;
+
+/**
+ * Queryable RAL backend handler factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class QueryableRALBackendHandlerFactory {
+
+ static {
+ ShardingSphereServiceLoader.register(RQLResultSet.class);
+ }
+
+ /**
+ * Create new instance of queryable RAL backend handler.
+ *
+ * @param sqlStatement queryable RAL statement
+ * @param backendConnection backend connection
+ * @return queryable RAL backend handler
+ */
+ public static TextProtocolBackendHandler newInstance(final
QueryableRALStatement sqlStatement, final BackendConnection backendConnection) {
+ RQLResultSet rqlResultSet =
TypedSPIRegistry.getRegisteredService(RQLResultSet.class,
sqlStatement.getClass().getCanonicalName(), new Properties());
+ return new QueryableRALBackendHandler(sqlStatement, backendConnection,
rqlResultSet);
+ }
+}
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 981afef..ed9c50b 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,22 +19,11 @@ package
org.apache.shardingsphere.proxy.backend.text.distsql.ral;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
+import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
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;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ResetScalingJobBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ShowScalingJobListBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ShowScalingJobStatusBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.StartScalingJobBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.StopScalingJobBackendHandler;
-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;
/**
* RAL backend handler factory.
@@ -46,29 +35,15 @@ public final class RALBackendHandlerFactory {
* Create new instance of RAL backend handler.
*
* @param sqlStatement RAL statement
+ * @param backendConnection backend connection
* @return RAL backend handler
*/
- public static TextProtocolBackendHandler newInstance(final RALStatement
sqlStatement) {
- if (sqlStatement instanceof ShowScalingJobListStatement) {
- return new ShowScalingJobListBackendHandler();
+ public static TextProtocolBackendHandler newInstance(final RALStatement
sqlStatement, final BackendConnection backendConnection) {
+ if (sqlStatement instanceof QueryableRALStatement) {
+ return
QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement)
sqlStatement, backendConnection);
}
- if (sqlStatement instanceof ShowScalingJobStatusStatement) {
- return new
ShowScalingJobStatusBackendHandler((ShowScalingJobStatusStatement)
sqlStatement);
- }
- if (sqlStatement instanceof StartScalingJobStatement) {
- return new
StartScalingJobBackendHandler((StartScalingJobStatement) sqlStatement);
- }
- if (sqlStatement instanceof StopScalingJobStatement) {
- return new StopScalingJobBackendHandler((StopScalingJobStatement)
sqlStatement);
- }
- if (sqlStatement instanceof DropScalingJobStatement) {
- return new DropScalingJobBackendHandler((DropScalingJobStatement)
sqlStatement);
- }
- if (sqlStatement instanceof ResetScalingJobStatement) {
- return new
ResetScalingJobBackendHandler((ResetScalingJobStatement) sqlStatement);
- }
- if (sqlStatement instanceof CheckScalingJobStatement) {
- return new
CheckScalingJobBackendHandler((CheckScalingJobStatement) sqlStatement);
+ if (sqlStatement instanceof UpdatableRALStatement) {
+ return
UpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement)
sqlStatement);
}
throw new
UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
}
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/UpdatableRALBackendHandler.java
similarity index 59%
copy from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java
copy to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/UpdatableRALBackendHandler.java
index 802d321..fa8ba0e 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/UpdatableRALBackendHandler.java
@@ -15,36 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral;
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.scaling.distsql.statement.ResetScalingJobStatement;
-import
org.apache.shardingsphere.proxy.backend.exception.ScalingJobOperateException;
+import lombok.Setter;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
+import org.apache.shardingsphere.infra.distsql.update.RALUpdater;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
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 java.sql.SQLException;
+import java.util.Properties;
/**
- * Reset scaling job backend handler.
+ * Updatable RAL backend handler factory.
*/
-@RequiredArgsConstructor
-public final class ResetScalingJobBackendHandler implements
TextProtocolBackendHandler {
+@Setter
+public final class UpdatableRALBackendHandler implements
TextProtocolBackendHandler {
- private final ResetScalingJobStatement sqlStatement;
+ static {
+ ShardingSphereServiceLoader.register(RALUpdater.class);
+ }
- private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
+ private UpdatableRALStatement sqlStatement;
+ @SuppressWarnings({"unchecked", "rawtypes"})
@Override
public ResponseHeader execute() {
- try {
- scalingAPI.reset(sqlStatement.getJobId());
- } catch (final SQLException ex) {
- throw new ScalingJobOperateException(ex.getMessage());
- }
+ RALUpdater updater =
TypedSPIRegistry.getRegisteredService(RALUpdater.class,
sqlStatement.getClass().getCanonicalName(), new Properties());
+ updater.executeUpdate(sqlStatement);
return new UpdateResponseHeader(sqlStatement);
}
}
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/UpdatableRALBackendHandlerFactory.java
similarity index 50%
copy from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java
copy to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/UpdatableRALBackendHandlerFactory.java
index d8c739d..fc4c522 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/UpdatableRALBackendHandlerFactory.java
@@ -15,29 +15,34 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
+import org.apache.shardingsphere.infra.distsql.update.RALUpdater;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
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.
+ * Updatable RAL backend handler factory.
*/
-@RequiredArgsConstructor
-public final class StopScalingJobBackendHandler implements
TextProtocolBackendHandler {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class UpdatableRALBackendHandlerFactory {
- private final StopScalingJobStatement sqlStatement;
-
- private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
+ static {
+ ShardingSphereServiceLoader.register(RALUpdater.class);
+ }
- @Override
- public ResponseHeader execute() {
- scalingAPI.stop(sqlStatement.getJobId());
- return new UpdateResponseHeader(sqlStatement);
+ /**
+ * Create new instance of queryable RAL backend handler.
+ *
+ * @param sqlStatement queryable RAL statement
+ * @return queryable RAL backend handler
+ */
+ public static TextProtocolBackendHandler newInstance(final
UpdatableRALStatement sqlStatement) {
+ UpdatableRALBackendHandler result = new UpdatableRALBackendHandler();
+ result.setSqlStatement(sqlStatement);
+ return result;
}
}
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
deleted file mode 100644
index d97e2d2..0000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobBackendHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-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;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * Check scaling job backend handler.
- */
-public final class CheckScalingJobBackendHandler implements
TextProtocolBackendHandler {
-
- private final CheckScalingJobStatement sqlStatement;
-
- private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
-
- private final List<QueryHeader> queryHeaders;
-
- private Iterator<Map<String, Object>> data;
-
- public CheckScalingJobBackendHandler(final CheckScalingJobStatement
sqlStatement) {
- this.sqlStatement = sqlStatement;
- queryHeaders = getQueryHeader();
- }
-
- private List<QueryHeader> getQueryHeader() {
- List<QueryHeader> result = Lists.newArrayList();
- result.add(new QueryHeader("", "", "table_name", "", Types.CHAR,
"CHAR", 1024, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "source_count", "", Types.BIGINT,
"BIGINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "target_count", "", Types.BIGINT,
"BIGINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "count_valid", "", Types.TINYINT,
"TINYINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "data_valid", "", Types.TINYINT,
"TINYINT", 255, 0, false, false, false, false));
- return result;
- }
-
- @Override
- public ResponseHeader execute() {
- loadData();
- return new QueryResponseHeader(queryHeaders);
- }
-
- private void loadData() {
- data =
scalingAPI.dataConsistencyCheck(sqlStatement.getJobId()).entrySet().stream()
- .map(entry -> {
- Map<String, Object> map = Maps.newHashMap();
- map.put("table_name", entry.getKey());
- map.put("source_count", entry.getValue().getSourceCount());
- map.put("target_count", entry.getValue().getTargetCount());
- map.put("count_valid", entry.getValue().isCountValid() ? 1
: 0);
- map.put("data_valid", entry.getValue().isDataValid() ? 1 :
0);
- return map;
- })
- .collect(Collectors.toList())
- .iterator();
- }
-
- @Override
- public boolean next() {
- return data.hasNext();
- }
-
- @Override
- public Collection<Object> getRowData() {
- Map<String, Object> next = data.next();
- return queryHeaders.stream()
- .map(each -> next.get(each.getColumnLabel()))
- .collect(Collectors.toList());
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobQueryResultSet.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobQueryResultSet.java
new file mode 100644
index 0000000..0213518
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/CheckScalingJobQueryResultSet.java
@@ -0,0 +1,72 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.impl;
+
+import org.apache.shardingsphere.infra.distsql.query.RQLResultSet;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import
org.apache.shardingsphere.scaling.distsql.statement.CheckScalingJobStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+/**
+ * Check scaling job query result set.
+ */
+public final class CheckScalingJobQueryResultSet implements RQLResultSet {
+
+ private Iterator<Collection<Object>> data;
+
+ @Override
+ public void init(final ShardingSphereMetaData metaData, final SQLStatement
sqlStatement) {
+ data =
ScalingAPIFactory.getScalingAPI().dataConsistencyCheck(((CheckScalingJobStatement)
sqlStatement).getJobId()).entrySet().stream()
+ .map(each -> {
+ Collection<Object> list = new LinkedList<>();
+ list.add(each.getKey());
+ list.add(each.getValue().getTargetCount());
+ list.add(each.getValue().getSourceCount());
+ list.add(each.getValue().isCountValid() ? 1 : 0);
+ list.add(each.getValue().isDataValid() ? 1 : 0);
+ return list;
+ }).collect(Collectors.toList()).iterator();
+ }
+
+ @Override
+ public Collection<String> getColumnNames() {
+ return Arrays.asList("table_name", "source_count", "target_count",
"count_valid", "data_valid");
+ }
+
+ @Override
+ public boolean next() {
+ return data.hasNext();
+ }
+
+ @Override
+ public Collection<Object> getRowData() {
+ return data.next();
+ }
+
+ @Override
+ public String getType() {
+ return CheckScalingJobStatement.class.getCanonicalName();
+ }
+}
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/DropScalingJobUpdater.java
similarity index 68%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobBackendHandler.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/DropScalingJobUpdater.java
index cea6334..e2edc04 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/DropScalingJobUpdater.java
@@ -17,27 +17,25 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-import lombok.RequiredArgsConstructor;
-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.infra.distsql.update.RALUpdater;
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.
+ * Drop scaling job updater.
*/
-@RequiredArgsConstructor
-public final class DropScalingJobBackendHandler implements
TextProtocolBackendHandler {
-
- private final DropScalingJobStatement sqlStatement;
+public final class DropScalingJobUpdater implements
RALUpdater<DropScalingJobStatement> {
private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
@Override
- public ResponseHeader execute() {
+ public void executeUpdate(final DropScalingJobStatement sqlStatement) {
scalingAPI.remove(sqlStatement.getJobId());
- return new UpdateResponseHeader(sqlStatement);
+ }
+
+ @Override
+ public String getType() {
+ return DropScalingJobStatement.class.getCanonicalName();
}
}
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/ResetScalingJobUpdater.java
similarity index 71%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobBackendHandler.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ResetScalingJobUpdater.java
index 802d321..5eefee1 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/ResetScalingJobUpdater.java
@@ -17,34 +17,32 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-import lombok.RequiredArgsConstructor;
-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;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+import org.apache.shardingsphere.infra.distsql.update.RALUpdater;
import org.apache.shardingsphere.scaling.core.api.ScalingAPI;
import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import
org.apache.shardingsphere.scaling.distsql.statement.ResetScalingJobStatement;
import java.sql.SQLException;
/**
- * Reset scaling job backend handler.
+ * Reset scaling job updater.
*/
-@RequiredArgsConstructor
-public final class ResetScalingJobBackendHandler implements
TextProtocolBackendHandler {
-
- private final ResetScalingJobStatement sqlStatement;
+public final class ResetScalingJobUpdater implements
RALUpdater<ResetScalingJobStatement> {
private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
@Override
- public ResponseHeader execute() {
+ public void executeUpdate(final ResetScalingJobStatement sqlStatement) {
try {
scalingAPI.reset(sqlStatement.getJobId());
} catch (final SQLException ex) {
throw new ScalingJobOperateException(ex.getMessage());
}
- return new UpdateResponseHeader(sqlStatement);
+ }
+
+ @Override
+ public String getType() {
+ return ResetScalingJobStatement.class.getCanonicalName();
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListBackendHandler.java
deleted file mode 100644
index eac9e3b..0000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListBackendHandler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-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 java.sql.Types;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * Show scaling job list backend handler.
- */
-public final class ShowScalingJobListBackendHandler implements
TextProtocolBackendHandler {
-
- private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
-
- private final List<QueryHeader> queryHeaders;
-
- private Iterator<Map<String, Object>> data;
-
- public ShowScalingJobListBackendHandler() {
- queryHeaders = getQueryHeader();
- }
-
- private List<QueryHeader> getQueryHeader() {
- List<QueryHeader> result = Lists.newArrayList();
- result.add(new QueryHeader("", "", "id", "", Types.BIGINT, "BIGINT",
255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "tables", "", Types.CHAR, "CHAR",
1024, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "sharding_total_count", "",
Types.SMALLINT, "SMALLINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "active", "", Types.TINYINT,
"TINYINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "create_time", "", Types.CHAR,
"CHAR", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "stop_time", "", Types.CHAR,
"CHAR", 255, 0, false, false, false, false));
- return result;
- }
-
- @Override
- public ResponseHeader execute() {
- loadData();
- return new QueryResponseHeader(queryHeaders);
- }
-
- private void loadData() {
- data = scalingAPI.list().stream()
- .map(each -> {
- Map<String, Object> map = Maps.newHashMap();
- map.put("id", each.getJobId());
- map.put("tables", each.getTables());
- map.put("sharding_total_count",
each.getShardingTotalCount());
- map.put("active", each.isActive() ? 1 : 0);
- map.put("create_time", each.getCreateTime());
- map.put("stop_time", each.getStopTime());
- return map;
- })
- .collect(Collectors.toList())
- .iterator();
- }
-
- @Override
- public boolean next() {
- return data.hasNext();
- }
-
- @Override
- public Collection<Object> getRowData() {
- Map<String, Object> next = data.next();
- return queryHeaders.stream()
- .map(each -> next.get(each.getColumnLabel()))
- .collect(Collectors.toList());
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListQueryResultSet.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListQueryResultSet.java
new file mode 100644
index 0000000..a7b3412
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobListQueryResultSet.java
@@ -0,0 +1,73 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.impl;
+
+import org.apache.shardingsphere.infra.distsql.query.RQLResultSet;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import
org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobListStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+/**
+ * Show scaling job list query result set.
+ */
+public final class ShowScalingJobListQueryResultSet implements RQLResultSet {
+
+ private Iterator<Collection<Object>> data;
+
+ @Override
+ public void init(final ShardingSphereMetaData metaData, final SQLStatement
sqlStatement) {
+ data = ScalingAPIFactory.getScalingAPI().list().stream()
+ .map(each -> {
+ Collection<Object> list = new LinkedList<>();
+ list.add(each.getJobId());
+ list.add(each.getTables());
+ list.add(each.getShardingTotalCount());
+ list.add(each.isActive() ? 1 : 0);
+ list.add(each.getCreateTime());
+ list.add(each.getStopTime());
+ return list;
+ }).collect(Collectors.toList()).iterator();
+ }
+
+ @Override
+ public Collection<String> getColumnNames() {
+ return Arrays.asList("id", "tables", "sharding_total_count", "active",
"create_time", "stop_time");
+ }
+
+ @Override
+ public boolean next() {
+ return data.hasNext();
+ }
+
+ @Override
+ public Collection<Object> getRowData() {
+ return data.next();
+ }
+
+ @Override
+ public String getType() {
+ return ShowScalingJobListStatement.class.getCanonicalName();
+ }
+}
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
deleted file mode 100644
index ba7117c..0000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusBackendHandler.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-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;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * Show scaling job status backend handler.
- */
-public final class ShowScalingJobStatusBackendHandler implements
TextProtocolBackendHandler {
-
- private final ShowScalingJobStatusStatement sqlStatement;
-
- private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
-
- private final List<QueryHeader> queryHeaders;
-
- private Iterator<Map<String, Object>> data;
-
- public ShowScalingJobStatusBackendHandler(final
ShowScalingJobStatusStatement sqlStatement) {
- this.sqlStatement = sqlStatement;
- queryHeaders = getQueryHeader();
- }
-
- private List<QueryHeader> getQueryHeader() {
- List<QueryHeader> result = Lists.newArrayList();
- result.add(new QueryHeader("", "", "item", "", Types.BIGINT, "BIGINT",
255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "data_source", "", Types.CHAR,
"CHAR", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "status", "", Types.CHAR, "CHAR",
255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "inventory_finished_percentage",
"", Types.TINYINT, "TINYINT", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "incremental_delay_milliseconds",
"", Types.BIGINT, "BIGINT", 255, 0, false, false, false, false));
- return result;
- }
-
- @Override
- public ResponseHeader execute() {
- loadData();
- return new QueryResponseHeader(queryHeaders);
- }
-
- private void loadData() {
- data =
scalingAPI.getProgress(sqlStatement.getJobId()).entrySet().stream()
- .map(entry -> {
- Map<String, Object> map = Maps.newHashMap();
- map.put("item", entry.getKey());
- if (null != entry.getValue()) {
- map.put("status", entry.getValue().getStatus());
- map.put("data_source",
entry.getValue().getDataSource());
- map.put("inventory_finished_percentage",
entry.getValue().getInventoryFinishedPercentage());
- map.put("incremental_delay_milliseconds",
entry.getValue().getIncrementalDelayMilliseconds());
- }
- return map;
- })
- .collect(Collectors.toList())
- .iterator();
- }
-
- @Override
- public boolean next() {
- return data.hasNext();
- }
-
- @Override
- public Collection<Object> getRowData() {
- Map<String, Object> next = data.next();
- return queryHeaders.stream()
- .map(each -> next.get(each.getColumnLabel()))
- .collect(Collectors.toList());
- }
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusQueryResultSet.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusQueryResultSet.java
new file mode 100644
index 0000000..0670c3d
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/ShowScalingJobStatusQueryResultSet.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
+
+import org.apache.shardingsphere.infra.distsql.query.RQLResultSet;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.scaling.core.api.ScalingAPIFactory;
+import
org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobListStatement;
+import
org.apache.shardingsphere.scaling.distsql.statement.ShowScalingJobStatusStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+/**
+ * Show scaling job status query result set.
+ */
+public final class ShowScalingJobStatusQueryResultSet implements RQLResultSet {
+
+ private Iterator<Collection<Object>> data;
+
+ @Override
+ public void init(final ShardingSphereMetaData metaData, final SQLStatement
sqlStatement) {
+ data =
ScalingAPIFactory.getScalingAPI().getProgress(((ShowScalingJobStatusStatement)
sqlStatement).getJobId()).entrySet().stream()
+ .map(entry -> {
+ Collection<Object> list = new LinkedList<>();
+ list.add(entry.getKey());
+ if (null != entry.getValue()) {
+ list.add(entry.getValue().getStatus());
+ list.add(entry.getValue().getDataSource());
+
list.add(entry.getValue().getInventoryFinishedPercentage());
+
list.add(entry.getValue().getIncrementalDelayMilliseconds());
+ }
+ return list;
+ }).collect(Collectors.toList()).iterator();
+ }
+
+ @Override
+ public Collection<String> getColumnNames() {
+ return Arrays.asList("item", "data_source", "status",
"inventory_finished_percentage", "incremental_delay_milliseconds");
+ }
+
+ @Override
+ public boolean next() {
+ return data.hasNext();
+ }
+
+ @Override
+ public Collection<Object> getRowData() {
+ return data.next();
+ }
+
+ @Override
+ public String getType() {
+ return ShowScalingJobListStatement.class.getCanonicalName();
+ }
+}
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/StartScalingJobUpdater.java
similarity index 68%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobBackendHandler.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StartScalingJobUpdater.java
index 1432eb9..2f04c56 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/StartScalingJobUpdater.java
@@ -17,27 +17,25 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-import lombok.RequiredArgsConstructor;
-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.infra.distsql.update.RALUpdater;
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.
+ * Start scaling job updater.
*/
-@RequiredArgsConstructor
-public final class StartScalingJobBackendHandler implements
TextProtocolBackendHandler {
-
- private final StartScalingJobStatement sqlStatement;
+public final class StartScalingJobUpdater implements
RALUpdater<StartScalingJobStatement> {
private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
@Override
- public ResponseHeader execute() {
+ public void executeUpdate(final StartScalingJobStatement sqlStatement) {
scalingAPI.start(sqlStatement.getJobId());
- return new UpdateResponseHeader(sqlStatement);
+ }
+
+ @Override
+ public String getType() {
+ return StartScalingJobStatement.class.getCanonicalName();
}
}
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/StopScalingJobUpdater.java
similarity index 68%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobBackendHandler.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/impl/StopScalingJobUpdater.java
index d8c739d..0c050ce 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/StopScalingJobUpdater.java
@@ -17,27 +17,25 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl;
-import lombok.RequiredArgsConstructor;
-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.infra.distsql.update.RALUpdater;
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.
+ * Stop scaling job updater.
*/
-@RequiredArgsConstructor
-public final class StopScalingJobBackendHandler implements
TextProtocolBackendHandler {
-
- private final StopScalingJobStatement sqlStatement;
+public final class StopScalingJobUpdater implements
RALUpdater<StopScalingJobStatement> {
private final ScalingAPI scalingAPI = ScalingAPIFactory.getScalingAPI();
@Override
- public ResponseHeader execute() {
+ public void executeUpdate(final StopScalingJobStatement sqlStatement) {
scalingAPI.stop(sqlStatement.getJobId());
- return new UpdateResponseHeader(sqlStatement);
+ }
+
+ @Override
+ public String getType() {
+ return StopScalingJobStatement.class.getCanonicalName();
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
index 7759fe9..239456c 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
@@ -16,3 +16,6 @@
#
org.apache.shardingsphere.proxy.backend.text.distsql.rql.DataSourceQueryResultSet
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.CheckScalingJobQueryResultSet
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ShowScalingJobListQueryResultSet
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ShowScalingJobStatusQueryResultSet
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater
similarity index 69%
copy from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
copy to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater
index 7759fe9..28d2726 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.RQLResultSet
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater
@@ -15,4 +15,7 @@
# limitations under the License.
#
-org.apache.shardingsphere.proxy.backend.text.distsql.rql.DataSourceQueryResultSet
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.StartScalingJobUpdater
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.StopScalingJobUpdater
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.ResetScalingJobUpdater
+org.apache.shardingsphere.proxy.backend.text.distsql.ral.impl.DropScalingJobUpdater
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
index c84a763..5e7885d 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/CheckScalingJobStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
/**
* Check scaling job statement.
*/
@RequiredArgsConstructor
@Getter
-public final class CheckScalingJobStatement extends RALStatement {
+public final class CheckScalingJobStatement extends QueryableRALStatement {
private final long jobId;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
index d03b618..face7e4 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/DropScalingJobStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
/**
* Drop scaling job statement.
*/
@RequiredArgsConstructor
@Getter
-public final class DropScalingJobStatement extends RALStatement {
+public final class DropScalingJobStatement extends UpdatableRALStatement {
private final long jobId;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
index b37dd06..b163499 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ResetScalingJobStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
/**
* Reset scaling job statement.
*/
@RequiredArgsConstructor
@Getter
-public final class ResetScalingJobStatement extends RALStatement {
+public final class ResetScalingJobStatement extends UpdatableRALStatement {
private final long jobId;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
index d8d9530..9cbf6c8 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobListStatement.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.scaling.distsql.statement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
/**
* Show scaling job list statement.
*/
-public final class ShowScalingJobListStatement extends RALStatement {
+public final class ShowScalingJobListStatement extends QueryableRALStatement {
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
index 127a114..ce005af 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/ShowScalingJobStatusStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
/**
* Show scaling job status statement.
*/
@RequiredArgsConstructor
@Getter
-public final class ShowScalingJobStatusStatement extends RALStatement {
+public final class ShowScalingJobStatusStatement extends QueryableRALStatement
{
private final long jobId;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
index a694af5..38e7385 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StartScalingJobStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
/**
* Start scaling job statement.
*/
@RequiredArgsConstructor
@Getter
-public final class StartScalingJobStatement extends RALStatement {
+public final class StartScalingJobStatement extends UpdatableRALStatement {
private final long jobId;
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
index 5923318..77edfec 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement/StopScalingJobStatement.java
@@ -19,14 +19,14 @@ package org.apache.shardingsphere.scaling.distsql.statement;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
/**
* Stop scaling job statement.
*/
@RequiredArgsConstructor
@Getter
-public final class StopScalingJobStatement extends RALStatement {
+public final class StopScalingJobStatement extends UpdatableRALStatement {
private final long jobId;
}