场景3:重置某应用运行态所有数据
操作场景
当您应用中的多个逻辑租户均产生很多脏数据,您希望可以一键恢复至应用的初始状态,您可以通过调用“数据清理与重置”的“application-clean-task”接口,自定义“name”参数值删除该应用运行态下的所有数据,重置应用,释放空间。
- 重置应用数据会清除应用运行态上的所有数据,将导致数据不可恢复,请谨慎操作。
- 如果您已将数据模型及其实例数据同步至LinkX-F系统,进行此操作后,将无法在LinkX-F系统进行数据模型及其实例数据的更新。
涉及接口
- 创建并执行重置应用数据任务
URI格式:POST http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/application-clean-task
- 查询任务执行结果
URI格式:GET http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/application-clean-task/{id}
- 重试重置应用数据任务
URI格式:PUT http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/application-clean-task/{id}
其中,{endpoint}表示承载REST服务端点的服务器域名或IP地址,{appID}表示应用ID,{id}表示重置应用数据任务ID。
操作步骤
- 创建并执行重置应用数据任务。
- URI格式:POST http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/application-clean-task
- 参数说明请参见全量数据服务的 。
- 请求示例:
POST https://dme.cn-north-4.huaweicloud.com/rdm_fce01234567d41828cf3473b07fa7ae2_app/services/rdm/basic/api/v1/application-clean-task X-AUTH-TOKEN: ABCDEFJ.... { "name": "ResetTestApp" }
- 响应示例:
{ "result": "SUCCESS", "data": [ { "id": 576800426431614976, "name": "ResetTestApp", "task_status": "AWAIT_START", "tenant_clean_tasks": [ { "id": "576800426490335232", "creator": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "createTime": "2023-12-14T15:58:58.109+0800", "modifier": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "lastUpdateTime": "2023-12-14T15:58:58.109+0800", "rdmVersion": 1, "rdmDeleteFlag": 0, "className": null, "rdmExtensionType": "TenantCleanTask", "hibernateVersion": 1, "tenant": { "id": "-1", "clazz": "Tenant" }, "name": "ResetTestApp", "applicationTaskId": 576800426431614976, "cleanTaskTenantId": -1, "type": "TENANT_RESET", "taskStatus": "ONGOING", "retryTimes": 0, "fileStatus": "AWAIT_START", "ddsStatus": "AWAIT_START", "cssStatus": "AWAIT_START", "rdsStatus": "AWAIT_START", "metadataStatus": "AWAIT_START", "failMessage": null }, { ...... }, ...... ] } ], "errors": [] }
- 记录响应中“data”的“id”,例如“576800426431614976”。
- 查询任务执行结果。
- URI格式:GET http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/tenant-clean-task/{id}
- 参数说明请参见全量数据服务的 。
- 请求示例:
GET https://dme.cn-north-4.huaweicloud.com/rdm_fce01234567d41828cf3473b07fa7ae2_app/services/rdm/basic/api/v1/tenant-clean-task/576800426431614976 X-AUTH-TOKEN: ABCDEFJ....
- 响应示例:
{ "result": "SUCCESS", "data": [ { "id": 576800426431614976, "name": "ResetTestApp", "task_status": "SUCCESS", "tenant_clean_tasks": [ { "id": "576800426490335232", "creator": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "createTime": "2023-12-14T15:58:58.109+0800", "modifier": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "lastUpdateTime": "2023-12-14T15:58:58.109+0800", "rdmVersion": 5, "rdmDeleteFlag": 0, "className": null, "rdmExtensionType": "TenantCleanTask", "hibernateVersion": 8, "tenant": { "id": "-1", "clazz": "Tenant" }, "name": "ResetTestApp", "applicationTaskId": 576800426431614976, "cleanTaskTenantId": -1, "type": "TENANT_RESET", "taskStatus": "SUCCESS", "retryTimes": 0, "fileStatus": "SUCCESS", "ddsStatus": "SUCCESS", "cssStatus": "SUCCESS", "rdsStatus": "SUCCESS", "metadataStatus": "SUCCESS", "failMessage": null }, { ...... }, ...... ] } ], "errors": [] }
- (可选)手动重试重置应用数据任务。
- 如果响应的“taskStatus”为“success”或“fail”,不允许调用重试接口。
- 如果响应的“taskStatus”为“fail_awai_retry”,则表示重置失败,正在等待重试。系统会连续3天在凌晨3点自动重试,如果重试3次后仍重置失败,则任务结束。您也可以通过此步骤手动重试。
- 一个“taskStatus”为“fail_awai_retry”的任务仅支持重试3次。
- URI格式:PUT http://{Endpoint}/rdm_{appID}_app/services/rdm/basic/api/v1/tenant-clean-task/{id}
- 参数说明请参见全量数据服务的 。
- 请求示例:
PUT https://dme.cn-north-4.huaweicloud.com/rdm_fce01234567d41828cf3473b07fa7ae2_app/services/rdm/basic/api/v1/tenant-clean-task/576800426431614976 X-AUTH-TOKEN: ABCDEFJ....
- 响应示例:
{ "result": "SUCCESS", "data": [ { "id": 576800426431614976, "name": "ResetTestApp", "task_status": "SUCCESS", "tenant_clean_tasks": [ { "id": "576800426490335232", "creator": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "createTime": "2023-12-14T15:58:58.109+0800", "modifier": "Tester_HQ 362613cab50d4f42be5749d111111d4f", "lastUpdateTime": "2023-12-14T15:58:58.109+0800", "rdmVersion": 5, "rdmDeleteFlag": 0, "className": null, "rdmExtensionType": "TenantCleanTask", "hibernateVersion": 8, "tenant": { "id": "-1", "clazz": "Tenant" }, "name": "ResetTestApp", "applicationTaskId": 576800426431614976, "cleanTaskTenantId": -1, "type": "TENANT_RESET", "taskStatus": "ONGOING", "retryTimes": 1, "fileStatus": "SUCCESS", "ddsStatus": "SUCCESS", "cssStatus": "SUCCESS", "rdsStatus": "SUCCESS", "metadataStatus": "SUCCESS", "failMessage": null }, { ...... }, ...... ] } ], "errors": [] }