This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch iotdb-collector
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/iotdb-collector by this push:
new f79440d7306 Collector Node: Build basic architecture, configuration
file reading and REST service (#14689)
f79440d7306 is described below
commit f79440d73067f85f51d19be44d63443efba48f22
Author: 0xB <[email protected]>
AuthorDate: Mon Jan 13 18:23:51 2025 +0800
Collector Node: Build basic architecture, configuration file reading and
REST service (#14689)
---
iotdb-collector/collector-core/pom.xml | 63 +++++
.../java/org/apache/iotdb/collector/Collector.java | 107 ++++++++
.../iotdb/collector/config/CollectorConfig.java | 39 +++
.../iotdb/collector/config/CollectorConstant.java | 24 ++
.../collector/config/CollectorDescriptor.java | 126 +++++++++
.../config/CollectorSystemPropertiesHandler.java | 52 ++++
.../iotdb/collector/config/ConfigFileUtils.java | 101 ++++++++
.../protocol/rest/filter/ApiOriginFilter.java | 52 ++++
.../protocol/rest/filter/AuthorizationFilter.java | 46 ++++
.../protocol/rest/impl/PingApiServiceImpl.java | 39 +++
.../protocol/rest/v1/impl/AdminApiServiceImpl.java | 68 +++++
.../iotdb/collector/service/CollectorMBean.java | 21 ++
.../collector/service/CollectorRestService.java | 113 +++++++++
.../apache/iotdb/collector/service/IService.java | 39 +++
.../iotdb/collector/service/RegisterManager.java | 82 ++++++
.../resources/iotdb-collector-system.properties | 20 ++
iotdb-collector/collector-openapi/pom.xml | 185 ++++++++++++++
.../main/openapi3/iotdb_collector_rest_common.yaml | 63 +++++
.../src/main/openapi3/iotdb_collector_rest_v1.yaml | 282 +++++++++++++++++++++
iotdb-collector/pom.xml | 42 +++
pom.xml | 1 +
21 files changed, 1565 insertions(+)
diff --git a/iotdb-collector/collector-core/pom.xml
b/iotdb-collector/collector-core/pom.xml
new file mode 100644
index 00000000000..820c73a5452
--- /dev/null
+++ b/iotdb-collector/collector-core/pom.xml
@@ -0,0 +1,63 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>iotdb-collector</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>collector-core</artifactId>
+ <name>IoTDB: Collector: Core</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>collector-openapi</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</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-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/Collector.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/Collector.java
new file mode 100644
index 00000000000..af107db6f55
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/Collector.java
@@ -0,0 +1,107 @@
+/*
+ * 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.collector;
+
+import org.apache.iotdb.collector.config.CollectorConfig;
+import org.apache.iotdb.collector.config.CollectorSystemPropertiesHandler;
+import org.apache.iotdb.collector.service.CollectorMBean;
+import org.apache.iotdb.collector.service.CollectorRestService;
+import org.apache.iotdb.collector.service.RegisterManager;
+import org.apache.iotdb.commons.ServerCommandLine;
+import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.StartupException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.Charset;
+import java.util.Set;
+
+public class Collector extends ServerCommandLine implements CollectorMBean {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(Collector.class);
+
+ private static final RegisterManager REGISTER_MANAGER =
RegisterManager.getInstance();
+
+ public Collector() {
+ super("Collector");
+ CollectorHolder.INSTANCE = this;
+ }
+
+ public static void main(String[] args) {
+ LOGGER.info(
+ "IoTDB-Collector environment variables: {}",
CollectorConfig.getEnvironmentVariables());
+ LOGGER.info("IoTDB-Collector default charset is: {}",
Charset.defaultCharset().displayName());
+
+ final Collector collector = new Collector();
+ final int returnCode = collector.run(args);
+ if (returnCode != 0) {
+ System.exit(returnCode);
+ }
+ }
+
+ @Override
+ protected void start() {
+ boolean isFirstStart;
+ try {
+ isFirstStart = prepareCollector();
+ if (isFirstStart) {
+ LOGGER.info("Collector is starting for the first time...");
+ } else {
+ LOGGER.info("Collector is restarting...");
+ }
+
+ pullAndCheckSystemConfigurations();
+
+ initProtocols();
+ } catch (final StartupException e) {
+ LOGGER.error("Collector start failed", e);
+ stop();
+ System.exit(-1);
+ }
+ }
+
+ private boolean prepareCollector() {
+ return CollectorSystemPropertiesHandler.getInstance().fileExist();
+ }
+
+ private void pullAndCheckSystemConfigurations() {
+ LOGGER.info("Pulling system configurations from the ConfigNode-leader...");
+ }
+
+ private void initProtocols() throws StartupException {
+ REGISTER_MANAGER.register(CollectorRestService.getInstance());
+ }
+
+ private void stop() {}
+
+ @Override
+ protected void remove(final Set<Integer> nodeIds) throws IoTDBException {
+ // empty method
+ }
+
+ private static class CollectorHolder {
+ private static Collector INSTANCE;
+
+ private CollectorHolder() {
+ // empty constructor
+ }
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConfig.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConfig.java
new file mode 100644
index 00000000000..99a40488e55
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConfig.java
@@ -0,0 +1,39 @@
+/*
+ * 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.collector.config;
+
+public class CollectorConfig {
+
+ public static final String CONFIG_NAME = "iotdb-collector-system.properties";
+
+ private int restServicePort = 17070;
+
+ public static String getEnvironmentVariables() {
+ return "";
+ }
+
+ public int getRestServicePort() {
+ return restServicePort;
+ }
+
+ public void setRestServicePort(int restServicePort) {
+ this.restServicePort = restServicePort;
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConstant.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConstant.java
new file mode 100644
index 00000000000..ed9bf141a2b
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorConstant.java
@@ -0,0 +1,24 @@
+/*
+ * 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.collector.config;
+
+public class CollectorConstant {
+ public static final String PROPERTIES_FILE_NAME = "system.properties";
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorDescriptor.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorDescriptor.java
new file mode 100644
index 00000000000..6046254e64d
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorDescriptor.java
@@ -0,0 +1,126 @@
+/*
+ * 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.collector.config;
+
+import org.apache.iotdb.commons.conf.TrimProperties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Optional;
+import java.util.Properties;
+
+public class CollectorDescriptor {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(CollectorDescriptor.class);
+
+ private static final CollectorConfig CONFIG = new CollectorConfig();
+ private static final String CONFIG_NAME = CollectorConfig.CONFIG_NAME;
+
+ static {
+ final Optional<URL> systemConfigUrl = getPropsUrl();
+ systemConfigUrl.ifPresent(
+ url -> {
+ try {
+ ConfigFileUtils.checkAndMayUpdate(url);
+ } catch (final Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
+ LOGGER.error("Failed to update config file", e);
+ }
+ });
+ }
+
+ private static Optional<URL> getPropsUrl() {
+ final URL url = CollectorConfig.class.getResource("/" + CONFIG_NAME);
+
+ if (url != null) {
+ return Optional.of(url);
+ } else {
+ LOGGER.warn(
+ "Cannot find IOTDB_COLLECTOR_HOME or IOTDB_COLLECTOR_CONF
environment variable when loading "
+ + "config file {}, use default configuration",
+ CONFIG_NAME);
+ // TODO update path
+ // IoTDBConfig: updatePath()
+ return Optional.empty();
+ }
+ }
+
+ protected CollectorDescriptor() {
+ loadProps();
+ }
+
+ private void loadProps() {
+ final TrimProperties collectorProperties = new TrimProperties();
+ final Optional<URL> url = getPropsUrl();
+
+ if (url.isPresent()) {
+ try (final InputStream inputStream = url.get().openStream()) {
+ LOGGER.info("Start to read config file {}", url.get());
+ final Properties properties = new Properties();
+ properties.load(new InputStreamReader(inputStream,
StandardCharsets.UTF_8));
+ collectorProperties.putAll(properties);
+ loadProperties(collectorProperties);
+ } catch (final FileNotFoundException e) {
+ LOGGER.error("Fail to find config file {}, reject DataNode startup.",
url.get(), e);
+ System.exit(-1);
+ } catch (final IOException e) {
+ LOGGER.error("Cannot load config file, reject DataNode startup.", e);
+ System.exit(-1);
+ } catch (final Exception e) {
+ LOGGER.error("Incorrect format in config file, reject DataNode
startup.", e);
+ System.exit(-1);
+ }
+ } else {
+ LOGGER.warn("Couldn't load the configuration {} from any of the known
sources.", CONFIG_NAME);
+ }
+ }
+
+ // properties config
+ private void loadProperties(final TrimProperties properties) {
+ CONFIG.setRestServicePort(
+ Integer.parseInt(
+ Optional.ofNullable(properties.getProperty("collector_rest_port"))
+ .orElse(String.valueOf(CONFIG.getRestServicePort()))));
+ }
+
+ public static CollectorDescriptor getInstance() {
+ return CollectorDescriptorHolder.INSTANCE;
+ }
+
+ public CollectorConfig getConfig() {
+ return CONFIG;
+ }
+
+ private static class CollectorDescriptorHolder {
+
+ private static final CollectorDescriptor INSTANCE = new
CollectorDescriptor();
+
+ private CollectorDescriptorHolder() {}
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorSystemPropertiesHandler.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorSystemPropertiesHandler.java
new file mode 100644
index 00000000000..ff4db04b995
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/CollectorSystemPropertiesHandler.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.collector.config;
+
+import org.apache.iotdb.commons.file.SystemPropertiesHandler;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static
org.apache.iotdb.collector.config.CollectorConstant.PROPERTIES_FILE_NAME;
+
+public class CollectorSystemPropertiesHandler extends SystemPropertiesHandler {
+
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(CollectorSystemPropertiesHandler.class);
+
+ private static CollectorSystemPropertiesHandler INSTANCE;
+
+ public CollectorSystemPropertiesHandler(final String filePath) {
+ super(filePath);
+ }
+
+ public static SystemPropertiesHandler getInstance() {
+ if (INSTANCE == null) {
+ synchronized (CollectorSystemPropertiesHandler.class) {
+ INSTANCE =
+ new CollectorSystemPropertiesHandler(
+ // TODO System File Folder
+ PROPERTIES_FILE_NAME);
+ INSTANCE.init();
+ }
+ }
+ return INSTANCE;
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/ConfigFileUtils.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/ConfigFileUtils.java
new file mode 100644
index 00000000000..54c687981dc
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/config/ConfigFileUtils.java
@@ -0,0 +1,101 @@
+/*
+ * 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.collector.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.StringJoiner;
+import java.util.concurrent.TimeUnit;
+
+public class ConfigFileUtils {
+
+ private static final String lockFileSuffix = ".lock";
+ private static final long maxTimeMillsToAcquireLock =
TimeUnit.SECONDS.toMillis(20);
+ private static final long waitTimeMillsPerCheck =
TimeUnit.MILLISECONDS.toMillis(100);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ConfigFileUtils.class);
+ private static final String lineSeparator = "\n";
+ private static final String license =
+ new StringJoiner(lineSeparator)
+ .add("# Licensed to the Apache Software Foundation (ASF) under one")
+ .add("# or more contributor license agreements. See the NOTICE
file")
+ .add("# distributed with this work for additional information")
+ .add("# regarding copyright ownership. The ASF licenses this file")
+ .add("# to you under the Apache License, Version 2.0 (the")
+ .add("# \"License\"); you may not use this file except in
compliance")
+ .add("# with the License. You may obtain a copy of the License at")
+ .add("#")
+ .add("# http://www.apache.org/licenses/LICENSE-2.0")
+ .add("#")
+ .add("# Unless required by applicable law or agreed to in writing,")
+ .add("# software distributed under the License is distributed on an")
+ .add("# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY")
+ .add("# KIND, either express or implied. See the License for the")
+ .add("# specific language governing permissions and limitations")
+ .add("# under the License.")
+ .toString();
+
+ public static void checkAndMayUpdate(final URL url) throws IOException,
InterruptedException {
+ final File systemFile = new File(url.getFile());
+ if (systemFile.exists()) {
+ return;
+ }
+ final File lockFile = new File(systemFile.getAbsolutePath() +
lockFileSuffix);
+ acquireTargetFileLock(lockFile);
+ try {
+ if (systemFile.exists()) {
+ return;
+ }
+ try (final RandomAccessFile raf = new RandomAccessFile(lockFile, "rw")) {
+ raf.write(license.getBytes());
+ }
+ Files.move(lockFile.toPath(), systemFile.toPath());
+ } finally {
+ releaseFileLock(lockFile);
+ }
+ }
+
+ private static void acquireTargetFileLock(final File file)
+ throws IOException, InterruptedException {
+ long totalWaitTime = 0;
+ while (totalWaitTime < maxTimeMillsToAcquireLock) {
+ if (file.createNewFile()) {
+ return;
+ }
+ totalWaitTime += waitTimeMillsPerCheck;
+ Thread.sleep(waitTimeMillsPerCheck);
+ }
+ LOGGER.warn(
+ "Waiting for {} seconds to acquire configuration file update lock."
+ + " There may have been an unexpected interruption in the last"
+ + " configuration file update. Ignore temporary file {}",
+ totalWaitTime / 1000,
+ file.getName());
+ }
+
+ private static void releaseFileLock(final File file) throws IOException {
+ Files.deleteIfExists(file.toPath());
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/ApiOriginFilter.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/ApiOriginFilter.java
new file mode 100644
index 00000000000..179836fec6e
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/ApiOriginFilter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.collector.protocol.rest.filter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+
+public class ApiOriginFilter implements javax.servlet.Filter {
+ @Override
+ public void doFilter(
+ final ServletRequest request, final ServletResponse response, final
FilterChain chain)
+ throws IOException, ServletException {
+ final HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST");
+ res.addHeader("Access-Control-Allow-Headers", "*");
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ // do nothing
+ }
+
+ @Override
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ // do nothing
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/AuthorizationFilter.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/AuthorizationFilter.java
new file mode 100644
index 00000000000..93524743bb9
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/filter/AuthorizationFilter.java
@@ -0,0 +1,46 @@
+/*
+ * 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.collector.protocol.rest.filter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.annotation.WebFilter;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.ext.Provider;
+
+import java.io.IOException;
+
+@WebFilter("/*")
+@Provider
+public class AuthorizationFilter implements ContainerRequestFilter,
ContainerResponseFilter {
+
+ @Override
+ public void filter(final ContainerRequestContext containerRequestContext)
throws IOException {}
+
+ @Override
+ public void filter(
+ final ContainerRequestContext containerRequestContext,
+ final ContainerResponseContext containerResponseContext)
+ throws IOException {}
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/impl/PingApiServiceImpl.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/impl/PingApiServiceImpl.java
new file mode 100644
index 00000000000..8d34d94852f
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/impl/PingApiServiceImpl.java
@@ -0,0 +1,39 @@
+/*
+ * 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.collector.protocol.rest.impl;
+
+import org.apache.iotdb.collector.protocol.rest.NotFoundException;
+import org.apache.iotdb.collector.protocol.rest.PingApiService;
+import org.apache.iotdb.collector.protocol.rest.v1.model.ExecutionStatus;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+
+public class PingApiServiceImpl extends PingApiService {
+
+ @Override
+ public Response tryPing(final SecurityContext securityContext) throws
NotFoundException {
+ return Response.ok()
+ .entity(
+ new ExecutionStatus()
+ .code(TSStatusCode.SUCCESS_STATUS.getStatusCode())
+ .message(TSStatusCode.SUCCESS_STATUS.name()))
+ .build();
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/v1/impl/AdminApiServiceImpl.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/v1/impl/AdminApiServiceImpl.java
new file mode 100644
index 00000000000..8b9c5ced25b
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/protocol/rest/v1/impl/AdminApiServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * 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.collector.protocol.rest.v1.impl;
+
+import org.apache.iotdb.collector.protocol.rest.v1.AdminApiService;
+import org.apache.iotdb.collector.protocol.rest.v1.NotFoundException;
+import org.apache.iotdb.collector.protocol.rest.v1.model.AlterPipeRequest;
+import org.apache.iotdb.collector.protocol.rest.v1.model.CreatePipeRequest;
+import org.apache.iotdb.collector.protocol.rest.v1.model.DropPipeRequest;
+import org.apache.iotdb.collector.protocol.rest.v1.model.StartPipeRequest;
+import org.apache.iotdb.collector.protocol.rest.v1.model.StopPipeRequest;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+
+public class AdminApiServiceImpl extends AdminApiService {
+ @Override
+ public Response alterPipe(
+ final AlterPipeRequest alterPipeRequest, final SecurityContext
securityContext)
+ throws NotFoundException {
+ return Response.ok("alterPipe").build();
+ }
+
+ @Override
+ public Response createPipe(
+ final CreatePipeRequest createPipeRequest, final SecurityContext
securityContext)
+ throws NotFoundException {
+ return Response.ok("createPipe").build();
+ }
+
+ @Override
+ public Response dropPipe(
+ final DropPipeRequest dropPipeRequest, final SecurityContext
securityContext)
+ throws NotFoundException {
+ return Response.ok("dropPipe").build();
+ }
+
+ @Override
+ public Response startPipe(
+ final StartPipeRequest startPipeRequest, final SecurityContext
securityContext)
+ throws NotFoundException {
+ return Response.ok("startPipe").build();
+ }
+
+ @Override
+ public Response stopPipe(
+ final StopPipeRequest stopPipeRequest, final SecurityContext
securityContext)
+ throws NotFoundException {
+ return Response.ok("stopPipe").build();
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorMBean.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorMBean.java
new file mode 100644
index 00000000000..60809ff37b1
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorMBean.java
@@ -0,0 +1,21 @@
+/*
+ * 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.collector.service;
+
+public interface CollectorMBean {}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorRestService.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorRestService.java
new file mode 100644
index 00000000000..b8caa7dad99
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/CollectorRestService.java
@@ -0,0 +1,113 @@
+/*
+ * 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.collector.service;
+
+import org.apache.iotdb.collector.config.CollectorConfig;
+import org.apache.iotdb.collector.config.CollectorDescriptor;
+import org.apache.iotdb.collector.protocol.rest.filter.ApiOriginFilter;
+import org.apache.iotdb.commons.service.ServiceType;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.glassfish.jersey.servlet.ServletContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.DispatcherType;
+
+import java.util.EnumSet;
+
+public class CollectorRestService implements IService {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(CollectorRestService.class);
+
+ private static final CollectorConfig CONFIG =
CollectorDescriptor.getInstance().getConfig();
+
+ private static Server server;
+
+ private CollectorRestService() {}
+
+ @Override
+ public void start() {
+ startNonSSL(CONFIG.getRestServicePort());
+ }
+
+ private void startNonSSL(final int restServicePort) {
+ server = new Server(restServicePort);
+ server.setHandler(constructServletContextHandler());
+ serverStart();
+ }
+
+ private ServletContextHandler constructServletContextHandler() {
+ final ServletContextHandler context =
+ new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
+ context.addFilter(
+ ApiOriginFilter.class, "/*", EnumSet.of(DispatcherType.INCLUDE,
DispatcherType.REQUEST));
+ final ServletHolder holder = context.addServlet(ServletContainer.class,
"/*");
+ holder.setInitOrder(1);
+ holder.setInitParameter(
+ "jersey.config.server.provider.packages",
+ "io.swagger.jaxrs.listing, io.swagger.sample.resource,
org.apache.iotdb.collector.protocol.rest");
+ holder.setInitParameter(
+ "jersey.config.server.provider.classnames",
+ "org.glassfish.jersey.media.multipart.MultiPartFeature");
+ holder.setInitParameter("jersey.config.server.wadl.disableWadl", "true");
+ context.setContextPath("/");
+ return context;
+ }
+
+ private void serverStart() {
+ try {
+ server.start();
+ } catch (final Exception e) {
+ LOGGER.warn("CollectorRestService failed to start: {}", e.getMessage());
+ server.destroy();
+ }
+ LOGGER.info("start CollectorRestService successfully");
+ }
+
+ @Override
+ public void stop() {
+ try {
+ server.stop();
+ } catch (final Exception e) {
+ LOGGER.warn("CollectorRestService failed to stop: {}", e.getMessage());
+ } finally {
+ server.destroy();
+ }
+ }
+
+ @Override
+ public ServiceType getID() {
+ return ServiceType.REST_SERVICE;
+ }
+
+ public static CollectorRestService getInstance() {
+ return CollectorRestServiceHolder.INSTANCE;
+ }
+
+ private static class CollectorRestServiceHolder {
+
+ private static final CollectorRestService INSTANCE = new
CollectorRestService();
+
+ private CollectorRestServiceHolder() {}
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/IService.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/IService.java
new file mode 100644
index 00000000000..95755d26085
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/IService.java
@@ -0,0 +1,39 @@
+/*
+ * 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.collector.service;
+
+import org.apache.iotdb.commons.exception.ShutdownException;
+import org.apache.iotdb.commons.exception.StartupException;
+import org.apache.iotdb.commons.service.ServiceType;
+
+public interface IService {
+ void start() throws StartupException;
+
+ default void waitAndStop(long milliseconds) {
+ stop();
+ }
+
+ default void shutdown(long milliseconds) throws ShutdownException {
+ waitAndStop(milliseconds);
+ }
+
+ void stop();
+
+ ServiceType getID();
+}
diff --git
a/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/RegisterManager.java
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/RegisterManager.java
new file mode 100644
index 00000000000..5498ff403ec
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/java/org/apache/iotdb/collector/service/RegisterManager.java
@@ -0,0 +1,82 @@
+/*
+ * 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.collector.service;
+
+import org.apache.iotdb.commons.exception.StartupException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class RegisterManager {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(RegisterManager.class);
+ private final List<IService> iServices;
+ private static final long DEREGISTER_TIME_OUT = 10_00L;
+
+ private RegisterManager() {
+ this.iServices = new ArrayList<>();
+ }
+
+ /** register service. */
+ public void register(final IService service) throws StartupException {
+ for (final IService iService : iServices) {
+ if (iService.getID() == service.getID()) {
+ LOGGER.debug("{} has already been registered. skip",
service.getID().getName());
+ return;
+ }
+ }
+ iServices.add(service);
+ final long startTime = System.currentTimeMillis();
+ service.start();
+ final long endTime = System.currentTimeMillis();
+ LOGGER.info(
+ "The {} service is started successfully, which takes {} ms.",
+ service.getID().getName(),
+ (endTime - startTime));
+ }
+
+ /** stop all service and clear iService list. */
+ public void deregisterAll() {
+ Collections.reverse(iServices);
+ for (IService service : iServices) {
+ try {
+ service.waitAndStop(DEREGISTER_TIME_OUT);
+ LOGGER.debug("{} deregistered", service.getID());
+ } catch (final Exception e) {
+ LOGGER.error("Failed to stop {} because:", service.getID().getName(),
e);
+ }
+ }
+ iServices.clear();
+ LOGGER.info("deregister all service.");
+ }
+
+ public static RegisterManager getInstance() {
+ return RegisterManagerHolder.INSTANCE;
+ }
+
+ private static class RegisterManagerHolder {
+ private static final RegisterManager INSTANCE = new RegisterManager();
+
+ private RegisterManagerHolder() {}
+ }
+}
diff --git
a/iotdb-collector/collector-core/src/main/resources/iotdb-collector-system.properties
b/iotdb-collector/collector-core/src/main/resources/iotdb-collector-system.properties
new file mode 100644
index 00000000000..bb4189f4f4c
--- /dev/null
+++
b/iotdb-collector/collector-core/src/main/resources/iotdb-collector-system.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+collector_rest_port=17070
\ No newline at end of file
diff --git a/iotdb-collector/collector-openapi/pom.xml
b/iotdb-collector/collector-openapi/pom.xml
new file mode 100644
index 00000000000..ab3de19dca5
--- /dev/null
+++ b/iotdb-collector/collector-openapi/pom.xml
@@ -0,0 +1,185 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>iotdb-collector</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>collector-openapi</artifactId>
+ <name>IoTDB: Collector: OpenAPI</name>
+ <dependencies>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-models</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-jsr310</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.validation</groupId>
+ <artifactId>jakarta.validation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.ws.rs</groupId>
+ <artifactId>jakarta.ws.rs-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jaxrs</artifactId>
+ </dependency>
+ <!-- Just needed for unused import code -->
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- TODO: For some reason the code-generation is run twice -->
+ <plugin>
+ <groupId>org.openapitools</groupId>
+ <artifactId>openapi-generator-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-java-rest-codes-common</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+
<inputSpec>${project.basedir}/src/main/openapi3/iotdb_collector_rest_common.yaml</inputSpec>
+
<output>${project.build.directory}/generated-sources/java</output>
+
<apiPackage>org.apache.iotdb.collector.protocol.rest</apiPackage>
+
<modelPackage>org.apache.iotdb.collector.protocol.rest.model</modelPackage>
+
<invokerPackage>org.apache.iotdb.collector.protocol.rest.invoker</invokerPackage>
+ <generatorName>jaxrs-jersey</generatorName>
+ <groupId>org.apache.iotdb.</groupId>
+
<artifactId>iotdb-collector-rest-service</artifactId>
+
<artifactVersion>${project.version}</artifactVersion>
+ <addCompileSourceRoot>true</addCompileSourceRoot>
+ <configOptions>
+ <licenseName>Apache License 2.0</licenseName>
+ <groupId>org.apache.iotdb</groupId>
+
<artifactId>iotdb-collector-rest-service</artifactId>
+
<artifactVersion>${project.version}</artifactVersion>
+ <dateLibrary>java8</dateLibrary>
+ <useGzipFeature>true</useGzipFeature>
+ </configOptions>
+ </configuration>
+ </execution>
+ <execution>
+ <id>generate-java-rest-codes-v1</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+
<inputSpec>${project.basedir}/src/main/openapi3/iotdb_collector_rest_v1.yaml</inputSpec>
+
<output>${project.build.directory}/generated-sources/java</output>
+
<apiPackage>org.apache.iotdb.collector.protocol.rest.v1</apiPackage>
+
<modelPackage>org.apache.iotdb.collector.protocol.rest.v1.model</modelPackage>
+
<invokerPackage>org.apache.iotdb.collector.protocol.rest.v1.invoker</invokerPackage>
+ <generatorName>jaxrs-jersey</generatorName>
+ <groupId>org.apache.iotdb</groupId>
+
<artifactId>iotdb-collector-rest-service</artifactId>
+
<artifactVersion>${project.version}</artifactVersion>
+ <addCompileSourceRoot>true</addCompileSourceRoot>
+ <configOptions>
+ <licenseName>Apache License 2.0</licenseName>
+ <groupId>org.apache.iotdb</groupId>
+
<artifactId>iotdb-collector-rest-service</artifactId>
+
<artifactVersion>${project.version}</artifactVersion>
+ <dateLibrary>java8</dateLibrary>
+ <useGzipFeature>true</useGzipFeature>
+ </configOptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <sources>
+
<source>${project.basedir}/target/generated-sources/java/src/gen/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!--
+ TODO: For some reason I am unable to prevent the generation of the
default implementations in the "impl"
+ package. Also I was unable to prevent the maven-compiler-plugin from
compiling them. So we're simply
+ excluding them from the jar as a measure of last resort.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/impl/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <usedDependencies combine.children="append">
+ <!-- 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>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_common.yaml
b/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_common.yaml
new file mode 100644
index 00000000000..a81a242ac87
--- /dev/null
+++
b/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_common.yaml
@@ -0,0 +1,63 @@
+#
+# 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.
+#
+
+openapi: 3.0.0
+info:
+ title: iotdb_collector_rest_common
+ description: IoTDB Rest API for Collector
+ license:
+ name: Apache 2.0
+ url: https://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+servers:
+- url: http://127.0.0.1:17070/
+ description: api
+security:
+- basic: []
+paths:
+ /ping:
+ get:
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+ operationId: tryPing
+
+components:
+ schemas:
+ ExecutionStatus:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ message:
+ type: string
+
+ securitySchemes:
+ basic:
+ type: http
+ scheme: basic
+ APIKey:
+ type: apiKey
+ name: API Key
+ in: header
diff --git
a/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_v1.yaml
b/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_v1.yaml
new file mode 100644
index 00000000000..85802287ffa
--- /dev/null
+++
b/iotdb-collector/collector-openapi/src/main/openapi3/iotdb_collector_rest_v1.yaml
@@ -0,0 +1,282 @@
+#
+# 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.
+#
+
+openapi: 3.0.0
+info:
+ title: iotdb-collector-rest
+ description: IoTDB Rest API for Collector
+ license:
+ name: Apache 2.0
+ url: https://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+servers:
+ - url: http://127.0.0.1:17070/
+ description: api
+security:
+ - basic: []
+paths:
+ /admin/v1/createPipe:
+ post:
+ summary: createPipe
+ description: createPipe
+ operationId: createPipe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/CreatePipeRequest'
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+
+ /admin/v1/alterPipe:
+ post:
+ summary: alterPipe
+ description: alterPipe
+ operationId: alterPipe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AlterPipeRequest'
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+
+ /admin/v1/startPipe:
+ post:
+ summary: startPipe
+ description: startPipe
+ operationId: startPipe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/StartPipeRequest'
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+
+ /admin/v1/stopPipe:
+ post:
+ summary: stopPipe
+ description: stopPipe
+ operationId: stopPipe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/StopPipeRequest'
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+
+ /admin/v1/dropPipe:
+ post:
+ summary: dropPipe
+ description: dropPipe
+ operationId: dropPipe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/DropPipeRequest'
+ responses:
+ "200":
+ description: ExecutionStatus
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ExecutionStatus'
+
+components:
+ schemas:
+ CreatePipeRequest:
+ title: CreatePipeRequest
+ type: object
+ properties:
+ timestamps:
+ type: array
+ items:
+ type: integer
+ format: int64
+ measurements:
+ type: array
+ items:
+ type: string
+ dataTypes:
+ type: array
+ items:
+ type: string
+ values:
+ type: array
+ items:
+ type: array
+ items:
+ type: object
+ isAligned:
+ type: boolean
+ deviceId:
+ type: string
+
+ AlterPipeRequest:
+ title: AlterPipeRequest
+ type: object
+ properties:
+ timestamps:
+ type: array
+ items:
+ type: integer
+ format: int64
+ measurements:
+ type: array
+ items:
+ type: string
+ dataTypes:
+ type: array
+ items:
+ type: string
+ values:
+ type: array
+ items:
+ type: array
+ items:
+ type: object
+ isAligned:
+ type: boolean
+ deviceId:
+ type: string
+
+ StartPipeRequest:
+ title: StartPipeRequest
+ type: object
+ properties:
+ timestamps:
+ type: array
+ items:
+ type: integer
+ format: int64
+ measurements:
+ type: array
+ items:
+ type: string
+ dataTypes:
+ type: array
+ items:
+ type: string
+ values:
+ type: array
+ items:
+ type: array
+ items:
+ type: object
+ isAligned:
+ type: boolean
+ deviceId:
+ type: string
+
+ StopPipeRequest:
+ title: StopPipeRequest
+ type: object
+ properties:
+ timestamps:
+ type: array
+ items:
+ type: integer
+ format: int64
+ measurements:
+ type: array
+ items:
+ type: string
+ dataTypes:
+ type: array
+ items:
+ type: string
+ values:
+ type: array
+ items:
+ type: array
+ items:
+ type: object
+ isAligned:
+ type: boolean
+ deviceId:
+ type: string
+
+ DropPipeRequest:
+ title: DropPipeRequest
+ type: object
+ properties:
+ timestamps:
+ type: array
+ items:
+ type: integer
+ format: int64
+ measurements:
+ type: array
+ items:
+ type: string
+ dataTypes:
+ type: array
+ items:
+ type: string
+ values:
+ type: array
+ items:
+ type: array
+ items:
+ type: object
+ isAligned:
+ type: boolean
+ deviceId:
+ type: string
+
+ ExecutionStatus:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ message:
+ type: string
+
+ securitySchemes:
+ basic:
+ type: http
+ scheme: basic
+ APIKey:
+ type: apiKey
+ name: API Key
+ in: header
diff --git a/iotdb-collector/pom.xml b/iotdb-collector/pom.xml
new file mode 100644
index 00000000000..261314f254e
--- /dev/null
+++ b/iotdb-collector/pom.xml
@@ -0,0 +1,42 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>iotdb-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>iotdb-collector</artifactId>
+ <packaging>pom</packaging>
+ <name>IoTDB: Collector</name>
+ <modules>
+ <module>collector-openapi</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.iotdb</groupId>
+ <artifactId>node-commons</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/pom.xml b/pom.xml
index e278d579b44..5dc5480caef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@
<modules>
<module>iotdb-api</module>
<module>iotdb-client</module>
+ <module>iotdb-collector</module>
<module>iotdb-core</module>
<module>iotdb-protocol</module>
<module>distribution</module>