Writing an Entity
Things To Know
All entities inherit from AbstractEntity
,
usually through one of the following:
SoftwareProcessEntity
: if it's a software processVanillaJavaApp
: if it's a plain-old-java appJavaWebAppSoftwareProcess
: if it's a JVM-based web-appWhirrEntity
: if it's a service launched using WhirrDynamicGroup
: if it's a collection of other entities
Software-based processes tend to use drivers to install and
launch the remote processes onto locations which support that driver type.
For example, StartStopSshDriver
is a common driver superclass,
targetting SshMachineLocation
(a machine to which Brooklyn can ssh).
The various SoftwareProcess
entities above (and some the exemplars
listed at the end of this page) have their own dedicated drivers.
Finally, there are a collection of traits
in the package brooklyn.entity.trait
providing common
sensors and effectors on entities, supplied as interfaces.
Choose one (or more) as appropriate.
Key Steps
So to get started:
- Create your entity class, extending the appropriate selection from above
- Create the driver class, again extending as appropriate
- Wire the
entity.newDriver(Location)
method to the driver - Provide the implementation of missing lifecycle methods in your driver class (details below)
- Connect the sensors from your entity
Helpful References
A few handy pointers will help make it easy to build your own entities. Check out some of the exemplar existing entities (note, some of the other entities use a deprecated class hierarchy, obvious with the word legacy in the FQN; it is suggested to avoid these, looking at the ones below instead):
- JBoss7Server
- MySqlNode
- OpenShift
You might also find the following helpful:
- Entity Design Tips
- The User Guide
- The Mailing List (brooklyn-dev@googlegroups.com)