Book Image

Getting Started with Hazelcast, Second Edition

By : Matthew Johns
Book Image

Getting Started with Hazelcast, Second Edition

By: Matthew Johns

Overview of this book

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

Atomic control


When interacting with Hazelcast's distributed collections, we set and retrieve data in a consistent and atomic way in that when we modify an entry, it is immediately available on the other nodes, irrespective of their processing state. This does mean that we have to be careful when developing applications, as data may change while performing an operation. However, it is this default lockless nature that significantly increases the application's throughput and scalability, especially under load. Two of the collections that we already looked at additionally implement specific atomic capabilities that are provided by the java.util.concurrent interfaces.

As we've previously seen, the distributed map collection provided by Hazelcast is defined by its own IMap class. This actually extends ConcurrentMap, which will provide us with additional atomic operations such as putIfAbsent(key, value) and replace(key, oldValue, newValue). These capabilities may prevent any concurrent modification...