lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r418386 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/IndexWriter.java src/test/org/apache/lucene/index/TestIndexWriter.java
Date Fri, 30 Jun 2006 21:46:29 GMT
Author: hossman
Date: Fri Jun 30 14:46:29 2006
New Revision: 418386

URL: http://svn.apache.org/viewvc?rev=418386&view=rev
Log:
LUCENE-621 - new static methods for modifing default lock timeouts

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=418386&r1=418385&r2=418386&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Jun 30 14:46:29 2006
@@ -34,7 +34,15 @@
     subclass allows explain methods to produce Explanations which model
     "matching" independent of having a positive value.
     (Chris Hostetter)
-           
+
+ 6. LUCENE-621: New static methods IndexWriter.setDefaultWriteLockTimeout
+    and IndexWriter.setDefaultCommitLockTimeout for overriding default
+    timeout values for all future instances of IndexWriter (as well
+    as for any other classes that may refrence the static values,
+    ie: IndexReader).
+    (Michael McCandless via Chris Hostetter)
+
+ 
 Bug fixes
 
  1. Fixed the web application demo (built with "ant war-demo") which

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=418386&r1=418385&r2=418386&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Fri Jun 30 14:46:29
2006
@@ -60,15 +60,17 @@
 
   /**
    * Default value for the write lock timeout (1,000).
+   * @see #setDefaultWriteLockTimeout
    */
-  public final static long WRITE_LOCK_TIMEOUT = 1000;
+  public static long WRITE_LOCK_TIMEOUT = 1000;
 
   private long writeLockTimeout = WRITE_LOCK_TIMEOUT;
 
   /**
    * Default value for the commit lock timeout (10,000).
+   * @see #setDefaultCommitLockTimeout
    */
-  public final static long COMMIT_LOCK_TIMEOUT = 10000;
+  public static long COMMIT_LOCK_TIMEOUT = 10000;
 
   private long commitLockTimeout = COMMIT_LOCK_TIMEOUT;
 
@@ -370,7 +372,8 @@
   }
 
   /**
-   * Sets the maximum time to wait for a commit lock (in milliseconds).
+   * Sets the maximum time to wait for a commit lock (in milliseconds) for this instance
of IndexWriter.  @see
+   * @see #setDefaultCommitLockTimeout to change the default value for all instances of IndexWriter.
    */
   public void setCommitLockTimeout(long commitLockTimeout) {
     this.commitLockTimeout = commitLockTimeout;
@@ -384,7 +387,22 @@
   }
 
   /**
-   * Sets the maximum time to wait for a write lock (in milliseconds).
+   * Sets the default (for any instance of IndexWriter) maximum time to wait for a commit
lock (in milliseconds)
+   */
+  public static void setDefaultCommitLockTimeout(long commitLockTimeout) {
+    IndexWriter.COMMIT_LOCK_TIMEOUT = commitLockTimeout;
+  }
+
+  /**
+   * @see #setDefaultCommitLockTimeout
+   */
+  public static long getDefaultCommitLockTimeout() {
+    return IndexWriter.COMMIT_LOCK_TIMEOUT;
+  }
+
+  /**
+   * Sets the maximum time to wait for a write lock (in milliseconds) for this instance of
IndexWriter.  @see
+   * @see #setDefaultWriteLockTimeout to change the default value for all instances of IndexWriter.
    */
   public void setWriteLockTimeout(long writeLockTimeout) {
     this.writeLockTimeout = writeLockTimeout;
@@ -395,6 +413,21 @@
    */
   public long getWriteLockTimeout() {
     return writeLockTimeout;
+  }
+
+  /**
+   * Sets the default (for any instance of IndexWriter) maximum time to wait for a write
lock (in
+   * milliseconds).
+   */
+  public static void setDefaultWriteLockTimeout(long writeLockTimeout) {
+    IndexWriter.WRITE_LOCK_TIMEOUT = writeLockTimeout;
+  }
+
+  /**
+   * @see #setDefaultWriteLockTimeout
+   */
+  public static long getDefaultWriteLockTimeout() {
+    return IndexWriter.WRITE_LOCK_TIMEOUT;
   }
 
   /** Flushes all changes to an index and closes all associated files. */

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=418386&r1=418385&r2=418386&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Jun 30 14:46:29
2006
@@ -27,7 +27,15 @@
         IndexReader reader = null;
         int i;
 
+        IndexWriter.setDefaultWriteLockTimeout(2000);
+        IndexWriter.setDefaultCommitLockTimeout(2000);
+        assertEquals(2000, IndexWriter.getDefaultWriteLockTimeout());
+        assertEquals(2000, IndexWriter.getDefaultCommitLockTimeout());
+
         writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+
+        IndexWriter.setDefaultWriteLockTimeout(1000);
+        IndexWriter.setDefaultCommitLockTimeout(1000);
 
         // add 100 documents
         for (i = 0; i < 100; i++) {



Mime
View raw message