Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-15011: /admin/logging handler is configured logs to all nodes #2230

Merged
merged 8 commits into from Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -49,25 +49,22 @@ public class LoggingHandler extends RequestHandlerBase implements SolrCoreAware

@SuppressWarnings({"rawtypes"})
private LogWatcher watcher;
private CoreContainer cc;
private final CoreContainer cc;

public LoggingHandler(CoreContainer cc) {
this.cc = cc;
this.watcher = cc.getLogging();
}

public LoggingHandler() {
dsmiley marked this conversation as resolved.
Show resolved Hide resolved

this.cc = null;
}

@Override
public void inform(SolrCore core) {
if (watcher == null) {
watcher = core.getCoreContainer().getLogging();
}
if (cc == null) {
cc = core.getCoreContainer();
}
}

@Override
Expand Down
Expand Up @@ -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;
Expand All @@ -27,12 +28,16 @@
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.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;
Expand All @@ -41,7 +46,9 @@
public class AdminHandlersProxyTest extends SolrCloudTestCase {
private CloseableHttpClient httpClient;
private CloudSolrClient solrClient;

private GenericSolrRequest req;
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
private SimpleSolrResponse rsp;
private ModifiableSolrParams mparams;
@BeforeClass
public static void setupCluster() throws Exception {
System.setProperty("metricsEnabled", "true");
Expand Down Expand Up @@ -91,6 +98,32 @@ public void proxyMetricsHandlerAllNodes() throws IOException, SolrServerExceptio
assertNotNull(((NamedList)nl.get(nl.getName(1))).get("metrics"));
}

@Test
public void proxyLoggingHandlerAllNodes() throws IOException, SolrServerException {
CollectionAdminRequest.createCollection("collection", "conf", 2, 2).process(solrClient);

mparams = new ModifiableSolrParams();
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
mparams.set(CommonParams.QT, "/admin/logging");
mparams.set("nodes", "all");
mparams.set("set", "com.codahale.metrics.jmx.JmxReporter:WARN");
req = new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/logging", mparams);
req.process(solrClient, "collection");

Set<String> nodes = solrClient.getClusterStateProvider().getLiveNodes();
nodes.forEach(node -> {
mparams.clear();
mparams.set("nodes", node);
req = new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/logging", mparams);
try {
rsp = req.process(solrClient, "collection");
} catch (Exception e) {
fail("Exception while proxying request to node " + node);
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
}
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"));
Expand Down
2 changes: 0 additions & 2 deletions solr/webapp/web/js/angular/controllers/logging.js
Expand Up @@ -51,7 +51,6 @@ solrAdminApp.controller('LoggingController',
}
$scope.events = events;
$scope.watcher = data.watcher;
$scope.nodes = 'all';
/* @todo sticky_mode
// state element is in viewport
sticky_mode = ( state.position().top <= $( window ).scrollTop() + $( window ).height() - ( $( 'body' ).height() - state.position().top ) );
Expand Down Expand Up @@ -127,7 +126,6 @@ solrAdminApp.controller('LoggingController',
Logging.levels(function(data) {
$scope.logging = makeTree(data.loggers, "");
$scope.watcher = data.watcher;
$scope.nodes = 'all';
$scope.levels = [];
for (level in data.levels) {
$scope.levels.push({name:data.levels[level], pos:level});
Expand Down