Là một dự án mã nguồn mở, influxdata/influxdb-java đã đạt 1.2k sao trên GitHub, ngôn ngữ Java. Java client for InfluxDB
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This is the official (and community-maintained) Java client library for InfluxDB (1.x), the open source time series database that is part of the TICK (Telegraf, InfluxDB, Chronograf, Kapacitor) stack.
For InfluxDB 3.0 users, this library is succeeded by the lightweight v3 client library.
Note: This library is for use with InfluxDB 1.x and 2.x compatibility API. For full supports of InfluxDB 2.x features, please use the influxdb-client-java client.
Adding the library to your project
The library artifact is published in Maven central, available at https://search.maven.org/artifact/org.influxdb/influxdb-java.
Influx Query Language (InfluxQL), with support for bind parameters (similar to JDBC PreparedStatement parameters);
it's own QueryBuilder, as you would do with e.g. EclipseLink or Hibernate;
Message Pack (requires InfluxDB 1.4+);
Writing data using:
Data Point (an object provided by this library that represents a ... data point);
Your own POJO (you need to add a few Java Annotations);
InfluxDB line protocol (for the braves only);
UDP, as supported by InfluxDB;
Support synchronous and asynchronous writes;
Batch support configurable with jitter interval, buffer size and flush interval.
Quick start
// Create an object to handle the communication with InfluxDB.
// (best practice tip: reuse the 'influxDB' instance when possible)
final String serverURL = "http://127.0.0.1:8086", username = "root", password = "root";
final InfluxDB influxDB = InfluxDBFactory.connect(serverURL, username, password);
// Create a database...
// https://docs.influxdata.com/influxdb/v1.7/query_language/database_management/
String databaseName = "NOAA_water_database";
influxDB.query(new Query("CREATE DATABASE " + databaseName));
influxDB.setDatabase(databaseName);
// ... and a retention policy, if necessary.
// https://docs.influxdata.com/influxdb/v1.7/query_language/database_management/
String retentionPolicyName = "one_day_only";
influxDB.query(new Query("CREATE RETENTION POLICY " + retentionPolicyName
+ " ON " + databaseName + " DURATION 1d REPLICATION 1 DEFAULT"));
influxDB.setRetentionPolicy(retentionPolicyName);
// Enable batch writes to get better performance.
influxDB.enableBatch(
BatchOptions.DEFAULTS
.threadFactory(runnable -> {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
})
);
// Close it if your application is terminating or you are not using it anymore.
Runtime.getRuntime().addShutdownHook(new Thread(influxDB::close));
// Write points to InfluxDB.
influxDB.write(Point.measurement("h2o_feet")
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag("location", "santa_monica")
.addField("level description", "below 3 feet")
.addField("water_level", 2.064d)
.build());
influxDB.write(Point.measurement("h2o_feet")
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag("location", "coyote_creek")
.addField("level description", "between 6 and 9 feet")
.addField("water_level", 8.12d)
.build());
// Wait a few seconds in order to let the InfluxDB client
// write your points asynchronously (note: you can adjust the
// internal time interval if you need via 'enableBatch' call).
Thread.sleep(5_000L);
// Query your data using InfluxQL.
// https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#the-basic-select-statement
QueryResult queryResult = influxDB.query(new Query("SELECT * FROM h2o_feet"));
System.out.println(queryResult);
// It will print something like:
// QueryResult [results=[Result [series=[Series [name=h2o_feet, tags=null,
// columns=[time, level description, location, water_level],
// values=[
// [2020-03-22T20:50:12.929Z, below 3 feet, santa_monica, 2.064],
// [2020-03-22T20:50:12.929Z, between 6 and 9 feet, coyote_creek, 8.12]
// ]]], error=null]], error=null]
Contribute
For version change history have a look at ChangeLog.
Build Requirements
Java 1.8+
Maven 3.5+
Docker (for Unit testing)
Then you can build influxdb-java with all tests with:
There is a shell script running InfluxDB and Maven from inside a Docker container and you can execute it by running:
$> ./compile-and-test.sh
Useful links
Manual (main documentation);
InfluxDB Object Mapper;
Query Builder;
FAQ;
Changelog.
License
The MIT License (MIT)
Copyright (c) 2014 Stefan Majer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/influxdata/influxdb-java là nguồn chính thức.
influxdata/influxdb-java có bao nhiêu sao?
influxdata/influxdb-java có 1.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/influxdata/influxdb-java. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
influxdata/influxdb-java có phải mã nguồn mở không?
Có — influxdata/influxdb-java phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/influxdata/influxdb-java.
influxdata/influxdb-java còn đang phát triển không?
Commit gần nhất trên influxdata/influxdb-java là 8 tháng trước (theo timestamp GitHub). Repo có 468 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
influxdata/influxdb-java là gì?
influxdata/influxdb-java (influxdata/influxdb-java) là dự án Java trên GitHub. Theo mô tả gốc: Java client for InfluxDB
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về influxdb-java?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về influxdb-java.