查询转储任务详情
功能介绍
查询转储任务详情。
调用方法
请参见如何调用API。
URI
GET /v2/{project_id}/streams/{stream_name}/transfer-tasks/{task_name}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID。 |
stream_name |
是 |
String |
已创建的通道的名称。 |
task_name |
是 |
String |
待删除的转储任务名称。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
stream_name |
String |
该转储任务所属通道名称。 |
task_name |
String |
转储任务名称。 |
state |
String |
转储任务状态。
|
destination_type |
String |
转储任务类型。
|
create_time |
Long |
转储任务创建时间。 |
last_transfer_timestamp |
Long |
转储任务最近一次转储时间。 |
partitions |
Array of PartitionResult objects |
分区转储详情列表。 |
obs_destination_description |
转储目的地为OBS的参数列表。 |
参数 |
参数类型 |
描述 |
---|---|---|
status |
String |
分区的当前状态。
|
partition_id |
String |
分区的唯一标识符。 |
hash_range |
String |
分区的可能哈希键值范围。 |
sequence_number_range |
String |
分区的序列号范围。 |
parent_partitions |
String |
父分区。 |
参数 |
参数类型 |
描述 |
---|---|---|
task_name |
String |
转储任务的名称。 任务名称由英文字母、数字、中划线和下划线组成。长度为1~64个字符。 |
agency_name |
String |
在统一身份认证服务(IAM)中创建委托的名称,DIS需要获取IAM委托信息去访问您指定的资源。创建委托的参数设置如下:- 委托类型:云服务- 云服务:DIS- 持续时间:永久- “所属区域”为“全局服务”,“项目”为“对象存储服务”对应的“策略”包含“Tenant Administrator”。如果已经创建过委托,可以使用IAM服务提供的查询委托列表接口,获取有效可用的委托名称。取值范围:长度不超过64位,且不可配置为空。如果有在Console控制台使用转储任务,会提示自动创建委托,自动创建的委托名称为:dis_admin_agency |
deliver_time_interval |
Integer |
根据用户配置的时间,周期性的将数据导入OBS,若某个时间段内无数据,则此时间段不会生成打包文件。 单位:秒 |
deliver_size_interval |
Integer |
转储文件大小,用户定义本地缓存达到的大小阈值来触发一次转储。取值范围:1到300。 单位:MB |
consumer_strategy |
String |
偏移量。
|
file_prefix |
String |
在OBS中存储通道文件的自定义目录,多级目录可用“/”进行分隔,不可以“/”开头。 取值范围:英文字母、数字、下划线和斜杠,最大长度为50个字符。 默认配置为空。 |
partition_format |
String |
将转储文件的生成时间使用“yyyy/MM/dd/HH/mm”格式生成分区字符串,用来定义写到OBS的Object文件所在的目录层次结构。- N/A:置空,不使用日期时间目录。- yyyy:年- yyyy/MM:年/- yyyy/MM/dd:年/月/日- yyyy/MM/dd/HH:年/月/日/时- yyyy/MM/dd/HH/mm:年/月/日/时/分例如:2017/11/10/14/49,目录结构就是“2017 > 11 > 10 > 14 > 49”,“2017”表示最外层文件夹。默认值:空说明:数据转储成功后,存储的目录结构为“obs_bucket_path/file_prefix/partition_format”。 |
obs_bucket_path |
String |
存储该通道数据的OBS桶名称。由英文小写字母、数字、中划线、下划线和点组成。长度为3~63个字符。 |
destination_file_type |
String |
转储文件格式。
说明: “源数据类型”为“JSON”,“转储服务类型”为“OBS”时才可选择“parquet”格式。 |
processing_schema |
ProcessingSchema object |
根据源数据的时间戳和已配置的"partition_format"生成对应的转储时间目录。将源数据的时间戳使用“yyyy/MM/dd/HH/mm”格式生成分区字符串,用来定义写到OBS的Object文件所在的目录层次结构。 |
record_delimiter |
String |
转储文件的记录分隔符,用于分隔写入转储文件的用户数据。 取值范围:
|
请求示例
查询转储任务详情
GET https://{Endpoint}/v2/{project_id}/streams/{stream_name}/transfer-tasks/{task_name}
响应示例
状态码:200
正常返回
{
"stream_id" : "RdMFID6edQdf8eDzc9e",
"stream_name" : "newstream",
"task_name" : "newtask",
"task_id" : "As805BudhcH1lDs6gbn",
"destination_type" : "OBS",
"state" : "RUNNING",
"create_time" : 1606554932552,
"last_transfer_timestamp" : 1606984428612,
"obs_destination_description" : {
"agency_name" : "dis_admin_agency",
"file_prefix\"" : "",
"partition_format" : "yyyy/MM/dd",
"obs_bucket_path" : "obsbucket",
"deliver_time_interval" : 60,
"consumer_strategy" : "LATEST",
"retry_duration" : 0,
"destination_file_type" : "text",
"record_delimiter" : "\n\n"
},
"partitions" : [ {
"partitionId" : "shardId-0000000000",
"discard" : 0,
"state" : "RUNNING",
"last_transfer_timestamp" : 1606984428612,
"last_transfer_offset" : 289897
} ]
}
SDK代码示例
SDK代码示例如下。
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dis.v2.region.DisRegion;
import com.huaweicloud.sdk.dis.v2.*;
import com.huaweicloud.sdk.dis.v2.model.*;
public class ShowTransferTaskSolution {
public static void main(String[] args) {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
String projectId = "{project_id}";
ICredential auth = new BasicCredentials()
.withProjectId(projectId)
.withAk(ak)
.withSk(sk);
DisClient client = DisClient.newBuilder()
.withCredential(auth)
.withRegion(DisRegion.valueOf("<YOUR REGION>"))
.build();
ShowTransferTaskRequest request = new ShowTransferTaskRequest();
request.withStreamName("{stream_name}");
request.withTaskName("{task_name}");
try {
ShowTransferTaskResponse response = client.showTransferTask(request);
System.out.println(response.toString());
} catch (ConnectionException e) {
e.printStackTrace();
} catch (RequestTimeoutException e) {
e.printStackTrace();
} catch (ServiceResponseException e) {
e.printStackTrace();
System.out.println(e.getHttpStatusCode());
System.out.println(e.getRequestId());
System.out.println(e.getErrorCode());
System.out.println(e.getErrorMsg());
}
}
}
|
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdis.v2.region.dis_region import DisRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdis.v2 import *
if __name__ == "__main__":
# The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
# In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak = os.environ["CLOUD_SDK_AK"]
sk = os.environ["CLOUD_SDK_SK"]
projectId = "{project_id}"
credentials = BasicCredentials(ak, sk, projectId)
client = DisClient.new_builder() \
.with_credentials(credentials) \
.with_region(DisRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = ShowTransferTaskRequest()
request.stream_name = "{stream_name}"
request.task_name = "{task_name}"
response = client.show_transfer_task(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
dis "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dis/v2/region"
)
func main() {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak := os.Getenv("CLOUD_SDK_AK")
sk := os.Getenv("CLOUD_SDK_SK")
projectId := "{project_id}"
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
WithProjectId(projectId).
Build()
client := dis.NewDisClient(
dis.DisClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.ShowTransferTaskRequest{}
request.StreamName = "{stream_name}"
request.TaskName = "{task_name}"
response, err := client.ShowTransferTask(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
正常返回 |
错误码
请参见错误码。