Class ClientConfig


  • public final class ClientConfig
    extends Object
    The ClientConfig holds the configurations for the InfluxDBClient client.

    You can configure following properties:

    • host - hostname or IP address of the InfluxDB server
    • token - authentication token for accessing the InfluxDB server
    • organization - organization to be used for operations
    • database - database to be used for InfluxDB operations
    • writePrecision - precision to use when writing points to InfluxDB
    • gzipThreshold - threshold when gzip compression is used for writing points to InfluxDB
    • responseTimeout - timeout when connecting to InfluxDB
    • allowHttpRedirects - allow redirects for InfluxDB connections
    • disableServerCertificateValidation - disable server certificate validation for HTTPS connections
    • proxy - HTTP proxy selector
    • authenticator - HTTP proxy authenticator
    • headers - set of HTTP headers to be added to requests

    If you want to create a client with custom configuration, you can use following code:

     ClientConfig config = new Config.Builder()
         .host("https://us-east-1-1.aws.cloud2.influxdata.com")
         .token("my-token".toCharArray())
         .database("my-database")
         .writePrecision(WritePrecision.S)
         .gzipThreshold(4096)
         .proxy(ProxySelector.of(new InetSocketAddress("http://proxy.local", 8888)))
         .build();
    
     try (InfluxDBClient client = InfluxDBClient.getInstance(config)) {
         //
         // your code here
         //
     } catch (Exception e) {
         throw new RuntimeException(e);
     }
     
    Immutable class.
    • Method Detail

      • getHost

        @Nonnull
        public String getHost()
        Gets URL of the InfluxDB server.
        Returns:
        URL of the InfluxDB server
      • getToken

        @Nullable
        public char[] getToken()
        Gets authentication token for accessing the InfluxDB server.
        Returns:
        authentication token for accessing the InfluxDB server, may be null
      • getOrganization

        @Nullable
        public String getOrganization()
        Gets organization to be used for operations.
        Returns:
        organization to be used for operations, may be null
      • getDatabase

        @Nullable
        public String getDatabase()
        Gets database to be used for InfluxDB operations.
        Returns:
        database to be used for InfluxDB operations, may be null
      • getWritePrecision

        @Nullable
        public WritePrecision getWritePrecision()
        Gets the default precision to use for the timestamp of points.
        Returns:
        the default precision to use for the timestamp of points, may be null
      • getGzipThreshold

        @Nonnull
        public Integer getGzipThreshold()
        Gets the threshold for compressing request body using GZIP.
        Returns:
        the threshold in bytes
      • getTimeout

        @Nonnull
        public Duration getTimeout()
        Gets the default timeout to use for the API calls. Default to '10 seconds'.
        Returns:
        the default timeout to use for the API calls
      • getAllowHttpRedirects

        @Nonnull
        public Boolean getAllowHttpRedirects()
        Gets the automatically following HTTP 3xx redirects. Default to 'false'.
        Returns:
        the automatically following HTTP 3xx redirects
      • getDisableServerCertificateValidation

        @Nonnull
        public Boolean getDisableServerCertificateValidation()
        Gets the disable server SSL certificate validation. Default to 'false'.
        Returns:
        the disable server SSL certificate validation
      • getProxy

        @Nullable
        public ProxySelector getProxy()
        Gets the proxy.
        Returns:
        the proxy, may be null
      • getAuthenticator

        @Nullable
        public Authenticator getAuthenticator()
        Gets the (proxy) authenticator.
        Returns:
        the (proxy) authenticator
      • getHeaders

        @Nullable
        public Map<String,​String> getHeaders()
        Gets custom HTTP headers.
        Returns:
        the HTTP headers
      • validate

        public void validate()
        Validates the configuration properties.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object