Apache Karaf Cellar and central management
Introduction
One of the first purpose of Apache Karaf Cellar is to synchronize the state of each Karaf instances in the Cellar cluster.
It means that any change performed on one node (install a feature, start a bundle, add a config, etc) generates a “cluster event” which is broadcasted by Cellar to all others nodes. The target node handles the “cluster event” and performed the corresponding action (install a feature, start a bundle, add a config, etc).
By default, the nodes have the same role. It means that you can perform actions on any node.
But, you may prefer to have one node dedicated to the management. It’s what we name “central management”.
Central management
With central management, one node is identified by the manager. It means that cluster actions will be performed only on this node. The manager is the only one which is able to produce cluster event. The managed nodes are only able to receive and handle events, not to produce.
With this approach, you can give access (for instance grant ssh or JMX access) to the manager node to an operator and manage the cluster (and all cluster groups) from this manager node.
We will see now how to implement central management.
We assume that we have three nodes:
- manager
- node1
- node2
First, we install Cellar on the three nodes:
karaf@manager> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.4-SNAPSHOT/xml/features
karaf@manager> features:install cellar
karaf@node1> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.4-SNAPSHOT/xml/features
karaf@node1> features:install cellar
karaf@node2> features:addurl mvn:org.apache.karaf.cellar/apache-karaf-cellar/2.2.3/xml/features
karaf@node2> features:install cellar
It’s a default installation, nothing special here.
Now, we disable the event producing on node1 and node2.
To do that, from the manager:
karaf@manager> cluster:producer-stop node1:5702
Node Status
node1:5702 false
karaf@manager> cluster:producer-stop node2:5703
Node Status
node2:5703 false
We can check that the producer are really stopped:
karaf@manager> cluster:producer-status node1:5702
Node Status
node1:5702 false
karaf@manager> cluster:producer-status node2:5703
Node Status
node2:5703 false
Whereas the manager is always able to produce event:
karaf@manager> cluster:producer-status
Node Status
manager:5701 true
Now, for instance, we can install eventadmin feature from the manager:
karaf@manager> cluster:features-install default eventadmin
We can see that this feature has been installed on node1:
karaf@node1> features:list|grep -i eventadmin
[installed ] [2.2.5 ] eventadmin karaf-2.2.5
and node2:
karaf@node2> features:list|grep -i eventadmin
[installed ] [2.2.5 ] eventadmin karaf-2.2.5
Now, we uninstall this feature from the manager:
karaf@manager> cluster:features-uninstall default eventadmin
We can see that the feature has been uninstall from node1:
karaf@node1> features:list|grep -i eventadmin
[uninstalled] [2.2.5 ] eventadmin karaf-2.2.5
And now, we try to install the eventadmin feature on the cluster from the node1:
karaf@node1> cluster:features-install default eventadmin
The event is not generated and the others nodes are not updated.
However, two kind of events are always produced (even if the producer is stopped):
- the events with the “force” flag. When you create an event (programmatically), you can use setForce(true) to force the event producing.
- the “admin” events, like the events produced to stop/start a producer, consumer, handler in the cluster.
NB: the event produce handling has been largely improved for Cellar 2.2.4.
Coming in next Cellar release
Currently, the cellar feature install the cellar core bundles, but also the cellar shell commands, and the MBeans.
If it makes sense for the manager, the managed nodes should not “display” the cluster:* commands as they are managed by the manager.
I will make a little refactoring of the Cellar features to split in two parts:
- the cellar-core feature will install hazelcast, and Cellar core bundles
- the cellar-manager feature will install the cluster:* shell commands and the MBeans
Comments
Post a Comment