You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by cr...@apache.org on 2026/01/28 11:55:10 UTC

(iotdb) branch master updated: Decouple rest from iotdb-server using ExternalService framework (#17099)

This is an automated email from the ASF dual-hosted git repository.

critas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new d05276e2955 Decouple rest from iotdb-server using ExternalService framework (#17099)
d05276e2955 is described below

commit d05276e2955bf17fbb8a5e26a61fcdc2df83b434
Author: LimJiaWenBrenda <88...@users.noreply.github.com>
AuthorDate: Wed Jan 28 19:55:03 2026 +0800

    Decouple rest from iotdb-server using ExternalService framework (#17099)
    
    * Move rest to independent module
    
    * Move openapi to independent module + Fix tests
    
    * Fix dependencies
    
    * Fix dependencies
    
    * Remove unnecessary code
    
    * Add comments
    
    * Remove unnecessary code
    
    * Remove unnecessary code + Move dependencies
    
    * Remove unnecessary tests
    
    * Remove unused dependencies
---
 distribution/pom.xml                               |   6 +
 distribution/src/assembly/all.xml                  |   4 +
 distribution/src/assembly/datanode.xml             |   4 +
 .../src/assembly/external-service-impl.xml         |   4 +
 external-service-impl/pom.xml                      |   2 +
 .../rest-openapi}/pom.xml                          |  34 +-
 .../src/main/openapi3/iotdb_rest_common.yaml       |   0
 .../src/main/openapi3/iotdb_rest_table_v1.yaml     |   0
 .../src/main/openapi3/iotdb_rest_v1.yaml           |   0
 .../src/main/openapi3/iotdb_rest_v2.yaml           |   0
 external-service-impl/rest/pom.xml                 | 226 +++++
 .../java/org/apache/iotdb/rest}/RestService.java   |  30 +-
 .../rest/protocol}/filter/ApiOriginFilter.java     |   2 +-
 .../rest/protocol}/filter/AuthorizationFilter.java |   4 +-
 .../protocol}/filter/BasicSecurityContext.java     |   2 +-
 .../apache/iotdb/rest/protocol}/filter/User.java   |   2 +-
 .../iotdb/rest/protocol}/filter/UserCache.java     |   2 +-
 .../protocol}/handler/AuthorizationHandler.java    |   4 +-
 .../rest/protocol}/impl/PingApiServiceImpl.java    |   6 +-
 .../table/v1/handler/ExceptionHandler.java         |   4 +-
 .../table/v1/handler/ExecuteStatementHandler.java  |   2 +-
 .../table/v1/handler/QueryDataSetHandler.java      |   6 +-
 .../table/v1/handler/RequestValidationHandler.java |   6 +-
 .../v1/handler/StatementConstructionHandler.java   |   4 +-
 .../table/v1/impl/RestApiServiceImpl.java          |  26 +-
 .../rest/protocol}/utils/InsertRowDataUtils.java   |   2 +-
 .../protocol}/utils/InsertTabletSortDataUtils.java |   2 +-
 .../protocol/v1}/handler/ExceptionHandler.java     |   4 +-
 .../v1/handler/ExecuteStatementHandler.java        |   2 +-
 .../protocol}/v1/handler/QueryDataSetHandler.java  |  26 +-
 .../v1/handler/RequestValidationHandler.java       |   8 +-
 .../v1/handler/StatementConstructionHandler.java   |   4 +-
 .../protocol}/v1/impl/GrafanaApiServiceImpl.java   |  18 +-
 .../rest/protocol}/v1/impl/RestApiServiceImpl.java |  32 +-
 .../protocol/v2}/handler/ExceptionHandler.java     |   4 +-
 .../v2/handler/ExecuteStatementHandler.java        |   2 +-
 .../rest/protocol}/v2/handler/FastLastHandler.java |  10 +-
 .../protocol}/v2/handler/QueryDataSetHandler.java  |  22 +-
 .../v2/handler/RequestValidationHandler.java       |  12 +-
 .../v2/handler/StatementConstructionHandler.java   |   8 +-
 .../protocol}/v2/impl/GrafanaApiServiceImpl.java   |  18 +-
 .../rest/protocol}/v2/impl/RestApiServiceImpl.java |  36 +-
 integration-test/pom.xml                           |   7 +
 integration-test/src/assembly/mpp-share.xml        |   4 +
 iotdb-core/confignode/pom.xml                      |   6 -
 iotdb-core/datanode/pom.xml                        |  58 +-
 .../java/org/apache/iotdb/db/service/DataNode.java |   4 -
 .../externalservice/BuiltinExternalServices.java   |   4 +-
 .../db/protocol/rest/GrafanaApiServiceTest.java    | 450 ----------
 .../db/protocol/rest/IoTDBRestServiceTest.java     | 918 ---------------------
 .../apache/iotdb/commons/service/ServiceType.java  |   1 -
 iotdb-protocol/pom.xml                             |   1 -
 52 files changed, 431 insertions(+), 1612 deletions(-)

diff --git a/distribution/pom.xml b/distribution/pom.xml
index 025a67b379d..65a3572fd3a 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -59,6 +59,12 @@
             <version>2.0.7-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>rest</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
diff --git a/distribution/src/assembly/all.xml b/distribution/src/assembly/all.xml
index 255912d75e6..1b2e1be054f 100644
--- a/distribution/src/assembly/all.xml
+++ b/distribution/src/assembly/all.xml
@@ -96,6 +96,10 @@
             <source>${maven.multiModuleProjectDirectory}/external-service-impl/mqtt/target/mqtt-${project.version}-jar-with-dependencies.jar</source>
             <outputDirectory>lib</outputDirectory>
         </file>
+        <file>
+            <source>${maven.multiModuleProjectDirectory}/external-service-impl/rest/target/rest-${project.version}-jar-with-dependencies.jar</source>
+            <outputDirectory>lib</outputDirectory>
+        </file>
     </files>
     <componentDescriptors>
         <componentDescriptor>common-files.xml</componentDescriptor>
diff --git a/distribution/src/assembly/datanode.xml b/distribution/src/assembly/datanode.xml
index 8994667fb87..225fa5a7e7d 100644
--- a/distribution/src/assembly/datanode.xml
+++ b/distribution/src/assembly/datanode.xml
@@ -79,6 +79,10 @@
             <source>${maven.multiModuleProjectDirectory}/external-service-impl/mqtt/target/mqtt-${project.version}-jar-with-dependencies.jar</source>
             <outputDirectory>lib</outputDirectory>
         </file>
+        <file>
+            <source>${maven.multiModuleProjectDirectory}/external-service-impl/rest/target/rest-${project.version}-jar-with-dependencies.jar</source>
+            <outputDirectory>lib</outputDirectory>
+        </file>
     </files>
     <componentDescriptors>
         <componentDescriptor>common-files.xml</componentDescriptor>
diff --git a/distribution/src/assembly/external-service-impl.xml b/distribution/src/assembly/external-service-impl.xml
index 273efe6eddf..c743fa85597 100644
--- a/distribution/src/assembly/external-service-impl.xml
+++ b/distribution/src/assembly/external-service-impl.xml
@@ -47,5 +47,9 @@
             <source>${maven.multiModuleProjectDirectory}/external-service-impl/mqtt/target/mqtt-${project.version}-jar-with-dependencies.jar</source>
             <outputDirectory>/</outputDirectory>
         </file>
+        <file>
+            <source>${maven.multiModuleProjectDirectory}/external-service-impl/rest/target/rest-${project.version}-jar-with-dependencies.jar</source>
+            <outputDirectory>/</outputDirectory>
+        </file>
     </files>
 </assembly>
diff --git a/external-service-impl/pom.xml b/external-service-impl/pom.xml
index 986522e6275..04483b289f3 100644
--- a/external-service-impl/pom.xml
+++ b/external-service-impl/pom.xml
@@ -31,6 +31,8 @@
     <packaging>pom</packaging>
     <modules>
         <module>mqtt</module>
+        <module>rest</module>
+        <module>rest-openapi</module>
     </modules>
     <properties>
         <maven.compiler.source>8</maven.compiler.source>
diff --git a/iotdb-protocol/openapi/pom.xml b/external-service-impl/rest-openapi/pom.xml
similarity index 87%
rename from iotdb-protocol/openapi/pom.xml
rename to external-service-impl/rest-openapi/pom.xml
index f31e3ba1d09..3b46227cf61 100644
--- a/iotdb-protocol/openapi/pom.xml
+++ b/external-service-impl/rest-openapi/pom.xml
@@ -23,11 +23,11 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.iotdb</groupId>
-        <artifactId>iotdb-protocol</artifactId>
+        <artifactId>external-service-impl</artifactId>
         <version>2.0.7-SNAPSHOT</version>
     </parent>
-    <artifactId>openapi</artifactId>
-    <name>IoTDB: Protocol: OpenAPI</name>
+    <artifactId>rest-openapi</artifactId>
+    <name>IoTDB: External-Service-Impl: Rest-OpenAPI</name>
     <dependencies>
         <dependency>
             <groupId>io.swagger</groupId>
@@ -91,9 +91,9 @@
                         <configuration>
                             <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_common.yaml</inputSpec>
                             <output>${project.build.directory}/generated-sources/java</output>
-                            <apiPackage>org.apache.iotdb.db.protocol.rest</apiPackage>
-                            <modelPackage>org.apache.iotdb.db.protocol.rest.model</modelPackage>
-                            <invokerPackage>org.apache.iotdb.db.protocol.rest.invoker</invokerPackage>
+                            <apiPackage>org.apache.iotdb.rest.protocol</apiPackage>
+                            <modelPackage>org.apache.iotdb.rest.protocol.model</modelPackage>
+                            <invokerPackage>org.apache.iotdb.rest.protocol.invoker</invokerPackage>
                             <generatorName>jaxrs-jersey</generatorName>
                             <groupId>org.apache.iotdb</groupId>
                             <artifactId>iotdb-rest-service</artifactId>
