db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r518419 - /db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
Date Thu, 15 Mar 2007 01:15:35 GMT
Author: arminw
Date: Wed Mar 14 18:15:34 2007
New Revision: 518419

URL: http://svn.apache.org/viewvc?view=rev&rev=518419
Log:
implement new locking-api methods, fix memory-leak (by Bruno CROS)

Modified:
    db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java?view=diff&rev=518419&r1=518418&r2=518419
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java Wed Mar
14 18:15:34 2007
@@ -37,19 +37,34 @@
 {
     private Logger log = LoggerFactory.getLogger(LockManagerInMemoryImpl.class);
     /** The period to search for timed out locks. */
-    private long cleanupFrequency = 10000; // milliseconds.
+    private long cleanupFrequency = 5000; // milliseconds.
     /** The number of lock entries to check for timeout */
-    private int maxLocksToClean = 500;
+    private int maxLocksToClean = 2000;
+    private long runtimePeriodCleanup;
+    private long maxRuntimePeriodCleanup;
+
+    /**
+     * keyLockMap cleaning process frequency
+     */
+    private final int keyCleanupFrequency = 6;
+    /**
+     * keyLockMap cleaning process counter
+     */
+    private int keyCleanupCounter = 0;
+
     /**
      * MBAIRD: a LinkedHashMap returns objects in the order you put them in,
      * while still maintaining an O(1) lookup like a normal hashmap. We can then
      * use this to get the oldest entries very quickly, makes cleanup a breeze.
      */
     private final Map resourceLockMap = new LinkedMap(70);
-    private final Map keyLockMap = new HashMap();
+    private final Map ownerLockMap = new HashMap();
     private final LockIsolationManager lockStrategyManager = new LockIsolationManager();
+
     private long m_lastCleanupAt = System.currentTimeMillis();
     private long lockTimeout;
+    // not supported, use placeholder
+    private final long blockTimeout = 0;
     private long timeoutCounterRead;
     private long timeoutCounterWrite;
 
@@ -68,6 +83,7 @@
     /** Set the period to search for timed out locks. */
     public void setCleanupFrequency(long cleanupFrequency)
     {
+        log.debug("Set cleanup period for timed out locks to " + cleanupFrequency + " ms");
         this.cleanupFrequency = cleanupFrequency;
     }
 
@@ -90,6 +106,7 @@
      */
     public void setMaxLocksToClean(int maxLocksToClean)
     {
+        log.debug("Set the number of lock entries to check for timeout on each lock cleanup
run: " + cleanupFrequency);
         this.maxLocksToClean = maxLocksToClean;
     }
 
@@ -100,6 +117,7 @@
 
     public void setLockTimeout(long timeout)
     {
+        log.debug("Set lock timeout to " + timeout + " ms");
         this.lockTimeout = timeout;
     }
 
@@ -126,25 +144,28 @@
 
         String eol = SystemUtils.LINE_SEPARATOR;
         StringBuffer msg = new StringBuffer("Class: " + LockManagerInMemoryImpl.class.getName()
+ eol);
-        msg.append("lock timeout: ").append(getLockTimeout()).append(" [ms]").append(eol);
-        msg.append("cleanup frequency: ").append(getCleanupFrequency()).append(" [ms]").append(eol);
-        msg.append("max locks to clean: ").append(getMaxLocksToClean()).append(eol);
-        msg.append(eol);
-        msg.append("lock map size: ").append(resourceLockMap.size()).append(eol);
-        msg.append("timed out write locks: ").append(timeoutCounterWrite).append(eol);
-        msg.append("timed out read locks: ").append(timeoutCounterRead).append(eol);
+        msg.append("config: lock timeout=").append(getLockTimeout()).append(" [ms]").append(eol);
+        msg.append("config: cleanup frequency=").append(getCleanupFrequency()).append(" [ms]").append(eol);
+        msg.append("config: max locks to check per cleanup=").append(getMaxLocksToClean()).append(eol);
+        msg.append("statistic: timed out write locks=").append(timeoutCounterWrite).append(eol);
+        msg.append("statistic: timed out read locks=").append(timeoutCounterRead).append(eol);
+        msg.append("statistic: last runtime period to cleanup timed out locks=").append(runtimePeriodCleanup).append("[ms]").append(eol);
+        msg.append("statistic: maximal runtime period to cleanup timed out locks=").append(maxRuntimePeriodCleanup).append("[ms]").append(eol);
+        msg.append("runtime: current locked resources=").append(resourceLockMap.size()).append(eol);
+        msg.append("runtime: owner map size (cleanup periodically)=").append(ownerLockMap.size()).append(eol);
         return msg.toString();
     }
 
-    public boolean readLock(final Object key, final Object resourceId, final IsolationLevels
isolationLevel)
+    public boolean readLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel,
+                            final long lockTimeout, final long blockTimeout)
     {
         if(isolationLevel.ignoreForLock()) return true;
 
-        if(log.isDebugEnabled()) log.debug("LM.readLock(tx-" + key + ", " + resourceId +
")");
+        if(log.isDebugEnabled()) log.debug("Try LM.readLock(" + owner + ", " + resource +
")");
         checkTimedOutLocks();
-        LockEntry reader = new LockEntry(resourceId,
-                key,
-                System.currentTimeMillis(),
+        LockEntry reader = new LockEntry(resource,
+                owner,
+                System.currentTimeMillis() + lockTimeout,
                 LockEntry.LOCK_READ);
         LockIsolation ls = lockStrategyManager.getStrategyFor(isolationLevel);
 
@@ -156,49 +177,57 @@
          */
         synchronized(resourceLockMap)
         {
-            objectLocks = (ObjectLocks) resourceLockMap.get(resourceId);
+            objectLocks = (ObjectLocks) resourceLockMap.get(resource);
             if(objectLocks == null)
             {
                 // no write or read lock, go on
-                objectLocks = new ObjectLocks(resourceId);
-                resourceLockMap.put(resourceId, objectLocks);
+                objectLocks = new ObjectLocks(resource);
+                resourceLockMap.put(resource, objectLocks);
             }
             result = objectLocks.addReader(reader, ls.allowMultipleRead(), ls.allowReadWhenWrite());
-            if(result) associateKeyWithObjectLock(reader.getKey(), objectLocks);
+            if(result) addOwnerLock(reader.getOwner(), objectLocks);
         }
         return result;
     }
 
-    public boolean releaseLock(final Object key, final Object resourceId)
+    public boolean readLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel)
+    {
+        return readLock(owner, resource, isolationLevel, lockTimeout, blockTimeout);
+    }
+
+    public boolean releaseLock(final Object owner, final Object resource)
     {
-        if(log.isDebugEnabled()) log.debug("LM.releaseLock(tx-" + key + ", " + resourceId
+ ")");
+        if(log.isDebugEnabled()) log.debug("LM.releaseLock(" + owner + ", " + resource +
")");
 
         synchronized(resourceLockMap)
         {
-            ObjectLocks lock = (ObjectLocks) resourceLockMap.get(resourceId);
-            return lock != null && lock.releaseLock(key);
+            ObjectLocks lock = (ObjectLocks) resourceLockMap.get(resource);
+            boolean result = lock != null && lock.releaseLock(owner);
+            if(result)
+            {
+                releaseOwnerLock(owner, lock);
+            }
+            return result;
         }
     }
 
     /** @see LockManager#releaseLocks(Object) */
