-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Doing jobs in parallel is the problem attacked in this project. The approach is provide each job with sufficient intelligence on when to start and signal when it is complete. Using this simple approach, each job is implemented in a separate thread which simply waits until its start conditions are met, starts and signals the finish. One of the paradigms used is to be as 'un-coordinated' as possible. In this manner the code is simplified in that the processing and code is within each job itself.
Let a,b,c,d,e be five jobs to be exected. Define the Starting conditions for each job (synonym to predecessor, pre-condition etc) as completion of other jobs. In this case the following example is chosen:
a => {c,d,e} - i.e. Job a can be started if c,d,e are complete.
b => {c,d,e}
c => {d,e}
d =>{}
e =>{}
The obvious solution to parallel execution here is: {d,e} => {c} => {a,b}. The jobs in each set are executed in parallel.
- Each job is defined as :
- Starting Conditions (The set of messages that this job looks for before starting - such as other jobs completing)
- There must be at least one starting condition. The default is 'start'.
- Job execution
- Post messages at during job execution.
- There must be at least one message posted. The default is 'complete'.
- Jobs start execution in their own thread space once their starting conditions are satisfied.
- There exists a message center, where jobs look for messages at some interval
There are three basic modules:
- Initiator: This module creates the job threads, and passes to each its starting conditions. Each job is given an id.
- Job Class: This is an abstract class, that contains the following methods:
- Ready, - a boolean indicating that the job can be started.
- TestIfReady - calls Ready in a 'wait' loop until ready is true. It then calls 'execute' and on completion posts a message in the message center.
- postMessage - posts message to the message center
- Message Center: This class holds a message set containing messages. Each message also has the job Id of the job posting the message. The class has two methods:
- Post Message - adds a message to the message set
- Is Message Posted - Returns true if a specified message has been posted to the Message Center.
This module contains the main procedure that is executed on startup. It sets up the jobs and the Message broker modules.
The setup for jobs is:
- Read a text file which contains job info with one job per line.
- The line format is:
a. jobId:jobClass:{json string} - The file is read, and each job is started with the json string and the Message broker as parameters
##Appendix I
- Clone repository into Eclipse (File->import from Git ..)
- Build (maven build of the pom file): a. Two artifacts in the target directory (lib directory and doJobs-1.0.jar) should be copied to directory on the deployment machine. b. In that directory 'java -jar doJobs-1.0.jar'. This starts the job
doJobs: Concurrent job execution