Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15011: /admin/logging now distributes setLevel to all nodes (#2230)

Nazerke Seidan6509a3003cf8
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 86c99b29ae3..314cb8a4167 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -72,6 +72,9 @@ Improvements
* SOLR-14949: Docker: Ability to customize the FROM image when building.
(Houston Putman)
+* SOLR-15011: /admin/logging handler will now propagate setLevel (log threshold) to all nodes
+when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)
+
Other Changes
----------------------
* SOLR-14656: Autoscaling framework removed (Ishan Chattopadhyaya, noble, Ilan Ginzburg)
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java b/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
index f1f944adbfa..bf6c2fcb265 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
@@ -111,8 +111,8 @@ public class AdminHandlersProxy {
log.warn("Timeout when fetching result from node {}", entry.getKey(), te);
}
}
- if (log.isInfoEnabled()) {
- log.info("Fetched response from {} nodes: {}", responses.keySet().size(), responses.keySet());
+ if (log.isDebugEnabled()) {
+ log.debug("Fetched response from {} nodes: {}", responses.keySet().size(), responses.keySet());
}
return true;
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
index ec27b1ceb30..d0c0e6de6dd 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java
@@ -49,13 +49,15 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware
@SuppressWarnings({"rawtypes"})
private LogWatcher watcher;
+ private final CoreContainer cc;
public LoggingHandler(CoreContainer cc) {
+ this.cc = cc;
this.watcher = cc.getLogging();
}
public LoggingHandler() {
-
+ this.cc = null;
}
@Override
@@ -151,6 +153,9 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware
rsp.add("loggers", info);
}
rsp.setHttpCaching(false);
+ if (cc != null && AdminHandlersProxy.maybeProxyToNodes(req, rsp, cc)) {
+ return; // Request was proxied to other node
+ }
}
// ////////////////////// SolrInfoMBeans methods //////////////////////
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java b/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java
index ee6183bfd27..0d3d65bc293 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java
@@ -18,6 +18,7 @@
package org.apache.solr.handler.admin;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -27,12 +28,17 @@ import org.apache.lucene.util.IOUtils;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -91,6 +97,32 @@ public class AdminHandlersProxyTest extends SolrCloudTestCase {
assertNotNull(((NamedList)nl.get(nl.getName(1))).get("metrics"));
}
+ @Test
+ public void proxyLoggingHandlerAllNodes() throws IOException, SolrServerException {
+ CollectionAdminRequest.createCollection("collection", "conf", 2, 2).process(solrClient);
+ ModifiableSolrParams mparams = new ModifiableSolrParams();
+
+ mparams.set(CommonParams.QT, "/admin/logging");
+ mparams.set("nodes", "all");
+ mparams.set("set", "com.codahale.metrics.jmx.JmxReporter:WARN");
+ solrClient.query("collection", mparams, SolrRequest.METHOD.GET);
+
+ Set<String> nodes = solrClient.getClusterStateProvider().getLiveNodes();
+ nodes.forEach(node -> {
+ mparams.clear();
+ mparams.set(CommonParams.QT, "/admin/logging");
+ mparams.set("nodes", node);
+ QueryResponse rsp = null;
+ try {
+ rsp = solrClient.query("collection", mparams, SolrRequest.METHOD.GET);
+ } catch (Exception e) {
+ fail("Exception while proxying request to node " + node);
+ }
+ NamedList<Object> nl = rsp.getResponse();
+ assertEquals("WARN", ((SimpleOrderedMap) ((ArrayList)nl.get("loggers")).get(5)).get("level"));
+ });
+ }
+
@Test(expected = SolrException.class)
public void proxySystemInfoHandlerNonExistingNode() throws IOException, SolrServerException {
MapSolrParams params = new MapSolrParams(Collections.singletonMap("nodes", "example.com:1234_solr"));
diff --git a/solr/solr-ref-guide/src/configuring-logging.adoc b/solr/solr-ref-guide/src/configuring-logging.adoc
index 9daf322f873..b5cebc0f8b5 100644
--- a/solr/solr-ref-guide/src/configuring-logging.adoc
+++ b/solr/solr-ref-guide/src/configuring-logging.adoc
@@ -38,6 +38,7 @@ When you select **Level**, you see the following menu:
image::images/logging/level_menu.png[image,width=1159,height=577]
Directories are shown with their current logging levels. The Log Level Menu floats over these. To set a log level for a particular directory, select it and click the appropriate log level button.
+The log level change will be distributed to all nodes in the cluster.
Log levels settings are as follows:
diff --git a/solr/webapp/web/js/angular/services.js b/solr/webapp/web/js/angular/services.js
index 51dde424825..4c409a684fc 100644
--- a/solr/webapp/web/js/angular/services.js
+++ b/solr/webapp/web/js/angular/services.js
@@ -61,7 +61,7 @@ solrAdminServices.factory('System',
return $resource('admin/info/logging', {'wt':'json', '_':Date.now()}, {
"events": {params: {since:'0'}},
"levels": {},
- "setLevel": {}
+ "setLevel": {params: {nodes:'all'}}
});
}])
.factory('Zookeeper',