开发者社区> 问答> 正文

如何查看迁移任务状态



描述


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

请求参数

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


返回参数

参数名称数据类型参数描述
MigrationJobIdString迁移任务ID`
MigrationJobNameString迁移任务名称
PayTypeString付费类型
MigrationJobClassString迁移实例规格
SourceEndpointEndpoint迁移源实例的连接方式Endpoint的定义参考Endpoint参数定义
DestinationEndpointEndpoint迁移目标实例的连接方式Endpoint的定义参考Endpoint参数定义
MigrationModeMigrationMode迁移类型MigrationMode的定义参考MigrationMode参数定义
MigrationObjectsList迁移对象
MigrationJobStatusString迁移任务状态,取值包括:NotStarted : 表示未启动 Prechecking : 表示预检查中 PrecheckFailed : 表示预检查失败 Migrating : 表示迁移中 Suspengding : 表示暂停中 MigrationFailed : 表示迁移失败 Finished : 表示完成
PrecheckStatusPrecheckStatus预检查的状态,包括检查进度及检查状态PrecheckStatus的定义详见PrecheckStatus的参数定义
StructureInitializationStatusStructureInitializationStatus结构迁移的状态,包括迁移状态及具体的迁移进度StructureInitializationStatus的定义详见 StructureInitializationStatus参数定义
DataInitializationStatusDataInitializationStatus全量数据迁移的状态,包括迁移状态及具体的迁移进度DataInitializationStatus的定义详见DataInitializationStatus参数定义
DataSynchronizationStatusDataSynchronizationStatus增量数据迁移的状态,包括迁移状态及具体的迁移进度DataSynchronizationStatus定义详见DataSynchronizationStatus参数定义


Endpoint 参数定义

参数名称数据类型参数描述
InstanceTypeString实例类型
RegionString源实例所在地域
InstanceIdString实例ID
EngineNameString数据库类型
IPString数据库连接地址
PortString数据库监听端口
UserNameString数据库访问账号
OracleSIDStringOracle SID
DatabaseNameString数据库名称


MigrationMode参数定义

参数名称数据类型参数描述
StructureInitializationString是否进行结构迁移
DataInitializationString是否进行全量数据迁移
DataSynchronizationString是否进行增量数据迁移


PrecheckStatus参数定义

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


CheckItem的参数定义

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


StructureInitializationStatus参数定义

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


DataInitializationStatus参数定义

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


DataSynchronizationStatus参数定义

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


示例


下面简单演示通过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());
        }
    }

展开
收起
云栖大讲堂 2017-10-31 16:10:25 1802 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
MaxCompute Logview参数详解和问题排查(废弃) 立即下载
运用新技术解决有状态应用的冷热迁移挑战 迁移策略+新容器运行时 立即下载
Logview参数详解和故障排查 立即下载