You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/01/29 18:08:38 UTC

svn commit: r501112 - /incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java

Author: mszefler
Date: Mon Jan 29 09:08:37 2007
New Revision: 501112

URL: http://svn.apache.org/viewvc?view=rev&rev=501112
Log:
Better logging for instance lock.

Modified:
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java?view=diff&rev=501112&r1=501111&r2=501112
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InstanceLockManager.java Mon Jan 29 09:08:37 2007
@@ -24,6 +24,9 @@
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 /**
  * 
  * WARNING --- EXPERIMENTAL
@@ -34,11 +37,16 @@
  * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
  */
 public class InstanceLockManager {
-
+    private static final Log __log = LogFactory.getLog(InstanceLockManager.class);
+    
     private final Lock _mutex = new java.util.concurrent.locks.ReentrantLock();
     private final Map<Long, InstanceInfo> _locks = new HashMap<Long,InstanceInfo> ();
     
     public void lock(Long iid, int time, TimeUnit tu) throws InterruptedException, TimeoutException {
+        String thrd = Thread.currentThread().toString();
+        if (__log.isDebugEnabled())
+            __log.debug(thrd + ": lock(iid=" + iid + ", time=" + time + tu+")");
+
         InstanceInfo li;
 
         _mutex.lock();
@@ -49,10 +57,18 @@
                 if (li == null) {
                     li = new InstanceInfo(iid, Thread.currentThread());
                     _locks.put(iid, li);
+                    if (__log.isDebugEnabled())
+                        __log.debug(thrd + ": lock(iid=" + iid + ", time=" + time + tu+")-->GRANTED");                    
                     return;
                 } else {
-                    if (!li.available.await(time, tu)) 
+                    if (__log.isDebugEnabled())
+                        __log.debug(thrd + ": lock(iid=" + iid + ", time=" + time + tu+")-->WAITING(held by " + li.acquierer + ")");
+                    
+                    if (!li.available.await(time, tu)) {
+                        if (__log.isDebugEnabled())
+                            __log.debug(thrd + ": lock(iid=" + iid + ", time=" + time + tu+")-->TIMEOUT (held by " + li.acquierer + ")");
                         throw new TimeoutException();
+                    }
                 }
             }
             
@@ -63,7 +79,10 @@
     }
     
     public void unlock(Long iid)  {
-        
+        String thrd = Thread.currentThread().toString();
+        if (__log.isDebugEnabled())
+            __log.debug(thrd + ": unlock(iid=" + iid + ")");        
+
         _mutex.lock();
         try {
             InstanceInfo li = _locks.get(iid);