mirror of https://github.com/apache/lucene.git
added testcase for sysprop.
This commit is contained in:
parent
5b066e091c
commit
621b46179c
|
@ -82,12 +82,17 @@ public class TestPolicyCloud extends SolrCloudTestCase {
|
||||||
}
|
}
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
val = provider.getNodeValues(overseerNode, Arrays.asList("nodeRole", "ip_1","ip_2","ip_3", "ip_4", "sysprop.java.version"));
|
val = provider.getNodeValues(overseerNode, Arrays.asList(
|
||||||
|
"nodeRole",
|
||||||
|
"ip_1","ip_2","ip_3", "ip_4",
|
||||||
|
"sysprop.java.version",
|
||||||
|
"sysprop.java.vendor"));
|
||||||
assertEquals("overseer", val.get("nodeRole"));
|
assertEquals("overseer", val.get("nodeRole"));
|
||||||
assertNotNull( val.get("ip_1"));
|
assertNotNull( val.get("ip_1"));
|
||||||
assertNotNull( val.get("ip_2"));
|
assertNotNull( val.get("ip_2"));
|
||||||
assertNotNull( val.get("ip_3"));
|
assertNotNull( val.get("ip_3"));
|
||||||
assertNotNull( val.get("ip_4"));
|
assertNotNull( val.get("ip_4"));
|
||||||
// assertNotNull( val.get("sysprop.java.version"));
|
assertNotNull( val.get("sysprop.java.version"));
|
||||||
|
assertNotNull( val.get("sysprop.java.vendor"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.solr.client.solrj.impl;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -53,8 +54,8 @@ import org.apache.zookeeper.data.Stat;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**Class that implements {@link ClusterStateProvider} accepting a SolrClient
|
/**
|
||||||
*
|
* Class that implements {@link ClusterStateProvider} accepting a SolrClient
|
||||||
*/
|
*/
|
||||||
public class SolrClientDataProvider implements ClusterDataProvider, MapWriter {
|
public class SolrClientDataProvider implements ClusterDataProvider, MapWriter {
|
||||||
|
|
||||||
|
@ -165,6 +166,7 @@ public class SolrClientDataProvider implements ClusterDataProvider, MapWriter {
|
||||||
@Override
|
@Override
|
||||||
protected void getRemoteInfo(String solrNode, Set<String> requestedTags, SnitchContext ctx) {
|
protected void getRemoteInfo(String solrNode, Set<String> requestedTags, SnitchContext ctx) {
|
||||||
ClientSnitchCtx snitchContext = (ClientSnitchCtx) ctx;
|
ClientSnitchCtx snitchContext = (ClientSnitchCtx) ctx;
|
||||||
|
readSysProps(solrNode, requestedTags, snitchContext);
|
||||||
Set<String> groups = new HashSet<>();
|
Set<String> groups = new HashSet<>();
|
||||||
List<String> prefixes = new ArrayList<>();
|
List<String> prefixes = new ArrayList<>();
|
||||||
if (requestedTags.contains(DISK)) {
|
if (requestedTags.contains(DISK)) {
|
||||||
|
@ -215,7 +217,39 @@ public class SolrClientDataProvider implements ClusterDataProvider, MapWriter {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "", e);
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readSysProps(String solrNode, Set<String> requestedTags, ClientSnitchCtx snitchContext) {
|
||||||
|
List<String> prefixes = null;
|
||||||
|
ModifiableSolrParams params;
|
||||||
|
List<String> sysProp = null;
|
||||||
|
for (String tag : requestedTags) {
|
||||||
|
if (!tag.startsWith(SYSPROP)) continue;
|
||||||
|
if (sysProp == null) {
|
||||||
|
prefixes = new ArrayList<>();
|
||||||
|
sysProp = new ArrayList<>();
|
||||||
|
prefixes.add("system.properties");
|
||||||
|
}
|
||||||
|
sysProp.add(tag.substring(SYSPROP.length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysProp == null) return;
|
||||||
|
params = new ModifiableSolrParams();
|
||||||
|
params.add("prefix", StrUtils.join(prefixes, ','));
|
||||||
|
for (String s : sysProp) params.add("property", s);
|
||||||
|
try {
|
||||||
|
SimpleSolrResponse rsp = snitchContext.invoke(solrNode, CommonParams.METRICS_PATH, params);
|
||||||
|
Map m = rsp.nl.asMap(6);
|
||||||
|
for (String s : sysProp) {
|
||||||
|
Object v = Utils.getObjectByPath(m, true,
|
||||||
|
Arrays.asList("metrics", "solr.jvm", "system.properties", "value", s));
|
||||||
|
if (v != null) snitchContext.getTags().put("sysprop." + s, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "", e);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue