This is an automated email from the ASF dual-hosted git repository. rong pushed a commit to branch remove-sync-entry in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 956df57556c51548f36dff811ae60731093b4c9e Author: Steve Yurong Su <[email protected]> AuthorDate: Sat Jun 17 01:10:09 2023 +0800 remove example/ext-pipe-plugin-example/ --- example/ext-pipe-plugin-example/README.md | 60 -------- example/ext-pipe-plugin-example/pom.xml | 65 -------- .../iotdb/extpipe/ExtPipeSinkWriterFactory.java | 139 ----------------- .../iotdb/extpipe/ExtPipeSinkWriterImpl.java | 164 --------------------- ...ipe.external.api.IExternalPipeSinkWriterFactory | 1 - example/pom.xml | 1 - 6 files changed, 430 deletions(-) diff --git a/example/ext-pipe-plugin-example/README.md b/example/ext-pipe-plugin-example/README.md deleted file mode 100644 index b24d0b8fc3f..00000000000 --- a/example/ext-pipe-plugin-example/README.md +++ /dev/null @@ -1,60 +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. - ---> - -# How to develop 1 ext-pipe plugin? - -## 1. Create 1 new java project, add below maven dependency. - -```xml -<dependencies> - <dependency> - <artifactId>external-pipe-api</artifactId> - <groupId>org.apache.iotdb</groupId> - <version>1.0.0</version> - </dependency> -</dependencies> -``` - -## 2. Develop 2 class to implement below 2 java Interface. - -```java -IExternalPipeSinkWriterFactory -IExternalPipeSinkWriter -``` - -**Note:** Please refer to example codes in **example/ext-pipe-plugin-example** . - - -## 3. build project and get plugin's xxx.jar file - -```shell -xxx-jar-with-dependencies.jar -``` - - -## 4. install plugin's xxx.jar file to IoTDB - -```shell -mkdir -p ext/extPipe -cp xxx-jar-with-dependencies.jar ext/extPipe -nohup ./A/sbin/start-server.sh >/dev/null 2>&1 -``` - diff --git a/example/ext-pipe-plugin-example/pom.xml b/example/ext-pipe-plugin-example/pom.xml deleted file mode 100644 index c2a425aa144..00000000000 --- a/example/ext-pipe-plugin-example/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?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> - <artifactId>iotdb-examples</artifactId> - <groupId>org.apache.iotdb</groupId> - <version>1.3.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>ext-pipe-plugin-example</artifactId> - <name>IoTDB-Ext-Pipe Example</name> - <properties> - <maven.compiler.source>8</maven.compiler.source> - <maven.compiler.target>8</maven.compiler.target> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.iotdb</groupId> - <artifactId>external-pipe-api</artifactId> - <version>1.3.0-SNAPSHOT</version> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> - <executions> - <execution> - <goals> - <goal>single</goal> - </goals> - <phase>prepare-package</phase> - </execution> - </executions> - <groupId>org.apache.maven.plugins</groupId> - <version>3.1.0</version> - </plugin> - </plugins> - </build> -</project> diff --git a/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterFactory.java b/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterFactory.java deleted file mode 100644 index 0e0a8830ee6..00000000000 --- a/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterFactory.java +++ /dev/null @@ -1,139 +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.extpipe; - -import org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriter; -import org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriterFactory; - -import java.util.Map; - -// == Command Format: -// 1) CREATE PIPESINK ${extSinkName} AS ${extSinkType} ( ${parameters} ) -// 2) CREATE PIPE ${pipeName} TO ${extSinkName} -// -// == Command Example: -// CREATE PIPESINK mySink1 AS mySink (address='http://129.168.1.1/abc', user='admin', -// passwd='admin123', project='project1', table='table1', thread_num='5', batch_size='1000'); -// CREATE PIPE pipe2mySink TO mySink1; -// -// == About Parameters in Command: Below 4 parameter keys are reserved and used by IotDB, -// thread_num : the number of IExternalPipeSinkWriter, default value 1. -// batch_size : the number of operations to get from pipe source each time for 1 thread, default -// value 100_000. -// attempt_times : the number of attempt times when 1 operation fails, default value 3. -// retry_interval : waiting interval(ms) before retry when operation fail, default value 1_000. -// == Other parameters keys can be customer-defined and used by ext-pipe plugin. -// such as address, user, project, table etc. - -public class ExtPipeSinkWriterFactory implements IExternalPipeSinkWriterFactory { - - private static final String PARAM_ADDRESS = "address"; - private static final String PARAM_USER = "user"; - private static final String PARAM_PASSWD = "passwd"; - private static final String PARAM_PROJECT = "project"; - private static final String PARAM_TABLE = "table"; - - private Map<String, String> sinkParams; - - /** - * Return the provider info of current exe-pipe plugin. In current IoTDB, this information is not - * important. - * - * @return - */ - @Override - public String getProviderName() { - return "Company_ABC"; - } - - /** - * Get the External PIPE's type name. For example: If customer self-defined getExternalPipeType() - * return "mySink", corresponding input CMD should be "CREATE PIPESINK mySink1 AS mySink (...)". - * Otherwise, the CMD will be refused. * - * - * @return External PIPE s type name - */ - @Override - public String getExternalPipeType() { - return "mySink"; - } - - /** - * This method is used to validate the parameters in client CMD. For example: When customer input - * CMD: "CREATE PIPESINK mySink1 AS mySink (p1='111', p2='abc')", The parameters (p1=111, p2=abc) - * will be saved in sinkParams and then send it to validateSinkParams(sinkParams) for validation. - * If validateSinkParams() does not return Exception, the CMD will be processed. Otherwise, the - * CMD will be refused with prompt info that is from Exception.getMessage(); - * - * @param sinkParams Contains the parameters in CMD "CREATE PIPESINK ..." - * @return true means successful - * @throws Exception - */ - @Override - public void validateSinkParams(Map<String, String> sinkParams) throws Exception { - // == Check whether mandatory parameters are enough - if (!sinkParams.containsKey(PARAM_ADDRESS)) { - throw new Exception("Need attribute: " + PARAM_ADDRESS); - } else if (!sinkParams.containsKey(PARAM_USER)) { - throw new Exception("Need attribute: " + PARAM_USER); - } else if (!sinkParams.containsKey(PARAM_PASSWD)) { - throw new Exception("Need attribute: " + PARAM_PASSWD); - } else if (!sinkParams.containsKey(PARAM_PROJECT)) { - throw new Exception("Need attribute: " + PARAM_PROJECT); - } else if (!sinkParams.containsKey(PARAM_TABLE)) { - throw new Exception("Need attribute: " + PARAM_TABLE); - } - - // == Here, you may add other checking. Such as, checking whether remote address can be accessed - // etc. - // ... - } - - /** - * After IoTDB create IExternalPipeSinkWriterFactory instance, IoTDB will call this method to let - * IExternalPipeSinkWriterFactory finish some init work. - * - * @param sinkParams Contains the parameters in CMD "CREATE PIPESINK ..." - */ - @Override - public void initialize(Map<String, String> sinkParams) throws Exception { - this.sinkParams = sinkParams; - - try { - // == If need, may check input parameters again. - validateSinkParams(sinkParams); - // == Here, do init work of IExternalPipeSinkWriterFactory instance. - // ... - } catch (Exception e) { - // LOGGER.error("Failed to init extPipeSink ..." , e); - throw e; - } - } - - /** - * Get 1 IExternalPipeSinkWriter instance who will occupy 1 thread to run. - * - * @return - */ - @Override - public IExternalPipeSinkWriter get() { - return new ExtPipeSinkWriterImpl(sinkParams); - } -} diff --git a/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterImpl.java b/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterImpl.java deleted file mode 100644 index 4780a45387a..00000000000 --- a/example/ext-pipe-plugin-example/src/main/java/org/apache/iotdb/extpipe/ExtPipeSinkWriterImpl.java +++ /dev/null @@ -1,164 +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.extpipe; - -import org.apache.iotdb.pipe.external.api.ExternalPipeSinkWriterStatus; -import org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriter; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class ExtPipeSinkWriterImpl implements IExternalPipeSinkWriter { - private Map<String, String> sinkParams; - // private ExtSession extSession; //maintain the connect to ext DB system - private long startTime; - - public ExtPipeSinkWriterImpl(Map<String, String> sinkParams) { - this.sinkParams = sinkParams; - } - - /** IoTDB call this method to initialize 1 IExternalPipeSinkWriter instance. */ - @Override - public void open() { - // == Use the parameters in sinkParams to start 1 session to ext DB system - // extSession = new ExtSession(sinkParams); - - // == Record the start-time of current external session. - startTime = System.currentTimeMillis(); - } - - @Override - public void insertBoolean(String sgName, String[] path, long timestamp, boolean value) - throws IOException { - // == Here, handle inserted Boolean type data from IoTDB. - // extSession.insertBoolean(...); - // ... - } - - @Override - public void insertInt32(String sgName, String[] path, long timestamp, int value) - throws IOException { - // == Here, handle inserted Int32 type data from IoTDB. - // extSession.insertInt32(...); - // ... - } - - @Override - public void insertInt64(String sgName, String[] path, long time, long value) throws IOException { - // == Here, handle inserted Int64 type data from IoTDB. - // ... - } - - @Override - public void insertFloat(String sgName, String[] path, long time, float value) throws IOException { - // == Here, handle inserted float type data from IoTDB. - // extSession.insertFloat(...); - // ... - } - - @Override - public void insertDouble(String sgName, String[] path, long time, double value) - throws IOException { - // == Here, handle inserted double type data from IoTDB. - // extSession.insertDouble(...); - // ... - } - - @Override - public void insertText(String sgName, String[] path, long time, String value) throws IOException { - // == Here, handle inserted Text type data from IoTDB. - // extSession.insertText(...); - // .. - } - - @Override - public void delete(String sgName, String delPath, long startTime, long endTime) - throws IOException { - - // == Here, handle delete operation. - // extSession.delete(...); - // ... - } - - // @Override - // public void createTimeSeries(String[] path, DataType dataType) { - // //== Here, handle create TimeSeries operation. - // //extSession.createTable(...); - // //... - // } - // - // @Override - // public void deleteTimeSeries(String[] path) { - // //== Here, handle delete TimeSeries operation. - // //extSession.deleteTable(...); - // //... - // } - - /** - * IoTDB call this method to flush data in plugin buf to external DB system, if data buf exist. - * - * @throws IOException - */ - @Override - public void flush() throws IOException { - // extSession.flush(...); - // ... - } - - /** - * When run CMD "stop pipe ..." or "drop pipe ..." , IoTDB will call this method to close - * connection to external DB system. - * - * @throws IOException - */ - @Override - public void close() throws IOException { - flush(); - - // == Close connection to external DB system. - // extSession.close(...); - } - - /** - * /** IoTDB use this method to collect statistic info of 1 ExternalPipeSinkWriter. When run CMD - * "show pipes", the statistic information will be show. - * - * @return - */ - @Override - public ExternalPipeSinkWriterStatus getStatus() { - ExternalPipeSinkWriterStatus status = new ExternalPipeSinkWriterStatus(); - - // == set basic statistic info - status.setStartTime(startTime); // ExternalPipeSinkWriter's beginning time - // status.setNumOfRecordsTransmitted(extSession.getNumOffRecords()); - // status.setNumOfBytesTransmitted(extSession.getNumOfBytes()); - - // == Here, customer may define & add other information. - Map<String, String> extendedFields = new HashMap<>(); - // extendedFields.put("AverageSpeed", Long.toString(extSession.getAvgSpeed()); - // extendedFields.put("Speed", Long.toString(extSession.getSpeed())); - // extendedFields.put("SessionId", extSession == null ? "N/A" : extSession.getId()); - status.setExtendedFields(extendedFields); - - return status; - } -} diff --git a/example/ext-pipe-plugin-example/src/main/resources/META-INF/services/org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriterFactory b/example/ext-pipe-plugin-example/src/main/resources/META-INF/services/org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriterFactory deleted file mode 100644 index 264bd012783..00000000000 --- a/example/ext-pipe-plugin-example/src/main/resources/META-INF/services/org.apache.iotdb.pipe.external.api.IExternalPipeSinkWriterFactory +++ /dev/null @@ -1 +0,0 @@ -org.apache.iotdb.extpipe.ExtPipeSinkWriterFactory \ No newline at end of file diff --git a/example/pom.xml b/example/pom.xml index f16beff4476..1256cd0ee89 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -48,7 +48,6 @@ <module>trigger</module> <module>rabbitmq</module> <module>rest-java-example</module> - <module>ext-pipe-plugin-example</module> </modules> <build> <pluginManagement>
