Incremental Migration on CDM Supported by DLF
The Data Lake Factory (DLF) component of DataArts Studio is a one-stop big data collaboration development platform. With DLF's online script editing, CDM jobs can be scheduled to implement incremental migration.
Obtaining the CDM Job JSON
- On the CDM console, create a table/file migration job from DWS to OBS.
- On the Table/File Migration tab page of the Job Management page, locate the created job, click More in the Operation column, and select View Job JSON from the drop-down list.
You can also view JSON of any other CDM job.
Figure 1 Viewing job JSON
- The job JSON is the request body template for creating a CDM job. Replace [Endpoint], {project_id}, and {cluster_id} in the URL with the actual values.
- [Endpoint]: indicates the endpoint.
An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. You can obtain endpoints of the service from Endpoints.
- {project_id}: indicates the project ID.
- {cluster_id}: Indicates the cluster ID. You can click the cluster name on the Cluster Management page to view the cluster ID.
- [Endpoint]: indicates the endpoint.
Modifying JSON
- Modify the WHERE clause to add incremental data in a certain period.
{ "name": "fromJobConfig.whereClause", "value": "_timestamp >= '${startTime}' and _timestamp < '${currentTime}'" }
- If the source database is DWS or MySQL, the value can be set to:
_timestamp >= '2018-10-10 00:00:00' and _timestamp < '2018-10-11 00:00:00' Or _timestamp between '2018-10-10 00:00:00' and '2018-10-11 00:00:00'
- If the source database is Oracle, the value should be set to:
_timestamp >= to_date (2018-10-10 00:00:00' , 'yyyy-mm-dd hh24:mi:ss' ) and _timestamp < to_date (2018-10-10 00:00:00' , 'yyyy-mm-dd hh24:mi:ss' )
- If the source database is DWS or MySQL, the value can be set to:
- Import incremental data in each period to different directories.
{ "name": "toJobConfig.outputDirectory", "value": "dws2obs/${currentTime}" }
- Change the job name to a dynamic one. Otherwise, the job cannot be created because the job name is duplicate.
"to-connector-name": "obs-connector", "from-link-name": "dws_link", "name": "dws2obs-${currentTime}"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
{ "jobs": [ { "job_type": "NORMAL_JOB", "to-config-values": { "configs": [ { "inputs": [ { "name": "toJobConfig.bucketName", "value": "cdm-test" }, { "name": "toJobConfig.outputDirectory", "value": "dws2obs/${currentTime}" }, { "name": "toJobConfig.outputFormat", "value": "CSV_FILE" }, { "name": "toJobConfig.fieldSeparator", "value": "," }, { "name": "toJobConfig.writeToTempFile", "value": "false" }, { "name": "toJobConfig.validateMD5", "value": "false" }, { "name": "toJobConfig.encodeType", "value": "UTF-8" }, { "name": "toJobConfig.duplicateFileOpType", "value": "REPLACE" }, { "name": "toJobConfig.kmsEncryption", "value": "false" } ], "name": "toJobConfig" } ] }, "from-config-values": { "configs": [ { "inputs": [ { "name": "fromJobConfig.schemaName", "value": "dws_database" }, { "name": "fromJobConfig.tableName", "value": "dws_from" }, { "name": "fromJobConfig.whereClause", "value": "_timestamp >= '${startTime}' and _timestamp < '${currentTime}'" }, { "name": "fromJobConfig.columnList", "value": "_tiny&_small&_int&_integer&_bigint&_float&_double&_date&_timestamp&_char&_varchar&_text" } ], "name": "fromJobConfig" } ] }, "from-connector-name": "generic-jdbc-connector", "to-link-name": "obs_link", "driver-config-values": { "configs": [ { "inputs": [ { "name": "throttlingConfig.numExtractors", "value": "1" }, { "name": "throttlingConfig.submitToCluster", "value": "false" }, { "name": "throttlingConfig.numLoaders", "value": "1" }, { "name": "throttlingConfig.recordDirtyData", "value": "false" }, { "name": "throttlingConfig.writeToLink", "value": "obs_link" } ], "name": "throttlingConfig" }, { "inputs": [], "name": "jarConfig" }, { "inputs": [], "name": "schedulerConfig" }, { "inputs": [], "name": "transformConfig" }, { "inputs": [], "name": "smnConfig" }, { "inputs": [], "name": "retryJobConfig" } ] }, "to-connector-name": "obs-connector", "from-link-name": "dws_link", "name": "dws2obs-${currentTime}" } ] } |
Creating a DLF Job
- In DLF, create the jobs shown in Figure 2. For details, see Creating a Job in DataArts Studio User Guide.
- Configure the CreatingJob node.
DLF uses a RestAPI node to call a RESTful API to create a CDM migration job. Configure the properties of the RestAPI node.
- Node Name: Enter a custom name, for example, CreatingJob. Note that the CDM job is only used as a node in the DLF job.
- URL Address: Set it to the URL obtained in Obtaining the CDM Job JSON. The format is https://{Endpoint}/cdm/v1.0/{project_id}/clusters/{cluster_id}/cdm/job.
- HTTP Method: Enter POST.
- Add the following request headers:
- Content-Type = application/json
- X-Language = en-us
- Request Body: Enter the modified JSON of the CDM job in Modifying JSON.
Figure 3 Properties of the node for creating the CDM job
- Configure the StartingJob node.
After configuring the RESTful API node for creating a CDM job, you must add the RESTful API node for running the CDM job. For details, see section "Starting a Job" in Cloud Data Migration API Reference. Configure the properties of the RestAPI node.
- Node Name: Enter the name of the node where the job is to be run.
- URL Address: Keep the values of project_id and cluster_id consistent with those in 2. Set the job name to dws2obs-${currentTime}. The format is https://{Endpoint}/cdm/v1.0/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/start.
- HTTP Method: Enter PUT.
- Request Header:
- Content-Type = application/json
- X-Language = en-us
Figure 4 Properties of the node for running the CDM job
- Configure the WaitingJobCompletion node.
CDM jobs are run asynchronously. Therefore, even if the REST request for running the job returns 200, it does not mean that the data has been migrated successfully. If a computing job depends on the CDM job, a RestAPI node is required to periodically check whether the migration is successful. Computing is performed only when the migration is successful. For details about the API used to check whether the CDM migration is successful, see section "Querying Job Status" in Cloud Data Migration API Reference.
After configuring the RestAPI node for running the CDM job, add the node for waiting for the CDM job completion. The node properties are as follows:- Node Name: Wait until the job is complete.
- URL Address: The format is https://{Endpoint}/cdm/v1.0/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/status. Keep the values of project_id and cluster_id consistent with those in 2. Set the job name to dws2obs-${currentTime}.
- HTTP Method: Enter GET.
- Request Header:
- Content-Type = application/json
- X-Language = en-us
- Check Return Value: Select YES.
- Property Path: Enter submissions[0].status.
- Request Success Flag: Set this parameter to SUCCEEDED.
- Retain default values for other parameters.
- (Optional) Configure the DeletingJob node.
You can delete jobs as required. DLF periodically creates CDM jobs to implement incremental migration. Therefore, a large number of jobs exist in the CDM cluster. After the migration is successful, you can delete the jobs that have been successfully executed. To delete a CDM job, add a RestAPI node for deleting CDM jobs after the node for querying the CDM job status. DLF calls the API for deleting a job described in Cloud Data Migration API Reference.
Properties of the node for deleting the CDM job are as follows:- Node Name: Enter DeletingJob.
- URL Address: The format is https://{Endpoint}/cdm/v1.0/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}. Keep the values of project_id and cluster_id consistent with those in 2. Set the job name to dws2obs-${currentTime}.
- HTTP Method: Enter DELETE.
- Request Header:
- Content-Type = application/json
- X-Language = en-us
- Retain default values for other parameters.
Figure 5 Properties of the node for deleting the CDM job
- To perform computing operations after the migration is complete, you can add various computing nodes.
- Configure DLF job parameters.
- Configure the DLF job parameters shown in Figure 6.
- startTime = $getTaskPlanTime(plantime,@@yyyyMMddHHmmss@@,-24*60*60)
- currentTime = $getTaskPlanTime(plantime,@@yyyyMMdd-HHmm@@,0)
- After saving the DLF job, choose Scheduling Configuration > Periodic Scheduling and set the scheduling period to one day.
In this way, DLF works with CDM to migrate data generated on the previous day every day.
- Configure the DLF job parameters shown in Figure 6.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.