This topic describes the types and details of TSDBConfig.Builder methods.
Class name: com.aliyun.hitsdb.client.TSDBConfig.Builder
java.lang.Object
com.aliyun.hitsdb.client.TSDBConfig.Builder
Enclosing class :TSDBConfig
publicstaticclassTSDBConfig.BuilderextendsObject
Constructor summary
Constructor
Description
Builder
(String host, int port)
Uses the IP address and port of Time Series Database (TSDB) to create a TSDBConfig.Builder object.Method summary
Method
Description
asyncPut(boolean asyncPut)
Specifies whether to enable asynchronous writes. By default, asynchronous writes are enabled. We recommend that you retain the default value.
batchPutBufferSize(int batchPutBufferSize)
Specifies the length of the buffer queue for a client. By default, the length is 10,000 requests. This method only takes effect when asynchronous writes are enabled.batchPutConsumerThreadCount(int batchPutConsumerThreadCount)
Specifies the number of consumer threads in the buffer queue. By default, the value is 1. This parameter only takes effect when asynchronous writes are enabled.
basicAuth(String tsdbUser, String basicPwd)
Specifies the authentication information.
The authentication information includes the TSDB username and password used for authentication. This method is supported by TSDB SDK V0.2.7 and later. The user authentication feature is supported by TSDB V2.5.13 and later.
batchPutSize(int batchPutSize)
Specifies the number of data points that are submitted at a time to clients. By default, the number is 500. This method only takes effect when asynchronous writes are enabled.
batchPutTimeLimit(int batchPutTimeLimit)
Specifies the timeout period for each asynchronous write. Unit: milliseconds. By default, the timeout period is 300 milliseconds. This method only takes effect when asynchronous writes are enabled.
closePutRequestLimit()
Specifies whether to disable the limit on the number of queues for write requests. We recommend that you enable the limit because out-of-memory (OOM) errors may occur if you disable the limit. This method only takes effect when asynchronous writes are enabled.
config()
Constructs a TSDBConfig object.
deduplicationEnable()
Deduplicates data points in each batch. This method only takes effect when asynchronous writes are enabled. Data points are duplicate if the data points are same in the following aspects:
The metric
The key-value pair of each tag
The fields in the multi-value data model
The timestamp
httpCompress(boolean httpCompress)
Specifies whether to enable HTTP compression.
httpConnectionLiveTime(int httpConnectionLiveTime)
Specifies the duration during which a connection is alive. Unit: seconds. By default, the duration is 0s. The value 0 specifies that this method does not take effect and your connections are persistent connections. For information about how to configure the duration, see the following note for httpConnectionLiveTime.
httpConnectionPool(int connectionPool)
Specifies the size of the HTTP connection pool.
httpConnectTimeout(int httpConnectTimeout)
Specifies the timeout period for each HTTP request. Unit: seconds. By default, the timeout period is 90 seconds.
httpKeepaliveTime(int httpKeepaliveTime)
Specifies the period during which each HTTP persistent connection is alive.
ioThreadCount(int ioThreadCount)
Specifies the number of I/O threads. By default, the number is 1.
listenBatchPut(AbstractBatchPutCallback<?> cb)
Specifies the callback interface for asynchronous batch writes.
maxTPS(int maxTPS)
Specifies the limit on the transactions per second (TPS) for clients. By default, no limit is applied on the TPS for clients.
openHttpCompress()
Enables HTTP compression.
putRequestLimit(int limit)
Specifies the number of queues for write requests. By default, the number is equal to the number of connection pools. This method only takes effect when asynchronous writes are enabled. You can configure the number of queues for asynchronous write requests based on the read/write ratio in your environment.
readonly()
Turns on the read-only switch. If the value true is passed, asynchronous writes are disabled.
readonly(boolean readonly)
Specifies whether to turn on the read-only switch. By default, the read-only switch is turned off. If the value true is passed, asynchronous writes are disabled.
Methods inherited from the java.lang.Object class
The inherited methods include
clone
,equals
,finalize
,getClass
,hashCode
,notify
,notifyAll
,toString
, andwait
.
Constructor details
Builder
public Builder(String host,int port)
Builder
public Builder(TSDBNetAddress... netAddresses)
Method details
putRequestLimit
public TSDBConfig.Builder putRequestLimit(int limit)
batchPutBufferSize
public TSDBConfig.Builder batchPutBufferSize(int batchPutBufferSize)
batchPutConsumerThreadCount
public TSDBConfig.Builder batchPutConsumerThreadCount(int batchPutConsumerThreadCount)
batchPutRetryCount
public TSDBConfig.Builder batchPutRetryCount(int batchPutRetryCount)
batchPutSize
public TSDBConfig.Builder batchPutSize(int batchPutSize)
batchPutTimeLimit
public TSDBConfig.Builder batchPutTimeLimit(int batchPutTimeLimit)
closePutRequestLimit
public TSDBConfig.Builder closePutRequestLimit()
closeBackpressure
public TSDBConfig.Builder closeBackpressure()
deduplicationEnable
public TSDBConfig.Builder deduplicationEnable()
NoteFor multi-value data points, deduplication is accurate to the field. If only one field in a MultiFieldPoint object meets the deduplication rules, the deduplication logic is implemented to deduplicate only the data points of the field.
httpConnectionLiveTime
public TSDBConfig.Builder httpConnectionLiveTime(int httpConnectionLiveTime
NoteThe default value of the httpConnectionLiveTime parameter is 0. The value 0 specifies that all connections are persistent connections. If you use persistent connections in production environments, the performance of servers may deteriorate due to load imbalance. This is because TSDB uses multiple nodes to provide services. If a node is faulty, connections to the node are switched to other nodes. After the node is restored, the connections are not switched back to the node because the connections are persistent connections. In this case, if no new connection requests are initiated from clients, the node cannot provide services. To prevent load imbalance among TSDB nodes, you can configure the httpConnectionLiveTime parameter to reestablish connections between clients and TSDB on a regular basis.
httpKeepaliveTime
public TSDBConfig.Builder httpKeepaliveTime(int httpKeepaliveTime)
readonly
public TSDBConfig.Builder readonly()
readonly
public TSDBConfig.Builder readonly(boolean readonly)
asyncPut
public TSDBConfig.Builder asyncPut(boolean asyncPut)
maxTPS
public TSDBConfig.Builder maxTPS(int maxTPS)
config
public TSDBConfig config()
httpCompress
public TSDBConfig.Builder httpCompress(boolean httpCompress)
httpConnectionPool
public TSDBConfig.Builder httpConnectionPool(int connectionPool)
httpConnectTimeout
public TSDBConfig.Builder httpConnectTimeout(int httpConnectTimeout)
ioThreadCount
public TSDBConfig.Builder ioThreadCount(int ioThreadCount)
listenBatchPut
public TSDBConfig.Builder listenBatchPut(AbstractBatchPutCallback<?> cb)
openHttpCompress
public TSDBConfig.Builder openHttpCompress()
NoteThe default value of the httpConnectionLiveTime parameter is 0. The value 0 specifies that all connections are persistent connections. If you use persistent connections in production environments, the performance of servers may deteriorate due to load imbalance. This is because TSDB uses multiple nodes to provide services. If a node is faulty, connections to the node are switched to other nodes. After the node is restored, the connections are not switched back to the node because the connections are persistent connections. In this case, if no new connection requests are initiated from clients, the node cannot provide services. To prevent load imbalance among TSDB nodes, you can configure the httpConnectionLiveTime parameter to reestablish connections between clients and TSDB on a regular basis.