* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
The Whirr Service API.
A service is an instance of a coherent system running on one or more machines.
A role is a part of a service running on a single machine. A role typically corresponds to a single process or daemon, although this is not required.
An instance template (
) is a specification of the role sets and
cardinalities that make up a cluster. For example,
1 role-a+role-b,4 role-c
specifies a cluster in which one node is in roles role-a and
role-b, and four nodes are in role role-c.
A cluster action (
) is an action that is performed on a set of machines
in a cluster. Examples of cluster actions include 'bootstrap' and 'configure'.
You can launch or destroy clusters using an instance of
launches a cluster by running the bootstrap action, followed by the
configure action. For each of these actions Whirr follows these rules:
The first rule implies that you can't rely on one template being processed first. In fact, Whirr will process them all in parallel. So to transfer information from one role to another (in a different template) you should use different actions. For example, use the configure phase to get information about another role that was set in its bootstrap phase.
The second rule implies that a cluster action handler for a given role will be run more than once if it appears in more than one template.
A cluster is
destroyed by running the destroy action.
For each role in a service you must write a
, which allows you to
run code at various points in the lifecycle. For example, you can specify a
script that must be run on bootstrap, and another at configuration time.
Roles for a service are discovered using Java's service-provider loading
facility defined by
. It's very easy to
register your service. Simply create a file with the following path (assuming
a Maven directory structure):
Then for each
implementation add its fully qualified name as a line in the file:
If you service is not a part of Whirr, then you can install it by first installing Whirr, then dropping the JAR file for your service into Whirr's lib directory.