You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/12/02 09:38:20 UTC

[GitHub] [camel] shengzhou1216 opened a new pull request, #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

shengzhou1216 opened a new pull request, #8824:
URL: https://github.com/apache/camel/pull/8824

   <!-- Uncomment and fill this section if your PR is not trivial
   - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   Add camel-influxdb2 component,support for influxdb2.x .


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on a diff in pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
davsclaus commented on code in PR #8824:
URL: https://github.com/apache/camel/pull/8824#discussion_r1038752153


##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Constants.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import org.apache.camel.spi.Metadata;
+
+public final class InfluxDb2Constants {
+
+    @Metadata(description = "The name of measurement", javaType = "String")
+    public static final String MEASUREMENT = "camelInfluxDB.MeasurementName";
+    @Metadata(description = "The string that defines the retention policy to the data created by the endpoint",
+              javaType = "String")
+    public static final String RETENTION_POLICY = "camelInfluxDB.RetentionPolicy";
+    @Metadata(description = "The name of the database where the time series will be stored", javaType = "String")
+    public static final String ORG = "camelInfluxDB.org";

Review Comment:
   Should ORG and BUCKET not have @Metadata also



##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java:
##########
@@ -0,0 +1,228 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+import com.influxdb.client.BucketsQuery;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.OrganizationsQuery;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.exceptions.NotFoundException;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.influxdb2.enums.Operation;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interact with <a href="https://influxdata.com/time-series-platform/influxdb/">InfluxDB</a>, a time series database.
+ */
+@UriEndpoint(firstVersion = "3.19.0", scheme = "influxdb2", title = "Influxdb2",

Review Comment:
   title = "InfluxDB2"



##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Constants.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import org.apache.camel.spi.Metadata;
+
+public final class InfluxDb2Constants {
+
+    @Metadata(description = "The name of measurement", javaType = "String")
+    public static final String MEASUREMENT = "camelInfluxDB.MeasurementName";

Review Comment:
   Header Keys should be without DOT in Camel. This may be wrong on the v1 component.
   
   Should be like this:
   CamelInfluxDB2MeasurementName



##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java:
##########
@@ -0,0 +1,228 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+import com.influxdb.client.BucketsQuery;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.OrganizationsQuery;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.exceptions.NotFoundException;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.influxdb2.enums.Operation;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interact with <a href="https://influxdata.com/time-series-platform/influxdb/">InfluxDB</a>, a time series database.
+ */
+@UriEndpoint(firstVersion = "3.19.0", scheme = "influxdb2", title = "Influxdb2",
+             syntax = "influxdb2:connectionBean?org=<org name>&bucket=<bucket name>", category = { Category.DATABASE },
+             producerOnly = true, headersClass = InfluxDb2Constants.class)
+public class InfluxDb2Endpoint extends DefaultEndpoint {
+    private static final Logger LOG = LoggerFactory.getLogger(InfluxDb2Endpoint.class);
+
+    private InfluxDBClient influxDBClient;
+
+    @UriPath
+    @Metadata(required = true, description = "connectionBean")

Review Comment:
   The description are to simple, they are for humans. So please improve these. Also should start with Upper case letter.



##########
components/camel-influxdb2/src/test/resources/log4j2.properties:
##########
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.out.type = Console

Review Comment:
   Should log to file, see other components



##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java:
##########
@@ -0,0 +1,228 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+import com.influxdb.client.BucketsQuery;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.OrganizationsQuery;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.exceptions.NotFoundException;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.influxdb2.enums.Operation;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interact with <a href="https://influxdata.com/time-series-platform/influxdb/">InfluxDB</a>, a time series database.
+ */
+@UriEndpoint(firstVersion = "3.19.0", scheme = "influxdb2", title = "Influxdb2",
+             syntax = "influxdb2:connectionBean?org=<org name>&bucket=<bucket name>", category = { Category.DATABASE },
+             producerOnly = true, headersClass = InfluxDb2Constants.class)
+public class InfluxDb2Endpoint extends DefaultEndpoint {
+    private static final Logger LOG = LoggerFactory.getLogger(InfluxDb2Endpoint.class);
+
+    private InfluxDBClient influxDBClient;
+
+    @UriPath
+    @Metadata(required = true, description = "connectionBean")
+    private String connectionBean;
+    @UriParam
+    @Metadata(required = true, description = "organization name")
+    private String org;
+    @UriParam
+    @Metadata(required = true, description = "bucket name")
+    private String bucket;
+    @UriParam(defaultValue = "default", description = "retention policy")
+    private String retentionPolicy = "default";
+
+    @UriParam(defaultValue = "INSERT", description = "operations")
+    private Operation operation = Operation.INSERT;
+    @UriParam(defaultValue = "true", description = "auto create organization")
+    private boolean autoCreateOrg = true;
+
+    @UriParam(defaultValue = "true", description = "auto create bucket")
+    private boolean autoCreateBucket = true;
+
+    @UriParam(defaultValue = "ms", description = "influxdb2 write precision")
+    private WritePrecision writePrecision = WritePrecision.MS;
+    private String orgID;
+
+    public InfluxDb2Endpoint(String uri, InfluxDb2Component component) {
+        super(uri, component);
+    }
+
+    public InfluxDb2Endpoint() {
+    }
+
+    public InfluxDBClient getInfluxDBClient() {
+        return influxDBClient;
+    }
+
+    public void setInfluxDBClient(InfluxDBClient influxDBClient) {
+        this.influxDBClient = influxDBClient;
+    }
+
+    public String getConnectionBean() {
+        return connectionBean;
+    }
+
+    public void setConnectionBean(String connectionBean) {
+        this.connectionBean = connectionBean;
+    }
+
+    public String getOrg() {
+        return org;
+    }
+
+    public void setOrg(String org) {
+        this.org = org;
+    }
+
+    public String getBucket() {
+        return bucket;
+    }
+
+    public void setBucket(String bucket) {
+        this.bucket = bucket;
+    }
+
+    public String getRetentionPolicy() {
+        return retentionPolicy;
+    }
+
+    public void setRetentionPolicy(String retentionPolicy) {
+        this.retentionPolicy = retentionPolicy;
+    }
+
+    public Operation getOperation() {
+        return operation;
+    }
+
+    public void setOperation(Operation operation) {
+        this.operation = operation;
+    }
+
+    public boolean isAutoCreateOrg() {
+        return autoCreateOrg;
+    }
+
+    public void setAutoCreateOrg(boolean autoCreateOrg) {
+        this.autoCreateOrg = autoCreateOrg;
+    }
+
+    public boolean isAutoCreateBucket() {
+        return autoCreateBucket;
+    }
+
+    public void setAutoCreateBucket(boolean autoCreateBucket) {
+        this.autoCreateBucket = autoCreateBucket;
+    }
+
+    public String getOrgID() {
+        return orgID;
+    }
+
+    public void setOrgID(String orgID) {
+        this.orgID = orgID;
+    }
+
+    public WritePrecision getWritePrecision() {
+        return writePrecision;
+    }
+
+    public void setWritePrecision(WritePrecision writePrecision) {
+        this.writePrecision = writePrecision;
+    }
+
+    public Producer createProducer() throws Exception {
+        return new InfluxDb2Producer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
+    }
+
+    @Override
+    protected void doInit() throws Exception {
+        super.doInit();
+        ensureOrgExists();
+        ensureBucketExists();
+    }
+
+    public ExecutorService createExecutor() {
+        // TODO: Delete me when you implemented your custom component

Review Comment:
   TODO is here, this need to be resolved



##########
components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java:
##########
@@ -0,0 +1,228 @@
+/*
+ * 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.camel.component.influxdb2;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+import com.influxdb.client.BucketsQuery;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.OrganizationsQuery;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.exceptions.NotFoundException;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.influxdb2.enums.Operation;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interact with <a href="https://influxdata.com/time-series-platform/influxdb/">InfluxDB</a>, a time series database.
+ */
+@UriEndpoint(firstVersion = "3.19.0", scheme = "influxdb2", title = "Influxdb2",

Review Comment:
   3.20.0



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] shengzhou1216 commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
shengzhou1216 commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1336604222

   Okay, i will trying to fix it. Is there any document for reference?


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] shengzhou1216 commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
shengzhou1216 commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1335163552

   The existing camle-influxdb only support influxdb 1.x . More info can be found here: https://github.com/influxdata/influxdb-java


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1334989162

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :warning: Please note that the changes on this PR may be **tested automatically**. 
   
   If necessary Apache Camel Committers may access logs and test results in the job summaries!


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
davsclaus commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1335148941

   There is already a camel-influxdb. What is the difference between this and yours?


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
davsclaus commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1335186435

   Okay thanks, so lets make this more clear in the component docs for these


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] github-actions[bot] commented on pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8824:
URL: https://github.com/apache/camel/pull/8824#issuecomment-1336902812

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 4 | 4 | 0 | 4 |


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel] davsclaus merged pull request #8824: [Component] Add camel-influxdb2 component,support for influxdb2.x .

Posted by GitBox <gi...@apache.org>.
davsclaus merged PR #8824:
URL: https://github.com/apache/camel/pull/8824


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org