Distributed Lock Service
Teracotta, including the Open Source edition, has distributed locking semantics by using either synchronized
or the java.util.concurrent.ReentrantReadWriteLock
- the latter apparently fitting your requirements.
Update
Since the question now added the requirement of 'mixing' with GigaSpaces, I'm going to say don't mix them. It's just going to add more complexity to your technological stack, and the effort of:
- integrating, in terms of both code and infrastructure;
- managing synchronisation between them;
- learning/tuning/debugging Teracotta.
will be better spent creating or implementing a locking solution based on GigaSpaces.
What is Distributed Lock Server
Often called a Distributed Lock Manager, it's a way for distributed applications to control access to shared resources. A typical example would be a cluster of computers that present what seems to be a single unified file system, even though behind the scenes they are sharing a collection of file systems. Machines in the cluster would need a (distributed) lock in order to make changes to a file, to prevent race conditions.
What's a distributed lock and why use it?
After asking people on quora. I think I got the answer.
Let's say N worker server access a database server. There are two parts here:
The database has its own lock methods to protect the data from corrupted by concurrent access of other clients (N work server). This is where a local lock in the database comes out.
N worker servers may need some coronation to make sure that they are doing the right thing, and this is application specific. This is where a distributed lock comes out. Say, if two worker server running a same process that drops a table of the database and add some record to the table. The database server can sure guarantee that its internal data is right, but this two process needs a distributed lock to coordinate each other, otherwise, one process will drop another process's table.
Related Topics
How to Mock New Date() in Java Using Mockito
Detect Internet Connection Using Java
Error: Java_Home Is Not Defined Correctly Executing Maven
How to Achieve Conditional Resource Import in a Spring Xml Context
Java Sorting Based on Enum Constants
Java Benchmarking - Why Is the Second Loop Faster
Is There Any Good and Free Date and Time Picker Available for Java Swing
Javafx and Maven: Nullpointerexception: Location Is Required
Can a Class Have No Constructor
Java 8 Lambda Expression and First-Class Values
Displaying Fancy Equations with Java
How to Change Java Version Used by Tomcat
How to Decode a String Encoded with Openssl Aes-128-Cbc Using Java