wu-sheng commented on a change in pull request #4239: Provide influxdb as a new 
storage plugin
URL: https://github.com/apache/skywalking/pull/4239#discussion_r376746175
 
 

 ##########
 File path: 
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxClient.java
 ##########
 @@ -0,0 +1,203 @@
+/*
+ * 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.skywalking.oap.server.storage.plugin.influxdb;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.OkHttpClient;
+import org.apache.skywalking.oap.server.core.analysis.Downsampling;
+import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
+import org.apache.skywalking.oap.server.library.client.Client;
+import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+import org.influxdb.InfluxDB;
+import org.influxdb.InfluxDBFactory;
+import org.influxdb.dto.BatchPoints;
+import org.influxdb.dto.Point;
+import org.influxdb.dto.Query;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.time.TimeInterval;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.ti;
+
+/**
+ * InfluxDB connection maintainer, provides base data write/query API.
+ */
+@Slf4j
+public class InfluxClient implements Client {
+    private InfluxStorageConfig config;
+    private InfluxDB influx;
+
+    /**
+     * A constant, the name of time field in Time-series database.
+     */
+    public static final String TIME = "time";
+    /**
+     * A constant, the name of tag.
+     */
+    public static final String TAG_ENTITY_ID = "entity_id";
+
+    private final String database;
+
+    public InfluxClient(InfluxStorageConfig config) {
+        this.config = config;
+        this.database = config.getDatabase();
+    }
+
+    public final String getDatabase() {
+        return database;
+    }
+
+    @Override
+    public void connect() {
+        influx = InfluxDBFactory.connect(config.getUrl(), config.getUser(), 
config.getPassword(),
+            new OkHttpClient.Builder(), InfluxDB.ResponseFormat.MSGPACK);
+        influx.query(new Query("CREATE DATABASE " + database));
+
+        influx.enableBatch(config.getActions(), config.getDuration(), 
TimeUnit.MILLISECONDS);
+        influx.setDatabase(database);
+    }
+
+    /**
+     * To get a connection of InfluxDB.
+     *
+     * @return InfluxDB's connection
+     */
+    public InfluxDB getInflux() {
 
 Review comment:
   I think this should be `private` to avoid misuse

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to