DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. Take Data Migration to the Next Level Using Dexecutor

Take Data Migration to the Next Level Using Dexecutor

See how you can use Dexecutor to migrate your data in parallel to avoid long wait times and delays.

Mohammad Nadeem user avatar by
Mohammad Nadeem
·
Oct. 18, 16 · Tutorial
Like (2)
Save
Tweet
Share
23.47K Views

Join the DZone community and get the full member experience.

Join For Free

Say you have a data migration process that updates your application from version X to X+1 by running migration scripts (each script consists of a sequence of instructions) sequentially to bring the application to a desired state.

Problem

The synchronous process is causing delays, leading to unproductive wait times and dissatisfaction from users. There is a need to run tasks in parallel wherever applicable to come to the desired state.

Driving Forces

The following are driving forces behind Dexecutor.

  • Supports parallel execution, conditionally may revert to sequential execution (if such logic is provided)
  • Ultra light (Version 1.1.1 is 44KB)
  • Ultra fast
  • Distributed Execution supported
  • Immediate/Scheduled Retry logic supported
  • Non-terminating behavior supported
  • Conditionally skip the task execution

Solution

Incorporate Dexecutor into your script execution logic — additionally distribute the execution using Infinispan, Hazelcast, or Ignite. Here is the sample application that demonstrates this functionality. Fork it and have fun!

Dexecutor can be used in this case easily by adding algorithmic logic on top of Dexecutor, which builds the graph based on table names. Let's assume the following scripts:

Script 1 ==> operates on Tables t1 and t2 and takes 5 minute
Script 2 ==> operates on Tables t1 and t3 and takes 5 minute
Script 3 ==> operates on Tables t2 and t4 and takes 5 minute
Script 4 ==> operates on Tables t5 and t6 and takes 5 minute
Script 5 ==> operates on Tables t5 and t7 and takes 5 minute
Script 6 ==> operates on Tables t6 and t8 and takes 5 minute

Normally these scripts are executed sequentially as follows.

Script 1  5 minutes
  |
  V
Script 2  5 minutes
  |
  V
Script 3  5 minutes
  |
  V
Script 4  5 minutes
  |
  V
Script 5  5 minutes
  |
  V
Script 6  5 minutes

Total time 30 minutes 

In a sequential case, your total execution time would be 30 minutes. However, if we could parallelize the script execution and make sure scripts are executed in right sequence and order, then we could save time, decreasing the total execution time to just 10 minutes.

       +----------+                       +----------+
       | Script 1 |                       | Script 4 |             ==> 5 minutes
  +----+----------+--+               +----+----------+-----+
  |                  |               |                     |
  |                  |               |                     |
+-----v----+   +-----v----+     +----v-----+        +------v---+
| Script 2 |   | Script 3 |     | Script 5 |        | Script 6 |   ==> 5 minutes
+----------+   +----------+     +----------+        +----------+

Total Time 10 minutes

Using Dexecutor, we just have to write the algorithm, which facilitates building graph using the API exposed by Dexecutor, and the rest would be taken care by Dexecutor.

MigrationTasksExecutor implements that algorithm, considering the SQL in the migration scripts. Because table names in the SQL play a crucial role in building the graph, we need an efficient, ultra light, and ultra fast library to extract table names out of the SQL, and hence, we would use sql-table-name-parser. Use it by adding the following dependency in your POM.

<dependency>
    <groupId>com.github.mnadeem</groupId>
    <artifactId>sql-table-name-parser</artifactId>
    <version>0.0.2</version>
</dependency>

And of course, Dexecutor should be added as dependency as well

<dependency>
    <groupId>com.github.dexecutor</groupId>
    <artifactId>dexecutor-core</artifactId>
    <version>LATEST_VERSION</version>
</dependency>


The graph, that would be built, considering the migration script is the following:

dexecutor-graph
















As can be seen here, nodes base1, base3, and base 4 run in parallel and once one of them finishes, their children are executed. For example, if node base1 is finished, then its children base2 and app3-1 are executed, and so on.

Notice that for node app2-4 to start, app1-4 and app2-1 must finish. Similarly, for node app3-2 to start, app3-1 andapp2-4 must finish.

Just run this class to see how things proceed.

Conclusion

We can indeed run dependent/independent tasks in easy and reliable way with Dexecutor.

References

  • Dexecutor
  • Dexecutor Website
  • Dexecutor Wiki
  • Dexecutor Migration Application
  • Introducing Dexecutor
Data migration Data (computing)

Published at DZone with permission of Mohammad Nadeem, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Utilize OpenAI API to Extract Information From PDF Files
  • 2023 Software Testing Trends: A Look Ahead at the Industry's Future
  • Why Open Source Is Much More Than Just a Free Tier
  • Why You Should Automate Code Reviews

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: