You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/01/03 07:43:35 UTC
[iotdb] 01/02: abstract redirect method
This is an automated email from the ASF dual-hosted git repository.
xiangweiwei pushed a commit to branch 0.12controlQueryThread
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5834195f4a2075e4b3f8b8496ce5f8bf9783a839
Author: Alima777 <wx...@gmail.com>
AuthorDate: Mon Jan 3 15:21:56 2022 +0800
abstract redirect method
---
client-cpp/pom.xml | 4 +--
compile-tools/pom.xml | 6 ++--
distribution/pom.xml | 2 +-
example/client-cpp-example/pom.xml | 2 +-
example/udf/pom.xml | 2 +-
grafana/pom.xml | 2 +-
jdbc/pom.xml | 2 +-
pom.xml | 8 ++---
.../org/apache/iotdb/db/service/TSServiceImpl.java | 36 ++++++++++++----------
9 files changed, 34 insertions(+), 30 deletions(-)
diff --git a/client-cpp/pom.xml b/client-cpp/pom.xml
index 014a0f5..79e295f 100644
--- a/client-cpp/pom.xml
+++ b/client-cpp/pom.xml
@@ -98,8 +98,8 @@
<cmake.root.dir>${project.parent.basedir}/compile-tools/thrift/target/cmake-${cmake-version}-win64-x64/</cmake.root.dir>
<thrift.exec.absolute.path>${project.parent.basedir}/compile-tools/thrift/target/build/compiler/cpp/bin/${cmake.build.type}/thrift.exe</thrift.exec.absolute.path>
<iotdb.server.script>start-server.bat</iotdb.server.script>
- <boost.include.dir />
- <boost.library.dir />
+ <boost.include.dir/>
+ <boost.library.dir/>
</properties>
</profile>
<profile>
diff --git a/compile-tools/pom.xml b/compile-tools/pom.xml
index 88bb39b..3d82f11 100644
--- a/compile-tools/pom.xml
+++ b/compile-tools/pom.xml
@@ -35,7 +35,7 @@
<cmake-version>3.17.3</cmake-version>
<openssl.include.dir>-Dtrue1=true1</openssl.include.dir>
<bison.executable.dir>-Dtrue1=true1</bison.executable.dir>
- <cmake.build.type />
+ <cmake.build.type/>
</properties>
<modules>
<module>thrift</module>
@@ -114,8 +114,8 @@
<thrift.make.executable>make</thrift.make.executable>
<thrift.compiler.executable>thrift.exe</thrift.compiler.executable>
<gradlew.executable>gradlew.bat</gradlew.executable>
- <boost.include.dir />
- <boost.library.dir />
+ <boost.include.dir/>
+ <boost.library.dir/>
</properties>
</profile>
</profiles>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 8f8c28e..49dceed 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -29,7 +29,7 @@
</parent>
<artifactId>iotdb-distribution</artifactId>
<name>IoTDB Distribution</name>
- <modules />
+ <modules/>
<build>
<plugins>
<plugin>
diff --git a/example/client-cpp-example/pom.xml b/example/client-cpp-example/pom.xml
index 1cc5a23..c06f132 100644
--- a/example/client-cpp-example/pom.xml
+++ b/example/client-cpp-example/pom.xml
@@ -69,7 +69,7 @@
<properties>
<cmake.generator>Visual Studio 16 2019</cmake.generator>
<cmake.root.dir>${project.parent.basedir}/../compile-tools/thrift/target/cmake-${cmake-version}-win64-x64/</cmake.root.dir>
- <boost.include.dir />
+ <boost.include.dir/>
</properties>
</profile>
<profile>
diff --git a/example/udf/pom.xml b/example/udf/pom.xml
index 131f05d..6d3127c 100644
--- a/example/udf/pom.xml
+++ b/example/udf/pom.xml
@@ -77,7 +77,7 @@
<importOrder>
<order>org.apache.iotdb,,javax,java,\#</order>
</importOrder>
- <removeUnusedImports />
+ <removeUnusedImports/>
</java>
</configuration>
<executions>
diff --git a/grafana/pom.xml b/grafana/pom.xml
index d0c29ec..d4d80ac 100644
--- a/grafana/pom.xml
+++ b/grafana/pom.xml
@@ -170,7 +170,7 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${start-class}</mainClass>
</transformer>
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 940678b..84a39f0 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -198,7 +198,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
diff --git a/pom.xml b/pom.xml
index b7d08a5..6e03cf7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,7 +151,7 @@
<sonar.junit.reportPaths>target/surefire-reports,target/failsafe-reports</sonar.junit.reportPaths>
<!-- By default, the argLine is empty-->
<gson.version>2.8.6</gson.version>
- <argLine />
+ <argLine/>
<!-- whether enable compiling the cpp client-->
<client-cpp>false</client-cpp>
<!-- disable enforcer by default-->
@@ -688,7 +688,7 @@
<importOrder>
<order>org.apache.iotdb,,javax,java,\#</order>
</importOrder>
- <removeUnusedImports />
+ <removeUnusedImports/>
</java>
<lineEndings>UNIX</lineEndings>
</configuration>
@@ -760,7 +760,7 @@
<phase>validate</phase>
<configuration>
<rules>
- <dependencyConvergence />
+ <dependencyConvergence/>
</rules>
</configuration>
<goals>
@@ -806,7 +806,7 @@
</requireJavaVersion>
<!-- Disabled for now as it breaks the ability to build single modules -->
<!--reactorModuleConvergence/-->
- <banVulnerable implementation="org.sonatype.ossindex.maven.enforcer.BanVulnerableDependencies" />
+ <banVulnerable implementation="org.sonatype.ossindex.maven.enforcer.BanVulnerableDependencies"/>
</rules>
</configuration>
</execution>
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 3f7c349..3fd9bee 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -28,7 +28,11 @@ import org.apache.iotdb.db.conf.IoTDBConstant;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.cost.statistic.Measurement;
import org.apache.iotdb.db.cost.statistic.Operation;
-import org.apache.iotdb.db.exception.*;
+import org.apache.iotdb.db.exception.BatchProcessException;
+import org.apache.iotdb.db.exception.IoTDBException;
+import org.apache.iotdb.db.exception.QueryInBatchStatementException;
+import org.apache.iotdb.db.exception.StorageEngineException;
+import org.apache.iotdb.db.exception.StorageGroupNotReadyException;
import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
@@ -738,16 +742,10 @@ public class TSServiceImpl implements TSIService.Iface {
QueryDataSet newDataSet = createQueryDataSet(queryId, plan, fetchSize);
if (newDataSet.getEndPoint() != null && enableRedirect) {
- // redirect query
LOGGER.debug(
"need to redirect {} {} to node {}", statement, queryId, newDataSet.getEndPoint());
- TSStatus status = new TSStatus();
- status.setRedirectNode(
- new EndPoint(newDataSet.getEndPoint().getIp(), newDataSet.getEndPoint().getPort()));
- status.setCode(TSStatusCode.NEED_REDIRECTION.getStatusCode());
- resp.setStatus(status);
- resp.setQueryId(queryId);
- return resp;
+ QueryDataSet.EndPoint endPoint = newDataSet.getEndPoint();
+ return redirectQueryToAnotherNode(resp, queryId, endPoint.getIp(), endPoint.getPort());
}
if (plan instanceof ShowPlan || plan instanceof AuthorPlan) {
@@ -772,13 +770,8 @@ public class TSServiceImpl implements TSIService.Iface {
} catch (RedirectException e) {
LOGGER.debug("need to redirect {} {} to {}", statement, queryId, e.getEndPoint());
if (enableRedirect) {
- // redirect query
- TSStatus status = new TSStatus();
- status.setRedirectNode(e.getEndPoint());
- status.setCode(TSStatusCode.NEED_REDIRECTION.getStatusCode());
- resp.setStatus(status);
- resp.setQueryId(queryId);
- return resp;
+ EndPoint endPoint = e.getEndPoint();
+ redirectQueryToAnotherNode(resp, queryId, endPoint.ip, endPoint.port);
} else {
LOGGER.error(
"execute {} error, if session does not support redirect,"
@@ -823,6 +816,17 @@ public class TSServiceImpl implements TSIService.Iface {
}
}
+ /** Redirect query */
+ private TSExecuteStatementResp redirectQueryToAnotherNode(
+ TSExecuteStatementResp resp, long queryId, String ip, int port) {
+ TSStatus status = new TSStatus();
+ status.setRedirectNode(new EndPoint(ip, port));
+ status.setCode(TSStatusCode.NEED_REDIRECTION.getStatusCode());
+ resp.setStatus(status);
+ resp.setQueryId(queryId);
+ return resp;
+ }
+
private TSExecuteStatementResp getListDataSetHeaders(QueryDataSet dataSet) {
return StaticResps.getNoTimeExecuteResp(
dataSet.getPaths().stream().map(Path::getFullPath).collect(Collectors.toList()),