SOLR-12444: Updating a cluster policy fails

This commit is contained in:
Noble Paul 2018-06-05 22:29:06 +10:00
parent 6624773613
commit add77d2725
3 changed files with 24 additions and 1 deletions

View File

@ -1312,6 +1312,8 @@ Bug Fixes
* SOLR-11477: Disallow resolving of external entities in the XML query parser (defType=xmlparser).
(Michael Stepankin, Olga Barinova, Uwe Schindler, Christine Poerschke)
* SOLR-12444: Updating a cluster policy fails (noble)
Optimizations
----------------------

View File

@ -17,6 +17,7 @@
package org.apache.solr.cloud.autoscaling;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.Map;
@ -26,6 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
@ -1011,6 +1013,25 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
assertEquals(5L, properties.get(AutoScalingParams.ACTION_THROTTLE_PERIOD_SECONDS));
}
public void testUpdatePolicy() throws IOException, SolrServerException {
CloudSolrClient solrClient = cluster.getSolrClient();
String setPropertiesCommand = "{'set-cluster-policy': [" +
"{'cores': '<4','node': '#ANY'}]}";
solrClient.request(createAutoScalingRequest(SolrRequest.METHOD.POST, setPropertiesCommand));
SolrRequest req = createAutoScalingRequest(SolrRequest.METHOD.GET, null);
NamedList<Object> response = solrClient.request(req);
assertEquals("<4", Utils.getObjectByPath(response,false,"cluster-policy[0]/cores"));
assertEquals("#ANY", Utils.getObjectByPath(response,false,"cluster-policy[0]/node"));
setPropertiesCommand = "{'set-cluster-policy': [" +
"{'cores': '<3','node': '#ANY'}]}";
solrClient.request(createAutoScalingRequest(SolrRequest.METHOD.POST, setPropertiesCommand));
req = createAutoScalingRequest(SolrRequest.METHOD.GET, null);
response = solrClient.request(req);
System.out.println(response);
}
static class AutoScalingRequest extends SolrRequest {
protected final String message;

View File

@ -140,7 +140,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Clause that = (Clause)o;
return compareTo(that) == 0;
return Objects.equals(this.original, that.original);
}
void addTags(Collection<String> params) {