描述
同步实例处于任何状态,都可以调用这个接口查询同步实例的状态及运行详情。
请求参数
返回参数
PrecheckStatus参数定义
CheckItem的参数定义
StructureInitializationStatus参数定义
DataInitializationStatus参数定义
DataSynchronizationStatus参数定义
Performance 参数定义
示例
下面简单演示通过JAVA SDK 查询同步任务状态的示例:
public void descSyncJobStatus(String SyncJobId,DefaultAcsClient client) {
DescribeSynchronizationJobStatusRequest request = new DescribeSynchronizationJobStatusRequest();
request.setSynchronizationJobId(SyncJobId);
DescribeSynchronizationJobStatusResponse response = new DescribeSynchronizationJobStatusResponse();
try {
response = client.getAcsResponse(request);
/*Get Sync Configure of the Sync Job*/
System.out.println("SyncJobId:"+response.getSynchronizationJobId()
+"SyncJobName:"+response.getSynchronizationJobName()
+"; PayType:"+response.getPayType()+"; ExpireTime:"+response.getExpireTime()
+"; SyncClass:"+response.getSynchronizationJobClass()
+"; StrucInit:"+response.getStructureInitialization()
+"; DataInit:"+response.getDataInitialization()+"; Status:"+response.getStatus()
+"; Delay:"+response.getDelay()
+"; ErrMSG:"+response.getErrorMessage());
/*Get Sync Objects of the Sync Job*/
System.out.println("Sync Objects:");
List<SynchronizationObject> syncObjects = response.getSynchronizationObjects();
/*Get the Source Endpoint of the synchronization job*/
SourceEndpoint sourceEndpoint = response.getSourceEndpoint();
System.out.println("InstanceType:"+sourceEndpoint.getInstanceType()
+"InstanceId:"+sourceEndpoint.getInstanceId());
/*Get the Destination Endpoint of the synchronization job*/
DestinationEndpoint destinationEndpoint = new DestinationEndpoint();
System.out.println("Instance Type:"+destinationEndpoint.getInstanceType()
+destinationEndpoint.getInstanceId());
// Get Sync Object of the synchronization job
System.out.println("SyncObject:"+org.json.JSONObject.valueToString(syncObjects));
// Get Precheck Status of the synchronization job
try {
com.aliyuncs.dts.model.v20160801.DescribeSynchronizationJobStatusResponse.PrecheckStatus precheckStatus = response.getPrecheckStatus();
System.out.println("Get Precheck Status for Sync Job Succeed");
System.out.println("Precheck Status:"+response.getPrecheckStatus().getStatus()
+"; Precheck Percent:"+response.getPrecheckStatus().getPercent());
List<com.aliyuncs.dts.model.v20160801.DescribeSynchronizationJobStatusResponse.PrecheckStatus.CheckItem> precheckDetails= precheckStatus.getDetail();
for (int i = 0; i < response.getPrecheckStatus().getDetail().size(); i++) {
System.out.println("CheckItem:"+response.getPrecheckStatus().getDetail().get(i).getCheckStatus()
+"; ErrorMSG:"+response.getPrecheckStatus().getDetail().get(i).getErrorMessage()
+"; RepairMethod:"+response.getPrecheckStatus().getDetail().get(i).getRepairMethod());
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Precheck Status for Sync Job Failed");
}
// Get Structure Initialization Status of the synchronization job
try {
System.out.println("Get Structure Initialization Status Succeed!");
System.out.println("Structure Init Status:"+response.getStructureInitializationStatus().getStatus()
+"; Percent:"+response.getStructureInitializationStatus().getPercent()
+"; Progress:"+response.getStructureInitializationStatus().getProgress()
+"; ErrMSG:"+response.getStructureInitializationStatus().getErrorMessage());
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Structure Init Status Failed!");
}
// Get Data Initialization Status of the synchronization job
try {
System.out.println("Get Data Initialization Status Succeed!");
System.out.println("Data Init Status:"+response.getDataInitializationStatus().getStatus()
+"; Percent:"+response.getDataInitializationStatus().getPercent()
+"; Progress:"+response.getDataInitializationStatus().getProgress()
+"; ErrMSG:"+response.getDataInitializationStatus().getErrorMessage());
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Data Init Status Failed!");
System.out.println(e.toString());
}
//Get Data Sync Status
try {
com.aliyuncs.dts.model.v20160801.DescribeSynchronizationJobStatusResponse.DataSynchronizationStatus dataSyncStatus = response.getDataSynchronizationStatus();
System.out.println("Get Data Synchronization Status Succeed!");
System.out.println("Data Sync Status:"+response.getDataSynchronizationStatus().getStatus()
+"; Percent:"+response.getDataSynchronizationStatus().getPercent()
+"; Delay:"+response.getDataSynchronizationStatus().getDelay()
+"; ErrMSG:"+response.getDataSynchronizationStatus().getErrorMessage());
} catch (Exception e) {
// TODO: handle exception
System.out.println("Get Data Sync Status Failed!");
System.out.println(e.toString());
}
//Get Performance
System.out.println("TPS:"+response.getPerformance().getRPS()
+"Flow:"+response.getPerformance().getRPS());
} catch (Exception e) {
// TODO: handle exception
System.out.println("Describe Status of Data Sync Job "+ SyncJobId + "Failed");
System.out.println(e.toString());
}
}