描述
当任务处于任意状态时,都可以调用这个接口查看数据迁移状态。可以查询的迁移状态包括:整个任务的迁移状态,各个迁移阶段(结构迁移、全量数据迁移、增量数据迁移)的迁移状态及进度 以及 预检查的状态。
请求参数
返回参数
Endpoint 参数定义
MigrationMode参数定义
PrecheckStatus参数定义
CheckItem的参数定义
StructureInitializationStatus参数定义
DataInitializationStatus参数定义
DataSynchronizationStatus参数定义
示例
下面简单演示通过JAVA SDK 查询迁移任务状态的示例:
private static void describeMigrationJobStatus(String MigrationJobId){
DescribeMigrationJobStatusRequest request = new DescribeMigrationJobStatusRequest();
request.setMigrationJobId(MigrationJobId);
try {
DescribeMigrationJobStatusResponse response = client.getAcsResponse(request);
System.out.println("Get Status of Migration Job "+MigrationJobId+" Succeed!");
String JobStatus=response.getMigrationJobStatus();
/*Get the basic information of the migration job*/
System.out.println("MigrationJobName:"+response.getMigrationJobName()
+"MigrationJobId:"+response.getMigrationJobId()
+"MigrationObjects:"+response.getMigrationObject()
+"; MigrationMode.StructureInitialization:" + response.getMigrationMode().getStructureInitialization()
+"; MigrationMode.DataInitialization:"+response.getMigrationMode().getDataInitialization()
+"; MigrationMode.DataSynchronization:"+response.getMigrationMode().getDataSynchronization()
+"; MigrationJobStatus:"+response.getMigrationJobStatus());
/*Get the source endpoint of the migration job*/
System.out.println("SourceEndpoint.InstanceType:"+response.getSourceEndpoint().getInstanceType()
+"; SourceEndpoint.InstanceId:"+response.getSourceEndpoint().getInstanceId()
+"; SourceEndpoint.EngineName:"+response.getSourceEndpoint().getEngineName()
+"; SourceEndpoint.IP:"+response.getSourceEndpoint().getIP()
+"; SourceEndpoint.Port"+response.getSourceEndpoint().getPort()
+"; SourceEndpoint.UserName:"+response.getSourceEndpoint().getUserName()
+"; SourceEndpoint.DatabaseName:"+response.getSourceEndpoint().getDatabaseName()
+"; SourceEndpoint.OracleSID:"+response.getSourceEndpoint().getOracleSID());
/*Get the destination endpoint of the migration job*/
System.out.println("DestinationEnpoint.InstanceType:"+response.getDestinationEndpoint().getInstanceType()
+"DestinationEndpoint.InstanceId:"+response.getDestinationEndpoint().getInstanceId()
+"DestinationEndpint.EngineName:"+response.getDestinationEndpoint().getEngineName()
+"DestinationEndpoint.IP:"+response.getDestinationEndpoint().getIP()
+"DestinationEndpoint:Port:"+response.getDestinationEndpoint().getPort()
+"DestinationEndpoint.UserName:"+response.getDestinationEndpoint().getUserName()
+"DestinationEndpoint.DatabaseName"+response.getDestinationEndpoint().getDatabaseName()
+"DestinationEndpoint.OracleSID:"+response.getDestinationEndpoint().getOracleSID());
/*Get Status of Precheck*/
try {
com.aliyuncs.dts.model.v20160801.DescribeMigrationJobStatusResponse.PrecheckStatus precheckStatus = response.getPrecheckStatus();
System.out.println("Get Precheck Status of Migration Job "+MigrationJobId +" Succeed!");
System.out.println("Precheck Status:"+ precheckStatus.getStatus()+";Precheck Percent:"+precheckStatus.getPercent());
List<CheckItem> checkItems = precheckStatus.getDetail();
for (int i = 0; i < checkItems.size(); i++) {
String checkItem=checkItems.get(i).getItemName();
String checkStatus = checkItems.get(i).getCheckStatus();
String repairMethod = checkItems.get(i).getRepairMethod();
String errorMessage =checkItems.get(i).getErrorMessage();
System.out.println("CheckItem:"+checkItem+"; CheckStatus:"+checkStatus
+"errorMessage:"+errorMessage+"; repairMethod:"+repairMethod);
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Precheck Status of Migration Job "+MigrationJobId +" Failed!");
System.out.println(e.toString());
}
/*Get Status of Structure Migration*/
try {
StructureInitializationStatus strucInitStatus = new StructureInitializationStatus();
strucInitStatus = response.getStructureInitializationStatus();
String status = strucInitStatus.getStatus();
String percent = strucInitStatus.getPercent();
String progress = strucInitStatus.getProgress();
String errorMsg = strucInitStatus.getErrorMessage();
System.out.println("Get Structure Initialization Status of Migration Job " +MigrationJobId+" Succeed!");
System.out.println("Status:"+status+";percent:"+percent+"; progress:"+progress+"; errorMsg:"+errorMsg);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Structure Initialization Status of Migration Job " +MigrationJobId+" Failed!");
System.out.println(e.toString());
}
/*Get Status of Data Migration*/
try {
DataInitializationStatus dataInitStatus = new DataInitializationStatus();
dataInitStatus = response.getDataInitializationStatus();
String datainitstatus=dataInitStatus.getStatus();
String datainitpercent = dataInitStatus.getPercent();
String datainitprogress = dataInitStatus.getProgress();
String datainiterrormsg = dataInitStatus.getErrorMessage();
System.out.println("Get Data Initialization Status of Migration Job " +MigrationJobId+" Succeed!");
System.out.println("Status:"+datainitstatus+";percent:"+datainitpercent+"; progress:"+datainitprogress+"; errorMsg:"+datainiterrormsg);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Data Initialization Status of Migration Job " +MigrationJobId+" Failed!");
System.out.println(e.toString());
}
/*Get Status of Data Synchronization*/
try {
DataSynchronizationStatus dataSyncStatus = new DataSynchronizationStatus();
dataSyncStatus = response.getDataSynchronizationStatus();
String datasynstatus=dataSyncStatus.getStatus();
String datasyncpercent=dataSyncStatus.getPercent();
String datasyncdelay=dataSyncStatus.getDelay();
String datasyncerrormsg=dataSyncStatus.getErrorMessage();
System.out.println("Get Data Synchronization Status of Migration Job " +MigrationJobId+" Succeed!");
System.out.println("Status:"+datasynstatus+";percent:"+datasyncpercent+"; delay:"+datasyncdelay+"; errorMsg:"+datasyncerrormsg);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Data Synchronization Status of Migration Job " +MigrationJobId+" Failed!");
System.out.println(e.toString());
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Status of Migration Job "+MigrationJobId+" Failed");
System.out.println(e.toString());
}
}