LindormTSDBClient is a Java client for reading from and writing to LindormTSDB. Before sending read or write requests with LindormTSDB SDK for Java, create and configure a LindormTSDBClient instance.
How it works
Build a
ClientOptionsobject — specify the endpoint, optional credentials, and tuning parameters.Call
LindormTSDBFactory.connect(options)to create the client.Use the client for read and write operations.
Call
client.shutdown()when done to release resources.
Prerequisites
Before you begin, ensure that you have:
A LindormTSDB endpoint. To get the endpoint, see View endpoints.
(If authentication is enabled) A username and password for LindormTSDB. See User and permission management.
Create a LindormTSDBClient instance
The following example shows the full set of ClientOptions parameters. Only url is required — all other parameters are optional.
// Endpoint of LindormTSDB
String url = "http://ld-bp1489gr5t*****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242";
// Credentials — required only if authentication is enabled
String username = "username";
String password = "password";
// Default database to connect to
String db = "default";
ClientOptions options = ClientOptions
.newBuilder(url) // Required
.setUsername(username) // Required if authentication is enabled
.setPassword(password) // Required if authentication is enabled
.setNumBatchThreads(8) // Optional. Default: 8
.setMaxRetries(3) // Optional. Default: 3
.setRetryBackoffMs(1000) // Optional. Default: 1000 ms
.setRequestTimeoutMs(30000) // Optional. Default: 30000 ms
.setConnectTimeoutMs(30000) // Optional. Default: 30000 ms
.setMaxWaitTimeMs(300) // Optional. Default: 300 ms
.setBatchSize(500) // Optional. Default: 500
.setMaxPointBatches(32) // Optional. Default: 32
.setDefaultDatabase(db) // Optional. Default: "default"
.setQueryChunkSize(1000) // Optional. Default: 1000
.setSchemaPolicy(SchemaPolicy.WEAK) // Optional. Default: STRONG
.build();
LindormTSDBClient client = LindormTSDBFactory.connect(options);
// ... perform read and write operations ...
client.shutdown();LindormTSDBClient is thread-safe. Reuse a single instance across threads — there is no need to create or destroy the client repeatedly.Configure ClientOptions
ClientOptions is the configuration class for LindormTSDBClient. The following tables describe each parameter, grouped by function.
Connection
| Parameter | Type | Required | Default | Description | Builder method |
|---|---|---|---|---|---|
url | String | Yes | — | Endpoint of LindormTSDB. | ClientOptions.newBuilder(url) |
username | String | Conditional | — | Username for LindormTSDB. Required if authentication is enabled. See User and permission management. | ClientOptions.Builder#setUsername |
password | String | Conditional | — | Password for LindormTSDB. Required if authentication is enabled. See User and permission management. | ClientOptions.Builder#setPassword |
connectTimeoutMs | int | No | 30000 | Connection timeout in milliseconds. | ClientOptions.Builder#setConnectTimeoutMs |
requestTimeoutMs | int | No | 30000 | Request timeout in milliseconds. | ClientOptions.Builder#setRequestTimeoutMs |
Batch write
| Parameter | Type | Required | Default | Description | Builder method |
|---|---|---|---|---|---|
numBatchThreads | int | No | 8 | Number of threads for asynchronous batch write operations. | ClientOptions.Builder#setNumBatchThreads |
batchSize | int | No | 500 | Number of data points per batch sent to the server. | ClientOptions.Builder#setBatchSize |
maxPointBatches | int | No | 32 | Maximum number of batches in the queue. The queue holds up to maxPointBatches × batchSize data points. Write operations block when the queue is full. | ClientOptions.Builder#setMaxPointBatches |
maxWaitTimeMs | int | No | 300 | Maximum time a batch write request waits in the queue, in milliseconds. | ClientOptions.Builder#setMaxWaitTimeMs |
Retry
| Parameter | Type | Required | Default | Description | Builder method |
|---|---|---|---|---|---|
maxRetries | int | No | 3 | Maximum number of retries for a write request that fails due to an internal server error or network error. | ClientOptions.Builder#setMaxRetries |
retryBackoffMs | int | No | 1000 | Wait time before retrying a failed write request, in milliseconds. | ClientOptions.Builder#setRetryBackoffMs |
Query
| Parameter | Type | Required | Default | Description | Builder method |
|---|---|---|---|---|---|
defaultDatabase | String | No | "default" | Default database to connect to. LindormTSDB creates a database named default automatically. | ClientOptions.Builder#setDefaultDatabase |
queryChunkSize | int | No | 1000 | Number of rows returned per batch in a query result. | ClientOptions.Builder#setQueryChunkSize |
Schema
| Parameter | Type | Required | Default | Description | Builder method |
|---|---|---|---|---|---|
schemaPolicy | SchemaPolicy | No | STRONG | Schema constraint policy. Valid values: STRONG, WEAK, NONE. See Supported schema constraint policies. | ClientOptions.Builder#setSchemaPolicy |