Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

Locks

Enforce mutual exclusion on cached objects.

Cache transactions will acquire locks implicitly. However, there are cases when explicit locks are more useful. The lock() method of IgniteCache API returns an instance of java.util.concurrent.locks.Lock, that lets you define explicit distributed locks for any given key. Locks can also be acquired on a collection of objects using IgniteCache.lockAll() method.

IgniteCache<String, Integer> cache = ignite.cache("myCache");

// Create a lock for the given key
Lock lock = cache.lock("keyLock");
// Acquire the lock
lock.lock();
try {  
    cache.put("Hello", 11);
    cache.put("World", 22);
}
finally {
    // Release the lock
    lock.unlock();
}

Atomicity Mode

In Ignite, locks are supported only for TRANSACTIONAL atomicity mode, which can be configured via atomicityMode property of CacheConfiguration.

Locks and Transactions

Explicit locks are not transactional and cannot not be used from within transactions (exception will be thrown). If you do need explicit locking within transactions, then you should use TransactionConcurrency.PESSIMISTIC concurrency control for transactions which will acquire explicit locks for relevant cache operations.