A simple Beatrix application
Here's how we use Beatrix to write and use a simple distributed application
which will serve a hello world message to a console. The principles
of plugins have been covered in Chapter ![[*]](crossref.png) but see Chapter
but see Chapter ![[*]](crossref.png) for the
deeper details of all this code.
 for the
deeper details of all this code.
The application will:
- Provide an administation service through the managers, allowing the
application owner to control it. This service will be called admin.
- Provide a consumer service through workers, allowing them to serve
the hello world message to any console that connects to them. This
service will be called skeleton.
- Maintain redundancy by keeping 2-4 managers alive at all times.
- Maintain redundancy by keeping 2-4 workers alive at all times.
- Demand network and disk resources for workers (though it doesn't use
either).
- Have managers adding plugins to new workers remotely.
Additionally Beatrix does the following for us:
- Maintains redundancy by ensuring each worker runs on a different node.
- Maintains redundancy by ensuring each manager runs on a different
node.
- Allows unused resources to be released or re-used as necessary.
- Allows launch and management through a command line console.
We need to implement five plugins and one interface--see Figure![[*]](crossref.png) for a visual overview. The interface:
for a visual overview. The interface:
- ISkeletonFacet. An interface that contains the getMessage()
method, providing the hello world message.
The plugins:
- AdminServiceProvider. Provides the owner's administration
service. We will call the service admin.
- SkeletonServiceProvider. Provides the basic consumer service
to deliver the hello world message. We call this service skeleton.
- LifeCyclePlugin. Handles the managers' life cycles: cold
starts, warm starts, joining and leadership changes. Program flow
starts here.
- SkeletonWorkerManager. A plugin to the managers which sets
up the workers. Sets their resource requirements and remotely adds
the plugins they need.
- SkeletonWorker. The main worker plugin. It binds the resources
allocated to it but doesn't use them.
An additional class, SkeletonFacet, is included in the SkeletonWorker.java
file. It implements the ISkeletonFacet.
Subsections
Nik Silver
2002-03-09