[hibernate-commits] Hibernate SVN: r19974 - search/branches/Branch_3_2/hibernate-search/src/main/java/org/hibernate/search/backend.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jul 20 05:15:34 EDT 2010


Author: epbernard
Date: 2010-07-20 05:15:34 -0400 (Tue, 20 Jul 2010)
New Revision: 19974

Modified:
   search/branches/Branch_3_2/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
Log:
HSEARCH-540 let the queue unsealed to cope with double preparation risk

Due to the flush process being called potentially after the queue processing
and thus the double queue processing registration, we:
 - no longer seal the queue
 - no longer clear the queue
So that the second processing can reprocess the works

Modified: search/branches/Branch_3_2/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- search/branches/Branch_3_2/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java	2010-07-20 09:15:01 UTC (rev 19973)
+++ search/branches/Branch_3_2/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java	2010-07-20 09:15:34 UTC (rev 19974)
@@ -24,24 +24,26 @@
  */
 package org.hibernate.search.backend;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
 
+import org.slf4j.Logger;
+
 import org.hibernate.annotations.common.AssertionFailure;
 import org.hibernate.search.util.LoggerFactory;
-import org.slf4j.Logger;
 
 /**
  * @author Emmanuel Bernard
  */
 public class WorkQueue {
-	
+
 	private static final Logger log = LoggerFactory.make();
-	
+
 	private List<Work> queue;
 
 	private List<LuceneWork> sealedQueue;
+	//is this class supposed to be
+	private boolean usedSealedData;
 
 	public WorkQueue(int size) {
 		queue = new ArrayList<Work>(size);
@@ -56,6 +58,10 @@
 	}
 
 	public void add(Work work) {
+		if ( usedSealedData ) {
+			//something is wrong fail with exception
+			throw new AssertionFailure( "Attempting to add a work in a used sealed queue" );
+		}
 		queue.add(work);
 	}
 
@@ -71,12 +77,22 @@
 
 	public List<LuceneWork> getSealedQueue() {
 		if (sealedQueue == null) throw new AssertionFailure("Access a Sealed WorkQueue which has not been sealed");
+		usedSealedData = true;
 		return sealedQueue;
 	}
 
 	public void setSealedQueue(List<LuceneWork> sealedQueue) {
 		//invalidate the working queue for serializability
-		queue = Collections.EMPTY_LIST;
+		/*
+		 * FIXME workaround for flush phase done later
+		 *
+		 * Due to sometimes flush applied after some beforeCompletion phase
+		 * we cannot safely seal the queue, keep it opened as a temporary measure.
+		 * This is not the proper fix unfortunately as we don't optimize the whole work queue but rather two subsets
+		 *
+		 * when the flush ordering is fixed, add the following line
+		 * queue = Collections.EMPTY_LIST;
+		 */
 		this.sealedQueue = sealedQueue;
 	}
 



More information about the hibernate-commits mailing list