In my last post, I explained how configuration was done through the use of ZooKeeper as the repository for configurations and profiles, propagated to various bundles using the OSGi ConfigurationAdmin service. The provisioning mechanism in Fabric is based on this mechanism: the fabric-agent bundle receives its configuration through the org.fusesource.fabric.agent pid and will automatically update bundles as needed. The nice thing is that the configurations are computed using an overlay mechanism which means that the list of bundles or features to deploy will come from the various profiles a give node has been assigned.
The agent itself supports several kinds of informations:
- bundles that need to be installed
- karaf features that need to be installed
- repositories for karaf features
- a url pointing to the osgi framework to use
- system properties
- osgi framework properties
An example of defining such profiles can be found in the fabric example.
The agent will use those informations and delegate to an internal OSGi resolver to compute the actual list of bundles to deploy. It will then compare this list to the list of bundles already installed and resolve the differences by installing / updating / uninstalling bundles. The agent is able to upgrade all bundles, including core Karaf bundles and even the OSGi framework itself and framework properties.
The profile notion I explained in my previous blog entry allow the use of profiles for provisioning and configuration. For example, a profile can be defined for deploying ActiveM or Camel. And remember one can override profiles, so you can define a profile for your application and change the IP of the ActiveMQ broker in overridden profiles based on the geographic location to connect to the nearest broker.
Due to the configuration bridge between the OSGi Configuration Admin and ZooKeeper, any change made into the zookeeper tree will be reflected to the provisionning agent and the bundles updated immediately. This may or may not be a desired behavior and that's one of the reason why the ZooKeeper tree used by Fabric has a notion of versions. But that'll be explained in a follow up entry.