jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r478986 - in /jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit: core/SearchManager.java core/query/lucene/MultiIndex.java core/state/XAItemStateManager.java util/Timer.java
Date Fri, 24 Nov 2006 20:27:59 GMT
Author: jukka
Date: Fri Nov 24 12:27:58 2006
New Revision: 478986

URL: http://svn.apache.org/viewvc?view=rev&rev=478986
Log:
1.1: Merged revisions 467292 and 469412 (JCR-600)

Added:
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/util/Timer.java
      - copied unchanged from r467292, jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/Timer.java
Modified:
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/SearchManager.java
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java

Modified: jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/SearchManager.java?view=diff&rev=478986&r1=478985&r2=478986
==============================================================================
--- jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/SearchManager.java
(original)
+++ jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/SearchManager.java
Fri Nov 24 12:27:58 2006
@@ -35,6 +35,7 @@
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.PathFormat;
+import org.apache.jackrabbit.util.Timer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,8 +56,6 @@
 import java.util.NoSuchElementException;
 import java.util.Properties;
 import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
 import java.util.WeakHashMap;
 
 /**
@@ -176,7 +175,7 @@
      * Task that checks if the query handler can be shut down because it
      * had been idle for {@link #idleTime} seconds.
      */
-    private final TimerTask idleChecker;
+    private final Timer.Task idleChecker;
 
     /**
      * Idle time in seconds. After the query handler had been idle for this
@@ -267,7 +266,7 @@
         // initialize query handler
         initializeQueryHandler();
 
-        idleChecker = new TimerTask() {
+        idleChecker = new Timer.Task() {
             public void run() {
                 if (lastAccess + (idleTime * 1000) < System.currentTimeMillis()) {
                     int inUse = activeQueries.size();

Modified: jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?view=diff&rev=478986&r1=478985&r2=478986
==============================================================================
--- jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Fri Nov 24 12:27:58 2006
@@ -23,6 +23,7 @@
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.uuid.Constants;
 import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.util.Timer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.lucene.document.Document;
@@ -36,8 +37,6 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
 import java.util.Arrays;
 import java.util.Set;
 import java.util.HashSet;
@@ -167,7 +166,7 @@
      * Task that is periodically called by {@link #FLUSH_TIMER} and checks
      * if index should be flushed.
      */
-    private final TimerTask flushTask;
+    private final Timer.Task flushTask;
 
     /**
      * The RedoLog of this <code>MultiIndex</code>.
@@ -288,7 +287,7 @@
         }
 
         lastFlushTime = System.currentTimeMillis();
-        flushTask = new TimerTask() {
+        flushTask = new Timer.Task() {
             public void run() {
                 checkFlush();
             }

Modified: jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?view=diff&rev=478986&r1=478985&r2=478986
==============================================================================
--- jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
(original)
+++ jackrabbit/branches/1.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java
Fri Nov 24 12:27:58 2006
@@ -31,6 +31,9 @@
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.PropertyType;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.IdentityHashMap;
+import java.util.Collections;
 
 /**
  * Extension to <code>LocalItemStateManager</code> that remembers changes on
@@ -50,15 +53,11 @@
     private static final String DEFAULT_ATTRIBUTE_NAME = "ChangeLog";
 
     /**
-     * ThreadLocal that holds the ChangeLog while this state manager is in one
-     * of the {@link #prepare}, {@link #commit}, {@link #rollback}
-     * methods.
-     */
-    private ThreadLocal commitLog = new ThreadLocal() {
-        protected synchronized Object initialValue() {
-            return new CommitLog();
-        }
-    };
+     * This map holds the ChangeLog on a per thread basis while this state
+     * manager is in one of the {@link #prepare}, {@link #commit}, {@link
+     * #rollback} methods.
+     */
+    private final Map commitLogs = Collections.synchronizedMap(new IdentityHashMap());
 
     /**
      * Current instance-local change log.
@@ -134,7 +133,7 @@
     public void beforeOperation(TransactionContext tx) {
         ChangeLog txLog = (ChangeLog) tx.getAttribute(attributeName);
         if (txLog != null) {
-            ((CommitLog) commitLog.get()).setChanges(txLog);
+            commitLogs.put(Thread.currentThread(), txLog);
         }
     }
 
@@ -195,7 +194,7 @@
      * {@inheritDoc}
      */
     public void afterOperation(TransactionContext tx) {
-        ((CommitLog) commitLog.get()).setChanges(null);
+        commitLogs.remove(Thread.currentThread());
     }
 
     /**
@@ -204,7 +203,7 @@
      * change log was found.
      */
     public ChangeLog getChangeLog() {
-        ChangeLog changeLog = ((CommitLog) commitLog.get()).getChanges();
+        ChangeLog changeLog = (ChangeLog) commitLogs.get(Thread.currentThread());
         if (changeLog == null) {
             changeLog = txLog;
         }
@@ -426,43 +425,6 @@
         if (refs != null) {
             refs.removeReference(sourceId);
             virtualProvider.setNodeReferences(refs);
-        }
-    }
-
-    //--------------------------< inner classes >-------------------------------
-
-    /**
-     * Helper class that serves as a container for a ChangeLog in a ThreadLocal.
-     * The <code>CommitLog</code> is associated with a <code>ChangeLog</code>
-     * while the <code>TransactionalItemStateManager</code> is in the commit
-     * method.
-     */
-    private static class CommitLog {
-
-        /**
-         * The changes that are about to be committed
-         */
-        private ChangeLog changes;
-
-        /**
-         * Sets changes that are about to be committed.
-         *
-         * @param changes that are about to be committed, or <code>null</code>
-         *                if changes have been committed and the commit log should be reset.
-         */
-        private void setChanges(ChangeLog changes) {
-            this.changes = changes;
-        }
-
-        /**
-         * The changes that are about to be committed, or <code>null</code> if
-         * the <code>TransactionalItemStateManager</code> is currently not
-         * committing any changes.
-         *
-         * @return the changes about to be committed.
-         */
-        private ChangeLog getChanges() {
-            return changes;
         }
     }
 }



Mime
View raw message