-    public void releaseLocks(final Object key)
+    public void releaseLocks(final Object owner)
     {
-        if(log.isDebugEnabled()) log.debug("LM.releaseLocks(tx-" + key + ")");
+        if(log.isDebugEnabled()) log.debug("LM.releaseLocks(" + owner + ")");
         checkTimedOutLocks();
-        doReleaseLocks(key);
-        //System.out.println("resourceLockMap: " + resourceLockMap.size());
-        //System.out.println("keyLockMap: " + keyLockMap.size());
+        releaseOwnerLocks(owner);
     }
 
-    public boolean writeLock(final Object key, final Object resourceId, final IsolationLevels
isolationLevel)
+    public boolean writeLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel,
+                            final long lockTimeout, final long blockTimeout)
     {
         if(isolationLevel.ignoreForLock()) return true;
-
-        if(log.isDebugEnabled()) log.debug("LM.writeLock(tx-" + key + ", " + resourceId +
")");
+        if(log.isDebugEnabled()) log.debug("Try LM.writeLock(" + owner + ", " + resource
+ ")");
         checkTimedOutLocks();
-        LockEntry writer = new LockEntry(resourceId,
-                key,
-                System.currentTimeMillis(),
+        LockEntry writer = new LockEntry(resource,
+                owner,
+                System.currentTimeMillis() + lockTimeout,
                 LockEntry.LOCK_WRITE);
         LockIsolation ls = lockStrategyManager.getStrategyFor(isolationLevel);
 
@@ -210,65 +239,77 @@
          */
         synchronized(resourceLockMap)
         {
-            objectLocks = (ObjectLocks) resourceLockMap.get(resourceId);
+            objectLocks = (ObjectLocks) resourceLockMap.get(resource);
             // if we don't upgrade, go on
             if(objectLocks == null)
             {
                 // no locks for current entity exist, so go on
-                objectLocks = new ObjectLocks(resourceId);
-                resourceLockMap.put(resourceId, objectLocks);
+                objectLocks = new ObjectLocks(resource);
+                resourceLockMap.put(resource, objectLocks);
             }
             result = objectLocks.addWriter(writer, ls.allowWriteWhenRead());
-            if(result) associateKeyWithObjectLock(writer.getKey(), objectLocks);
+            if(result) addOwnerLock(writer.getOwner(), objectLocks);
         }
         return result;
     }
 
-    public boolean upgradeLock(final Object key, final Object resourceId, final IsolationLevels
isolationLevel)
+    public boolean writeLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel)
+    {
+        return writeLock(owner, resource, isolationLevel, lockTimeout, blockTimeout);
+    }
+
+    public boolean upgradeLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel,
+                            final long lockTimeout, final long blockTimeout)
     {
         if(isolationLevel.ignoreForLock()) return true;
 
-        if(log.isDebugEnabled()) log.debug("LM.upgradeLock(tx-" + key + ", " + resourceId
+ ")");
-        return writeLock(key, resourceId, isolationLevel);
+        if(log.isDebugEnabled()) log.debug("Try LM.upgradeLock(" + owner + ", " + resource
+ ")");
+        return writeLock(owner, resource, isolationLevel, lockTimeout, blockTimeout);
+    }
+
+    public boolean upgradeLock(final Object owner, final Object resource, final IsolationLevels
isolationLevel)
+    {
+        if(log.isDebugEnabled()) log.debug("Try LM.upgradeLock(" + owner + ", " + resource
+ ")");
+        return writeLock(owner, resource, isolationLevel);
     }
 
     /** @see LockManager#hasWrite(Object, Object) */
