[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Can't get lock to work  XML
Forum Index -> Terracotta Platform
Author Message
vtatai

neo

Joined: 06/15/2012 10:41:26
Messages: 2
Offline

Hello,

I am new to Terracotta, and I am trying to get a simple lock to work with no success - based on the docs I've tried doing:

Code:
 ClusteringToolkit toolkit = new TerracottaClient("localhost:9510").getToolkit();
 ReadWriteLock rwLock = toolkit.getReadWriteLock("foo");
 Lock lock = rwLock.readLock();
 lock.unlock();


With TC server up it connects successfully (I'm using no config file), but then when calling unlock() the following exception is thrown:

Code:
 Exception in thread "main" java.lang.IllegalMonitorStateException
 	at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:363)
 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1317)
 	at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:745)
 	at org.terracotta.locking.TerracottaReadWriteLock$ReadLock.unlock(TerracottaReadWriteLock.java:284)
 	at com.xxxx.services.terracotta.TerracottaLock.main(TerracottaLock.java:41)

Also the client logs don't show anything special AFAICT.

Is there any configuration I need to make in order for this to run? I've also tried using a Terracotta EE server / jars but got the exact same message.

Thanks,

Victor
ari

seraphim

Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline

very close. a rwLock is a lock that supports multiple readers and one writer at a time.

When you get the readLock() you get a HANDLE to the readLock, not a locked readlock.

Try lock.lock(); with your reference to rwLock's readlock before you unlock().

Cheers,

--Ari
[WWW]
vtatai

neo

Joined: 06/15/2012 10:41:26
Messages: 2
Offline

Oh.

Thanks!

V.
 
Forum Index -> Terracotta Platform
Go to:   
Powered by JForum 2.1.7 © JForum Team