@NotThreadSafe public static class InfluxDBClientOptions.Builder extends Object
InfluxDBClientOptions
.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
InfluxDBClientOptions.Builder |
addDefaultTag(String key,
String expression)
Add default tag that will be use for writes by Point and POJO.
|
InfluxDBClientOptions.Builder |
authenticate(String username,
char[] password)
Setup authorization by
InfluxDBClientOptions.AuthScheme.SESSION . |
InfluxDBClientOptions.Builder |
authenticateToken(char[] token)
Setup authorization by
InfluxDBClientOptions.AuthScheme.TOKEN . |
InfluxDBClientOptions.Builder |
bucket(String bucket)
Specify the default destination bucket for writes.
|
InfluxDBClientOptions |
build()
Build an instance of InfluxDBClientOptions.
|
InfluxDBClientOptions.Builder |
clientType(String clientType)
Set the
clientType to customize the User-Agent HTTP header. |
InfluxDBClientOptions.Builder |
connectionString(String connectionString)
Configure Builder via connection string.
|
InfluxDBClientOptions.Builder |
consistency(WriteConsistency consistency)
Specify the write consistency for the point.
|
InfluxDBClientOptions.Builder |
loadProperties()
Configure Builder via
influx2.properties . |
InfluxDBClientOptions.Builder |
logLevel(LogLevel logLevel)
Set the log level for the request and response information.
|
InfluxDBClientOptions.Builder |
okHttpClient(okhttp3.OkHttpClient.Builder okHttpClient)
Set the HTTP client to use for communication with InfluxDB.
|
InfluxDBClientOptions.Builder |
org(String org)
Specify the default destination organization for writes and queries.
|
InfluxDBClientOptions.Builder |
precision(WritePrecision precision)
Specify the default precision for unix timestamps in the line protocol.
|
InfluxDBClientOptions.Builder |
url(String url)
Set the url to connect to InfluxDB.
|
@Nonnull public InfluxDBClientOptions.Builder url(@Nonnull String url)
The url could be a connection string with various configurations. For more info
see: connectionString(String)
.
url
- the url to connect to InfluxDB (required). Example: http://localhost:8086?readTimeout=5000this
@Nonnull public InfluxDBClientOptions.Builder clientType(@Nonnull String clientType)
clientType
to customize the User-Agent HTTP header.
If the clientType
is set to "awesome-service" the User-Agent header will be:
influxdb-client-awesome-service/6.2.0
.
clientType
- the client type to report as a part of User-Agent to remote serverthis
@Nonnull public InfluxDBClientOptions.Builder okHttpClient(@Nonnull okhttp3.OkHttpClient.Builder okHttpClient)
okHttpClient
- the HTTP client to use.this
@Nonnull public InfluxDBClientOptions.Builder logLevel(@Nonnull LogLevel logLevel)
logLevel
- The log level for the request and response information.this
@Nonnull public InfluxDBClientOptions.Builder authenticate(@Nonnull String username, @Nonnull char[] password)
InfluxDBClientOptions.AuthScheme.SESSION
.
The username/password auth is based on
HTTP "Basic" authentication. The authorization expires when the
time-to-live (TTL) (default 60 minutes) is reached
and client produces UnauthorizedException
.
username
- the username to use in the basic authpassword
- the password to use in the basic auththis
@Nonnull public InfluxDBClientOptions.Builder authenticateToken(char[] token)
InfluxDBClientOptions.AuthScheme.TOKEN
.token
- the token to use for the authorizationthis
@Nonnull public InfluxDBClientOptions.Builder org(@Nullable String org)
org
- the default destination organization for writes and queriesthis
@Nonnull public InfluxDBClientOptions.Builder bucket(@Nullable String bucket)
bucket
- default destination bucket for writesthis
@Nonnull public InfluxDBClientOptions.Builder precision(@Nullable WritePrecision precision)
precision
- default precision for unix timestamps in the line protocolthis
@Nonnull public InfluxDBClientOptions.Builder consistency(@Nullable WriteConsistency consistency)
InfluxDB assumes that the write consistency is WriteConsistency.ONE
if you do not specify consistency.
See the InfluxDB Enterprise documentation for
detailed descriptions of each consistency option.
Available with InfluxDB Enterprise clusters only!
consistency
- The write consistency for the point.this
@Nonnull public InfluxDBClientOptions.Builder addDefaultTag(@Nonnull String key, @Nullable String expression)
The expressions can be:
key
- the tag nameexpression
- the tag value expression@Nonnull public InfluxDBClientOptions.Builder connectionString(@Nonnull String connectionString)
org
- default destination organization for writes and queriesbucket
- default destination bucket for writestoken
- the token to use for the authorizationlogLevel
- rest client verbosity levelreadTimeout
- read timeoutwriteTimeout
- write timeoutconnectTimeout
- socket timeoutprecision
- default precision for unix timestamps in the line protocolconsistency
- specify the write consistency for the pointclientType
- to customize the User-Agent HTTP headerConnection string example:
http://localhost:8086?readTimeout=30000&token=my-token&bucket=my-bucket&org=my-org
this
@Nonnull public InfluxDBClientOptions.Builder loadProperties()
influx2.properties
.this
@Nonnull public InfluxDBClientOptions build()
InfluxDBClientOptions
Copyright © 2018–2022 InfluxData, Inc.. All rights reserved.