From d459073f6122ea5162e6b5781dab933d0f4fb042 Mon Sep 17 00:00:00 2001 From: Andrzej Bialecki Date: Mon, 21 Aug 2017 18:45:19 +0200 Subject: [PATCH] SOLR-11270: Automatically added SystemLogListener should not prevent deleting a trigger. --- solr/CHANGES.txt | 2 ++ .../solr/cloud/autoscaling/AutoScalingHandler.java | 10 +++++++++- .../solr/cloud/autoscaling/AutoScalingHandlerTest.java | 10 +--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e11f16fa14b..bd2d7a93ea0 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -180,6 +180,8 @@ Other Changes * SOLR-11249: Upgrade Jetty from 9.3.14.v20161028 to 9.3.20.v20170531 (Michael Braun via David Smiley) +* SOLR-11270: Automatically added SystemLogListener should not prevent deleting a trigger. (ab) + ================== 7.0.0 ================== Versions of Major Components diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java index abd85cfa0da..a5d1bc7dd64 100644 --- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java +++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java @@ -601,7 +601,15 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission } } if (!activeListeners.isEmpty()) { - if (removeListeners) { + boolean onlySystemLog = false; + if (activeListeners.size() == 1) { + AutoScalingConfig.TriggerListenerConfig cfg = listeners.get(activeListeners.iterator().next()); + if (SystemLogListener.class.getName().equals(cfg.listenerClass) || + ("solr." + SystemLogListener.class.getSimpleName()).equals(cfg.listenerClass)) { + onlySystemLog = true; + } + } + if (removeListeners || onlySystemLog) { listeners = new HashMap<>(listeners); listeners.keySet().removeAll(activeListeners); } else { diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoScalingHandlerTest.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoScalingHandlerTest.java index 79879e8bb63..335fdbc307b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoScalingHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoScalingHandlerTest.java @@ -355,22 +355,14 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase { "\t\t\"name\" : \"xyz\"\n" + "\t}\n" + "}"; - String removeListenerCommand1 = "{\n" + - "\t\"remove-listener\" : {\n" + - "\t\t\"name\" : \"node_lost_trigger.system\"\n" + - "\t}\n" + - "}"; req = createAutoScalingRequest(SolrRequest.METHOD.POST, removeListenerCommand); response = solrClient.request(req); assertEquals(response.get("result").toString(), "success"); - req = createAutoScalingRequest(SolrRequest.METHOD.POST, removeListenerCommand1); - response = solrClient.request(req); - assertEquals(response.get("result").toString(), "success"); data = zkClient().getData(SOLR_AUTOSCALING_CONF_PATH, null, null, true); loaded = ZkNodeProps.load(data); listeners = (Map) loaded.get("listeners"); assertNotNull(listeners); - assertEquals(0, listeners.size()); + assertEquals(1, listeners.size()); removeTriggerCommand = "{" + "'remove-trigger' : {" +