Events unfolding in the wider world
Now that we can determine what is going on with our data within the cluster, we might wish to have a degree of visibility of the state of the cluster itself. We could use this to trigger application-level responses to cluster instability, or provide mechanisms to enable graceful scaling. We are provided with a number of interfaces for different types of cluster activity. All of these listeners can be configured retrospectively as we have seen in our previous examples; however, in production, it would be better to configure them in advance for the same race condition reasons as the collection listeners. We can either do this using the hazelcast.xml
configuration or by using the Config
class.
<hazelcast> <listeners> <listener>com.packtpub.hazelcast.MyClusterListener</listener> </listeners> </hazelcast>
The first of these, InstanceListener
, simply notifies all the nodes in the cluster as to new collection instances...