@@ -118,9 +118,9 @@
                         <configuration>
                             <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_v1.yaml</inputSpec>
                             <output>${project.build.directory}/generated-sources/java</output>
-                            <apiPackage>org.apache.iotdb.db.protocol.rest.v1</apiPackage>
-                            <modelPackage>org.apache.iotdb.db.protocol.rest.v1.model</modelPackage>
-                            <invokerPackage>org.apache.iotdb.db.protocol.rest.v1.invoker</invokerPackage>
+                            <apiPackage>org.apache.iotdb.rest.protocol.v1</apiPackage>
+                            <modelPackage>org.apache.iotdb.rest.protocol.v1.model</modelPackage>
+                            <invokerPackage>org.apache.iotdb.rest.protocol.v1.invoker</invokerPackage>
                             <generatorName>jaxrs-jersey</generatorName>
                             <groupId>org.apache.iotdb</groupId>
                             <artifactId>iotdb-rest-service</artifactId>
@@ -145,9 +145,9 @@
                         <configuration>
                             <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_v2.yaml</inputSpec>
                             <output>${project.build.directory}/generated-sources/java</output>
-                            <apiPackage>org.apache.iotdb.db.protocol.rest.v2</apiPackage>
-                            <modelPackage>org.apache.iotdb.db.protocol.rest.v2.model</modelPackage>
-                            <invokerPackage>org.apache.iotdb.db.protocol.rest.v2.invoker</invokerPackage>
+                            <apiPackage>org.apache.iotdb.rest.protocol.v2</apiPackage>
+                            <modelPackage>org.apache.iotdb.rest.protocol.v2.model</modelPackage>
+                            <invokerPackage>org.apache.iotdb.rest.protocol.v2.invoker</invokerPackage>
                             <generatorName>jaxrs-jersey</generatorName>
                             <groupId>org.apache.iotdb</groupId>
                             <artifactId>iotdb-rest-service</artifactId>
@@ -172,9 +172,9 @@
                         <configuration>
                             <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_table_v1.yaml</inputSpec>
                             <output>${project.build.directory}/generated-sources/java</output>
-                            <apiPackage>org.apache.iotdb.db.protocol.rest.table.v1</apiPackage>
-                            <modelPackage>org.apache.iotdb.db.protocol.rest.table.v1.model</modelPackage>
-                            <invokerPackage>org.apache.iotdb.db.protocol.rest.table.v1.invoker</invokerPackage>
+                            <apiPackage>org.apache.iotdb.rest.protocol.table.v1</apiPackage>
+                            <modelPackage>org.apache.iotdb.rest.protocol.table.v1.model</modelPackage>
+                            <invokerPackage>org.apache.iotdb.rest.protocol.table.v1.invoker</invokerPackage>
                             <generatorName>jaxrs-jersey</generatorName>
                             <groupId>org.apache.iotdb</groupId>
                             <artifactId>iotdb-rest-service</artifactId>
@@ -232,6 +232,10 @@
                         <!-- We just need this dependency to prevent the compiler from freaking out on unused imports -->
                         <usedDependency>org.glassfish.jersey.media:jersey-media-multipart</usedDependency>
                     </usedDependencies>
+                    <ignoredDependencies>
+                        <ignoredDependency>org.apache.iotdb:external-service-api</ignoredDependency>
+                        <ignoredDependency>junit:junit</ignoredDependency>
+                    </ignoredDependencies>
                 </configuration>
             </plugin>
         </plugins>
