The OBKV-Table Java client provides a rich set of APIs for accessing OceanBase AI Database. This topic describes how to set and use the parameters for connecting to a cluster with the OBKV-Table Java client.
Parameter description
The parameters are summarized as follows:
Category |
Parameter |
Default value |
Description |
|---|---|---|---|
| Timeout and retry | RUNTIME_MAX_WAIT | 5000ms | The timeout period for a single execution. Failed calls are retried within this period. |
| Timeout and retry | RPC_EXECUTE_TIMEOUT | 3000ms | The socket timeout period for RPC requests. |
| Timeout and retry | RPC_OPERATION_TIMEOUT | 2000ms | The timeout period for internal RPC requests in OceanBase AI Database. |
| Timeout and retry | RUNTIME.RETRY.TIMES | 3 | The number of retries when a retryable error occurs during execution. |
| Timeout and retry | RUNTIME.RETRY.INTERVAL | 100ms | The retry interval when an error occurs during execution. |
| Connection | SERVER.CONNECTION.POOL.SIZE | 10 | The maximum number of connections per server. |
Timeout and retry parameters
Execution-related parameters are among the most fundamental ones to consider, especially the three parameters RUNTIME_MAX_WAIT, RPC_EXECUTE_TIMEOUT, and RPC_OPERATION_TIMEOUT.
Setting principle: RUNTIME_MAX_WAIT > RPC_EXECUTE_TIMEOUT > RPC_OPERATION_TIMEOUT
Specifically:
Parameter |
Default value |
Description |
Best practices |
|---|---|---|---|
| RUNTIME_MAX_WAIT | 5000ms | The maximum timeout period for a single API call from the business application to the OBKV-Table client. Retries are performed for failed calls within this period. | We recommend that you use the default value. Consider increasing the value in the following scenarios:
|
| RPC_EXECUTE_TIMEOUT | 3000ms | The maximum amount of time the client waits after sending an RPC request. | We recommend that you use the default value. Consider increasing the value in the following scenarios:
|
| RPC_OPERATION_TIMEOUT | 2000ms | The maximum execution time of a request on the server side, which also represents the transaction timeout period. | We recommend that you use the default value. Consider increasing the value in the following scenarios:
|
| RUNTIME.RETRY.TIMES | 3 | The number of internal retries performed by the OBKV-Table client when an execution fails. | We recommend that you use the default value. You can adjust it based on your business requirements. |
| RUNTIME.RETRY.INTERVAL | 100ms | The interval between internal retries performed by the OBKV-Table client when an execution fails. | We recommend that you set a larger value to prevent message storms caused by continuous retries after exceptions. |
SERVER parameters
Parameter |
Default value |
Description |
Best practices |
|---|---|---|---|
| SERVER.CONNECTION.POOL.SIZE | 10 | The maximum number of connections per server. The OBKV-Table client creates a connection string with each OBServer node, and this parameter specifies the maximum number of connections in the connection pool. |
|
Parameter setting
Interface
The interface for setting parameters in ObTableClient is as follows:
API |
Description |
|---|---|
void addProperty(String key, String value) |
Sets the value of a single parameter. |
Example
This example uses the addProperty interface to set the value of RPC_OPERATION_TIMEOUT to 1000 milliseconds.
// Assume the current cluster is as follows.
// Cluster name: obkv
// Tenant name: obkv_table
// Database name: obkv_table_db
// Username: test_user
// Password: admin123
// User under the system tenant: test_sys_user
// Password for the user under the system tenant: sys123
// Config URL: http://127.0.0.1:8080/services?Action=ObRootServiceInfo&ObCluster=obkv
String paramURL = "http://127.0.0.1:8080/services?Action=ObRootServiceInfo&ObCluster=obkv&database=obkv_table_db";
ObTableClient obkvHandle = new ObTableClient();
obkvHandle.setParamURL(paramURL);
obkvHandle.setFullUserName("test_user@obkv_table#obkv");
obkvHandle.setPassword("admin123");
obkvHandle.setSysUserName("test_sys_user");
obkvHandle.setSysPassword("sys123");
obkvHandle.addProperty(Property.RPC_OPERATION_TIMEOUT.getKey(), "1000");
obkvHandle.init();
Advanced parameters
In addition to the common parameters above, OBKV-Table supports the following advanced features:
Feature |
Description |
References |
|---|---|---|
| Weak consistency read and near-neighbor read | Supports reading data from follower replicas to reduce leader load and network latency. | For detailed parameter descriptions, see Weak-consistency reads and near reads in OBKV-Table. |