Book Image

Getting Started with Hazelcast

By : Matthew Johns
Book Image

Getting Started with Hazelcast

By: Matthew Johns

Overview of this book

Table of Contents (18 chapters)
Getting Started with Hazelcast
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...