You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by ab...@apache.org on 2009/11/28 22:26:52 UTC
svn commit: r885150 - in /lucene/nutch/trunk: CHANGES.txt
src/java/org/apache/nutch/searcher/FetchedSegments.java
Author: ab
Date: Sat Nov 28 21:26:51 2009
New Revision: 885150
URL: http://svn.apache.org/viewvc?rev=885150&view=rev
Log:
NUTCH-738 Close SegmentUpdater when FetchedSegments is closed.
Modified:
lucene/nutch/trunk/CHANGES.txt
lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
Modified: lucene/nutch/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/CHANGES.txt?rev=885150&r1=885149&r2=885150&view=diff
==============================================================================
--- lucene/nutch/trunk/CHANGES.txt (original)
+++ lucene/nutch/trunk/CHANGES.txt Sat Nov 28 21:26:51 2009
@@ -2,6 +2,9 @@
Unreleased Changes
+* NUTCH-738 Close SegmentUpdater when FetchedSegments is closed
+ (Martina Kich, Kirby Bohling via ab)
+
* NUTCH-746 NutchBeanConstructor does not close NutchBean upon contextDestroyed,
causing resource leak in the container. (Kirby Bohling via ab)
Modified: lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java?rev=885150&r1=885149&r2=885150&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java Sat Nov 28 21:26:51 2009
@@ -66,9 +66,19 @@
private class SegmentUpdater extends Thread {
+ private volatile boolean stopRequested = false;
+
+ @Override
+ public void interrupt() {
+ super.interrupt();
+ stopRequested = true;
+ }
+
+
@Override
public void run() {
- while (true) {
+
+ while (!stopRequested && !Thread.currentThread().isInterrupted()) {
try {
final FileStatus[] fstats = fs.listStatus(segmentsDir,
HadoopFSUtil.getPassDirectoriesFilter(fs));
@@ -194,7 +204,9 @@
private final FileSystem fs;
private final Configuration conf;
private final Path segmentsDir;
- private final SegmentUpdater segUpdater;
+
+ // This must be nullable upon close, so do not declare final.
+ private SegmentUpdater segUpdater;
private final Summarizer summarizer;
/** Construct given a directory containing fetcher output. */
@@ -303,6 +315,13 @@
}
public void close() throws IOException {
+ // Interrupt that thread to convince it to stop running.
+ segUpdater.interrupt();
+
+ // Break reference cycle, otherwise this points to segUpdater, and
+ // segUpdater.$0 points to this. It appeared to keep the thread from
+ // being GC'ed/reaped.
+ segUpdater = null;
final Iterator<Segment> iterator = segments.values().iterator();
while (iterator.hasNext()) {
iterator.next().close();