Distributed Lock Service

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:

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

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



Leave a reply



Submit