-    public boolean hasWrite(final Object key, final Object resourceId)
+    public boolean hasWrite(final Object owner, final Object resource)
     {
-        if(log.isDebugEnabled()) log.debug("LM.hasWrite(tx-" + key + ", " + resourceId +
")");
+        if(log.isDebugEnabled()) log.debug("LM.hasWrite(tx-" + owner + ", " + resource +
")");
         checkTimedOutLocks();
 
         ObjectLocks objectLocks;
         synchronized(resourceLockMap)
         {
-            objectLocks = (ObjectLocks) resourceLockMap.get(resourceId);
+            objectLocks = (ObjectLocks) resourceLockMap.get(resource);
             if(objectLocks != null)
             {
-                return objectLocks.hasWriteLock(key);
+                return objectLocks.hasWriteLock(owner);
             }
         }
         return false;
     }
 
-    public boolean hasUpgrade(final Object key, final Object resourceId)
+    public boolean hasUpgrade(final Object owner, final Object resource)
     {
-        if(log.isDebugEnabled()) log.debug("LM.hasUpgrade(tx-" + key + ", " + resourceId
+ ")");
-        return hasWrite(key, resourceId);
+        if(log.isDebugEnabled()) log.debug("LM.hasUpgrade(tx-" + owner + ", " + resource
+ ")");
+        return hasWrite(owner, resource);
     }
 
     /** @see LockManager#hasRead(Object, Object) */
