lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ganyo <scott.ga...@etapestry.com>
Subject Adding lock timeouts to write.lock
Date Fri, 08 Aug 2003 20:09:28 GMT
As suggested in previous emails, I have implemented the ability to wait 
on any kind of lock.  I've attached the diffs, but here are the highlights:

1) added the following statics to Lock:

    public static long WRITE_LOCK_TIMEOUT = 1000;
    public static long COMMIT_LOCK_TIMEOUT = 10000;
    public static long LOCK_POLL_INTERVAL = 1000;

2) added the following method to Lock:

  /** Attempt to obtain an exclusive lock within amount
   *  of time given. Currently polls once per second until
   *  lockWaitTimeout is passed.
   * @param lockWaitTimeout length of time to wait in ms
   * @return true if lock was obtained
   * @throws IOException if lock wait times out or obtain() throws an 
IOException
   */
  public boolean obtain(long lockWaitTimeout) throws IOException

3) added the following method to Lock.With:

    /** Constructs an executor that will grab the named lock. */
    public With(Lock lock, long lockWaitTimeout)

4) cleaned up Lock.With to use the new obtain(long) method on Lock.

5) changed callers obtaining "write.lock" to pass Lock.WRITE_LOCK_TIMEOUT

6) changed callers obtaining "commit.lock" to pass Lock.COMMIT_LOCK_TIMEOUT

The net effect is to expose the timeout and change the write.lock to 
have a 1 second timeout as a default instead of immediately throwing an 
IOException.

So that there can be a review and comment period, I won't plan to check 
it in Wednesday of next week.

Scott


Mime
View raw message