Skip to content

Worker

Definition

Beehive provides a Java class called Worker which represents one of the several worker threads on a Beehive system. Each Worker maintains the following information:

workpool
A reference to the local workpool from which this Worker will be drawing its tasks
dataStorage
A reference to a local storage system from which it can retrieve, update, or add nodes
rwsetinfo
An abstraction provided by Beehive to keep track of which nodes (by id) have been read or written to for a given transaction
updatedNodes
A mapping from the node id's of the nodes that were updated for a given transaction to the nodes themselves
updatedNodeData
A mapping from the node id's of the nodes that are going to be updated via fine-grain remote data access to the NodeData themselves.
readsetTS
A mapping from the node id's of the nodes that were read to their current, respective timestamps
tasksCreated
A set of tasks that were created upon completion of any given task.
master
Whether or not this Worker is the "master" worker
workerId
An identifier for this Worker. The ids are for debugging purposes, there are no requirements imposed on the given ids.

Programmers must extend this class in order to do application programming with Beehive since the for task execution is dependent on the application. This can be done by writing a subclass of Worker. Depending on the application, one could have one or many types of Workers in the application, each with their own execution logic. As a running example, consider the Graph Coloring problem. Below is a Graph Coloring specific Worker.

public class GCWorker extends Worker {
    // Application specific fields

    @Override
    public void doTask(Task tsk) {
        // Begin transaction
        // Application specific computation logic
        // Validate transaction
    }

    // Auxillary methods
}

In addition to subclassing the Worker class, programmers must also override the doTask method. There are three essential components to the doTask method:

Starting the Transaction
This starts the transaction for a given task computation
Computation
This is the computational phase of the task. In other words, this is where the application specific logic is placed
Validation
This validates the results of the computation to check for any read-write and/or write-write conflicts the the nodes used during the computation

Utilities

Beehive's Worker class provides the following primitives that may be useful in application programming:

  • getNeighbors(Node u)
  • getLocalNeighbors(Node u)
  • getRemoteNeighbors(Node u)
  • getNeighborIds(Node u)

A full listing and their respective functionality can be found in the java documentation.