-    public boolean hasRead(final Object key, final Object resourceId)
+    public boolean hasRead(final Object owner, final Object resource)
     {
-        if(log.isDebugEnabled()) log.debug("LM.hasRead(tx-" + key + ", " + resourceId + ')');
+        if(log.isDebugEnabled()) log.debug("LM.hasRead(tx-" + owner + ", " + resource + ')');
         checkTimedOutLocks();
 
         ObjectLocks objectLocks;
         synchronized(resourceLockMap)
         {
-            objectLocks = (ObjectLocks) resourceLockMap.get(resourceId);
+            objectLocks = (ObjectLocks) resourceLockMap.get(resource);
             if(objectLocks != null)
             {
-                return objectLocks.hasReadLock(key);
+                return objectLocks.hasReadLock(owner);
             }
         }
         return false;
@@ -289,7 +330,7 @@
     {
         if(System.currentTimeMillis() - m_lastCleanupAt > cleanupFrequency)
         {
-            removeTimedOutLocks(getLockTimeout());
+            removeTimedOutLocks();
             m_lastCleanupAt = System.currentTimeMillis();
         }
     }
@@ -297,13 +338,15 @@
     /**
      * removes all timed out lock entries from the persistent storage.
      */
-    private void removeTimedOutLocks(long timeout)
+    private void removeTimedOutLocks()
     {
-        int count = 0;
-        long maxAge = System.currentTimeMillis() - timeout;
-        ObjectLocks temp;
         synchronized(resourceLockMap)
         {
+            int count = 0;
+            final long maxAge = System.currentTimeMillis();
+            ObjectLocks temp;
+
+            if(log.isDebugEnabled()) log.debug("Start check for timed out locks");
             Iterator it = resourceLockMap.values().iterator();
             /**
              * run this loop while:
@@ -316,9 +359,10 @@
                 temp = (ObjectLocks) it.next();
                 if(temp.getWriter() != null)
                 {
-                    if(temp.getWriter().getTimestamp() < maxAge)
+                    if(temp.getWriter().getTimeout() < maxAge)
                     {
                         // writer has timed out, set it to null
+                        if(log.isEnabledFor(Logger.INFO)) log.info("Remove timed out write-lock:
" + temp.getWriter());
                         temp.setWriter(null);
                         ++timeoutCounterWrite;
                     }
@@ -328,12 +372,16 @@
                     // all readers are older than timeout.
                     if(temp.lastReader < maxAge)
                     {
+                        if(log.isDebugEnabled()) log.debug("Remove read-locks on resource:
" + temp.getResource());
                         timeoutCounterRead += temp.getReaders().size();
                         if(temp.getWriter() == null)
                         {
                             // all readers and writer are older than timeout,
                             // remove the objectLock from the iterator (which
                             // is backed by the map, so it will be removed.
+
+                            // clear all reader locks, needed to free entries in ownerLockMap
+                            temp.getReaders().clear();
                             it.remove();
                         }
                         else
@@ -352,7 +400,7 @@
                             while(readerIt.hasNext())
                             {
                                 readerLock = (LockEntry) readerIt.next();
-                                if(readerLock.getTimestamp() < maxAge)
+                                if(readerLock.getTimeout() < maxAge)
                                 {
                                     // this read lock is old, remove it.
                                     readerIt.remove();
@@ -375,34 +423,85 @@
                 }
                 count++;
             }
+            /*
+             avoid memory leak in ownerLockMap, we have to search for lost entries
+             if lock was not released after timeout. This could be a very costly check,
+             so we skip this check most of the time
+            */
+            ++keyCleanupCounter;
+			if (keyCleanupCounter >= keyCleanupFrequency)
+            {
+                removeTimedOutLocksOwnerMap();
+                keyCleanupCounter = 0;
+        }
+            runtimePeriodCleanup = System.currentTimeMillis() - maxAge;
+            if(runtimePeriodCleanup > maxRuntimePeriodCleanup) maxRuntimePeriodCleanup
= runtimePeriodCleanup;
+            //System.out.println("period: " + runtimePeriodCleanup);
+    }
+    }
+
+    private void removeTimedOutLocksOwnerMap()
+    {
+        // cleanup no more used keys (BC)
+        Iterator ownerMapIterator = ownerLockMap.values().iterator();
+        while (ownerMapIterator.hasNext())
+        {
+            List list = (List) ownerMapIterator.next();
+            boolean cleanList = true;
+            // iterate ObjectLocks
+            Iterator lockIter = list.iterator();
+            while (lockIter.hasNext())
+            {
+                ObjectLocks lock = (ObjectLocks) lockIter.next();
+                if (!lock.isEmpty())
+                {
+                    cleanList = false;
+                    break;
+                }
+            }
+            // evict the no more used list
+            if (cleanList)
+            {
+                ownerMapIterator.remove();
+                //System.out.println("owner: " + ownerLockMap.size());
+            }
         }
     }
 
-    private void associateKeyWithObjectLock(Object key, ObjectLocks lock)
+    private void addOwnerLock(Object owner, ObjectLocks lock)
     {
-        List list = (List) keyLockMap.get(key);
+        List list = (List) ownerLockMap.get(owner);
         if(list == null)
         {
             list = new ArrayList();
-            keyLockMap.put(key, list);
+            ownerLockMap.put(owner, list);
         }
         if(!list.contains(lock)) list.add(lock);
     }
 
-    private void doReleaseLocks(Object key)
+    private void releaseOwnerLock(Object owner, ObjectLocks lock)
+    {
+        List list = (List) ownerLockMap.get(owner);
+        if(list != null)
+        {
+            list.remove(lock);
+        }
+    }
+
+    private void releaseOwnerLocks(Object owner)
     {
         synchronized(resourceLockMap)
         {
-            List list = (List) keyLockMap.get(key);
+            List list = (List) ownerLockMap.get(owner);
             if(list != null)
             {
                 for(int i = 0; i < list.size(); i++)
                 {
                     ObjectLocks lock = (ObjectLocks) list.get(i);
-                    lock.releaseLock(key);
-                    if(lock.isEmpty()) resourceLockMap.remove(lock.getResourceId());
+                    lock.releaseLock(owner);
+                    if(lock.isEmpty()) resourceLockMap.remove(lock.getResource());
                 }
-                keyLockMap.remove(key);
+                ownerLockMap.remove(owner);
             }
         }
     }
@@ -415,13 +514,13 @@
     {
         private LockEntry writer;
         private Map readers;
-        private Object resourceId;
+        private Object resource;
         private long lastReader = 0;
         private long eldestReader = Long.MAX_VALUE;
 
-        ObjectLocks(Object resourceId)
+        ObjectLocks(Object resource)
         {
-            this.resourceId = resourceId;
+            this.resource = resource;
         }
 
         private void newReaderMap()
@@ -434,23 +533,23 @@
             return writer == null && (readers == null || readers.size() == 0);
         }
 
-        boolean releaseLock(Object key)
+        boolean releaseLock(Object owner)
         {
-            if(writer != null && writer.isOwnedBy(key))
+            if(writer != null && writer.isOwnedBy(owner))
             {
                 writer = null;
                 return true;
             }
             else if(readers != null)
             {
-                return readers.remove(key) != null;
+                return readers.remove(owner) != null;
             }
             return false;
         }
 
-        public Object getResourceId()
+        public Object getResource()
         {
-            return resourceId;
+            return resource;
         }
 
         boolean addWriter(LockEntry writer, boolean allowReaders)
@@ -458,7 +557,7 @@
             boolean result = false;
             if(this.writer != null)
             {
-                result = this.writer.isOwnedBy(writer.getKey());
+                result = this.writer.isOwnedBy(writer.getOwner());
             }
             else // writer was not set
             {
@@ -467,13 +566,13 @@
                 if(readerSize > 0)
                 {
                     // does current entity have already an read lock
-                    if(getReader(writer.getKey()) != null)
+                    if(getReader(writer.getOwner()) != null)
                     {
                         if(readerSize == 1)
                         {
                             // only current entity has a read lock, so go on
                             setWriter(writer);
-                            removeReader(this.writer.getKey());
+                            removeReader(this.writer.getOwner());
                             result = true;
                         }
                         else
@@ -483,7 +582,7 @@
                             if(allowReaders)
                             {
                                 setWriter(writer);
-                                removeReader(this.writer.getKey());
+                                removeReader(this.writer.getOwner());
                                 result = true;
                             }
                         }
@@ -513,15 +612,15 @@
             return this.writer;
         }
 
-        boolean hasWriteLock(Object key)
+        boolean hasWriteLock(Object owner)
         {
-            return writer != null && writer.isOwnedBy(key);
+            return writer != null && writer.isOwnedBy(owner);
         }
 
         private void setWriter(LockEntry writer)
         {
             this.writer = writer;
-            if(this.writer != null) this.resourceId = writer.getResourceId();
+            if(this.writer != null) this.resource = writer.getResource();
         }
 
         Map getReaders()
@@ -529,16 +628,16 @@
             return readers;
         }
 
-        boolean hasReadLock(Object key)
+        boolean hasReadLock(Object owner)
         {
             if(writer != null)
             {
-                return writer.isOwnedBy(key);
+                return writer.isOwnedBy(owner);
             }
             else if(readers != null)
             {
-                LockEntry lock = (LockEntry) readers.get(key);
-                return lock != null && lock.isOwnedBy(key);
+                LockEntry lock = (LockEntry) readers.get(owner);
+                return lock != null && lock.isOwnedBy(owner);
             }
             return false;
         }
@@ -549,7 +648,7 @@
             {
                 return internalAddReader(reader, allowMultipleReader);
             }
-            else if(writer.isOwnedBy(reader.getKey()))
+            else if(writer.isOwnedBy(reader.getOwner()))
             {
                 return true;
             }
@@ -566,20 +665,20 @@
             if(readers == null)
             {
                 newReaderMap();
-                readers.put(reader.getKey(), reader);
+                readers.put(reader.getOwner(), reader);
             }
             else if(readers.size() == 0)
             {
-                readers.put(reader.getKey(), reader);
+                readers.put(reader.getOwner(), reader);
             }
             else
             {
-                if(this.readers.get(reader.getKey()) != null)
+                if(this.readers.get(reader.getOwner()) != null)
                 {
                 }
                 else if(allowMultipleReader)
                 {
-                    this.readers.put(reader.getKey(), reader);
+                    this.readers.put(reader.getOwner(), reader);
                 }
                 else
                 {
@@ -588,20 +687,20 @@
             }
             if(result)
             {
-                if(reader.timestamp > lastReader) lastReader = reader.timestamp;
-                if(reader.timestamp < eldestReader) eldestReader = reader.timestamp;
+                if(reader.timeout > lastReader) lastReader = reader.timeout;
+                if(reader.timeout < eldestReader) eldestReader = reader.timeout;
             }
             return result;
         }
 
-        LockEntry getReader(Object key)
+        LockEntry getReader(Object owner)
         {
-            return this.readers != null ? (LockEntry) this.readers.get(key) : null;
+            return this.readers != null ? (LockEntry) this.readers.get(owner) : null;
         }
 
-        LockEntry removeReader(Object key)
+        LockEntry removeReader(Object owner)
         {
-            return this.readers != null ? (LockEntry) this.readers.remove(key) : null;
+            return this.readers != null ? (LockEntry) this.readers.remove(owner) : null;
         }
     }
 
