Skip to content

Commit 6509a30

Browse files
NazerkeBSNazerke Seidandsmiley
authored
SOLR-15011: /admin/logging now distributes setLevel to all nodes (#2230)
The admin UI will set nodes=all for this. Co-authored-by: Nazerke Seidan <[email protected]> Co-authored-by: David Smiley <[email protected]>
1 parent 8d0cbcb commit 6509a30

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

solr/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Improvements
7272
* SOLR-14949: Docker: Ability to customize the FROM image when building.
7373
(Houston Putman)
7474

75+
* SOLR-15011: /admin/logging handler will now propagate setLevel (log threshold) to all nodes
76+
when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)
77+
7578
Other Changes
7679
----------------------
7780
* SOLR-14656: Autoscaling framework removed (Ishan Chattopadhyaya, noble, Ilan Ginzburg)

solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public static boolean maybeProxyToNodes(SolrQueryRequest req, SolrQueryResponse
111111
log.warn("Timeout when fetching result from node {}", entry.getKey(), te);
112112
}
113113
}
114-
if (log.isInfoEnabled()) {
115-
log.info("Fetched response from {} nodes: {}", responses.keySet().size(), responses.keySet());
114+
if (log.isDebugEnabled()) {
115+
log.debug("Fetched response from {} nodes: {}", responses.keySet().size(), responses.keySet());
116116
}
117117
return true;
118118
}

solr/core/src/java/org/apache/solr/handler/admin/LoggingHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware
4949

5050
@SuppressWarnings({"rawtypes"})
5151
private LogWatcher watcher;
52+
private final CoreContainer cc;
5253

5354
public LoggingHandler(CoreContainer cc) {
55+
this.cc = cc;
5456
this.watcher = cc.getLogging();
5557
}
5658

5759
public LoggingHandler() {
58-
60+
this.cc = null;
5961
}
6062

6163
@Override
@@ -151,6 +153,9 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
151153
rsp.add("loggers", info);
152154
}
153155
rsp.setHttpCaching(false);
156+
if (cc != null && AdminHandlersProxy.maybeProxyToNodes(req, rsp, cc)) {
157+
return; // Request was proxied to other node
158+
}
154159
}
155160

156161
// ////////////////////// SolrInfoMBeans methods //////////////////////

solr/core/src/test/org/apache/solr/handler/admin/AdminHandlersProxyTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.solr.handler.admin;
1919

2020
import java.io.IOException;
21+
import java.util.ArrayList;
2122
import java.util.Collections;
2223
import java.util.Set;
2324
import java.util.concurrent.TimeUnit;
@@ -27,12 +28,17 @@
2728
import org.apache.solr.client.solrj.SolrRequest;
2829
import org.apache.solr.client.solrj.SolrServerException;
2930
import org.apache.solr.client.solrj.impl.CloudSolrClient;
31+
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
3032
import org.apache.solr.client.solrj.request.GenericSolrRequest;
33+
import org.apache.solr.client.solrj.response.QueryResponse;
3134
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
3235
import org.apache.solr.cloud.SolrCloudTestCase;
3336
import org.apache.solr.common.SolrException;
37+
import org.apache.solr.common.params.CommonParams;
3438
import org.apache.solr.common.params.MapSolrParams;
39+
import org.apache.solr.common.params.ModifiableSolrParams;
3540
import org.apache.solr.common.util.NamedList;
41+
import org.apache.solr.common.util.SimpleOrderedMap;
3642
import org.junit.After;
3743
import org.junit.Before;
3844
import org.junit.BeforeClass;
@@ -91,6 +97,32 @@ public void proxyMetricsHandlerAllNodes() throws IOException, SolrServerExceptio
9197
assertNotNull(((NamedList)nl.get(nl.getName(1))).get("metrics"));
9298
}
9399

100+
@Test
101+
public void proxyLoggingHandlerAllNodes() throws IOException, SolrServerException {
102+
CollectionAdminRequest.createCollection("collection", "conf", 2, 2).process(solrClient);
103+
ModifiableSolrParams mparams = new ModifiableSolrParams();
104+
105+
mparams.set(CommonParams.QT, "/admin/logging");
106+
mparams.set("nodes", "all");
107+
mparams.set("set", "com.codahale.metrics.jmx.JmxReporter:WARN");
108+
solrClient.query("collection", mparams, SolrRequest.METHOD.GET);
109+
110+
Set<String> nodes = solrClient.getClusterStateProvider().getLiveNodes();
111+
nodes.forEach(node -> {
112+
mparams.clear();
113+
mparams.set(CommonParams.QT, "/admin/logging");
114+
mparams.set("nodes", node);
115+
QueryResponse rsp = null;
116+
try {
117+
rsp = solrClient.query("collection", mparams, SolrRequest.METHOD.GET);
118+
} catch (Exception e) {
119+
fail("Exception while proxying request to node " + node);
120+
}
121+
NamedList<Object> nl = rsp.getResponse();
122+
assertEquals("WARN", ((SimpleOrderedMap) ((ArrayList)nl.get("loggers")).get(5)).get("level"));
123+
});
124+
}
125+
94126
@Test(expected = SolrException.class)
95127
public void proxySystemInfoHandlerNonExistingNode() throws IOException, SolrServerException {
96128
MapSolrParams params = new MapSolrParams(Collections.singletonMap("nodes", "example.com:1234_solr"));

solr/solr-ref-guide/src/configuring-logging.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ When you select **Level**, you see the following menu:
3838
image::images/logging/level_menu.png[image,width=1159,height=577]
3939

4040
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.
41+
The log level change will be distributed to all nodes in the cluster.
4142

4243
Log levels settings are as follows:
4344

solr/webapp/web/js/angular/services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ solrAdminServices.factory('System',
6161
return $resource('admin/info/logging', {'wt':'json', '_':Date.now()}, {
6262
"events": {params: {since:'0'}},
6363
"levels": {},
64-
"setLevel": {}
64+
"setLevel": {params: {nodes:'all'}}
6565
});
6666
}])
6767
.factory('Zookeeper',

0 commit comments

Comments
 (0)