Author: epbernard
Date: 2010-07-14 14:28:37 -0400 (Wed, 14 Jul 2010)
New Revision: 19951
Modified:
search/trunk/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/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
---
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-07-14
18:28:01 UTC (rev 19950)
+++
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/WorkQueue.java 2010-07-14
18:28:37 UTC (rev 19951)
@@ -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;
}
Show replies by date