diff --git a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_common.yaml b/external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_common.yaml
similarity index 100%
rename from iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_common.yaml
rename to external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_common.yaml
diff --git a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_table_v1.yaml b/external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_table_v1.yaml
similarity index 100%
rename from iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_table_v1.yaml
rename to external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_table_v1.yaml
diff --git a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml b/external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_v1.yaml
similarity index 100%
rename from iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v1.yaml
rename to external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_v1.yaml
diff --git a/iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v2.yaml b/external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_v2.yaml
similarity index 100%
rename from iotdb-protocol/openapi/src/main/openapi3/iotdb_rest_v2.yaml
rename to external-service-impl/rest-openapi/src/main/openapi3/iotdb_rest_v2.yaml
diff --git a/external-service-impl/rest/pom.xml b/external-service-impl/rest/pom.xml
new file mode 100644
index 00000000000..edb8aa3fc33
--- /dev/null
+++ b/external-service-impl/rest/pom.xml
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<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.iotdb</groupId>
+        <artifactId>external-service-impl</artifactId>
+        <version>2.0.7-SNAPSHOT</version>
+    </parent>
+    <artifactId>rest</artifactId>
+    <name>IoTDB: External-Service-Impl: Rest</name>
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.jersey.inject</groupId>
+            <artifactId>jersey-hk2</artifactId>
+            <scope>runtime</scope>
+            <exclusions>
+                <!-- repeated in node commons -->
+                <exclusion>
+                    <groupId>jakarta.annotation</groupId>
+                    <artifactId>jakarta.annotation-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>rest-openapi</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <exclusions>
+                <!-- repeated in datanode -->
+                <exclusion>
+                    <groupId>jakarta.xml.bind</groupId>
+                    <artifactId>jakarta.xml.bind-api</artifactId>
+                </exclusion>
+                <!-- repeated in datanode -->
+                <exclusion>
+                    <groupId>jakarta.validation</groupId>
+                    <artifactId>jakarta.validation-api</artifactId>
+                </exclusion>
+                <!-- repeated in datanode -->
+                <exclusion>
+                    <groupId>org.javassist</groupId>
+                    <artifactId>javassist</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.servlet</groupId>
+            <artifactId>jakarta.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet-core</artifactId>
+            <exclusions>
+                <!-- repeated in datanode -->
+                <exclusion>
+                    <groupId>jakarta.validation</groupId>
+                    <artifactId>jakarta.validation-api</artifactId>
+                </exclusion>
+                <!-- repeated in node commons -->
+                <exclusion>
+                    <groupId>jakarta.annotation</groupId>
+                    <artifactId>jakarta.annotation-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>node-commons</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-server</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-session</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.github.ben-manes.caffeine</groupId>
+            <artifactId>caffeine</artifactId>
+            <scope>provided</scope>
+            <exclusions>
+                <!-- version conflicts with checker-qual in guava -->
+                <exclusion>
+                    <groupId>org.checkerframework</groupId>
+                    <artifactId>checker-qual</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>service-rpc</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.ws.rs</groupId>
+            <artifactId>jakarta.ws.rs-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-thrift</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tsfile</groupId>
+            <artifactId>tsfile</artifactId>
+            <version>${tsfile.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tsfile</groupId>
+            <artifactId>common</artifactId>
+            <version>${tsfile.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>iotdb-thrift-commons</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.antlr</groupId>
+            <artifactId>antlr4-runtime</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>${maven.assembly.version}</version>
+                <configuration>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <!-- bind to the packaging phase -->
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <!-- this is used for inheritance merges -->
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <configuration>
+                    <ignoredDependencies>
+                        <ignoredDependency>org.apache.tsfile:common</ignoredDependency>
+                        <ignoredDependency>junit:junit</ignoredDependency>
+                    </ignoredDependencies>
+                    <usedDependencies>
+                        <!-- This dependency is required at runtime, when enabling the rest service -->
+                        <usedDependency>org.glassfish.jersey.inject:jersey-hk2</usedDependency>
+                    </usedDependencies>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/RestService.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/RestService.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/RestService.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/RestService.java
index 7fc4d788380..9a90e6b18f2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/RestService.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/RestService.java
@@ -14,14 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.iotdb.db.service;
+package org.apache.iotdb.rest;
 
-import org.apache.iotdb.commons.exception.StartupException;
-import org.apache.iotdb.commons.service.IService;
-import org.apache.iotdb.commons.service.ServiceType;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceConfig;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-import org.apache.iotdb.db.protocol.rest.filter.ApiOriginFilter;
+import org.apache.iotdb.externalservice.api.IExternalService;
+import org.apache.iotdb.rest.protocol.filter.ApiOriginFilter;
 
 import org.eclipse.jetty.http.HttpVersion;
 import org.eclipse.jetty.server.HttpConfiguration;
@@ -41,7 +39,7 @@ import javax.servlet.DispatcherType;
 
 import java.util.EnumSet;
 
-public class RestService implements IService {
+public class RestService implements IExternalService {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(RestService.class);
 
@@ -97,7 +95,7 @@ public class RestService implements IService {
     holder.setInitOrder(1);
     holder.setInitParameter(
         "jersey.config.server.provider.packages",
-        "io.swagger.jaxrs.listing, io.swagger.sample.resource, org.apache.iotdb.db.protocol.rest");
+        "io.swagger.jaxrs.listing, io.swagger.sample.resource, org.apache.iotdb.rest.protocol");
     holder.setInitParameter(
         "jersey.config.server.provider.classnames",
         "org.glassfish.jersey.media.multipart.MultiPartFeature");
@@ -117,7 +115,7 @@ public class RestService implements IService {
   }
 
   @Override
-  public void start() throws StartupException {
+  public void start() {
     IoTDBRestServiceConfig config = IoTDBRestServiceDescriptor.getInstance().getConfig();
     if (IoTDBRestServiceDescriptor.getInstance().getConfig().isEnableHttps()) {
       startSSL(
@@ -143,20 +141,4 @@ public class RestService implements IService {
       server.destroy();
     }
   }
-
-  @Override
-  public ServiceType getID() {
-    return ServiceType.REST_SERVICE;
-  }
-
-  public static RestService getInstance() {
-    return RestServiceHolder.INSTANCE;
-  }
-
-  private static class RestServiceHolder {
-
-    private static final RestService INSTANCE = new RestService();
-
-    private RestServiceHolder() {}
-  }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/ApiOriginFilter.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/ApiOriginFilter.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/ApiOriginFilter.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/ApiOriginFilter.java
index aacc2bcc09a..578b8b35748 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/ApiOriginFilter.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/ApiOriginFilter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.filter;
+package org.apache.iotdb.rest.protocol.filter;
 
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
index 1f4da4c5a6a..a31e5b953ab 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.filter;
+package org.apache.iotdb.rest.protocol.filter;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.auth.AuthException;
@@ -23,9 +23,9 @@ import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.db.auth.AuthorityChecker;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceConfig;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
 import org.apache.iotdb.db.protocol.session.RestClientSession;
 import org.apache.iotdb.db.protocol.session.SessionManager;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import javax.servlet.annotation.WebFilter;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/BasicSecurityContext.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/BasicSecurityContext.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/BasicSecurityContext.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/BasicSecurityContext.java
index 28030577a93..5bea8d520dd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/BasicSecurityContext.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/BasicSecurityContext.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.filter;
+package org.apache.iotdb.rest.protocol.filter;
 
 import javax.ws.rs.core.SecurityContext;
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/User.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/User.java
similarity index 96%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/User.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/User.java
index af4b27e2a61..b6deb5825e3 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/User.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/User.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.filter;
+package org.apache.iotdb.rest.protocol.filter;
 
 public class User {
   private long userId = -1;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
index f53273def2d..8c8a55f25b5 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/UserCache.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.filter;
+package org.apache.iotdb.rest.protocol.filter;
 
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceConfig;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/handler/AuthorizationHandler.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/handler/AuthorizationHandler.java
index 3c30e3e95a9..4826a39fadd 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/handler/AuthorizationHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/handler/AuthorizationHandler.java
@@ -15,13 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.handler;
+package org.apache.iotdb.rest.protocol.handler;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.audit.UserEntity;
 import org.apache.iotdb.db.auth.AuthorityChecker;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import javax.ws.rs.core.Response;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/impl/PingApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/impl/PingApiServiceImpl.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/impl/PingApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/impl/PingApiServiceImpl.java
index f85de024b47..740bb28b069 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/impl/PingApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/impl/PingApiServiceImpl.java
@@ -15,12 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.impl;
+package org.apache.iotdb.rest.protocol.impl;
 
 import org.apache.iotdb.commons.service.ThriftService;
-import org.apache.iotdb.db.protocol.rest.PingApiService;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
 import org.apache.iotdb.db.service.ExternalRPCService;
+import org.apache.iotdb.rest.protocol.PingApiService;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import javax.ws.rs.core.Response;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExceptionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExceptionHandler.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExceptionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExceptionHandler.java
index 1d2da9ad57a..61e64465a06 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExceptionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExceptionHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.handler;
+package org.apache.iotdb.rest.protocol.table.v1.handler;
 
 import org.apache.iotdb.commons.auth.AuthException;
 import org.apache.iotdb.commons.exception.IllegalPathException;
@@ -27,8 +27,8 @@ import org.apache.iotdb.db.exception.metadata.DatabaseNotSetException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.exception.sql.SemanticException;
 import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.parser.ParsingException;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.antlr.v4.runtime.misc.ParseCancellationException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExecuteStatementHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExecuteStatementHandler.java
similarity index 99%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExecuteStatementHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExecuteStatementHandler.java
index 1b273753139..4fa749dd567 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/ExecuteStatementHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/ExecuteStatementHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.handler;
+package org.apache.iotdb.rest.protocol.table.v1.handler;
 
 import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CountDevice;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DescribeTable;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/QueryDataSetHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/QueryDataSetHandler.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/QueryDataSetHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/QueryDataSetHandler.java
index 25e331b38a8..ec22f478b8b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/QueryDataSetHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/QueryDataSetHandler.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.handler;
+package org.apache.iotdb.rest.protocol.table.v1.handler;
 
 import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.QueryDataSet;
 import org.apache.iotdb.db.queryengine.common.header.DatasetHeader;
 import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Query;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Statement;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.table.v1.model.QueryDataSet;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.apache.tsfile.block.column.Column;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/RequestValidationHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/RequestValidationHandler.java
similarity index 95%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/RequestValidationHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/RequestValidationHandler.java
index 66958785ce5..fc546212caf 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/RequestValidationHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/RequestValidationHandler.java
@@ -15,10 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.handler;
+package org.apache.iotdb.rest.protocol.table.v1.handler;
 
-import org.apache.iotdb.db.protocol.rest.table.v1.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.SQL;
+import org.apache.iotdb.rest.protocol.table.v1.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.table.v1.model.SQL;
 
 import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.external.commons.lang3.Validate;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/StatementConstructionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/StatementConstructionHandler.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/StatementConstructionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/StatementConstructionHandler.java
index bda0627ce61..b7f712c41f7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/handler/StatementConstructionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/handler/StatementConstructionHandler.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.handler;
+package org.apache.iotdb.rest.protocol.table.v1.handler;
 
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.InsertTabletRequest;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.TimestampPrecisionUtils;
+import org.apache.iotdb.rest.protocol.table.v1.model.InsertTabletRequest;
 
 import org.apache.tsfile.enums.ColumnCategory;
 import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/impl/RestApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/impl/RestApiServiceImpl.java
similarity index 92%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/impl/RestApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/impl/RestApiServiceImpl.java
index ec0237f13ea..b35e9d27f59 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/table/v1/impl/RestApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/impl/RestApiServiceImpl.java
@@ -15,22 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.table.v1.impl;
+package org.apache.iotdb.rest.protocol.table.v1.impl;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-import org.apache.iotdb.db.protocol.rest.table.v1.NotFoundException;
-import org.apache.iotdb.db.protocol.rest.table.v1.RestApiService;
-import org.apache.iotdb.db.protocol.rest.table.v1.handler.ExceptionHandler;
-import org.apache.iotdb.db.protocol.rest.table.v1.handler.ExecuteStatementHandler;
-import org.apache.iotdb.db.protocol.rest.table.v1.handler.QueryDataSetHandler;
-import org.apache.iotdb.db.protocol.rest.table.v1.handler.RequestValidationHandler;
-import org.apache.iotdb.db.protocol.rest.table.v1.handler.StatementConstructionHandler;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.table.v1.model.SQL;
 import org.apache.iotdb.db.protocol.session.IClientSession;
 import org.apache.iotdb.db.protocol.session.SessionManager;
 import org.apache.iotdb.db.protocol.thrift.OperationType;
@@ -46,6 +36,16 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.parser.SqlParser;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.CommonUtils;
 import org.apache.iotdb.db.utils.SetThreadName;
+import org.apache.iotdb.rest.protocol.table.v1.NotFoundException;
+import org.apache.iotdb.rest.protocol.table.v1.RestApiService;
+import org.apache.iotdb.rest.protocol.table.v1.handler.ExceptionHandler;
+import org.apache.iotdb.rest.protocol.table.v1.handler.ExecuteStatementHandler;
+import org.apache.iotdb.rest.protocol.table.v1.handler.QueryDataSetHandler;
+import org.apache.iotdb.rest.protocol.table.v1.handler.RequestValidationHandler;
+import org.apache.iotdb.rest.protocol.table.v1.handler.StatementConstructionHandler;
+import org.apache.iotdb.rest.protocol.table.v1.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.table.v1.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.table.v1.model.SQL;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import javax.ws.rs.core.Response;
@@ -294,7 +294,7 @@ public class RestApiServiceImpl extends RestApiService {
     if (statement == null) {
       return Response.ok()
           .entity(
-              new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+              new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                   .code(TSStatusCode.SQL_PARSE_ERROR.getStatusCode())
                   .message("This operation type is not supported"))
           .build();
@@ -304,7 +304,7 @@ public class RestApiServiceImpl extends RestApiService {
     if (userQuery == isQueryStmt) {
       return Response.ok()
           .entity(
-              new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+              new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                   .code(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())
                   .message(TSStatusCode.EXECUTE_STATEMENT_ERROR.name()))
           .build();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertRowDataUtils.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertRowDataUtils.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertRowDataUtils.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertRowDataUtils.java
index fae611dcf77..08deec903c9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertRowDataUtils.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertRowDataUtils.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.utils;
+package org.apache.iotdb.rest.protocol.utils;
 
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.rpc.NoValidValueException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertTabletSortDataUtils.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertTabletSortDataUtils.java
index e2e3d2f7976..82969f46bf2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/utils/InsertTabletSortDataUtils.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.utils;
+package org.apache.iotdb.rest.protocol.utils;
 
 import java.util.ArrayList;
 import java.util.Arrays;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExceptionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExceptionHandler.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExceptionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExceptionHandler.java
index 69994577f09..6edcb57ab4d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExceptionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExceptionHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v1.handler;
 
 import org.apache.iotdb.commons.auth.AuthException;
 import org.apache.iotdb.commons.exception.IllegalPathException;
@@ -27,7 +27,7 @@ import org.apache.iotdb.db.exception.metadata.DatabaseNotSetException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.exception.sql.SemanticException;
 import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.v1.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.antlr.v4.runtime.misc.ParseCancellationException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExecuteStatementHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExecuteStatementHandler.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExecuteStatementHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExecuteStatementHandler.java
index f1c621a4aa4..ab3811cf116 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExecuteStatementHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExecuteStatementHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.handler;
+package org.apache.iotdb.rest.protocol.v1.handler;
 
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
 import org.apache.iotdb.db.queryengine.plan.statement.StatementType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/QueryDataSetHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/QueryDataSetHandler.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/QueryDataSetHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/QueryDataSetHandler.java
index 55623ecad21..c2fe52440a7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/QueryDataSetHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/QueryDataSetHandler.java
@@ -15,10 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.handler;
+package org.apache.iotdb.rest.protocol.v1.handler;
 
 import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.protocol.rest.v1.model.ExecutionStatus;
 import org.apache.iotdb.db.queryengine.common.header.DatasetHeader;
 import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
@@ -30,6 +29,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowAIDevic
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowLoadedModelsStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowModelsStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.sys.AuthorStatement;
+import org.apache.iotdb.rest.protocol.v1.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.apache.tsfile.block.column.Column;
@@ -83,8 +83,8 @@ public class QueryDataSetHandler {
   public static Response fillDataSetWithTimestamps(
       IQueryExecution queryExecution, final int actualRowSizeLimit, final long timePrecision)
       throws IoTDBException {
-    org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v1.model.QueryDataSet();
 
     return fillQueryDataSetWithTimestamps(
         queryExecution, actualRowSizeLimit, targetDataSet, timePrecision);
@@ -93,8 +93,8 @@ public class QueryDataSetHandler {
   public static Response fillAggregationPlanDataSet(
       IQueryExecution queryExecution, final int actualRowSizeLimit) throws IoTDBException {
 
-    org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v1.model.QueryDataSet();
 
     DatasetHeader datasetHeader = queryExecution.getDatasetHeader();
     List<TSDataType> dataTypes = new ArrayList<>();
@@ -117,8 +117,8 @@ public class QueryDataSetHandler {
 
   private static Response fillShowPlanDataSet(
       IQueryExecution queryExecution, final int actualRowSizeLimit) throws IoTDBException {
-    org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v1.model.QueryDataSet();
     int[] targetDataSetIndexToSourceDataSetIndex =
         new int[queryExecution.getDatasetHeader().getRespColumns().size()];
     initTargetDatasetOrderByOrderWithSourceDataSet(
@@ -135,7 +135,7 @@ public class QueryDataSetHandler {
   private static void initTargetDatasetOrderByOrderWithSourceDataSet(
       DatasetHeader datasetHeader,
       int[] targetDataSetIndexToSourceDataSetIndex,
-      org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet) {
+      org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet) {
     if (datasetHeader.getRespColumns() != null) {
       for (int i = 0; i < datasetHeader.getRespColumns().size(); i++) {
         targetDataSet.addColumnNamesItem(datasetHeader.getRespColumns().get(i));
@@ -148,7 +148,7 @@ public class QueryDataSetHandler {
   private static Response fillQueryDataSetWithTimestamps(
       IQueryExecution queryExecution,
       int actualRowSizeLimit,
-      org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet,
+      org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet,
       final long timePrecision)
       throws IoTDBException {
     int fetched = 0;
@@ -167,7 +167,7 @@ public class QueryDataSetHandler {
       if (0 < actualRowSizeLimit && actualRowSizeLimit <= fetched) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.QUERY_PROCESS_ERROR.getStatusCode())
                     .message(
                         String.format(
@@ -216,7 +216,7 @@ public class QueryDataSetHandler {
       IQueryExecution queryExecution,
       int[] targetDataSetIndexToSourceDataSetIndex,
       int actualRowSizeLimit,
-      org.apache.iotdb.db.protocol.rest.v1.model.QueryDataSet targetDataSet,
+      org.apache.iotdb.rest.protocol.v1.model.QueryDataSet targetDataSet,
       List<TSDataType> dataTypes)
       throws IoTDBException {
     int fetched = 0;
@@ -225,7 +225,7 @@ public class QueryDataSetHandler {
       if (0 < actualRowSizeLimit && actualRowSizeLimit <= fetched) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.QUERY_PROCESS_ERROR.getStatusCode())
                     .message(
                         String.format(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/RequestValidationHandler.java
similarity index 90%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/RequestValidationHandler.java
index d7239f9fe62..dc81322cc78 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/RequestValidationHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/RequestValidationHandler.java
@@ -15,11 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.handler;
+package org.apache.iotdb.rest.protocol.v1.handler;
 
-import org.apache.iotdb.db.protocol.rest.v1.model.ExpressionRequest;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.v1.model.SQL;
+import org.apache.iotdb.rest.protocol.v1.model.ExpressionRequest;
+import org.apache.iotdb.rest.protocol.v1.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.v1.model.SQL;
 
 import org.apache.tsfile.external.commons.lang3.Validate;
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/StatementConstructionHandler.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/StatementConstructionHandler.java
index 523b8ccfb6a..65ec7a966f1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/StatementConstructionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/StatementConstructionHandler.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.handler;
+package org.apache.iotdb.rest.protocol.v1.handler;
 
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
 import org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.TimestampPrecisionUtils;
+import org.apache.iotdb.rest.protocol.v1.model.InsertTabletRequest;
 
 import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.utils.Binary;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/GrafanaApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/GrafanaApiServiceImpl.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/GrafanaApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/GrafanaApiServiceImpl.java
index c9a4f8f9ee1..0db4cd06c66 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/GrafanaApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/GrafanaApiServiceImpl.java
@@ -15,20 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.impl;
+package org.apache.iotdb.rest.protocol.v1.impl;
 
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.protocol.rest.handler.AuthorizationHandler;
-import org.apache.iotdb.db.protocol.rest.v1.GrafanaApiService;
-import org.apache.iotdb.db.protocol.rest.v1.handler.ExceptionHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.QueryDataSetHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.RequestValidationHandler;
-import org.apache.iotdb.db.protocol.rest.v1.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.v1.model.ExpressionRequest;
-import org.apache.iotdb.db.protocol.rest.v1.model.SQL;
 import org.apache.iotdb.db.protocol.session.SessionManager;
 import org.apache.iotdb.db.queryengine.plan.Coordinator;
 import org.apache.iotdb.db.queryengine.plan.analyze.ClusterPartitionFetcher;
@@ -42,6 +34,14 @@ import org.apache.iotdb.db.queryengine.plan.statement.Statement;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.QueryStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowStatement;
 import org.apache.iotdb.db.utils.SetThreadName;
+import org.apache.iotdb.rest.protocol.handler.AuthorizationHandler;
+import org.apache.iotdb.rest.protocol.v1.GrafanaApiService;
+import org.apache.iotdb.rest.protocol.v1.handler.ExceptionHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.QueryDataSetHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.RequestValidationHandler;
+import org.apache.iotdb.rest.protocol.v1.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.v1.model.ExpressionRequest;
+import org.apache.iotdb.rest.protocol.v1.model.SQL;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import com.google.common.base.Joiner;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/RestApiServiceImpl.java
similarity index 91%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/RestApiServiceImpl.java
index 6982fb0b533..329ac47034b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/impl/RestApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/RestApiServiceImpl.java
@@ -15,22 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.impl;
+package org.apache.iotdb.rest.protocol.v1.impl;
 
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-import org.apache.iotdb.db.protocol.rest.handler.AuthorizationHandler;
-import org.apache.iotdb.db.protocol.rest.utils.InsertTabletSortDataUtils;
-import org.apache.iotdb.db.protocol.rest.v1.RestApiService;
-import org.apache.iotdb.db.protocol.rest.v1.handler.ExceptionHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.ExecuteStatementHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.QueryDataSetHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.RequestValidationHandler;
-import org.apache.iotdb.db.protocol.rest.v1.handler.StatementConstructionHandler;
-import org.apache.iotdb.db.protocol.rest.v1.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.v1.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.v1.model.SQL;
 import org.apache.iotdb.db.protocol.session.SessionManager;
 import org.apache.iotdb.db.protocol.thrift.OperationType;
 import org.apache.iotdb.db.queryengine.plan.Coordinator;
@@ -48,6 +37,17 @@ import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.CreateTableViewStatement;
 import org.apache.iotdb.db.utils.CommonUtils;
 import org.apache.iotdb.db.utils.SetThreadName;
+import org.apache.iotdb.rest.protocol.handler.AuthorizationHandler;
+import org.apache.iotdb.rest.protocol.utils.InsertTabletSortDataUtils;
+import org.apache.iotdb.rest.protocol.v1.RestApiService;
+import org.apache.iotdb.rest.protocol.v1.handler.ExceptionHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.ExecuteStatementHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.QueryDataSetHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.RequestValidationHandler;
+import org.apache.iotdb.rest.protocol.v1.handler.StatementConstructionHandler;
+import org.apache.iotdb.rest.protocol.v1.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.v1.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.v1.model.SQL;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import javax.ws.rs.core.Response;
@@ -91,7 +91,7 @@ public class RestApiServiceImpl extends RestApiService {
       if (statement == null) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.SQL_PARSE_ERROR.getStatusCode())
                     .message("This operation type is not supported"))
             .build();
@@ -99,7 +99,7 @@ public class RestApiServiceImpl extends RestApiService {
       if (!ExecuteStatementHandler.validateStatement(statement)) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())
                     .message(TSStatusCode.EXECUTE_STATEMENT_ERROR.name()))
             .build();
@@ -181,7 +181,7 @@ public class RestApiServiceImpl extends RestApiService {
       if (statement == null) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.SQL_PARSE_ERROR.getStatusCode())
                     .message("This operation type is not supported"))
             .build();
@@ -189,7 +189,7 @@ public class RestApiServiceImpl extends RestApiService {
       if (ExecuteStatementHandler.validateStatement(statement)) {
         return Response.ok()
             .entity(
-                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                     .code(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())
                     .message(TSStatusCode.EXECUTE_STATEMENT_ERROR.name()))
             .build();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExceptionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExceptionHandler.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExceptionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExceptionHandler.java
index 8784d4ff721..931ec0cec00 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v1/handler/ExceptionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExceptionHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v1.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
 import org.apache.iotdb.commons.auth.AuthException;
 import org.apache.iotdb.commons.exception.IllegalPathException;
@@ -27,7 +27,7 @@ import org.apache.iotdb.db.exception.metadata.DatabaseNotSetException;
 import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.exception.sql.SemanticException;
 import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
-import org.apache.iotdb.db.protocol.rest.v1.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.antlr.v4.runtime.misc.ParseCancellationException;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExecuteStatementHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExecuteStatementHandler.java
similarity index 98%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExecuteStatementHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExecuteStatementHandler.java
index 00e43d17cce..1e937f0c8aa 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/ExecuteStatementHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/ExecuteStatementHandler.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
 import org.apache.iotdb.db.queryengine.plan.statement.StatementType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/FastLastHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/FastLastHandler.java
similarity index 87%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/FastLastHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/FastLastHandler.java
index 59ebb57ffbb..2895e0b198e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/FastLastHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/FastLastHandler.java
@@ -15,12 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
-import org.apache.iotdb.db.protocol.rest.v2.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.v2.model.PrefixPathList;
 import org.apache.iotdb.db.protocol.session.IClientSession;
+import org.apache.iotdb.rest.protocol.v2.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.v2.model.PrefixPathList;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.service.rpc.thrift.TSLastDataQueryReq;
 
@@ -45,7 +45,7 @@ public class FastLastHandler {
   public static Response buildErrorResponse(TSStatusCode statusCode) {
     return Response.ok()
         .entity(
-            new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+            new org.apache.iotdb.rest.protocol.model.ExecutionStatus()
                 .code(statusCode.getStatusCode())
                 .message(statusCode.name()))
         .build();
@@ -58,7 +58,7 @@ public class FastLastHandler {
   }
 
   public static void setupTargetDataSet(
-      org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet dataSet) {
+      org.apache.iotdb.rest.protocol.v2.model.QueryDataSet dataSet) {
     dataSet.addExpressionsItem("Timeseries");
     dataSet.addExpressionsItem("Value");
     dataSet.addExpressionsItem("DataType");
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/QueryDataSetHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/QueryDataSetHandler.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/QueryDataSetHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/QueryDataSetHandler.java
index b89c4f768a7..188b37ebb1e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/QueryDataSetHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/QueryDataSetHandler.java
@@ -15,10 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
 import org.apache.iotdb.commons.exception.IoTDBException;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
 import org.apache.iotdb.db.queryengine.common.header.DatasetHeader;
 import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
 import org.apache.iotdb.db.queryengine.plan.statement.Statement;
@@ -30,6 +29,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowAIDevic
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowLoadedModelsStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowModelsStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.sys.AuthorStatement;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.apache.tsfile.block.column.Column;
@@ -83,8 +83,8 @@ public class QueryDataSetHandler {
   public static Response fillDataSetWithTimestamps(
       IQueryExecution queryExecution, final int actualRowSizeLimit, final long timePrecision)
       throws IoTDBException {
-    org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v2.model.QueryDataSet();
 
     return fillQueryDataSetWithTimestamps(
         queryExecution, actualRowSizeLimit, targetDataSet, timePrecision);
@@ -93,8 +93,8 @@ public class QueryDataSetHandler {
   public static Response fillAggregationPlanDataSet(
       IQueryExecution queryExecution, final int actualRowSizeLimit) throws IoTDBException {
 
-    org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v2.model.QueryDataSet();
 
     DatasetHeader datasetHeader = queryExecution.getDatasetHeader();
     int[] targetDataSetIndexToSourceDataSetIndex = new int[datasetHeader.getRespColumns().size()];
@@ -113,8 +113,8 @@ public class QueryDataSetHandler {
 
   private static Response fillShowPlanDataSet(
       IQueryExecution queryExecution, final int actualRowSizeLimit) throws IoTDBException {
-    org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet =
-        new org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet();
+    org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet =
+        new org.apache.iotdb.rest.protocol.v2.model.QueryDataSet();
     int[] targetDataSetIndexToSourceDataSetIndex =
         new int[queryExecution.getDatasetHeader().getRespColumns().size()];
     initTargetDatasetOrderByOrderWithSourceDataSet(
@@ -127,7 +127,7 @@ public class QueryDataSetHandler {
   private static void initTargetDatasetOrderByOrderWithSourceDataSet(
       DatasetHeader datasetHeader,
       int[] targetDataSetIndexToSourceDataSetIndex,
-      org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet) {
+      org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet) {
     if (datasetHeader.getRespColumns() != null) {
       for (int i = 0; i < datasetHeader.getRespColumns().size(); i++) {
         targetDataSet.addColumnNamesItem(datasetHeader.getRespColumns().get(i));
@@ -140,7 +140,7 @@ public class QueryDataSetHandler {
   private static Response fillQueryDataSetWithTimestamps(
       IQueryExecution queryExecution,
       int actualRowSizeLimit,
-      org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet,
+      org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet,
       final long timePrecision)
       throws IoTDBException {
     int fetched = 0;
@@ -209,7 +209,7 @@ public class QueryDataSetHandler {
       IQueryExecution queryExecution,
       int[] targetDataSetIndexToSourceDataSetIndex,
       int actualRowSizeLimit,
-      org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet targetDataSet)
+      org.apache.iotdb.rest.protocol.v2.model.QueryDataSet targetDataSet)
       throws IoTDBException {
     int fetched = 0;
     int columnNum = queryExecution.getOutputValueColumnCount();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/RequestValidationHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/RequestValidationHandler.java
similarity index 93%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/RequestValidationHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/RequestValidationHandler.java
index 4192caaeca2..5f999b3ddcc 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/RequestValidationHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/RequestValidationHandler.java
@@ -15,13 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
-import org.apache.iotdb.db.protocol.rest.v2.model.ExpressionRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertRecordsRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.PrefixPathList;
-import org.apache.iotdb.db.protocol.rest.v2.model.SQL;
+import org.apache.iotdb.rest.protocol.v2.model.ExpressionRequest;
+import org.apache.iotdb.rest.protocol.v2.model.InsertRecordsRequest;
+import org.apache.iotdb.rest.protocol.v2.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.v2.model.PrefixPathList;
+import org.apache.iotdb.rest.protocol.v2.model.SQL;
 
 import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.external.commons.lang3.Validate;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/StatementConstructionHandler.java
similarity index 97%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/StatementConstructionHandler.java
index 4bf9a1a5510..6668244e9e4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/handler/StatementConstructionHandler.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/handler/StatementConstructionHandler.java
@@ -15,20 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.handler;
+package org.apache.iotdb.rest.protocol.v2.handler;
 
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.exception.WriteProcessRejectException;
 import org.apache.iotdb.db.exception.metadata.DataTypeMismatchException;
-import org.apache.iotdb.db.protocol.rest.utils.InsertRowDataUtils;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertRecordsRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertTabletRequest;
 import org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertRowsStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.utils.TimestampPrecisionUtils;
+import org.apache.iotdb.rest.protocol.utils.InsertRowDataUtils;
+import org.apache.iotdb.rest.protocol.v2.model.InsertRecordsRequest;
+import org.apache.iotdb.rest.protocol.v2.model.InsertTabletRequest;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 
 import org.apache.tsfile.enums.TSDataType;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/GrafanaApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/GrafanaApiServiceImpl.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/GrafanaApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/GrafanaApiServiceImpl.java
index 229e9a41b27..5b120b9c1d7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/GrafanaApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/GrafanaApiServiceImpl.java
@@ -15,20 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.impl;
+package org.apache.iotdb.rest.protocol.v2.impl;
 
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.protocol.rest.handler.AuthorizationHandler;
-import org.apache.iotdb.db.protocol.rest.v2.GrafanaApiService;
-import org.apache.iotdb.db.protocol.rest.v2.handler.ExceptionHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.QueryDataSetHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.RequestValidationHandler;
-import org.apache.iotdb.db.protocol.rest.v2.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.v2.model.ExpressionRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.SQL;
 import org.apache.iotdb.db.protocol.session.SessionManager;
 import org.apache.iotdb.db.queryengine.plan.Coordinator;
 import org.apache.iotdb.db.queryengine.plan.analyze.ClusterPartitionFetcher;
@@ -42,6 +34,14 @@ import org.apache.iotdb.db.queryengine.plan.statement.Statement;
 import org.apache.iotdb.db.queryengine.plan.statement.crud.QueryStatement;
 import org.apache.iotdb.db.queryengine.plan.statement.metadata.ShowStatement;
 import org.apache.iotdb.db.utils.SetThreadName;
+import org.apache.iotdb.rest.protocol.handler.AuthorizationHandler;
+import org.apache.iotdb.rest.protocol.v2.GrafanaApiService;
+import org.apache.iotdb.rest.protocol.v2.handler.ExceptionHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.QueryDataSetHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.RequestValidationHandler;
+import org.apache.iotdb.rest.protocol.v2.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.v2.model.ExpressionRequest;
+import org.apache.iotdb.rest.protocol.v2.model.SQL;
 import org.apache.iotdb.rpc.TSStatusCode;
 
 import com.google.common.base.Joiner;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/RestApiServiceImpl.java
similarity index 94%
rename from iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
rename to external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/RestApiServiceImpl.java
index b657523987d..1ea82c60657 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/v2/impl/RestApiServiceImpl.java
+++ b/external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/RestApiServiceImpl.java
@@ -15,29 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.iotdb.db.protocol.rest.v2.impl;
+package org.apache.iotdb.rest.protocol.v2.impl;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
-import org.apache.iotdb.db.protocol.rest.handler.AuthorizationHandler;
-import org.apache.iotdb.db.protocol.rest.model.ExecutionStatus;
-import org.apache.iotdb.db.protocol.rest.utils.InsertTabletSortDataUtils;
-import org.apache.iotdb.db.protocol.rest.v2.NotFoundException;
-import org.apache.iotdb.db.protocol.rest.v2.RestApiService;
-import org.apache.iotdb.db.protocol.rest.v2.handler.ExceptionHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.ExecuteStatementHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.FastLastHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.QueryDataSetHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.RequestValidationHandler;
-import org.apache.iotdb.db.protocol.rest.v2.handler.StatementConstructionHandler;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertRecordsRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.InsertTabletRequest;
-import org.apache.iotdb.db.protocol.rest.v2.model.PrefixPathList;
-import org.apache.iotdb.db.protocol.rest.v2.model.QueryDataSet;
-import org.apache.iotdb.db.protocol.rest.v2.model.SQL;
 import org.apache.iotdb.db.protocol.session.IClientSession;
 import org.apache.iotdb.db.protocol.session.SessionManager;
 import org.apache.iotdb.db.protocol.thrift.OperationType;
@@ -60,6 +44,22 @@ import org.apache.iotdb.db.schemaengine.SchemaEngine;
 import org.apache.iotdb.db.schemaengine.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.utils.CommonUtils;
 import org.apache.iotdb.db.utils.SetThreadName;
+import org.apache.iotdb.rest.protocol.handler.AuthorizationHandler;
+import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
+import org.apache.iotdb.rest.protocol.utils.InsertTabletSortDataUtils;
+import org.apache.iotdb.rest.protocol.v2.NotFoundException;
+import org.apache.iotdb.rest.protocol.v2.RestApiService;
+import org.apache.iotdb.rest.protocol.v2.handler.ExceptionHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.ExecuteStatementHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.FastLastHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.QueryDataSetHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.RequestValidationHandler;
+import org.apache.iotdb.rest.protocol.v2.handler.StatementConstructionHandler;
+import org.apache.iotdb.rest.protocol.v2.model.InsertRecordsRequest;
+import org.apache.iotdb.rest.protocol.v2.model.InsertTabletRequest;
+import org.apache.iotdb.rest.protocol.v2.model.PrefixPathList;
+import org.apache.iotdb.rest.protocol.v2.model.QueryDataSet;
+import org.apache.iotdb.rest.protocol.v2.model.SQL;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.service.rpc.thrift.TSLastDataQueryReq;
 
@@ -90,7 +90,7 @@ public class RestApiServiceImpl extends RestApiService {
 
   private static final SessionManager SESSION_MANAGER = SessionManager.getInstance();
 
-  private static final String FORMAT = "rest/v2/fastLastQuery %s";
+  private static final String FORMAT = "org/apache/iotdb/rest/protocol/v2/fastLastQuery %s";
 
   private final IPartitionFetcher partitionFetcher;
 
diff --git a/integration-test/pom.xml b/integration-test/pom.xml
index c82a63c3f3b..a4776a57c55 100644
--- a/integration-test/pom.xml
+++ b/integration-test/pom.xml
@@ -239,6 +239,13 @@
             <!--We will integrate mqtt-jar-with-dependencies into lib by assembly plugin-->
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>rest</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+            <!--We will integrate rest-jar-with-dependencies into lib by assembly plugin-->
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
diff --git a/integration-test/src/assembly/mpp-share.xml b/integration-test/src/assembly/mpp-share.xml
index 96ac13e64d1..70072e8282e 100644
--- a/integration-test/src/assembly/mpp-share.xml
+++ b/integration-test/src/assembly/mpp-share.xml
@@ -35,5 +35,9 @@
             <source>${project.basedir}/../external-service-impl/mqtt/target/mqtt-${project.version}-jar-with-dependencies.jar</source>
             <outputDirectory>lib</outputDirectory>
         </file>
+        <file>
+            <source>${project.basedir}/../external-service-impl/rest/target/rest-${project.version}-jar-with-dependencies.jar</source>
+            <outputDirectory>lib</outputDirectory>
+        </file>
     </files>
 </assembly>
diff --git a/iotdb-core/confignode/pom.xml b/iotdb-core/confignode/pom.xml
index 805848aadaf..1112363f466 100644
--- a/iotdb-core/confignode/pom.xml
+++ b/iotdb-core/confignode/pom.xml
@@ -132,12 +132,6 @@
             <groupId>org.reflections</groupId>
             <artifactId>reflections</artifactId>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.javassist</groupId>
-                    <artifactId>javassist</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.code.findbugs</groupId>
diff --git a/iotdb-core/datanode/pom.xml b/iotdb-core/datanode/pom.xml
index b55fd8e5c68..2ccae580549 100644
--- a/iotdb-core/datanode/pom.xml
+++ b/iotdb-core/datanode/pom.xml
@@ -59,11 +59,6 @@
             <artifactId>external-api</artifactId>
             <version>2.0.7-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.iotdb</groupId>
-            <artifactId>openapi</artifactId>
-            <version>2.0.7-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>org.apache.iotdb</groupId>
             <artifactId>node-commons</artifactId>
@@ -188,10 +183,6 @@
             <groupId>org.eclipse.milo</groupId>
             <artifactId>sdk-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>jakarta.servlet</groupId>
-            <artifactId>jakarta.servlet-api</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.eclipse.milo</groupId>
             <artifactId>stack-server</artifactId>
@@ -208,10 +199,6 @@
             <groupId>org.bouncycastle</groupId>
             <artifactId>bcprov-jdk18on</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-http</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-pool2</artifactId>
@@ -220,18 +207,10 @@
             <groupId>org.antlr</groupId>
             <artifactId>antlr4-runtime</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-util</artifactId>
-        </dependency>
         <dependency>
             <groupId>io.airlift</groupId>
             <artifactId>airline</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.eclipse.milo</groupId>
             <artifactId>sdk-server</artifactId>
@@ -259,31 +238,20 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.glassfish.jersey.containers</groupId>
-            <artifactId>jersey-container-servlet-core</artifactId>
-        </dependency>
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.glassfish.jersey.inject</groupId>
-            <artifactId>jersey-hk2</artifactId>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
+            <exclusions>
+                <!-- version conflicts with checker-qual in guava -->
+                <exclusion>
+                    <groupId>org.checkerframework</groupId>
+                    <artifactId>checker-qual</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
@@ -330,11 +298,6 @@
             <artifactId>json-smart</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpcore</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.ratis</groupId>
             <artifactId>ratis-thirdparty-misc</artifactId>
@@ -345,11 +308,6 @@
             <artifactId>oauth2-oidc-sdk</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.powermock</groupId>
             <artifactId>powermock-core</artifactId>
@@ -538,8 +496,6 @@
                         <!-- These are used at runtime in tests -->
                         <usedDependency>io.jsonwebtoken:jjwt-impl</usedDependency>
                         <usedDependency>io.jsonwebtoken:jjwt-jackson</usedDependency>
-                        <!-- This dependency is required at runtime, when enabling the rest service -->
-                        <usedDependency>org.glassfish.jersey.inject:jersey-hk2</usedDependency>
                     </usedDependencies>
                 </configuration>
             </plugin>
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
index d0eef468d4f..eaa4fa0a4e9 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -75,7 +75,6 @@ import org.apache.iotdb.db.conf.DataNodeSystemPropertiesHandler;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.IoTDBStartCheck;
-import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
 import org.apache.iotdb.db.consensus.DataRegionConsensusImpl;
 import org.apache.iotdb.db.consensus.SchemaRegionConsensusImpl;
 import org.apache.iotdb.db.pipe.agent.PipeDataNodeAgent;
@@ -1311,9 +1310,6 @@ public class DataNode extends ServerCommandLine implements DataNodeMBean {
   }
 
   private void initProtocols() throws StartupException {
-    if (IoTDBRestServiceDescriptor.getInstance().getConfig().isEnableRestService()) {
-      registerManager.register(RestService.getInstance());
-    }
     prepareExternalServiceResources();
     if (PipeConfig.getInstance().getPipeAirGapReceiverEnabled()) {
       registerManager.register(PipeDataNodeAgent.receiver().airGap());
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/externalservice/BuiltinExternalServices.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/externalservice/BuiltinExternalServices.java
index 4dee890e65f..157734aef56 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/externalservice/BuiltinExternalServices.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/externalservice/BuiltinExternalServices.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.db.service.externalservice;
 
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor;
 
 import java.util.function.Supplier;
 
@@ -31,8 +32,7 @@ public enum BuiltinExternalServices {
   REST(
       "REST",
       "org.apache.iotdb.rest.RestService",
-      // IoTDBRestServiceDescriptor.getInstance().getConfig()::isEnableRestService
-      () -> false);
+      IoTDBRestServiceDescriptor.getInstance().getConfig()::isEnableRestService);
 
   private final String serviceName;
   private final String className;
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/GrafanaApiServiceTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/GrafanaApiServiceTest.java
deleted file mode 100644
index 55d74742453..00000000000
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/GrafanaApiServiceTest.java
+++ /dev/null
@@ -1,450 +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.iotdb.db.protocol.rest;
-
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-// move to integration-test
-@Ignore
-public class GrafanaApiServiceTest {
-  @Before
-  public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
-  }
-
-  private String getAuthorization(String username, String password) {
-    return Base64.getEncoder()
-        .encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
-  }
-
-  private HttpPost getHttpPost(String url) {
-    HttpPost httpPost = new HttpPost(url);
-    httpPost.addHeader("Content-type", "application/json; charset=utf-8");
-    httpPost.setHeader("Accept", "application/json");
-    String authorization = getAuthorization("root", "root");
-    httpPost.setHeader("Authorization", authorization);
-    return httpPost;
-  }
-
-  @Test
-  public void login() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    HttpGet httpGet = new HttpGet("http://127.0.0.1:18080/grafana/v1/login");
-    CloseableHttpResponse response = null;
-    try {
-      String authorization = getAuthorization("root", "root");
-      httpGet.setHeader("Authorization", authorization);
-      response = httpClient.execute(httpGet);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(200, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (httpClient != null) {
-          httpClient.close();
-        }
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void rightInsertTablet(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/insertTablet");
-      String json =
-          "{\"timestamps\":[1635232143960,1635232153960],\"measurements\":[\"s4\",\"s5\"],\"dataTypes\":[\"INT32\",\"INT32\"],\"values\":[[11,2],[15,13]],\"isAligned\":false,\"deviceId\":\"root.sg25\"}";
-      httpPost.setEntity(new StringEntity(json, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(200, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void expressionAggGroupByTimeAndLevel(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"count(s4)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232143960,\"endTime\":1635232153960,\"control\":\"group by([1635232143960,1635232153960),1s),level=1\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-      List<Long> expressionsResult = (List<Long>) map.get("expressions");
-      List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-      Assert.assertTrue(map.size() > 0);
-      Assert.assertTrue(timestampsResult.size() == 10);
-      Assert.assertTrue(valuesResult.size() == 1);
-      Assert.assertTrue("count(root.sg25.s4)".equals(expressionsResult.get(0)));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void expression(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"s4\",\"s5\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232133960,\"endTime\":1635232163960}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map<String, List> map = mapper.readValue(message, Map.class);
-      String[] expressionsResult = {"root.sg25.s4", "root.sg25.s5"};
-      Long[] timestamps = {1635232143960L, 1635232153960L};
-      Object[] values1 = {11, 2};
-      Object[] values2 = {15, 13};
-      Assert.assertArrayEquals(
-          expressionsResult, (map.get("expressions")).toArray(new String[] {}));
-      Assert.assertArrayEquals(timestamps, (map.get("timestamps")).toArray(new Long[] {}));
-      Assert.assertArrayEquals(
-          values1, ((List) (map.get("values")).get(0)).toArray(new Object[] {}));
-      Assert.assertArrayEquals(
-          values2, ((List) (map.get("values")).get(1)).toArray(new Object[] {}));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void expressionWithControl(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"sum(s4)\",\"avg(s5)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232133960,\"endTime\":1635232163960,\"control\":\"group by([1635232133960,1635232163960),20s)\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map<String, List> map = mapper.readValue(message, Map.class);
-      String[] expressionsResult = {"sum(root.sg25.s4)", "avg(root.sg25.s5)"};
-      Long[] timestamps = {1635232133960L, 1635232153960L};
-      Object[] values1 = {11.0, 2.0};
-      Object[] values2 = {15.0, 13.0};
-      Assert.assertArrayEquals(
-          expressionsResult, (map.get("expressions")).toArray(new String[] {}));
-      Assert.assertArrayEquals(timestamps, (map.get("timestamps")).toArray(new Long[] {}));
-      Assert.assertArrayEquals(
-          values1, ((List) (map.get("values")).get(0)).toArray(new Object[] {}));
-      Assert.assertArrayEquals(
-          values2, ((List) (map.get("values")).get(1)).toArray(new Object[] {}));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void expressionWithConditionControl(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"sum(s4)\",\"avg(s5)\"],\"prefixPath\":[\"root.sg25\"],\"condition\":\"timestamp=1635232143960\",\"startTime\":1635232133960,\"endTime\":1635232163960,\"control\":\"group by([1635232133960,1635232163960),20s)\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map<String, List> map = mapper.readValue(message, Map.class);
-      String[] expressionsResult = {"sum(root.sg25.s4)", "avg(root.sg25.s5)"};
-      Long[] timestamps = {1635232133960L, 1635232153960L};
-      Object[] values1 = {11.0, null};
-      Object[] values2 = {15.0, null};
-      Assert.assertArrayEquals(expressionsResult, map.get("expressions").toArray(new String[] {}));
-      Assert.assertArrayEquals(timestamps, (map.get("timestamps")).toArray(new Long[] {}));
-      Assert.assertArrayEquals(
-          values1, ((List) (map.get("values")).get(0)).toArray(new Object[] {}));
-      Assert.assertArrayEquals(
-          values2, ((List) (map.get("values")).get(1)).toArray(new Object[] {}));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void variable(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/variable");
-      String sql = "{\"sql\":\"show child paths root.sg25\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      List list = mapper.readValue(message, List.class);
-      String[] expectedResult = {"s4", "s5"};
-      Assert.assertArrayEquals(expectedResult, list.toArray(new String[] {}));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  @Test
-  public void expressionWithConditionControlTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-    expressionWithConditionControl(httpClient);
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void expressionTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-    expression(httpClient);
-    expressionAggGroupByTimeAndLevel(httpClient);
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void expressionWithControlTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-    expressionWithControl(httpClient);
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void variableTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-    variable(httpClient);
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void expressionWithAggGroupByTimeTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"count(s4)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232143960,\"endTime\":1635232153960,\"control\":\"group by([1635232143960,1635232153960),1s)\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-      List<Long> expressionsResult = (List<Long>) map.get("expressions");
-      List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-      Assert.assertTrue(map.size() > 0);
-      Assert.assertTrue(timestampsResult.size() == 10);
-      Assert.assertTrue(valuesResult.size() == 1);
-      Assert.assertTrue("count(root.sg25.s4)".equals(expressionsResult.get(0)));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void expressionWithAggGroupByLevelTest() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/grafana/v1/query/expression");
-      String sql =
-          "{\"expression\":[\"count(s4)\"],\"prefixPath\":[\"root.sg25\"],\"startTime\":1635232143960,\"endTime\":1635232153960,\"control\":\"group by level = 1\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-      List<Long> expressionsResult = (List<Long>) map.get("expressions");
-      List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-      Assert.assertTrue(map.size() > 0);
-      Assert.assertTrue(timestampsResult == null);
-      Assert.assertTrue(valuesResult.size() == 1);
-      Assert.assertTrue("count(root.sg25.s4)".equals(expressionsResult.get(0)));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-}
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/IoTDBRestServiceTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/IoTDBRestServiceTest.java
deleted file mode 100644
index 4c15d3635ac..00000000000
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/rest/IoTDBRestServiceTest.java
+++ /dev/null
@@ -1,918 +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.iotdb.db.protocol.rest;
-
-import org.apache.iotdb.commons.exception.StartupException;
-import org.apache.iotdb.db.service.ExternalRPCService;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-// Move it to integration-test
-@Ignore
-@FixMethodOrder(MethodSorters.JVM)
-public class IoTDBRestServiceTest {
-  @Before
-  public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
-  }
-
-  private String getAuthorization(String username, String password) {
-    return Base64.getEncoder()
-        .encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
-  }
-
-  @Test
-  public void ping() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    HttpGet httpGet = new HttpGet("http://127.0.0.1:18080/ping");
-    CloseableHttpResponse response = null;
-    try {
-      response = httpClient.execute(httpGet);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(200, response.getStatusLine().getStatusCode());
-      assertEquals(200, Integer.parseInt(result.get("code").toString()));
-
-      // Shutdown RPCService to test
-      ExternalRPCService.getInstance().stop();
-      response = httpClient.execute(httpGet);
-      responseEntity = response.getEntity();
-      message = EntityUtils.toString(responseEntity, "utf-8");
-      result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(503, response.getStatusLine().getStatusCode());
-      assertEquals(500, Integer.parseInt(result.get("code").toString()));
-      ExternalRPCService.getInstance().start();
-
-    } catch (IOException | StartupException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (httpClient != null) {
-          httpClient.close();
-        }
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  private HttpPost getHttpPost(String url) {
-    HttpPost httpPost = new HttpPost(url);
-    httpPost.addHeader("Content-type", "application/json; charset=utf-8");
-    httpPost.setHeader("Accept", "application/json");
-    String authorization = getAuthorization("root", "root");
-    httpPost.setHeader("Authorization", authorization);
-    return httpPost;
-  }
-
-  public void rightInsertTablet(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/insertTablet");
-      String json =
-          "{\"timestamps\":[1635232143960,1635232153960],\"measurements\":[\"s3\",\"s4\",\"s5\",\"s6\",\"s7\",\"s8\"],\"dataTypes\":[\"TEXT\",\"INT32\",\"INT64\",\"FLOAT\",\"BOOLEAN\",\"DOUBLE\"],\"values\":[[\"2aa\",\"\"],[11,2],[1635000012345555,1635000012345556],[1.41,null],[null,false],[null,3.5555]],\"isAligned\":false,\"deviceId\":\"root.sg25\"}";
-      httpPost.setEntity(new StringEntity(json, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(200, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  @Test
-  public void errorInsertTablet() {
-    CloseableHttpResponse response = null;
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/insertTablet");
-      String json =
-          "{\"timestamps\":[1635232143960,1635232153960],\"measurements\":[\"s3\",\"s4\",\"s5\",\"s6\",\"s7\",\"s8\"],\"dataTypes\":[\"TEXT\",\"INT32\",\"INT64\",\"FLOAT\",\"BOOLEAN\",\"DOUBLE\"],\"values\":[[\"2aa\",\"\"],[111111112312312442352545452323123,2],[16,15],[1.41,null],[null,false],[null,3.55555555555555555555555555555555555555555555312234235345123127318927461482308478123645555555555555555555555555555555555555555555531223423534512312731892746148230847812364]],\"isAligned\":fal [...]
-      httpPost.setEntity(new StringEntity(json, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(413, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  @Test
-  public void insertAndQuery() {
-    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-    rightInsertTablet(httpClient);
-    query(httpClient);
-    queryGroupByLevel(httpClient);
-    queryRowLimit(httpClient);
-    queryShowChildPaths(httpClient);
-    queryShowNodes(httpClient);
-    showAllTTL(httpClient);
-    showStorageGroup(httpClient);
-    showFunctions(httpClient);
-    showTimeseries(httpClient);
-
-    showLastTimeseries(httpClient);
-    countTimeseries(httpClient);
-    countNodes(httpClient);
-    showDevices(httpClient);
-
-    showDevicesWithStroage(httpClient);
-    listUser(httpClient);
-    selectCount(httpClient);
-    selectLast(httpClient);
-    try {
-      httpClient.close();
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-  }
-
-  @Test
-  public void queryWithUnsetAuthorization() {
-    CloseableHttpResponse response = null;
-    try {
-      CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-      HttpPost httpPost = new HttpPost("http://127.0.0.1:18080/rest/v1/query");
-      httpPost.addHeader("Content-type", "application/json; charset=utf-8");
-      httpPost.setHeader("Accept", "application/json");
-      String sql = "{\"sql\":\"select *,s4+1,s4+1 from root.sg25\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      Assert.assertEquals(401, response.getStatusLine().getStatusCode());
-      String message = EntityUtils.toString(response.getEntity(), "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(603, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  @Test
-  public void queryWithWrongAuthorization() {
-    CloseableHttpResponse response = null;
-    try {
-      CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-      HttpPost httpPost = new HttpPost("http://127.0.0.1:18080/rest/v1/query");
-      httpPost.addHeader("Content-type", "application/json; charset=utf-8");
-      httpPost.setHeader("Accept", "application/json");
-      String authorization = getAuthorization("abc", "def");
-      httpPost.setHeader("Authorization", authorization);
-      String sql = "{\"sql\":\"select *,s4+1,s4+1 from root.sg25\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      Assert.assertEquals(401, response.getStatusLine().getStatusCode());
-      String message = EntityUtils.toString(response.getEntity(), "utf-8");
-      JsonObject result = JsonParser.parseString(message).getAsJsonObject();
-      assertEquals(600, Integer.parseInt(result.get("code").toString()));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void query(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/query");
-      String sql = "{\"sql\":\"select *,s4+1,s4+1 from root.sg25\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-      List<Long> expressionsResult = (List<Long>) map.get("expressions");
-      List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-      Assert.assertTrue(map.size() > 0);
-      List<Object> expressions =
-          new ArrayList<Object>() {
-            {
-              add("root.sg25.s3");
-              add("root.sg25.s4");
-              add("root.sg25.s5");
-              add("root.sg25.s6");
-              add("root.sg25.s7");
-              add("root.sg25.s8");
-              add("root.sg25.s4 + 1");
-              add("root.sg25.s4 + 1");
-            }
-          };
-      List<Object> timestamps =
-          new ArrayList<Object>() {
-            {
-              add(1635232143960l);
-              add(1635232153960l);
-            }
-          };
-      List<Object> values1 =
-          new ArrayList<Object>() {
-            {
-              add("2aa");
-              add("");
-            }
-          };
-      List<Object> values2 =
-          new ArrayList<Object>() {
-            {
-              add(11);
-              add(2);
-            }
-          };
-      List<Object> values3 =
-          new ArrayList<Object>() {
-            {
-              add(1635000012345555l);
-              add(1635000012345556l);
-            }
-          };
-
-      List<Object> values4 =
-          new ArrayList<Object>() {
-            {
-              add(1.41);
-              add(null);
-            }
-          };
-      List<Object> values5 =
-          new ArrayList<Object>() {
-            {
-              add(null);
-              add(false);
-            }
-          };
-      List<Object> values6 =
-          new ArrayList<Object>() {
-            {
-              add(null);
-              add(3.5555);
-            }
-          };
-
-      Assert.assertEquals(expressions, expressionsResult);
-      Assert.assertEquals(timestamps, timestampsResult);
-      Assert.assertEquals(values1, valuesResult.get(0));
-      Assert.assertEquals(values2, valuesResult.get(1));
-      Assert.assertEquals(values3, valuesResult.get(2));
-      Assert.assertEquals(values4, valuesResult.get(3));
-      Assert.assertEquals(values5, valuesResult.get(4));
-      Assert.assertEquals(values6, valuesResult.get(5));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void queryGroupByLevel(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/query");
-      String sql =
-          "{\"sql\":\"select count(s4) from root.sg25 group by([1635232143960,1635232153960),1s),level=1\"}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-      List<Long> expressionsResult = (List<Long>) map.get("expressions");
-      List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-      Assert.assertTrue(map.size() > 0);
-      Assert.assertTrue(timestampsResult.size() == 10);
-      Assert.assertTrue(valuesResult.size() == 1);
-      Assert.assertTrue("count(root.sg25.s4)".equals(expressionsResult.get(0)));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public void queryRowLimit(CloseableHttpClient httpClient) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/query");
-      String sql = "{\"sql\":\"select *,s4+1,s4+1 from root.sg25\",\"rowLimit\":1}";
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      assertTrue(message.contains("row size exceeded the given max row size"));
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-  }
-
-  public Map queryMetaData(CloseableHttpClient httpClient, String sql) {
-    CloseableHttpResponse response = null;
-    try {
-      HttpPost httpPost = getHttpPost("http://127.0.0.1:18080/rest/v1/query");
-      httpPost.setEntity(new StringEntity(sql, Charset.defaultCharset()));
-      response = httpClient.execute(httpPost);
-      HttpEntity responseEntity = response.getEntity();
-      String message = EntityUtils.toString(responseEntity, "utf-8");
-      ObjectMapper mapper = new ObjectMapper();
-      Map map = mapper.readValue(message, Map.class);
-      return map;
-
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    } finally {
-      try {
-        if (response != null) {
-          response.close();
-        }
-      } catch (IOException e) {
-        e.printStackTrace();
-        fail(e.getMessage());
-      }
-    }
-    return null;
-  }
-
-  public void queryShowChildPaths(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show child paths root\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("child paths");
-            add("node types");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void queryShowNodes(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show child nodes root\",\"rowLimit\":1}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("child nodes");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("sg25");
-          }
-        };
-
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void showAllTTL(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show all ttl\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("database");
-            add("ttl");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add(null);
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2, valuesResult.get(1));
-  }
-
-  public void showStorageGroup(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"SHOW DATABASES root.*\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("database");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void showFunctions(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show functions\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    assertEquals(3, columnNamesResult.size());
-    assertEquals(3, valuesResult.size());
-  }
-
-  public void showTimeseries(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show timeseries\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("timeseries");
-            add("alias");
-            add("database");
-            add("dataType");
-            add("encoding");
-            add("compression");
-            add("tags");
-            add("attributes");
-            add("deadband");
-            add("deadbandparameters");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25.s3");
-            add("root.sg25.s4");
-            add("root.sg25.s5");
-            add("root.sg25.s6");
-            add("root.sg25.s7");
-            add("root.sg25.s8");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-          }
-        };
-    List<Object> values3 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-          }
-        };
-
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2, valuesResult.get(1));
-    Assert.assertEquals(values3, valuesResult.get(2));
-  }
-
-  public void showLastTimeseries(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"SHOW LATEST TIMESERIES\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("timeseries");
-            add("alias");
-            add("database");
-            add("dataType");
-            add("encoding");
-            add("compression");
-            add("tags");
-            add("attributes");
-            add("deadband");
-            add("deadbandparameters");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25.s3");
-            add("root.sg25.s4");
-            add("root.sg25.s5");
-            add("root.sg25.s7");
-            add("root.sg25.s8");
-            add("root.sg25.s6");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-            add(null);
-          }
-        };
-    List<Object> values3 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-            add("root.sg25");
-          }
-        };
-
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2, valuesResult.get(1));
-    Assert.assertEquals(values3, valuesResult.get(2));
-  }
-
-  public void countTimeseries(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"COUNT TIMESERIES root.** GROUP BY LEVEL=1\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("column");
-            add("count");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add(6);
-          }
-        };
-
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2, valuesResult.get(1));
-  }
-
-  public void countNodes(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"count nodes root.** level=2\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("count");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add(6);
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void showDevices(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show devices\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("devices");
-            add("isAligned");
-            add("Template");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    List<Boolean> values2 =
-        new ArrayList<Boolean>() {
-          {
-            add(false);
-          }
-        };
-    List<String> values3 =
-        new ArrayList<String>() {
-          {
-            add("null");
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    // Assert.assertEquals(values2, valuesResult.get(1));
-  }
-
-  public void showDevicesWithStroage(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"show devices with database\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("devices");
-            add("database");
-            add("isAligned");
-            add("Template");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25");
-          }
-        };
-    List<Object> values3 =
-        new ArrayList<Object>() {
-          {
-            add("false");
-          }
-        };
-    List<Object> values4 =
-        new ArrayList<Object>() {
-          {
-            add("null");
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2, valuesResult.get(1));
-    Assert.assertEquals(values3, valuesResult.get(2));
-    Assert.assertEquals(values4, valuesResult.get(3));
-  }
-
-  public void listUser(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"list user\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("user");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root");
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void selectCount(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"select count(s3) from root.** group by level = 1\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("count(root.sg25.s3)");
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add(2);
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-  }
-
-  public void selectLast(CloseableHttpClient httpClient) {
-    String sql = "{\"sql\":\"select last s4 from root.sg25\"}";
-    Map map = queryMetaData(httpClient, sql);
-    List<String> columnNamesResult = (List<String>) map.get("columnNames");
-    List<List<Object>> valuesResult = (List<List<Object>>) map.get("values");
-    List<Long> timestampsResult = (List<Long>) map.get("timestamps");
-    Assert.assertTrue(map.size() > 0);
-    List<Object> columnNames =
-        new ArrayList<Object>() {
-          {
-            add("timeseries");
-            add("value");
-            add("dataType");
-          }
-        };
-    List<Long> timestamps =
-        new ArrayList<Long>() {
-          {
-            add(1635232153960l);
-          }
-        };
-    List<Object> values1 =
-        new ArrayList<Object>() {
-          {
-            add("root.sg25.s4");
-          }
-        };
-    List<Object> values2 =
-        new ArrayList<Object>() {
-          {
-            add("2");
-          }
-        };
-    List<Object> values3 =
-        new ArrayList<Object>() {
-          {
-            add("INT32");
-          }
-        };
-    Assert.assertEquals(columnNames, columnNamesResult);
-    Assert.assertEquals(timestamps, timestampsResult);
-    Assert.assertEquals(values1, valuesResult.get(0));
-    Assert.assertEquals(values2.get(0), valuesResult.get(1).get(0));
-    Assert.assertEquals(values3, valuesResult.get(2));
-  }
-}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
index 55fad14e5a1..7180f1e092c 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/ServiceType.java
@@ -67,7 +67,6 @@ public enum ServiceType {
       "Cluster Data Heartbeat RPC Service", "ClusterDataHeartbeatRPCService"),
   CLUSTER_META_ENGINE("Cluster Meta Engine", "ClusterMetaEngine"),
   CLUSTER_DATA_ENGINE("Cluster Data Engine", "ClusterDataEngine"),
-  REST_SERVICE("REST Service", "REST Service"),
   CONFIG_NODE_SERVICE("Config Node service", "ConfigNodeRPCServer"),
   DATA_NODE_REGION_MIGRATE_SERVICE("Data Node Region Migrate service", ""),
   DATA_NODE_MANAGEMENT_SERVICE("Data Node management service", "DataNodeManagementServer"),
diff --git a/iotdb-protocol/pom.xml b/iotdb-protocol/pom.xml
index 853a97ab209..3d1cfa12eff 100644
--- a/iotdb-protocol/pom.xml
+++ b/iotdb-protocol/pom.xml
@@ -30,7 +30,6 @@
     <packaging>pom</packaging>
     <name>IoTDB: Protocol</name>
     <modules>
-        <module>openapi</module>
         <module>thrift-datanode</module>
         <module>thrift-commons</module>
         <module>thrift-confignode</module>