mirror of https://github.com/apache/lucene.git
SOLR-13484:
autoscaling/diagnostics APIshould be able to give diagnostics output from config pasted as a payload
This commit is contained in:
parent
75f8ae55d0
commit
93ce10e705
|
@ -144,11 +144,15 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
List<String> parts = StrUtils.splitSmart(path, '/');
|
List<String> parts = StrUtils.splitSmart(path, '/');
|
||||||
if (parts.get(0).isEmpty()) parts.remove(0);
|
if (parts.get(0).isEmpty()) parts.remove(0);
|
||||||
if (parts.size() == 3 && SUGGESTIONS.equals(parts.get(2))) {
|
if(parts.size() == 3) {
|
||||||
Map map = (Map) Utils.fromJSON(req.getContentStreams().iterator().next().getStream());
|
Map map = (Map) Utils.fromJSON(req.getContentStreams().iterator().next().getStream());
|
||||||
AutoScalingConfig config = new AutoScalingConfig(map);
|
if (SUGGESTIONS.equals(parts.get(2))) {
|
||||||
handleSuggestions(rsp, config);
|
handleSuggestions(rsp, new AutoScalingConfig(map));
|
||||||
return;
|
return;
|
||||||
|
} else if (DIAGNOSTICS.equals(parts.get(2))) {
|
||||||
|
handleDiagnostics(rsp, new AutoScalingConfig(map));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,26 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
|
||||||
CollectionAdminRequest.deleteCollection(COLLNAME)
|
CollectionAdminRequest.deleteCollection(COLLNAME)
|
||||||
.process(cluster.getSolrClient());
|
.process(cluster.getSolrClient());
|
||||||
}
|
}
|
||||||
|
public void testDiagnosticsWithPayload() throws Exception {
|
||||||
|
CloudSolrClient solrClient = cluster.getSolrClient();
|
||||||
|
String COLLNAME = "testDiagnosticsWithPayload.COLL";
|
||||||
|
CollectionAdminResponse adminResponse = CollectionAdminRequest.createCollection(COLLNAME, CONFIGSET_NAME, 1, 2)
|
||||||
|
.setMaxShardsPerNode(4)
|
||||||
|
.process(solrClient);
|
||||||
|
cluster.waitForActiveCollection(COLLNAME, 1, 2);
|
||||||
|
DocCollection collection = solrClient.getClusterStateProvider().getCollection(COLLNAME);
|
||||||
|
Replica aReplica = collection.getReplicas().get(0);
|
||||||
|
|
||||||
|
String configPayload = "{\n" +
|
||||||
|
" 'cluster-policy': [{'replica': 0, 'node': '_NODE'}]\n" +
|
||||||
|
"}";
|
||||||
|
configPayload = configPayload.replaceAll("_NODE", aReplica.getNodeName());
|
||||||
|
SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, "/diagnostics", configPayload);
|
||||||
|
NamedList<Object> response = solrClient.request(req);
|
||||||
|
assertEquals(response._getStr("diagnostics/violations[0]/node",null),response._getStr("diagnostics/violations[0]/node",null));
|
||||||
|
CollectionAdminRequest.deleteCollection(COLLNAME)
|
||||||
|
.process(cluster.getSolrClient());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuspendTrigger() throws Exception {
|
public void testSuspendTrigger() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue