全部产品
数据传输服务DTS

查看迁移任务状态

更新时间:2017-08-18 13:54:04   分享:   

描述

当任务处于任意状态时,都可以调用这个接口查看数据迁移状态。可以查询的迁移状态包括:整个任务的迁移状态,各个迁移阶段(结构迁移、全量数据迁移、增量数据迁移)的迁移状态及进度 以及 预检查的状态。

请求参数

参数名称 数据类型 是否必须 参数描述
Action String 系统必须参数,为这个接口的接口定义,具体取值为:
DescribeMigrationJobStatus
MigrationJobId String 迁移任务ID

返回参数

参数名称 数据类型 参数描述
MigrationJobId String 迁移任务ID`
MigrationJobName String 迁移任务名称
PayType String 付费类型
MigrationJobClass String 迁移实例规格
SourceEndpoint Endpoint 迁移源实例的连接方式
Endpoint的定义参考Endpoint参数定义
DestinationEndpoint Endpoint 迁移目标实例的连接方式
Endpoint的定义参考Endpoint参数定义
MigrationMode MigrationMode 迁移类型
MigrationMode的定义参考MigrationMode参数定义
MigrationObjects List 迁移对象
MigrationJobStatus String 迁移任务状态,取值包括:
NotStarted : 表示未启动
Prechecking : 表示预检查中
PrecheckFailed : 表示预检查失败
Migrating : 表示迁移中
Suspengding : 表示暂停中
MigrationFailed : 表示迁移失败
Finished : 表示完成
PrecheckStatus PrecheckStatus 预检查的状态,包括检查进度及检查状态
PrecheckStatus的定义详见PrecheckStatus的参数定义
StructureInitializationStatus StructureInitializationStatus 结构迁移的状态,包括迁移状态及具体的迁移进度
StructureInitializationStatus的定义详见 StructureInitializationStatus参数定义
DataInitializationStatus DataInitializationStatus 全量数据迁移的状态,包括迁移状态及具体的迁移进度
DataInitializationStatus的定义详见DataInitializationStatus参数定义
DataSynchronizationStatus DataSynchronizationStatus 增量数据迁移的状态,包括迁移状态及具体的迁移进度
DataSynchronizationStatus定义详见DataSynchronizationStatus参数定义

Endpoint 参数定义

参数名称 数据类型 参数描述
InstanceType String 实例类型
Region String 源实例所在地域
InstanceId String 实例ID
EngineName String 数据库类型
IP String 数据库连接地址
Port String 数据库监听端口
UserName String 数据库访问账号
OracleSID String Oracle SID
DatabaseName String 数据库名称

MigrationMode参数定义

参数名称 数据类型 参数描述
StructureInitialization String 是否进行结构迁移
DataInitialization String 是否进行全量数据迁移
DataSynchronization String 是否进行增量数据迁移

PrecheckStatus参数定义

参数名称 数据类型 参数说明
Status String 预检查状态
Percent String 预检查进度,单位为百分比
Detail List 各个预检查项的检查情况
CheckItem的定义详见CheckItem的参数定义

CheckItem的参数定义

参数名称 数据类型 参数说明
ItemName String 检查项名称
CheckStatus String 检查状态,取值包括
NotStarted : 未启动
Checking : 检查中
Failed : 检查失败
Finished : 检查成功
ErrorMessage String 失败原因
RepairMethod String 修复方法

StructureInitializationStatus参数定义

参数名称 数据类型 参数说明
Status String 迁移状态,取值包括:
NotStarted:未启动
Migrating : 迁移中
Failed :迁移失败
Finished: 迁移完成
ErrorMessage String 迁移失败原因
Percent String 迁移进度,单位为百分比
Progress String 已经完成迁移的表数量

DataInitializationStatus参数定义

参数名称 数据类型 参数说明
Status String 迁移状态,取值包括:
NotStarted:未启动
Migrating : 迁移中
Failed :迁移失败
Finished: 迁移完成
ErrorMessage String 迁移失败原因
Percent String 迁移进度,单位为百分比
Progress String 已经完成迁移的表数量

DataSynchronizationStatus参数定义

参数名称 数据类型 参数说明
Status String 迁移状态,取值包括:
NotStarted:未启动
Migrating : 迁移中
Failed :迁移失败
Finished: 迁移完成
ErrorMessage String 迁移失败原因
Percent String 迁移进度,单位为百分比
Delay String 迁移延迟

示例

下面简单演示通过JAVA SDK 查询迁移任务状态的示例:

  1. private static void describeMigrationJobStatus(String MigrationJobId){
  2. DescribeMigrationJobStatusRequest request = new DescribeMigrationJobStatusRequest();
  3. request.setMigrationJobId(MigrationJobId);
  4. try {
  5. DescribeMigrationJobStatusResponse response = client.getAcsResponse(request);
  6. System.out.println("Get Status of Migration Job "+MigrationJobId+" Succeed!");
  7. String JobStatus=response.getMigrationJobStatus();
  8. /*Get the basic information of the migration job*/
  9. System.out.println("MigrationJobName:"+response.getMigrationJobName()
  10. +"MigrationJobId:"+response.getMigrationJobId()
  11. +"MigrationObjects:"+response.getMigrationObject()
  12. +"; MigrationMode.StructureInitialization:" + response.getMigrationMode().getStructureInitialization()
  13. +"; MigrationMode.DataInitialization:"+response.getMigrationMode().getDataInitialization()
  14. +"; MigrationMode.DataSynchronization:"+response.getMigrationMode().getDataSynchronization()
  15. +"; MigrationJobStatus:"+response.getMigrationJobStatus());
  16. /*Get the source endpoint of the migration job*/
  17. System.out.println("SourceEndpoint.InstanceType:"+response.getSourceEndpoint().getInstanceType()
  18. +"; SourceEndpoint.InstanceId:"+response.getSourceEndpoint().getInstanceId()
  19. +"; SourceEndpoint.EngineName:"+response.getSourceEndpoint().getEngineName()
  20. +"; SourceEndpoint.IP:"+response.getSourceEndpoint().getIP()
  21. +"; SourceEndpoint.Port"+response.getSourceEndpoint().getPort()
  22. +"; SourceEndpoint.UserName:"+response.getSourceEndpoint().getUserName()
  23. +"; SourceEndpoint.DatabaseName:"+response.getSourceEndpoint().getDatabaseName()
  24. +"; SourceEndpoint.OracleSID:"+response.getSourceEndpoint().getOracleSID());
  25. /*Get the destination endpoint of the migration job*/
  26. System.out.println("DestinationEnpoint.InstanceType:"+response.getDestinationEndpoint().getInstanceType()
  27. +"DestinationEndpoint.InstanceId:"+response.getDestinationEndpoint().getInstanceId()
  28. +"DestinationEndpint.EngineName:"+response.getDestinationEndpoint().getEngineName()
  29. +"DestinationEndpoint.IP:"+response.getDestinationEndpoint().getIP()
  30. +"DestinationEndpoint:Port:"+response.getDestinationEndpoint().getPort()
  31. +"DestinationEndpoint.UserName:"+response.getDestinationEndpoint().getUserName()
  32. +"DestinationEndpoint.DatabaseName"+response.getDestinationEndpoint().getDatabaseName()
  33. +"DestinationEndpoint.OracleSID:"+response.getDestinationEndpoint().getOracleSID());
  34. /*Get Status of Precheck*/
  35. try {
  36. com.aliyuncs.dts.model.v20160801.DescribeMigrationJobStatusResponse.PrecheckStatus precheckStatus = response.getPrecheckStatus();
  37. System.out.println("Get Precheck Status of Migration Job "+MigrationJobId +" Succeed!");
  38. System.out.println("Precheck Status:"+ precheckStatus.getStatus()+";Precheck Percent:"+precheckStatus.getPercent());
  39. List<CheckItem> checkItems = precheckStatus.getDetail();
  40. for (int i = 0; i < checkItems.size(); i++) {
  41. String checkItem=checkItems.get(i).getItemName();
  42. String checkStatus = checkItems.get(i).getCheckStatus();
  43. String repairMethod = checkItems.get(i).getRepairMethod();
  44. String errorMessage =checkItems.get(i).getErrorMessage();
  45. System.out.println("CheckItem:"+checkItem+"; CheckStatus:"+checkStatus
  46. +"errorMessage:"+errorMessage+"; repairMethod:"+repairMethod);
  47. }
  48. } catch (Exception e) {
  49. // TODO: handle exception
  50. System.out.println("Get Precheck Status of Migration Job "+MigrationJobId +" Failed!");
  51. System.out.println(e.toString());
  52. }
  53. /*Get Status of Structure Migration*/
  54. try {
  55. StructureInitializationStatus strucInitStatus = new StructureInitializationStatus();
  56. strucInitStatus = response.getStructureInitializationStatus();
  57. String status = strucInitStatus.getStatus();
  58. String percent = strucInitStatus.getPercent();
  59. String progress = strucInitStatus.getProgress();
  60. String errorMsg = strucInitStatus.getErrorMessage();
  61. System.out.println("Get Structure Initialization Status of Migration Job " +MigrationJobId+" Succeed!");
  62. System.out.println("Status:"+status+";percent:"+percent+"; progress:"+progress+"; errorMsg:"+errorMsg);
  63. } catch (Exception e) {
  64. // TODO: handle exception
  65. System.out.println("Get Structure Initialization Status of Migration Job " +MigrationJobId+" Failed!");
  66. System.out.println(e.toString());
  67. }
  68. /*Get Status of Data Migration*/
  69. try {
  70. DataInitializationStatus dataInitStatus = new DataInitializationStatus();
  71. dataInitStatus = response.getDataInitializationStatus();
  72. String datainitstatus=dataInitStatus.getStatus();
  73. String datainitpercent = dataInitStatus.getPercent();
  74. String datainitprogress = dataInitStatus.getProgress();
  75. String datainiterrormsg = dataInitStatus.getErrorMessage();
  76. System.out.println("Get Data Initialization Status of Migration Job " +MigrationJobId+" Succeed!");
  77. System.out.println("Status:"+datainitstatus+";percent:"+datainitpercent+"; progress:"+datainitprogress+"; errorMsg:"+datainiterrormsg);
  78. } catch (Exception e) {
  79. // TODO: handle exception
  80. System.out.println("Get Data Initialization Status of Migration Job " +MigrationJobId+" Failed!");
  81. System.out.println(e.toString());
  82. }
  83. /*Get Status of Data Synchronization*/
  84. try {
  85. DataSynchronizationStatus dataSyncStatus = new DataSynchronizationStatus();
  86. dataSyncStatus = response.getDataSynchronizationStatus();
  87. String datasynstatus=dataSyncStatus.getStatus();
  88. String datasyncpercent=dataSyncStatus.getPercent();
  89. String datasyncdelay=dataSyncStatus.getDelay();
  90. String datasyncerrormsg=dataSyncStatus.getErrorMessage();
  91. System.out.println("Get Data Synchronization Status of Migration Job " +MigrationJobId+" Succeed!");
  92. System.out.println("Status:"+datasynstatus+";percent:"+datasyncpercent+"; delay:"+datasyncdelay+"; errorMsg:"+datasyncerrormsg);
  93. } catch (Exception e) {
  94. // TODO: handle exception
  95. System.out.println("Get Data Synchronization Status of Migration Job " +MigrationJobId+" Failed!");
  96. System.out.println(e.toString());
  97. }
  98. } catch (Exception e) {
  99. // TODO: handle exception
  100. System.out.println("Get Status of Migration Job "+MigrationJobId+" Failed");
  101. System.out.println(e.toString());
  102. }
  103. }
本文导读目录
本文导读目录
以上内容是否对您有帮助?