[exo-jcr-commits] exo-jcr SVN: r1477 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/query and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 19 07:18:31 EST 2010


Author: nzamosenchuk
Date: 2010-01-19 07:18:31 -0500 (Tue, 19 Jan 2010)
New Revision: 1477

Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
Log:
EXOJCR-414: Added parameter "max-volatile-time" to QueryHandler config that measures the max age of volatile (in-memory) index. After this time volatile will be flushed to FS in any case (even if the index is under heavy load now). If nothing is configured or "-1" is set, then max age is unlimited. In this case behavior of Indexer flushings is the same as it was before. In cluster configuration this value is set to 60 seconds.

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java	2010-01-19 12:15:17 UTC (rev 1476)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java	2010-01-19 12:18:31 UTC (rev 1477)
@@ -94,6 +94,8 @@
    public static final String PARAM_VOLATILE_IDLE_TIME = "volatile-idle-time";
    
    public static final String PARAM_MAX_VOLATILE_SIZE = "max-volatile-size";
+   
+   public static final String PARAM_MAX_VOLATILE_TIME = "max-volatile-time";
 
    //since https://jira.jboss.org/jira/browse/EXOJCR-17
 

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java	2010-01-19 12:15:17 UTC (rev 1476)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java	2010-01-19 12:18:31 UTC (rev 1477)
@@ -131,6 +131,8 @@
          searchIndex.setVolatileIdleTime(Integer.parseInt(value));
       else if (QueryHandlerParams.PARAM_MAX_VOLATILE_SIZE.equals(name))
          searchIndex.setMaxVolatileIndexSize(Integer.parseInt(value));
+      else if (QueryHandlerParams.PARAM_MAX_VOLATILE_TIME.equals(name))
+         searchIndex.setMaxVolatileTime(Integer.parseInt(value));
       else if (QueryHandlerParams.PARAM_ANALYZER_CLASS.equals(name))
       {
          searchIndex.setAnalyzer(value);

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java	2010-01-19 12:15:17 UTC (rev 1476)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java	2010-01-19 12:18:31 UTC (rev 1477)
@@ -163,6 +163,11 @@
    private long lastFlushTime;
 
    /**
+    * The time this index was last flushed or a transaction was committed.
+    */
+   private long lastFileSystemFlushTime;
+   
+   /**
     * The <code>IndexMerger</code> for this <code>MultiIndex</code>.
     */
    private final IndexMerger merger;
@@ -1060,13 +1065,14 @@
             }
          }
          executeAndLog(new Commit(getTransactionId()));
-
+         
          indexNames.write();
 
          // reset redo log
          redoLog.clear();
 
          lastFlushTime = System.currentTimeMillis();
+         lastFileSystemFlushTime = System.currentTimeMillis();
       }
 
       // delete obsolete indexes
@@ -1150,6 +1156,7 @@
       };
       FLUSH_TIMER.schedule(flushTask, 0, 1000);
       lastFlushTime = System.currentTimeMillis();
+      lastFileSystemFlushTime = System.currentTimeMillis();
    }
 
    /**
@@ -1215,6 +1222,12 @@
          commitVolatileIndex();
          return true;
       }
+      long volatileTime = System.currentTimeMillis() - lastFileSystemFlushTime;
+      if (handler.getMaxVolatileTime() > 0 && volatileTime >= handler.getMaxVolatileTime() * 1000)
+      {
+         commitVolatileIndex();
+         return true;
+      }
       return false;
    }
 

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2010-01-19 12:15:17 UTC (rev 1476)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2010-01-19 12:18:31 UTC (rev 1477)
@@ -143,6 +143,20 @@
    public static final long DEFAULT_EXTRACTOR_TIMEOUT = 100;
 
    /**
+    * The maximum volatile index size in bytes until it is written to disk. The
+    * default value is 1048576 (1MB).
+    */
+   public static final long DEFAULT_MAX_VOLATILE_INDEX_SIZE = 1024 * 1024;
+
+   /**
+    * volatileTime config parameter.
+    * Max age of volatile. It is guaranteed that in any case volatile index will 
+    * be flush to FS not later then in maxVolatileTime seconds.
+    * Default is (-1) that means no maximal timeout set
+    */
+   public static final int DEFAULT_MAX_VOLATILE_TIME = -1;
+   
+   /**
     * The default value for {@link #termInfosIndexDivisor}.
     */
    public static final int DEFAULT_TERM_INFOS_INDEX_DIVISOR = 1;
@@ -183,9 +197,16 @@
     * The maximum volatile index size in bytes until it is written to disk. The
     * default value is 1048576 (1MB).
     */
-   private long maxVolatileIndexSize = 1024 * 1024;
+   private long maxVolatileIndexSize = DEFAULT_MAX_VOLATILE_INDEX_SIZE;
 
    /**
+    * volatileTime config parameter.
+    * Max age of volatile. It is guaranteed that in any case volatile index will 
+    * be flush to FS not later then in maxVolatileTime seconds.
+    */
+   private int maxVolatileTime = DEFAULT_MAX_VOLATILE_TIME;
+   
+   /**
     * volatileIdleTime config parameter.
     */
    private int volatileIdleTime = 3;
@@ -2460,6 +2481,22 @@
    }
 
    /**
+    * @return maxVolatileTime in seconds
+    */
+   public int getMaxVolatileTime()
+   {
+      return maxVolatileTime;
+   }
+
+   /**
+    * @param maxVolatileTime in seconds
+    */
+   public void setMaxVolatileTime(int maxVolatileTime)
+   {
+      this.maxVolatileTime = maxVolatileTime;
+   }
+
+   /**
     * @return the name of the directory manager class.
     */
    public String getDirectoryManagerClass()

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml	2010-01-19 12:15:17 UTC (rev 1476)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jcr-config.xml	2010-01-19 12:18:31 UTC (rev 1477)
@@ -76,6 +76,7 @@
                      <property name="index-dir" value="${java.io.tmpdir}/cluster_nfs/db1/ws" />
                      <property name="changesfilter-class" value="org.exoplatform.services.jcr.impl.core.query.jbosscache.JbossCacheIndexChangesFilter" />
                      <property name="changesfilter-config-path" value="conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml" />
+                     <property name="max-volatile-time" value="60" />
                    </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
@@ -117,6 +118,7 @@
                      <property name="index-dir" value="${java.io.tmpdir}/cluster_nfs/db1/ws1" />
                      <property name="changesfilter-class" value="org.exoplatform.services.jcr.impl.core.query.jbosscache.JbossCacheIndexChangesFilter" />
                      <property name="changesfilter-config-path" value="conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml" />
+                     <property name="max-volatile-time" value="60" />
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">



More information about the exo-jcr-commits mailing list