Kafka实例开始分区平衡任务
功能介绍
该接口用于向Kafka实例提交分区平衡任务,若成功则返回分区平衡任务的job id。
URI
POST /v2/{project_id}/kafka/instances/{instance_id}/reassign
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID,获取方式请参见获取项目ID。 |
|
instance_id |
是 |
String |
实例ID。 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
reassignments |
是 |
Array of PartitionReassignEntity objects |
分区平衡分配方案。 |
|
throttle |
否 |
Integer |
分区平衡门限值。 |
|
is_schedule |
否 |
Boolean |
是否作为定时任务执行。若非定时执行,is_schedule和execute_at字段可为空。若为定时执行,is_schedule为true,execute_at字段非空。 |
|
execute_at |
否 |
Long |
定时时间,格式为Unix时间戳,单位为毫秒 |
|
time_estimate |
否 |
Boolean |
设为true表示执行时间预估任务,false为执行分区平衡任务。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
topic |
是 |
String |
Topic名称 |
|
brokers |
否 |
Array of integers |
分区平衡到的broker列表,自动生成分配方案时需指定该参数。 |
|
replication_factor |
否 |
Integer |
副本因子,自动生成分配方案时可指定。 |
|
assignment |
否 |
Array of TopicAssignment objects |
手动指定的分配方案。brokers参数与该参数不能同时为空。 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
job_id |
String |
任务ID(当执行分区平衡任务时仅返回job_id)。 |
|
reassignment_time |
Integer |
预估时间,单位为秒(当执行预估时间任务时仅返回reassignment_time)。 |
请求示例
POST https://{endpoint}/v2/kafka/{project_id}/instances/{instance_id}/reassign
{
"reassignments" : [ {
"topic" : "topic-1513476102",
"brokers" : [ 0, 1, 2 ],
"replication_factor" : 3,
"assignment" : [ {
"partition" : 0,
"partition_brokers" : [ 0, 1, 2 ]
}, {
"partition" : 1,
"partition_brokers" : [ 1, 2, 0 ]
}, {
"partition" : 2,
"partition_brokers" : [ 2, 0, 1 ]
} ]
}, {
"topic" : "topic-1513558717",
"brokers" : [ 0, 1, 4 ],
"replication_factor" : 3,
"assignment" : [ {
"partition" : 0,
"partition_brokers" : [ 0, 1, 2 ]
}, {
"partition" : 1,
"partition_brokers" : [ 1, 2, 0 ]
}, {
"partition" : 2,
"partition_brokers" : [ 2, 0, 1 ]
} ]
} ],
"throttle" : 10000000,
"time_estimate" : false
}
响应示例
状态码:200
提交分区平衡任务成功(若为预估时间任务则返回预估时间)。
{
"job_id" : "8a2c259182ab0e9d0182ab1882560009",
"reassignment_time" : 10
}
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
提交分区平衡任务成功(若为预估时间任务则返回预估时间)。 |
错误码
请参见错误码。