Now that we can determine what is going on with our data within the cluster, we may wish to have a higher degree of visibility of the state of the cluster itself. We can use this either 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 the previous examples. However, in production, it is better to configure them in advance for the same reasons regarding the race condition as the collection listeners. We can do this either by using the hazelcast.xml
configuration, or by using the Config
class, as follows:
<hazelcast> <listeners> <listener>com.packtpub.hazelcast.MyClusterListener</listener> </listeners> </hazelcast>
The first of these, DistributedObjectListener
, simply notifies all the nodes...