触发Compaction
Request
POST /api/compaction/run?tablet_id={int}&compact_type={enum} POST /api/compaction/run?table_id={int}&compact_type=full 注意,table_id=xxx只有在compact_type=full时指定才会生效。 GET /api/compaction/run_status?tablet_id={int}
Description
用于手动触发 Compaction 以及状态查询。
Query parameters
-
tablet_id -
tablet的id
-
table_id -
table的id。注意,table_id=xxx只有在compact_type=full时指定才会生效,并且tablet_id和table_id只能指定一个,不能够同时指定,指定table_id后会自动对此table下所有tablet执行full_compaction。
-
compact_type -
取值为
base或cumulative或full。full_compaction的使用场景请参考数据恢复。
Request body
无
Response
触发Compaction
若 tablet 不存在,返回 JSON 格式的错误:
1. {
2. "status": "Fail",
3. "msg": "Tablet not found"
4. }
若 compaction 执行任务触发失败时,返回 JSON 格式的错误:
1. {
2. "status": "Fail",
3. "msg": "fail to execute compaction, error = -2000"
4. }
若 compaction 执行触发成功时,则返回 JSON 格式的结果:
1. {
2. "status": "Success",
3. "msg": "compaction task is successfully triggered."
4. }
结果说明:
- status:触发任务状态,当成功触发时为Success;当因某些原因(比如,没有获取到合适的版本)时,返回Fail。
- msg:给出具体的成功或失败的信息。
查询状态
若 tablet 不存在,返回 JSON 格式:
1. {
2. "status": "Fail",
3. "msg": "Tablet not found"
4. }
若 tablet 存在并且 tablet 不在正在执行 compaction,返回 JSON 格式:
1. {
2. "status" : "Success",
3. "run_status" : false,
4. "msg" : "this tablet_id is not running",
5. "tablet_id" : 11308,
6. "schema_hash" : 700967178,
7. "compact_type" : ""
8. }
若 tablet 存在并且 tablet 正在执行 compaction,返回 JSON 格式:
1. {
2. "status" : "Success",
3. "run_status" : true,
4. "msg" : "this tablet_id is running",
5. "tablet_id" : 11308,
6. "schema_hash" : 700967178,
7. "compact_type" : "cumulative"
8. }
结果说明:
- run_status:获取当前手动 compaction 任务执行状态
Examples
1. curl -X POST "http://127.0.0.1:8040/api/compaction/run?tablet_id=10015&compact_type=cumulative"
