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/03 09:02:36 UTC

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

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