public class SyncClient extends Object implements SyncClientInterface
| Modifier and Type | Class and Description |
|---|---|
class |
SyncClient.DefaultPrepareCallback |
| Constructor and Description |
|---|
SyncClient(String endpoint,
CredentialsProvider credsProvider,
String instanceName,
ClientConfiguration config,
ResourceManager resourceManager) |
SyncClient(String endpoint,
String accessKeyId,
String accessKeySecret,
String instanceName)
使用指定的TableStore Endpoint和默认配置构造一个新的
SyncClient实例。 |
SyncClient(String endpoint,
String accessKeyId,
String accessKeySecret,
String instanceName,
ClientConfiguration config)
使用指定的TableStore Endpoint和配置构造一个新的
SyncClient实例。 |
SyncClient(String endpoint,
String accessKeyId,
String accessKeySecret,
String instanceName,
ClientConfiguration config,
String stsToken)
使用指定的TableStore Endpoint和默认配置构造一个新的
SyncClient实例。 |
SyncClient(String endpoint,
String accessKeyId,
String accessKeySecret,
String instanceName,
ClientConfiguration config,
String stsToken,
ExecutorService callbackExecutor)
使用指定的TableStore Endpoint和默认配置构造一个新的
SyncClient实例。 |
SyncClient(String endpoint,
String accessKeyId,
String accessKeySecret,
String instanceName,
String stsToken)
使用指定的TableStore Endpoint和默认配置构造一个新的
SyncClient实例。 |
public SyncClient(String endpoint, String accessKeyId, String accessKeySecret, String instanceName)
SyncClient实例。endpoint - TableStore服务的endpoint。accessKeyId - 访问TableStore服务的Access ID。accessKeySecret - 访问TableStore服务的Access Key。instanceName - 访问TableStore服务的实例名称。public SyncClient(String endpoint, String accessKeyId, String accessKeySecret, String instanceName, String stsToken)
SyncClient实例。endpoint - TableStore服务的endpoint。accessKeyId - 访问TableStore服务的Access ID。accessKeySecret - 访问TableStore服务的Access Key。instanceName - 访问TableStore服务的实例名称。stsToken - Sts Token.public SyncClient(String endpoint, String accessKeyId, String accessKeySecret, String instanceName, ClientConfiguration config)
SyncClient实例。endpoint - TableStore服务的endpoint。accessKeyId - 访问TableStore服务的Access ID。accessKeySecret - 访问TableStore服务的Access Key。instanceName - 访问TableStore服务的实例名称。config - 客户端配置信息(ClientConfiguration)。 如果传入null则使用默认配置。public SyncClient(String endpoint, String accessKeyId, String accessKeySecret, String instanceName, ClientConfiguration config, String stsToken)
SyncClient实例。endpoint - TableStore服务的endpoint。accessKeyId - 访问TableStore服务的Access ID。accessKeySecret - 访问TableStore服务的Access Key。instanceName - 访问TableStore服务的实例名称。config - 客户端配置信息(ClientConfiguration)。 如果传入null则使用默认配置。stsToken - Sts Token.public SyncClient(String endpoint, String accessKeyId, String accessKeySecret, String instanceName, ClientConfiguration config, String stsToken, ExecutorService callbackExecutor)
SyncClient实例。endpoint - TableStore服务的endpoint。accessKeyId - 访问TableStore服务的Access ID。accessKeySecret - 访问TableStore服务的Access Key。instanceName - 访问TableStore服务的实例名称。config - 客户端配置信息(ClientConfiguration)。 如果传入null则使用默认配置。stsToken - Sts Token.callbackExecutor - 执行callback的线程池,需要注意的是,client在shutdown的时候也会shutdown这个线程池。public SyncClient(String endpoint, CredentialsProvider credsProvider, String instanceName, ClientConfiguration config, ResourceManager resourceManager)
public String getEndpoint()
public String getInstanceName()
public CreateTableResponse createTable(CreateTableRequest createTableRequest) throws TableStoreException, ClientException
SyncClientInterface表被创建后不能立即进行读写操作, 需要等待几秒钟.
createTable in interface SyncClientInterfacecreateTableRequest - 执行CreateTable所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public ListTableResponse listTable() throws TableStoreException, ClientException
SyncClientInterfacelistTable in interface SyncClientInterfaceTableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DescribeTableResponse describeTable(DescribeTableRequest request) throws TableStoreException, ClientException
SyncClientInterface获取表的详细信息,表的详细信息包括:
TableMeta)ReservedThroughputDetails)TableOptions)describeTable in interface SyncClientInterfacerequest - 执行DescribeTable所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DeleteTableResponse deleteTable(DeleteTableRequest deleteTableRequest) throws TableStoreException, ClientException
SyncClientInterface注意:表被成功删除后该表下所有的数据都将会被清空,无法恢复,请谨慎操作!
deleteTable in interface SyncClientInterfacedeleteTableRequest - 执行DeleteTable所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public UpdateTableResponse updateTable(UpdateTableRequest request) throws TableStoreException, ClientException
SyncClientInterface例如用户想要调整表的TTL、MaxVersions等配置或者用户发现当前预留吞吐量过小需要上调预留吞吐量。
UpdateTable操作不能用于更改表的TableMeta,可以调整的配置为:
ReservedThroughput):
表的预留吞吐量可被动态更改,读或写吞吐量都可以分别单独更改。调整每个表读写吞吐量的最小时间间隔为 1 分钟,
如果本次 UpdateTable 操作距上次 UpdateTable 或者 CreateTable 操作不到 1 分钟的话该请求将被拒绝。
TableOptions):
只有表的部分配置项可以允许被动态更改,例如TTL、MaxVersions等。
updateTable in interface SyncClientInterfacerequest - 执行UpdateTable所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public CreateIndexResponse createIndex(CreateIndexRequest createIndexRequest) throws TableStoreException, ClientException
SyncClientInterfacecreateIndex in interface SyncClientInterfaceTableStoreException - TableStore服务返回的异常ClientException - 请求返回的结果无效,或遇到网络异常public DeleteIndexResponse deleteIndex(DeleteIndexRequest deleteIndexRequest) throws TableStoreException, ClientException
SyncClientInterface注意:索引表被成功删除后该索引表下所有的数据都将被清空,无法恢复,请谨慎操作!
deleteIndex in interface SyncClientInterfacedeleteIndexRequest - 执行DeleteIndex所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public AddDefinedColumnResponse addDefinedColumn(AddDefinedColumnRequest addDefinedColumnRequest) throws TableStoreException, ClientException
SyncClientInterfaceaddDefinedColumn in interface SyncClientInterfaceaddDefinedColumnRequest - 执行AddDefinedColumn所需的参数^MTableStoreException - TableStore服务返回的异常^MClientException - 请求的返回结果无效、或遇到网络异常^Mpublic DeleteDefinedColumnResponse deleteDefinedColumn(DeleteDefinedColumnRequest deleteDefinedColumnRequest) throws TableStoreException, ClientException
SyncClientInterfacedeleteDefinedColumn in interface SyncClientInterfacedeleteDefinedColumnRequest - 执行DeleteDefinedColumn所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public GetRowResponse getRow(GetRowRequest getRowRequest) throws TableStoreException, ClientException
SyncClientInterfacegetRow in interface SyncClientInterfacegetRowRequest - 执行GetRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public PutRowResponse putRow(PutRowRequest putRowRequest) throws TableStoreException, ClientException
SyncClientInterface若要写入的行已经存在,则旧行会被删除后写入新的一行。
若要写入的行不存在,则直接写入新的一行。
putRow in interface SyncClientInterfaceputRowRequest - 执行PutRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public UpdateRowResponse updateRow(UpdateRowRequest updateRowRequest) throws TableStoreException, ClientException
SyncClientInterface若要更新的行不存在,则新写入一行数据。
更新操作可以包括新写入一个属性列或者删除一个属性列的一个或多个版本。
updateRow in interface SyncClientInterfaceupdateRowRequest - 执行UpdateRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DeleteRowResponse deleteRow(DeleteRowRequest deleteRowRequest) throws TableStoreException, ClientException
SyncClientInterface若该行存在,则删除该行。
若该行不存在,则该操作不产生任何影响。
deleteRow in interface SyncClientInterfacedeleteRowRequest - 执行DeleteRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public BatchGetRowResponse batchGetRow(BatchGetRowRequest batchGetRowRequest) throws TableStoreException, ClientException
SyncClientInterfaceBatchGetRow 操作可视为多个 GetRow 操作的集合,各个操作独立执行,独立返回结果,独立计算服务能力单元。
与执行大量的 GetRow 操作相比,使用 BatchGetRow 操作可以有效减少请求的响应时间,提高数据的读取速率。
但需要注意的是 BatchGetRow 只支持在表级别设置查询条件。操作完成后,需要逐个检查子请求的状态,并选择对失败的行进行重试。
batchGetRow in interface SyncClientInterfacebatchGetRowRequest - 执行BatchGetRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public BatchWriteRowResponse batchWriteRow(BatchWriteRowRequest batchWriteRowRequest) throws TableStoreException, ClientException
SyncClientInterfaceBatchWriteRow 操作可视为多个PutRow、UpdateRow、DeleteRow 操作的集合,各个操作独立执行,独立返回结果,独立计算服务能力单元。
执行 BatchWriteRow 操作后,需要逐个检查子请求的状态,来判断写入结果,并选择对失败的行进行重试。
batchWriteRow in interface SyncClientInterfacebatchWriteRowRequest - 执行BatchWriteRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public BulkImportResponse bulkImport(BulkImportRequest bulkImportRequest) throws TableStoreException, ClientException
SyncClientInterfaceBulkImport 操作可视为多个PutRow、UpdateRow、DeleteRow 操作的集合,各个操作独立执行,独立返回结果,独立计算消费单元。
执行 BulkImport 操作后,需要逐个检查子请求的状态,来判断写入结果,并选择对失败的行进行重试。
bulkImport in interface SyncClientInterfacebulkImportRequest - 执行BatchWriteRow操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public GetRangeResponse getRange(GetRangeRequest getRangeRequest) throws TableStoreException, ClientException
SyncClientInterfacegetRange in interface SyncClientInterfacegetRangeRequest - 执行GetRange操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public BulkExportResponse bulkExport(BulkExportRequest bulkExportRequest) throws TableStoreException, ClientException
SyncClientInterfacebulkExport in interface SyncClientInterfacebulkExportRequest - 执行GetRange操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public ComputeSplitsBySizeResponse computeSplitsBySize(ComputeSplitsBySizeRequest computeSplitsBySizeRequest) throws TableStoreException, ClientException
SyncClientInterfacecomputeSplitsBySize in interface SyncClientInterfacecomputeSplitsBySizeRequest - 执行ComputeSplitsBySize操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public Iterator<Row> createRangeIterator(RangeIteratorParameter rangeIteratorParameter) throws TableStoreException, ClientException
SyncClientInterfaceSyncClientInterface.getRange(GetRangeRequest)接口。createRangeIterator in interface SyncClientInterfacerangeIteratorParameter - 执行createRangeIterator操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public Iterator<Row> createBulkExportIterator(RangeIteratorParameter rangeIteratorParameter) throws TableStoreException, ClientException
createBulkExportIterator in interface SyncClientInterfaceTableStoreExceptionClientExceptionpublic WideColumnIterator createWideColumnIterator(GetRowRequest getRowRequest) throws TableStoreException, ClientException
createWideColumnIterator in interface SyncClientInterfaceTableStoreExceptionClientExceptionpublic ListStreamResponse listStream(ListStreamRequest listStreamRequest) throws TableStoreException, ClientException
SyncClientInterfacelistStream in interface SyncClientInterfacelistStreamRequest - 执行ListStream操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DescribeStreamResponse describeStream(DescribeStreamRequest describeStreamRequest) throws TableStoreException, ClientException
SyncClientInterfacedescribeStream in interface SyncClientInterfacedescribeStreamRequest - 执行DescribeStream操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public GetShardIteratorResponse getShardIterator(GetShardIteratorRequest getShardIteratorRequest) throws TableStoreException, ClientException
SyncClientInterfacegetShardIterator in interface SyncClientInterfacegetShardIteratorRequest - 执行GetShardIterator操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public GetStreamRecordResponse getStreamRecord(GetStreamRecordRequest getStreamRecordRequest) throws TableStoreException, ClientException
SyncClientInterfacegetStreamRecord in interface SyncClientInterfacegetStreamRecordRequest - 执行GetStreamRecord操作所需的参数。TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public CreateSearchIndexResponse createSearchIndex(CreateSearchIndexRequest request) throws TableStoreException, ClientException
SyncClientInterfacecreateSearchIndex in interface SyncClientInterfacerequest - 创建SearchIndex所需的参数,详见CreateSearchIndexRequestTableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public UpdateSearchIndexResponse updateSearchIndex(UpdateSearchIndexRequest request) throws TableStoreException, ClientException
SyncClientInterfaceupdateSearchIndex in interface SyncClientInterfacerequest - 更新SearchIndex所需的参数,详见UpdateSearchIndexRequestTableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public ListSearchIndexResponse listSearchIndex(ListSearchIndexRequest request) throws TableStoreException, ClientException
SyncClientInterface一个table下面,可以存在多个SearchIndex表,通过该函数,将能够获取一个table下面的所有SearchIndex信息
listSearchIndex in interface SyncClientInterfacerequest - 获取SearchIndex列表所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DeleteSearchIndexResponse deleteSearchIndex(DeleteSearchIndexRequest request) throws TableStoreException, ClientException
SyncClientInterface通过指定 tableName 和 indexName 即可删除一个index
提示:在没有删除一个table下面所有的index之前,是不允许删除table的
deleteSearchIndex in interface SyncClientInterfacerequest - 删除SearchIndex所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DescribeSearchIndexResponse describeSearchIndex(DescribeSearchIndexRequest request) throws TableStoreException, ClientException
SyncClientInterfacedescribeSearchIndex in interface SyncClientInterfacerequest - 获取SearchIndex所需的参数(tableName 和 indexName)TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public ComputeSplitsResponse computeSplits(ComputeSplitsRequest request) throws TableStoreException, ClientException
SyncClientInterfacecomputeSplits in interface SyncClientInterfacerequest - Parameters required to perform the computeSplits operation.TableStoreException - Exception returned by Tablestore service.ClientException - The return result of the request is invalid or a network exception was encountered.public ParallelScanResponse parallelScan(ParallelScanRequest request) throws TableStoreException, ClientException
SyncClientInterfaceparallelScan in interface SyncClientInterfacerequest - Parameters required to perform the parallelScan operation.TableStoreException - Exception returned by Tablestore service.ClientException - The return result of the request is invalid or a network exception was encountered.public RowIterator createParallelScanIterator(ParallelScanRequest request) throws TableStoreException, ClientException
SyncClientInterfacecreateParallelScanIterator in interface SyncClientInterfacerequest - Parameters required to perform ParallelScan operation.TableStoreException - Exception returned by Tablestore service.ClientException - The return result of the request is invalid or a network exception was encountered.public RowIterator createSearchIterator(SearchRequest request) throws TableStoreException, ClientException
SyncClientInterfaceNote: If your searchIndex has a nested field and you want to search data, please specify the Sort.
createSearchIterator in interface SyncClientInterfacerequest - Parameters required to perform searchRequest operation.TableStoreException - Exception returned by Tablestore service.ClientException - The return result of the request is invalid or a network exception was encountered.public SearchResponse search(SearchRequest request) throws TableStoreException, ClientException
SyncClientInterface构建自己的SearchRequest,然后获取SearchResponse
示例:
SearchQuery searchQuery = new SearchQuery();
TermQuery termQuery = new TermQuery();
termQuery.setFieldName("user_name");
termQuery.setTerm("jay");
searchQuery.setQuery(termQuery);
SearchRequest searchRequest = new SearchRequest(tableName, indexName, searchQuery);
SearchResponse resp = ots.search(searchRequest);
search in interface SyncClientInterfacerequest - 进行搜索所需的参数,详见SearchRequestSearchResponseTableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public StartLocalTransactionResponse startLocalTransaction(StartLocalTransactionRequest request) throws TableStoreException, ClientException
SyncClientInterfacestartLocalTransaction in interface SyncClientInterfacerequest - 启动本地事务操作所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public CommitTransactionResponse commitTransaction(CommitTransactionRequest request) throws TableStoreException, ClientException
SyncClientInterfacecommitTransaction in interface SyncClientInterfacerequest - 提交事务操作所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public AbortTransactionResponse abortTransaction(AbortTransactionRequest request) throws TableStoreException, ClientException
SyncClientInterfaceabortTransaction in interface SyncClientInterfacerequest - 取消事务操作所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public CreateDeliveryTaskResponse createDeliveryTask(CreateDeliveryTaskRequest request) throws TableStoreException, ClientException
SyncClientInterfacecreateDeliveryTask in interface SyncClientInterfacerequest - 创建投递任务所需的参数TableStoreException - TableStore服务返回的异常ClientException - 请求的返回结果无效、或遇到网络异常public DeleteDeliveryTaskResponse deleteDeliveryTask(DeleteDeliveryTaskRequest request) throws TableStoreException, ClientException
SyncClientInterfacedeleteDeliveryTask in interface SyncClientInterfacerequest - 删除投递任务所需的参数TableStoreException - Tablestore服务返回的异常ClientException - 请求的结果无效、或遇到网络异常public DescribeDeliveryTaskResponse describeDeliveryTask(DescribeDeliveryTaskRequest request) throws TableStoreException, ClientException
SyncClientInterfacedescribeDeliveryTask in interface SyncClientInterfacerequest - 描述投递任务所需的参数TableStoreException - Tablestore服务返回的异常ClientException - 请求的结果无效、或遇到网络异常public ListDeliveryTaskResponse listDeliveryTask(ListDeliveryTaskRequest request) throws TableStoreException, ClientException
SyncClientInterfacelistDeliveryTask in interface SyncClientInterfacerequest - 获取投递任务列表所需参数TableStoreException - Tablestore服务返回的异常ClientException - 请求的结果无效、或遇到网络异常public SQLQueryResponse sqlQuery(SQLQueryRequest request) throws TableStoreException, ClientException
SyncClientInterfacesqlQuery in interface SyncClientInterfacerequest - sql query的参数TableStoreException - Tablestore服务返回的异常ClientException - 请求的结果无效、或遇到网络异常public AsyncClientInterface asAsyncClient()
SyncClientInterfaceasAsyncClient in interface SyncClientInterfacepublic TimeseriesClient asTimeseriesClient()
public AsyncTimeseriesClient asAsyncTimeseriesClient()
public void shutdown()
SyncClientInterface请确保在所有请求执行完毕之后释放资源。释放资源之后将不能再发送请求,正在执行的请求可能无法返回结果。
shutdown in interface SyncClientInterfacepublic void setPrepareCallback(PrepareCallback cb)
public void setCredentials(ServiceCredentials credentials)
public void switchCredentialsProvider(CredentialsProvider newCrdsProvider)
SyncClientInterfaceswitchCredentialsProvider in interface SyncClientInterfacenewCrdsProvider - new CredentialsProvider, see CredentialsProviderFactory.Copyright © 2024. All Rights Reserved.