mirror of https://github.com/apache/lucene.git
SOLR-10931: Refactoring the package name for autoscaling client classes
This commit is contained in:
parent
ce4a7911ea
commit
13a3ae2922
|
@ -29,11 +29,11 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.PolicyHelper;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.SolrClientDataProvider;
|
||||
import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider;
|
||||
import org.apache.solr.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.cloud.autoscaling.PolicyHelper;
|
||||
import org.apache.solr.cloud.rule.ReplicaAssigner;
|
||||
import org.apache.solr.cloud.rule.Rule;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -48,7 +48,7 @@ import org.apache.solr.core.CoreContainer;
|
|||
import org.apache.zookeeper.KeeperException;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_PATH;
|
||||
|
|
|
@ -37,12 +37,12 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
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.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException;
|
||||
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.cloud.overseer.OverseerAction;
|
||||
import org.apache.solr.cloud.rule.ReplicaAssigner;
|
||||
import org.apache.solr.cloud.rule.ReplicaAssigner.Position;
|
||||
|
@ -81,7 +81,7 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.common.cloud.DocCollection.SNITCH;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
||||
|
|
|
@ -28,6 +28,11 @@ import java.util.Map;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.solr.api.Api;
|
||||
import org.apache.solr.api.ApiBag;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Cell;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Preference;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Row;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.SolrClientDataProvider;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -139,11 +144,11 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission
|
|||
List<Map<String, Object>> sortedNodes = new ArrayList<>(sorted.size());
|
||||
for (Row row : sorted) {
|
||||
Map<String, Object> map = Utils.makeMap("node", row.node);
|
||||
for (Cell cell : row.cells) {
|
||||
for (Cell cell : row.getCells()) {
|
||||
for (Preference clusterPreference : clusterPreferences) {
|
||||
Policy.SortParam name = clusterPreference.name;
|
||||
if (cell.name.equalsIgnoreCase(name.name())) {
|
||||
map.put(name.name(), cell.val);
|
||||
Policy.SortParam name = clusterPreference.getName();
|
||||
if (cell.getName().equalsIgnoreCase(name.name())) {
|
||||
map.put(name.name(), cell.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.client.solrj.response.RequestStatusState.COMPLETED;
|
||||
import static org.apache.solr.client.solrj.response.RequestStatusState.FAILED;
|
||||
import static org.apache.solr.client.solrj.response.RequestStatusState.NOT_FOUND;
|
||||
|
@ -109,7 +110,6 @@ import static org.apache.solr.cloud.OverseerCollectionMessageHandler.ONLY_IF_DOW
|
|||
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.REQUESTID;
|
||||
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.SHARDS_PROP;
|
||||
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.SHARD_UNIQUE;
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
|
||||
import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
|
||||
import static org.apache.solr.common.cloud.DocCollection.RULE;
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.Suggester;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.Suggester;
|
||||
|
||||
class AddReplicaSuggester extends Suggester {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -23,18 +23,18 @@ import java.util.HashMap;
|
|||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
||||
class Cell implements MapWriter {
|
||||
public class Cell implements MapWriter {
|
||||
final int index;
|
||||
final String name;
|
||||
Object val, approxVal;
|
||||
|
||||
Cell(int index, String name, Object val) {
|
||||
public Cell(int index, String name, Object val) {
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
Cell(int index, String name, Object val, Object approxVal) {
|
||||
public Cell(int index, String name, Object val, Object approxVal) {
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.val = val;
|
||||
|
@ -54,4 +54,16 @@ class Cell implements MapWriter {
|
|||
public Cell copy() {
|
||||
return new Cell(index, name, val, approxVal);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public Object getApproxValue() {
|
||||
return approxVal;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,32 +30,32 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.solr.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.cloud.rule.ImplicitSnitch;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.cloud.autoscaling.Clause.TestStatus.PASS;
|
||||
import static org.apache.solr.cloud.autoscaling.Operand.EQUAL;
|
||||
import static org.apache.solr.cloud.autoscaling.Operand.GREATER_THAN;
|
||||
import static org.apache.solr.cloud.autoscaling.Operand.LESS_THAN;
|
||||
import static org.apache.solr.cloud.autoscaling.Operand.NOT_EQUAL;
|
||||
import static org.apache.solr.cloud.autoscaling.Operand.WILDCARD;
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.ANY;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Clause.TestStatus.PASS;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Operand.EQUAL;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Operand.GREATER_THAN;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Operand.LESS_THAN;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Operand.NOT_EQUAL;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Operand.WILDCARD;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.ANY;
|
||||
import static org.apache.solr.common.params.CoreAdminParams.COLLECTION;
|
||||
import static org.apache.solr.common.params.CoreAdminParams.REPLICA;
|
||||
import static org.apache.solr.common.params.CoreAdminParams.SHARD;
|
||||
|
||||
// a set of conditions in a policy
|
||||
public class Clause implements MapWriter, Comparable<Clause> {
|
||||
Map<String, Object> original;
|
||||
Condition collection, shard, replica, tag, globalTag;
|
||||
public Map<String, Object> original;
|
||||
public Condition collection, shard, replica, tag, globalTag;
|
||||
|
||||
boolean strict = true;
|
||||
|
||||
Clause(Map<String, Object> m) {
|
||||
public Clause(Map<String, Object> m) {
|
||||
this.original = m;
|
||||
strict = Boolean.parseBoolean(String.valueOf(m.getOrDefault("strict", "true")));
|
||||
Optional<String> globalTagName = m.keySet().stream().filter(Policy.GLOBAL_ONLY_TAGS::contains).findFirst();
|
||||
|
@ -125,7 +125,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||
if (tag != null && !params.contains(tag.name)) params.add(tag.name);
|
||||
}
|
||||
|
||||
static class Condition {
|
||||
public static class Condition {
|
||||
final String name;
|
||||
final Object val;
|
||||
final Operand op;
|
||||
|
@ -144,11 +144,11 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||
return op.match(this.val, testVal);
|
||||
}
|
||||
|
||||
boolean isPass(Object inputVal) {
|
||||
public boolean isPass(Object inputVal) {
|
||||
return op.match(val, validate(name, inputVal, false)) == PASS;
|
||||
}
|
||||
|
||||
boolean isPass(Row row) {
|
||||
public boolean isPass(Row row) {
|
||||
return op.match(val, row.getVal(name)) == PASS;
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,18 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||
public Integer delta(Object val) {
|
||||
return op.delta(this.val, val);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public Operand getOperand() {
|
||||
return op;
|
||||
}
|
||||
}
|
||||
|
||||
static Condition parse(String s, Map m) {
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
|
@ -15,15 +15,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.Suggester;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.Suggester;
|
||||
import org.apache.solr.common.util.Pair;
|
||||
|
||||
public class MoveReplicaSuggester extends Suggester {
|
|
@ -15,16 +15,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Clause.TestStatus.FAIL;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Clause.TestStatus.NOT_APPLICABLE;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Clause.TestStatus.PASS;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.ANY;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.cloud.autoscaling.Clause.TestStatus;
|
||||
|
||||
import static org.apache.solr.cloud.autoscaling.Clause.TestStatus.FAIL;
|
||||
import static org.apache.solr.cloud.autoscaling.Clause.TestStatus.NOT_APPLICABLE;
|
||||
import static org.apache.solr.cloud.autoscaling.Clause.TestStatus.PASS;
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.ANY;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause.TestStatus;
|
||||
|
||||
|
||||
public enum Operand {
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -36,7 +36,7 @@ import java.util.function.Supplier;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.common.IteratorWriter;
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.params.CollectionParams.CollectionAction;
|
||||
|
@ -263,7 +263,7 @@ public class Policy implements MapWriter {
|
|||
return new Session(dataProvider);
|
||||
}
|
||||
|
||||
enum SortParam {
|
||||
public enum SortParam {
|
||||
freedisk(0, Integer.MAX_VALUE), cores(0, Integer.MAX_VALUE), heapUsage(0, Integer.MAX_VALUE), sysLoadAvg(0, 100);
|
||||
|
||||
public final int min,max;
|
||||
|
@ -480,7 +480,7 @@ public class Policy implements MapWriter {
|
|||
|
||||
}
|
||||
|
||||
static List<Clause> mergePolicies(String coll,
|
||||
public static List<Clause> mergePolicies(String coll,
|
||||
List<Clause> collPolicy,
|
||||
List<Clause> globalPolicy) {
|
||||
|
||||
|
@ -515,5 +515,7 @@ public class Policy implements MapWriter {
|
|||
ops.put(CollectionAction.MOVEREPLICA, () -> new MoveReplicaSuggester());
|
||||
}
|
||||
|
||||
|
||||
public Map<String, List<Clause>> getPolicies() {
|
||||
return policies;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.Suggester.Hint;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.Suggester.Hint;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CoreAdminParams;
|
||||
import org.apache.solr.common.util.Utils;
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -25,7 +25,7 @@ import org.apache.solr.common.MapWriter;
|
|||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
||||
class Preference implements MapWriter {
|
||||
public class Preference implements MapWriter {
|
||||
final Policy.SortParam name;
|
||||
Integer precision;
|
||||
final Policy.Sort sort;
|
||||
|
@ -82,4 +82,8 @@ class Preference implements MapWriter {
|
|||
ew.put(String.valueOf(e.getKey()), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public Policy.SortParam getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -24,23 +24,23 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.common.IteratorWriter;
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.util.Pair;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
|
||||
import static org.apache.solr.common.params.CoreAdminParams.NODE;
|
||||
|
||||
|
||||
class Row implements MapWriter {
|
||||
public class Row implements MapWriter {
|
||||
public final String node;
|
||||
final Cell[] cells;
|
||||
Map<String, Map<String, List<ReplicaInfo>>> collectionVsShardVsReplicas;
|
||||
public Map<String, Map<String, List<ReplicaInfo>>> collectionVsShardVsReplicas;
|
||||
List<Clause> violations = new ArrayList<>();
|
||||
boolean anyValueMissing = false;
|
||||
|
||||
Row(String node, List<String> params, ClusterDataProvider dataProvider) {
|
||||
public Row(String node, List<String> params, ClusterDataProvider dataProvider) {
|
||||
collectionVsShardVsReplicas = dataProvider.getReplicaInfo(node, params);
|
||||
if (collectionVsShardVsReplicas == null) collectionVsShardVsReplicas = new HashMap<>();
|
||||
this.node = node;
|
||||
|
@ -54,7 +54,7 @@ class Row implements MapWriter {
|
|||
}
|
||||
}
|
||||
|
||||
Row(String node, Cell[] cells, boolean anyValueMissing, Map<String, Map<String, List<ReplicaInfo>>> collectionVsShardVsReplicas, List<Clause> violations) {
|
||||
public Row(String node, Cell[] cells, boolean anyValueMissing, Map<String, Map<String, List<ReplicaInfo>>> collectionVsShardVsReplicas, List<Clause> violations) {
|
||||
this.node = node;
|
||||
this.cells = new Cell[cells.length];
|
||||
for (int i = 0; i < this.cells.length; i++) {
|
||||
|
@ -89,7 +89,7 @@ class Row implements MapWriter {
|
|||
}
|
||||
|
||||
// this adds a replica to the replica info
|
||||
Row addReplica(String coll, String shard) {
|
||||
public Row addReplica(String coll, String shard) {
|
||||
Row row = copy();
|
||||
Map<String, List<ReplicaInfo>> c = row.collectionVsShardVsReplicas.computeIfAbsent(coll, k -> new HashMap<>());
|
||||
List<ReplicaInfo> replicas = c.computeIfAbsent(shard, k -> new ArrayList<>());
|
||||
|
@ -101,7 +101,7 @@ class Row implements MapWriter {
|
|||
|
||||
}
|
||||
|
||||
Pair<Row, ReplicaInfo> removeReplica(String coll, String shard) {
|
||||
public Pair<Row, ReplicaInfo> removeReplica(String coll, String shard) {
|
||||
Row row = copy();
|
||||
Map<String, List<ReplicaInfo>> c = row.collectionVsShardVsReplicas.get(coll);
|
||||
if (c == null) return null;
|
||||
|
@ -113,4 +113,8 @@ class Row implements MapWriter {
|
|||
return new Pair(row, s.remove(0));
|
||||
|
||||
}
|
||||
|
||||
public Cell[] getCells() {
|
||||
return cells;
|
||||
}
|
||||
}
|
|
@ -19,5 +19,5 @@
|
|||
* Common classes for autoscaling parsing filtering nodes and sorting
|
||||
*/
|
||||
|
||||
package org.apache.solr.cloud.autoscaling;
|
||||
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||
|
|
@ -32,10 +32,10 @@ import java.util.Set;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.ClusterDataProvider;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.client.solrj.request.GenericSolrRequest;
|
||||
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
|
||||
import org.apache.solr.cloud.autoscaling.ClusterDataProvider;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.ReplicaInfo;
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
import static org.apache.solr.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.client.solrj.cloud.autoscaling.Policy.POLICY;
|
||||
import static org.apache.solr.common.params.CollectionAdminParams.COUNT_PROP;
|
||||
import static org.apache.solr.common.params.CollectionAdminParams.CREATE_NODE_SET_PARAM;
|
||||
import static org.apache.solr.common.params.CollectionAdminParams.CREATE_NODE_SET_SHUFFLE_PARAM;
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Objects;
|
|||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.apache.solr.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.noggit.JSONUtil;
|
||||
|
|
|
@ -31,9 +31,16 @@ import java.util.Map;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Cell;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.ClusterDataProvider;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Operand;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.PolicyHelper;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Row;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.Policy.Suggester.Hint;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.cloud.autoscaling.Clause.Violation;
|
||||
import org.apache.solr.cloud.autoscaling.Policy.Suggester.Hint;
|
||||
import org.apache.solr.common.params.CollectionParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
@ -219,7 +226,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||
" }" +
|
||||
"}");
|
||||
Policy policy = new Policy(map);
|
||||
List<Clause> clauses = Policy.mergePolicies("mycoll", policy.policies.get("policy1"), policy.clusterPolicy);
|
||||
List<Clause> clauses = Policy.mergePolicies("mycoll", policy.getPolicies().get("policy1"), policy.getClusterPolicy());
|
||||
Collections.sort(clauses);
|
||||
assertEquals(clauses.size(), 4);
|
||||
assertEquals("1", String.valueOf(clauses.get(0).original.get("replica")));
|
||||
|
@ -240,8 +247,8 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||
Policy p = new Policy((Map<String, Object>) Utils.fromJSONString(rules));
|
||||
List<Clause> clauses = new ArrayList<>(p.getClusterPolicy());
|
||||
Collections.sort(clauses);
|
||||
assertEquals("nodeRole", clauses.get(1).tag.name);
|
||||
assertEquals("sysprop.rack", clauses.get(0).tag.name);
|
||||
assertEquals("nodeRole", clauses.get(1).tag.getName());
|
||||
assertEquals("sysprop.rack", clauses.get(0).tag.getName());
|
||||
}
|
||||
|
||||
public void testRules() throws IOException {
|
||||
|
@ -275,9 +282,9 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||
|
||||
List<Violation> violations = session.getViolations();
|
||||
assertEquals(3, violations.size());
|
||||
assertTrue(violations.stream().anyMatch(violation -> "node3".equals(violation.getClause().tag.val)));
|
||||
assertTrue(violations.stream().anyMatch(violation -> "nodeRole".equals(violation.getClause().tag.name)));
|
||||
assertTrue(violations.stream().anyMatch(violation -> (violation.getClause().replica.op == Operand.LESS_THAN && "node".equals(violation.getClause().tag.name))));
|
||||
assertTrue(violations.stream().anyMatch(violation -> "node3".equals(violation.getClause().tag.getValue())));
|
||||
assertTrue(violations.stream().anyMatch(violation -> "nodeRole".equals(violation.getClause().tag.getName())));
|
||||
assertTrue(violations.stream().anyMatch(violation -> (violation.getClause().replica.getOperand() == Operand.LESS_THAN && "node".equals(violation.getClause().tag.getName()))));
|
||||
|
||||
Policy.Suggester suggester = session.getSuggester(ADDREPLICA)
|
||||
.hint(Hint.COLL, "gettingstarted")
|
||||
|
|
Loading…
Reference in New Issue