Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Examples

⚠️ The examples depends on the "influxdb3-java" module and this module should be built first by running "mvn install" in the root directory. ⚠️ Some JDK internals must be exposed by adding --add-opens=java.base/java.nio=ALL-UNNAMED to your JVM arguments.

Basic

  • IOxExample - How to use write and query data from InfluxDB IOx

RetryExample

  • RetryExample - How to catch an InfluxDBApiHttpException to then retry making write requests.

Command line run

  • Set environment variables.
export INFLUX_HOST=<INFLUX_CLOUD_HOST_URL>
export INFLUX_TOKEN=<ORGANIZATION_TOKEN>
export INFLUX_DATABASE=<TARGET_DATABASE>
  • Run with maven
mvn compile exec:java -Dexec.main="com.influxdb.v3.RetryExample"
  • Repeat previous step to force an HTTP 429 response and rewrite attempt.

Durable example

This example illustrates one approach to ensuring clients, once initialized, are long-lived and reused.

The underlying write (HTTP/REST) and query (Apache arrow Flight/GRPC) transports are designed to be robust and to be able to recover from most errors. The InfluxDBClient query API is based on GRPC stubs and channels. GRPC best practices recommends reusing them and their resources for the life of an application if at all possible. Unnecessary frequent regeneration of InfluxDBClient instances is wasteful of system resources. Recreating the query transport means fully recreating a GRPC channel, its connection pool and its management API. Fully recreating a client only to use it for a single query also means recreating an unused write transport alongside the query transport. This example attempts to show a more resource friendly use of the API by leveraging already used client instances.

Command line run

  • Set environment variables
export INFLUX_HOST=<INFLUX_HOST_URL>
export INFLUX_TOKEN=<ORGANIZATION_TOKEN>
export INFLUX_DATABASE=<TARGET_DATABASE>
  • Run with maven
MAVEN_OPTS="--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED" mvn compile exec:java -Dexec.main="com.influxdb.v3.durable.DurableExample"