@@ -619,13 +718,13 @@
         static final int LOCK_WRITE = 1;
 
         /** the object to be locked. */
-        private Object resourceId;
+        private Object resource;
 
-        /** key for locked object */
-        private Object key;
+        /** owner of the locked object */
+        private Object owner;
 
         /** the timestamp marking the time of acquisition of this lock */
-        private long timestamp;
+        private long timeout;
 
         /**
          * marks if this is a read or a write lock.
@@ -635,34 +734,34 @@
         private int lockType;
 
         /** Multiargument constructor for fast loading of LockEntries by OJB. */
-        public LockEntry(Object resourceId,
-                         Object key,
-                         long timestamp,
+        LockEntry(Object resource,
+                         Object owner,
+                         long timeout,
                          int lockType)
         {
-            this.resourceId = resourceId;
-            this.key = key;
-            this.timestamp = timestamp;
+            this.resource = resource;
+            this.owner = owner;
+            this.timeout = timeout;
             this.lockType = lockType;
 
         }
 
         /** Returns the resource id of the locked object (or the locked object itself). */
-        public Object getResourceId()
+        public Object getResource()
         {
-            return resourceId;
+            return resource;
         }
 
         /** Returns lock key. */
-        public Object getKey()
+        public Object getOwner()
         {
-            return key;
+            return owner;
         }
 
         /** returns the timestamp of the acqusition of the lock. */
-        public long getTimestamp()
+        public long getTimeout()
         {
-            return timestamp;
+            return timeout;
         }
 
         /**
@@ -686,40 +785,45 @@
             this.lockType = locktype;
         }
 
-        /** Returns true if this lock is owned by the specified key. */
-        public boolean isOwnedBy(Object key)
+        /** Returns true if this lock is owned by the specified owner. */
+        public boolean isOwnedBy(Object owner)
         {
-            return this.getKey().equals(key);
+            return this.getOwner().equals(owner);
         }
 
         /**
-         * Sets the resourceId.
+         * Sets the resource.
          *
-         * @param resourceId The resourceId to set
+         * @param resource The resource to set
          */
-        public void setresourceId(String resourceId)
+        public void setResource(String resource)
         {
-            this.resourceId = resourceId;
+            this.resource = resource;
         }
 
         /**
          * Sets the timestamp.
          *
-         * @param timestamp The timestamp to set
+         * @param timeout The timestamp to set
          */
-        public void setTimestamp(long timestamp)
+        public void setTimeout(long timeout)
         {
-            this.timestamp = timestamp;
+            this.timeout = timeout;
         }
 
         /**
          * Sets the key.
          *
-         * @param key The key to set
+         * @param owner The key to set
          */
-        public void setKey(Object key)
+        public void setOwner(Object owner)
+        {
+            this.owner = owner;
+        }
+
+        public String toString()
         {
-            this.key = key;
+            return "LockEntry[resource=" + resource + ", owner=" + owner + "]";
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message