You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/07/31 21:02:33 UTC
lucene-solr:feature/autoscaling: SOLR-11171 Catch
AlreadyClosedException when trying to add triggers while closing.
Repository: lucene-solr
Updated Branches:
refs/heads/feature/autoscaling 4e7af7246 -> 19b06e843
SOLR-11171 Catch AlreadyClosedException when trying to add triggers while closing.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/19b06e84
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/19b06e84
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/19b06e84
Branch: refs/heads/feature/autoscaling
Commit: 19b06e8435e368f75262b23130132a09d003250f
Parents: 4e7af72
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Mon Jul 31 23:01:27 2017 +0200
Committer: Andrzej Bialecki <ab...@apache.org>
Committed: Mon Jul 31 23:02:25 2017 +0200
----------------------------------------------------------------------
.../autoscaling/OverseerTriggerThread.java | 26 ++++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/19b06e84/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
index ca9bb2e..6b7aa91 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
@@ -28,6 +28,7 @@ import java.util.Set;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
+import org.apache.lucene.store.AlreadyClosedException;
import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
import org.apache.solr.client.solrj.cloud.autoscaling.TriggerEventType;
import org.apache.solr.cloud.ZkController;
@@ -72,7 +73,7 @@ public class OverseerTriggerThread implements Runnable, Closeable {
private Map<String, AutoScaling.Trigger> activeTriggers = new HashMap<>();
- private boolean isClosed = false;
+ private volatile boolean isClosed = false;
private AutoScalingConfig autoScalingConfig;
@@ -178,15 +179,24 @@ public class OverseerTriggerThread implements Runnable, Closeable {
// absent then clean up old nodeLost / nodeAdded markers
boolean cleanOldNodeLostMarkers = true;
boolean cleanOldNodeAddedMarkers = true;
- // add new triggers and/or replace and close the replaced triggers
- for (Map.Entry<String, AutoScaling.Trigger> entry : copy.entrySet()) {
- if (entry.getValue().getEventType().equals(TriggerEventType.NODELOST)) {
- cleanOldNodeLostMarkers = false;
+ try {
+ // add new triggers and/or replace and close the replaced triggers
+ for (Map.Entry<String, AutoScaling.Trigger> entry : copy.entrySet()) {
+ if (entry.getValue().getEventType().equals(TriggerEventType.NODELOST)) {
+ cleanOldNodeLostMarkers = false;
+ }
+ if (entry.getValue().getEventType().equals(TriggerEventType.NODEADDED)) {
+ cleanOldNodeAddedMarkers = false;
+ }
+ scheduledTriggers.add(entry.getValue());
}
- if (entry.getValue().getEventType().equals(TriggerEventType.NODEADDED)) {
- cleanOldNodeAddedMarkers = false;
+ } catch (AlreadyClosedException e) {
+ // this _should_ mean that we're closing, complain loudly if that's not the case
+ if (isClosed) {
+ return;
+ } else {
+ throw new IllegalStateException("Caught AlreadyClosedException from ScheduledTriggers, but we're not closed yet!", e);
}
- scheduledTriggers.add(entry.getValue());
}
if (cleanOldNodeLostMarkers) {
log.debug("-- clean old nodeLost markers");