Child pages
  • Zookeeper lock server for the autonomous components
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Zookeeper

We use zookeeper to track locks between the autonomous components. To make zookeeper easier to use, we use the netflix curator api http://curator.incubator.apache.org/

Zookeeper maintains a tree structure internally. In each leaf in the tree should correspond to some real world thing. A leaf can be locked, and the system is based on the idea that you will lock the leaf before accessing the thing it represents.

We have two "kinds" of leafs. 

The specific lock paths are as follows

SBOI lock = "/SBOI/" + runnable.getComponentName();

batch lock = "/"+runnable.getComponentName() + "/B" + batch.getBatchID() + "-RT" + batch.getRoundTripNumber();

Why?

An autonomous components will be able to "poll" the Summa Batch Object Index for events that have happened. The component will know which events should have occurred for a batch before I can start processing the batch. Also which events should have occurred and failed, and which events should not have occurred. The component also needs to know which batches it is currently working on itself. This is what the zookeeper tracks the locks for.

Autonomous component locking procedure 1

Each of the autonomous components will exist as cron jobs. Periodically, often every minute or thereabouts, the cron job will activate. It will then follow the procedure below.

  1. Lock "SBOI+component name"
    1. query SBOI for batches
    2. For each returned batch
    3. Attempt to lock the "batch+component name"
    4. if successful, break loop
  2. unlock "SBOI+component name"
  3. Do work on locked batch (if any)
  4. store results in DOMS
  5. unlock "batch+component name"

 

Autonomous component locking procedure 2

Each of the autonomous components will exist as cron jobs. Periodically, often every minute or thereabouts, the cron job will activate. It will then follow the procedure below.

  1. Lock "SBOI+component name"
  2. query SBOI for batches
  3. For each returned batch
    1. Attempt to lock the "batch+component name"
    2. Do work on locked batch (if any). Possibly spawn sub process
    3. store results in DOMS
    4. unlock "batch+component name"
  4. unlock "SBOI+component name"

 

Which one will we use?

Method 1 is simpler to implement (and already done). Method 1 will only maintain a very shortlived lock on SBOI. To run method 1 on three batches, just start it three times.

Method 2 is conceptually simpler to understand. It allows for developer controlled degree of parallelism, but will also force us to code this ourselves.  This is the method described on the Autonomous Components page. Well actually the description is this:

If the robot finds that a batch is ready to work on, it starts working on this batch. The robot will not poll for more work while working.

Some of the robots will be able to multitask, and others will not. Multitasking is done in a slightly different way for robots than for humans. The multitasking robot will build a new little non-multitasking robot child, give him the batch to work on, and then go back to sleep. Next time it polls for work, it will have to remember not the start work on batches that already have been assigned to any of the robots children. This also means that there must only ever be one instance of each type of multitasking robot running.

When a robot have finished work on a batch, it must record this, so the assembly line can move forward. It records the event Batch Object, stored in the Digital Object Management System, DOMS, system, in the form of an event somewhat like "I, <ROBOT>, did this <THIS WORK> on batch <ID> with <THIS RESULT>". The SBOI will then periodically (often) query DOMS for updates to the Batch objects. When the SBOI discover a batch object update, it updates the index, so that robots further along the assembly line can work on the batch.

 

 

 

  • No labels