Revision: 16588
http://sourceforge.net/p/gate/code/16588
Author: valyt
Date: 2013-03-13 09:22:25 +0000 (Wed, 13 Mar 2013)
Log Message:
-----------
Added explicit boolean flag for the closed state. Used to silently abort the
background thread operations if the runner has been closed from a different
thread.
Modified Paths:
--------------
mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
Modified:
mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
===================================================================
--- mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
2013-03-13 08:55:20 UTC (rev 16587)
+++ mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
2013-03-13 09:22:25 UTC (rev 16588)
@@ -39,7 +39,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
@@ -74,7 +73,7 @@
@Override
public void run() {
try {
- while(true) {
+ while(!closed) {
Runnable job = backgroundTasks.take();
if(job == NO_MORE_TASKS) break;
else job.run();
@@ -151,12 +150,17 @@
}
documentHits.set(docIndex, hits);
} else {
+ // this could happen if we've been closed in the mean time
+ if(closed) return;
// we got the wrong document ID
logger.error("Unexpected document ID returned by executor " +
"(got " + newDoc + " while expecting " + docId + "!");
}
}
} catch(IOException e) {
+ // this could happen if we've been closed in the mean time
+ if(closed) return;
+ // otherwise, it's an error
logger.error("Exception while restarting the query executor.", e);
try {
close();
@@ -228,6 +232,9 @@
rankDocuments(docBlockSize -1);
}
} catch (Exception e) {
+ // this could happen if we've been closed in the mean time
+ if(closed) return;
+ // otherwise, it's an error
logger.error("Exception while collecting document IDs", e);
try {
close();
@@ -325,6 +332,11 @@
protected volatile FutureTask<Object> docIdCollectorFuture;
/**
+ * Internal flag used to mark when this query runner has been closed.
+ */
+ protected volatile boolean closed;
+
+ /**
* Creates a query runner in ranking mode.
* @param qNode the {@link QueryNode} for the query being executed.
* @param scorer the {@link MimirScorer} to use for ranking.
@@ -334,6 +346,7 @@
public RankingQueryRunnerImpl(QueryExecutor executor, MimirScorer scorer)
throws IOException {
this.queryExecutor = executor;
this.scorer = scorer;
+ this.closed = false;
ranking = scorer != null;
queryEngine = queryExecutor.getQueryEngine();
docBlockSize = queryEngine.getDocumentBlockSize();
@@ -706,6 +719,7 @@
*/
@Override
public void close() throws IOException {
+ this.closed = true;
try{
if(queryEngine != null) queryEngine.releaseQueryRunner(this);
if(queryExecutor != null) queryExecutor.close();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs