jun0315 commented on a change in pull request #4081: URL: https://github.com/apache/iotdb/pull/4081#discussion_r723940672
########## File path: influxdb-protocol/pom.xml ########## @@ -0,0 +1,127 @@ +<?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>iotdb-parent</artifactId> + <version>0.13.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>influxdb-protocol</artifactId> + <name>InfluxDB Protocol</name> + <description>compatible with the protocol of influxdb.</description> + <properties> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> + </properties> + <dependencies> + <dependency> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-session</artifactId> + <version>0.13.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-thrift</artifactId> + <version>0.13.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.influxdb</groupId> + <artifactId>influxdb-java</artifactId> + <version>2.21</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.antlr</groupId> + <artifactId>antlr4-runtime</artifactId> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <version>LATEST</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.antlr</groupId> + <artifactId>antlr4-maven-plugin</artifactId> + <version>${antlr4.version}</version> + <executions> + <execution> + <configuration> + <listener>false</listener> + <visitor>true</visitor> + </configuration> + <goals> + <goal>antlr4</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.2.0</version> Review comment: This is same with the pom of iotdb-antlr~ ########## File path: influxdb-protocol/src/main/java/org/apache/iotdb/influxdb/IoTDBInfluxDB.java ########## @@ -0,0 +1,432 @@ +/* + * 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.influxdb; + +import org.apache.iotdb.rpc.IoTDBConnectionException; +import org.apache.iotdb.session.Session; + +import org.influxdb.BatchOptions; +import org.influxdb.InfluxDB; +import org.influxdb.dto.BatchPoints; +import org.influxdb.dto.Point; +import org.influxdb.dto.Pong; +import org.influxdb.dto.Query; +import org.influxdb.dto.QueryResult; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class IoTDBInfluxDB implements InfluxDB { + + static final String METHOD_NOT_SUPPORTED = "Method not supported"; + + private static Session session; + + /** + * constructor function + * + * @param url contain host and port + * @param userName username + * @param password user password + */ + public IoTDBInfluxDB(String url, String userName, String password) { + try { + URI uri = new URI(url); + new IoTDBInfluxDB(uri.getHost(), uri.getPort(), userName, password); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } Review comment: Thanks for your review~ If this() is called, it may only be called in this way ```java public IoTDBInfluxDB(String url, String userName, String password) throws URISyntaxException { this(new URI(url).getHost(), new URI(url).getPort(), userName, password); } ``` Because this () can only be called on the first line, there can be no try/catch and URI generation. I think throwing mistakes may not be a good choice? ########## File path: influxdb-protocol/src/main/java/org/apache/iotdb/influxdb/IoTDBInfluxDB.java ########## @@ -0,0 +1,432 @@ +/* + * 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.influxdb; + +import org.apache.iotdb.rpc.IoTDBConnectionException; +import org.apache.iotdb.session.Session; + +import org.influxdb.BatchOptions; +import org.influxdb.InfluxDB; +import org.influxdb.dto.BatchPoints; +import org.influxdb.dto.Point; +import org.influxdb.dto.Pong; +import org.influxdb.dto.Query; +import org.influxdb.dto.QueryResult; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +public class IoTDBInfluxDB implements InfluxDB { + + static final String METHOD_NOT_SUPPORTED = "Method not supported"; + + private static Session session; + + /** + * constructor function + * + * @param url contain host and port + * @param userName username + * @param password user password + */ + public IoTDBInfluxDB(String url, String userName, String password) { + try { + URI uri = new URI(url); + new IoTDBInfluxDB(uri.getHost(), uri.getPort(), userName, password); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } Review comment: Thanks for your review~ If this() is called, it may only be called in this way ```java public IoTDBInfluxDB(String url, String userName, String password) throws URISyntaxException { this(new URI(url).getHost(), new URI(url).getPort(), userName, password); } ``` Because this () can only be called on the first line, there can be no try/catch and URI generation. I think throwing exception may not be a good choice? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
