All Products
Search
Document Center

TSDBConfig

Last Updated: Aug 25, 2021

You can use TSDBConfig to configure all settings of a Time Series Database (TSDB) client. You can use the config() method to build a TSDBConfig object. For more information about how to use TSDBConfig to configure a TSDB client, see the following sample code.

Sample code

TSDBConfig config =TSDBConfig
// Configure the endpoint of the TSDB client. example.tsdb.com specifies the domain or the IP address of the TSDB client. 8242 specifies the port used by the TSDB client. 
.address("example.tsdb.com",8242)
// tsdbuser and password specify the username and the password used for user authentication. You can create a user for a TSDB instance on the instance details page in the TSDB console. If user authentication is disabled for the TSDB instance, you do not need to call the basicAuth() method when you create a TSDBConfig object. 
.basicAuth("tsdbuser","password")

// Specify whether the TSDBConfig object is read-only. By default, the value is false. If you set the value to true, asynchronous writes are not allowed. 
.readonly(false)

// Configure the size of the connection pool. By default, the value is 64. 
.httpConnectionPool(64)

// Configure the time-out period for an HTTP connection. Unit: seconds. By default, the value is 90. 
.httpConnectTimeout(90)

// Configure the duration during which an HTTP connection is alive. Unit: seconds. By default, the value is 0. The value 0 specifies that this method does not take effect and your connections are persistent connections. We recommend that you configure a proper value. In this case, after a server recovers from a failure, the TSDB client connects to the server again. This enables server load balancing. 
.httpConnectionLiveTime(0)

// Configure the number of I/O threads. By default, the value is 1. 
.ioThreadCount(1)

// Specify whether to enable asynchronous writes. By default, the value is true. We recommend that you retain the default value. 
.asyncPut(true)

// Configure the size of the buffer. By default, the value is 10000. This parameter takes effect only when asynchronous writes are allowed. 
.batchPutBufferSize(20000)

// Configure the number of consumer threads in the buffer. By default, the value is 1. This parameter takes effect only when asynchronous writes are allowed. 
.batchPutConsumerThreadCount(2)

// Configure the number of data points to be submitted to the TSDB client. By default, the value is 500. This parameter takes effect only when asynchronous writes are allowed. 
.batchPutSize(500)

// Configure the maximum waiting time. Unit: milliseconds. By default, the value is 300. This parameter takes effect only when asynchronous writes are allowed. 
.batchPutTimeLimit(300)

// Configure the number of write request queues. By default, the value is equal to the number of connection pools. This parameter takes effect only when asynchronous writes are allowed. You can configure this parameter based on the read/write ratio. 
.putRequestLimit(100)

// Specify whether to lift the limit on the number of write request queues. We recommend that you impose the limit because out-of-memory (OOM) errors can occur if you lift the limit. This parameter takes effect only when asynchronous writes are allowed. 
.closePutRequestLimit()

// Use the callback interface for asynchronous PUT requests. This parameter takes effect only when asynchronous writes are allowed. 
.listenBatchPut(newBatchPutCallback(){
// The following callback function is invoked if a write operation is successful.
@Override
publicvoid response(List<Point> input,Result output){;;}
// The following callback function is invoked if a write operation fails.
@Override
publicvoid failed(String address,List<Point> input,Exception ex){;;}
})

// Configure the maximum number of data points to be submitted per second. This parameter is used to configure traffic throttling. 
.maxTPS(50000)

.config();// Build a TSDBConfig object.