Skip to content

6.12.0

Compare
Choose a tag to compare
@bednar bednar released this 15 Dec 08:33
· 150 commits to master since this release

Features

  1. #643: ConnectionClosingInterceptor interceptor closes connections that exceed
    a specified maximum lifetime age (TTL). It's beneficial for scenarios where your application requires establishing new connections to the same host after
    a predetermined interval.

The connection to the InfluxDB Enterprise with the ConnectionClosingInterceptor can be configured as follows:

package example;

import java.time.Duration;
import java.util.Collections;

import okhttp3.OkHttpClient;
import okhttp3.Protocol;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.InfluxDBClientOptions;
import com.influxdb.client.domain.WriteConsistency;
import com.influxdb.rest.ConnectionClosingInterceptor;

public class InfluxQLExample {

    public static void main(final String[] args) throws InterruptedException {

        //
        // Credentials to connect to InfluxDB Enterprise
        //
        String url = "https://localhost:8086";
        String username = "admin";
        String password = "password";
        String database = "database";
        WriteConsistency consistency = WriteConsistency.ALL;

        //
        // Configure underlying HTTP client
        //
        OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
                .protocols(Collections.singletonList(Protocol.HTTP_1_1));

        //
        // Use new Connection TTL feature
        //
        Duration connectionMaxAge = Duration.ofMinutes(1);
        ConnectionClosingInterceptor interceptor = new ConnectionClosingInterceptor(connectionMaxAge);
        okHttpClientBuilder
                .addNetworkInterceptor(interceptor)
                .eventListenerFactory(call -> interceptor);

        //
        // Configure InfluxDB client
        //
        InfluxDBClientOptions.Builder optionsBuilder = InfluxDBClientOptions.builder()
                .url(url)
                .org("-")
                .authenticateToken(String.format("%s:%s", username, password).toCharArray())
                .bucket(String.format("%s/%s", database, ""))
                .consistency(consistency)
                .okHttpClient(okHttpClientBuilder);

        //
        // Create client and write data
        //
        try (InfluxDBClient client = InfluxDBClientFactory.create(optionsBuilder.build())) {

            // ...
        }
    }
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy