All Products
Search
Document Center

Lindorm:Initialize a LindormTSDB client

Last Updated:Mar 28, 2026

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

  1. Build a ClientOptions object — specify the endpoint, optional credentials, and tuning parameters.

  2. Call LindormTSDBFactory.connect(options) to create the client.

  3. Use the client for read and write operations.

  4. Call client.shutdown() when done to release resources.

Prerequisites

Before you begin, ensure that you have:

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();
Note 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

ParameterTypeRequiredDefaultDescriptionBuilder method
urlStringYesEndpoint of LindormTSDB.ClientOptions.newBuilder(url)
usernameStringConditionalUsername for LindormTSDB. Required if authentication is enabled. See User and permission management.ClientOptions.Builder#setUsername
passwordStringConditionalPassword for LindormTSDB. Required if authentication is enabled. See User and permission management.ClientOptions.Builder#setPassword
connectTimeoutMsintNo30000Connection timeout in milliseconds.ClientOptions.Builder#setConnectTimeoutMs
requestTimeoutMsintNo30000Request timeout in milliseconds.ClientOptions.Builder#setRequestTimeoutMs

Batch write

ParameterTypeRequiredDefaultDescriptionBuilder method
numBatchThreadsintNo8Number of threads for asynchronous batch write operations.ClientOptions.Builder#setNumBatchThreads
batchSizeintNo500Number of data points per batch sent to the server.ClientOptions.Builder#setBatchSize
maxPointBatchesintNo32Maximum 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
maxWaitTimeMsintNo300Maximum time a batch write request waits in the queue, in milliseconds.ClientOptions.Builder#setMaxWaitTimeMs

Retry

ParameterTypeRequiredDefaultDescriptionBuilder method
maxRetriesintNo3Maximum number of retries for a write request that fails due to an internal server error or network error.ClientOptions.Builder#setMaxRetries
retryBackoffMsintNo1000Wait time before retrying a failed write request, in milliseconds.ClientOptions.Builder#setRetryBackoffMs

Query

ParameterTypeRequiredDefaultDescriptionBuilder method
defaultDatabaseStringNo"default"Default database to connect to. LindormTSDB creates a database named default automatically.ClientOptions.Builder#setDefaultDatabase
queryChunkSizeintNo1000Number of rows returned per batch in a query result.ClientOptions.Builder#setQueryChunkSize

Schema

ParameterTypeRequiredDefaultDescriptionBuilder method
schemaPolicySchemaPolicyNoSTRONGSchema constraint policy. Valid values: STRONG, WEAK, NONE. See Supported schema constraint policies.ClientOptions.Builder#setSchemaPolicy

What's next