You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/02/24 07:12:27 UTC
[20/53] [abbrv] lucene-solr git commit: SOLR-8708: DaemonStream
should catch InterruptedException when reading underlying stream.
SOLR-8708: DaemonStream should catch InterruptedException when reading underlying stream.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2b3529c3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2b3529c3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2b3529c3
Branch: refs/heads/apiv2
Commit: 2b3529c3b8b8ea923b6e86a71b22db0d425ca5e7
Parents: 2fd90cd
Author: jbernste <jb...@apache.org>
Authored: Sat Feb 20 22:33:13 2016 -0500
Committer: jbernste <jb...@apache.org>
Committed: Sat Feb 20 22:35:10 2016 -0500
----------------------------------------------------------------------
.../client/solrj/io/stream/DaemonStream.java | 24 +++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2b3529c3/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
index 358eea4..2f65394 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/DaemonStream.java
@@ -151,7 +151,7 @@ public class DaemonStream extends TupleStream implements Expressible {
}
public void open() {
- this.streamRunner = new StreamRunner(runInterval);
+ this.streamRunner = new StreamRunner(runInterval, id);
this.streamRunner.start();
}
@@ -215,11 +215,13 @@ public class DaemonStream extends TupleStream implements Expressible {
private long sleepMillis = 1000;
private long runInterval;
private long lastRun;
+ private String id;
private boolean shutdown;
- public StreamRunner(long runInterval) {
+ public StreamRunner(long runInterval, String id) {
this.runInterval = runInterval;
+ this.id = id;
}
public synchronized void setShutdown(boolean shutdown) {
@@ -232,6 +234,7 @@ public class DaemonStream extends TupleStream implements Expressible {
}
public void run() {
+ int errors = 0;
setStartTime(new Date().getTime());
OUTER:
while (!getShutdown()) {
@@ -244,6 +247,7 @@ public class DaemonStream extends TupleStream implements Expressible {
while (true) {
Tuple tuple = tupleStream.read();
if (tuple.EOF) {
+ errors = 0; // Reset errors on successful run.
break INNER;
} else if (!eatTuples) {
try {
@@ -255,7 +259,15 @@ public class DaemonStream extends TupleStream implements Expressible {
}
} catch (IOException e) {
exception = e;
- logger.error("Error in DaemonStream", e);
+ logger.error("Error in DaemonStream:"+id, e);
+ ++errors;
+ if(errors > 100) {
+ logger.error("Too many consectutive errors. Stopping DaemonStream:"+id);
+ break OUTER;
+ }
+ } catch (Throwable t) {
+ logger.error("Fatal Error in DaemonStream:"+id, t);
+ //For anything other then IOException break out of the loop and shutdown the thread.
break OUTER;
} finally {
try {
@@ -263,7 +275,7 @@ public class DaemonStream extends TupleStream implements Expressible {
} catch (IOException e1) {
if (exception == null) {
exception = e1;
- logger.error("Error in DaemonStream", e1);
+ logger.error("Error in DaemonStream:"+id, e1);
break OUTER;
}
}
@@ -273,7 +285,7 @@ public class DaemonStream extends TupleStream implements Expressible {
try {
Thread.sleep(sleepMillis);
} catch (InterruptedException e) {
- logger.error("Error in DaemonStream", e);
+ logger.error("Error in DaemonStream:"+id, e);
break OUTER;
}
}
@@ -285,7 +297,7 @@ public class DaemonStream extends TupleStream implements Expressible {
try {
queue.put(tuple);
} catch (InterruptedException e) {
- logger.error("Error in DaemonStream", e);
+ logger.error("Error in DaemonStream:"+id, e);
}
}
setStopTime(new Date().getTime());