You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:09:49 UTC
[lucene] 17/33: SOLR-15004: Move around some of the test support
classes so that they can be used in other placement tests (this required
changing visibility of some classes / methods). Allow using the test
framework random() for repeatable randomness.
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch jira/solr-15016
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit d0e989c52e215460d3a1faa426b3724ed30c3b4a
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Wed Nov 25 14:13:05 2020 +0100
SOLR-15004: Move around some of the test support classes so that they can be used in other
placement tests (this required changing visibility of some classes / methods). Allow using
the test framework random() for repeatable randomness.
---
.../placement/impl/AttributeFetcherImpl.java | 4 +-
.../placement/impl/AttributeValuesImpl.java | 2 +-
.../placement/impl/PlacementPlanFactoryImpl.java | 2 +-
.../placement/impl/PlacementPluginConfigImpl.java | 2 +-
.../placement/impl/PlacementRequestImpl.java | 2 +-
.../plugins/AffinityPlacementFactory.java | 31 +++++----
.../placement/plugins/RandomPlacementFactory.java | 11 +++-
.../{impl => }/AttributeFetcherForTest.java | 2 +-
.../cluster/placement/{impl => }/Builders.java | 76 +++++++++++-----------
.../{impl => }/ClusterAbstractionsForTest.java | 2 +-
.../AffinityPlacementFactoryTest.java | 12 ++--
11 files changed, 83 insertions(+), 63 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
index 98367d3..97d4ba1 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
@@ -218,11 +218,11 @@ public class AttributeFetcherImpl implements AttributeFetcher {
}
}
- static String getMetricSnitchTag(String metricName, NodeMetricRegistry registry) {
+ public static String getMetricSnitchTag(String metricName, NodeMetricRegistry registry) {
return SolrClientNodeStateProvider.METRICS_PREFIX + SolrMetricManager.getRegistryName(getGroupFromMetricRegistry(registry), metricName);
}
- static String getSystemPropertySnitchTag(String name) {
+ public static String getSystemPropertySnitchTag(String name) {
return ImplicitSnitch.SYSPROP + name;
}
}
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
index 78c2143..0f4c1ab 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeValuesImpl.java
@@ -34,7 +34,7 @@ public class AttributeValuesImpl implements AttributeValues {
final Map<String, Map<Node, String>> syspropSnitchToNodeToValue;
final Map<String, Map<Node, Double>> metricSnitchToNodeToValue;
- AttributeValuesImpl(Map<Node, Integer> nodeToCoreCount,
+ public AttributeValuesImpl(Map<Node, Integer> nodeToCoreCount,
Map<Node, AttributeFetcher.DiskHardwareType> nodeToDiskType,
Map<Node, Long> nodeToFreeDisk,
Map<Node, Long> nodeToTotalDisk,
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPlanFactoryImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPlanFactoryImpl.java
index 3829372..56071da 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPlanFactoryImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPlanFactoryImpl.java
@@ -24,7 +24,7 @@ import org.apache.solr.cluster.placement.*;
import java.util.Set;
-class PlacementPlanFactoryImpl implements PlacementPlanFactory {
+public class PlacementPlanFactoryImpl implements PlacementPlanFactory {
@Override
public PlacementPlan createPlacementPlan(PlacementRequest request, Set<ReplicaPlacement> replicaPlacements) {
return new PlacementPlanImpl(request, replicaPlacements);
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginConfigImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginConfigImpl.java
index 4c079d4..98d02b7 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginConfigImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginConfigImpl.java
@@ -112,7 +112,7 @@ public class PlacementPluginConfigImpl implements PlacementPluginConfig {
*
* <p>See configuration example and how-to in {@link AffinityPlacementFactory}.</p>
*/
- static PlacementPluginConfig createConfigFromProperties(Map<String, Object> pluginConfig) {
+ public static PlacementPluginConfig createConfigFromProperties(Map<String, Object> pluginConfig) {
final Map<String, String> stringConfigs = new HashMap<>();
final Map<String, Long> longConfigs = new HashMap<>();
final Map<String, Boolean> boolConfigs = new HashMap<>();
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementRequestImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementRequestImpl.java
index 82a26d1..555b103 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementRequestImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementRequestImpl.java
@@ -34,7 +34,7 @@ public class PlacementRequestImpl implements PlacementRequest {
private final Set<Node> targetNodes;
private final EnumMap<Replica.ReplicaType, Integer> countReplicas = new EnumMap<>(Replica.ReplicaType.class);
- PlacementRequestImpl(SolrCollection solrCollection,
+ public PlacementRequestImpl(SolrCollection solrCollection,
Set<String> shardNames, Set<Node> targetNodes,
int countNrtReplicas, int countTlogReplicas, int countPullReplicas) {
this.solrCollection = solrCollection;
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
index 6982b8f..ddddfd7 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java
@@ -17,7 +17,9 @@
package org.apache.solr.cluster.placement.plugins;
-import com.google.common.collect.*;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Ordering;
+import com.google.common.collect.TreeMultimap;
import org.apache.solr.cluster.*;
import org.apache.solr.cluster.placement.*;
import org.apache.solr.common.util.Pair;
@@ -157,7 +159,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
* See {@link AffinityPlacementFactory} for instructions on how to configure a cluster to use this plugin and details
* on what the plugin does.
*/
- static private class AffinityPlacementPlugin implements PlacementPlugin {
+ static class AffinityPlacementPlugin implements PlacementPlugin {
/**
* If a node has strictly less GB of free disk than this value, the node is excluded from assignment decisions.
@@ -173,6 +175,8 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
*/
private final long deprioritizedFreeDiskGB;
+ private Random random = new Random();
+
/**
* The factory has decoded the configuration for the plugin instance and passes it the parameters it needs.
*/
@@ -181,6 +185,11 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
this.deprioritizedFreeDiskGB = deprioritizedFreeDiskGB;
}
+ @VisibleForTesting
+ void setRandom(Random random) {
+ this.random = random;
+ }
+
@SuppressForbidden(reason = "Ordering.arbitrary() has no equivalent in Comparator class. Rather reuse than copy.")
public PlacementPlan computePlacement(Cluster cluster, PlacementRequest request, AttributeFetcher attributeFetcher,
PlacementPlanFactory placementPlanFactory) throws PlacementException {
@@ -205,7 +214,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
// All available zones of live nodes. Due to some nodes not being candidates for placement, and some existing replicas
// being one availability zones that might be offline (i.e. their nodes are not live), this set might contain zones
// on which it is impossible to place replicas. That's ok.
- ImmutableSet<String> availabilityZones = getZonesFromNodes(nodes, attrValues);
+ Set<String> availabilityZones = getZonesFromNodes(nodes, attrValues);
// Build the replica placement decisions here
Set<ReplicaPlacement> replicaPlacements = new HashSet<>();
@@ -225,14 +234,14 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
return placementPlanFactory.createPlacementPlan(request, replicaPlacements);
}
- private ImmutableSet<String> getZonesFromNodes(Set<Node> nodes, final AttributeValues attrValues) {
+ private Set<String> getZonesFromNodes(Set<Node> nodes, final AttributeValues attrValues) {
Set<String> azs = new HashSet<>();
for (Node n : nodes) {
azs.add(getNodeAZ(n, attrValues));
}
- return ImmutableSet.copyOf(azs);
+ return Collections.unmodifiableSet(azs);
}
/**
@@ -247,7 +256,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
/**
* This class captures an availability zone and the nodes that are legitimate targets for replica placement in that
- * Availability Zone. Instances are used as values in a {@link TreeMap} in which the total number of already
+ * Availability Zone. Instances are used as values in a {@link java.util.TreeMap} in which the total number of already
* existing replicas in the AZ is the key. This allows easily picking the set of nodes from which to select a node for
* placement in order to balance the number of replicas per AZ. Picking one of the nodes from the set is done using
* different criteria unrelated to the Availability Zone (picking the node is based on the {@link CoresAndDiskComparator}
@@ -280,7 +289,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
*/
private Pair<EnumMap<Replica.ReplicaType, Set<Node>>, Map<Node, Integer>> getNodesPerReplicaType(Set<Node> nodes, final AttributeValues attrValues) {
EnumMap<Replica.ReplicaType, Set<Node>> replicaTypeToNodes = new EnumMap<>(Replica.ReplicaType.class);
- Map<Node, Integer> coresOnNodes = Maps.newHashMap();
+ Map<Node, Integer> coresOnNodes = new HashMap<>();
for (Replica.ReplicaType replicaType : Replica.ReplicaType.values()) {
replicaTypeToNodes.put(replicaType, new HashSet<>());
@@ -347,7 +356,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
* </ol>
*/
@SuppressForbidden(reason = "Ordering.arbitrary() has no equivalent in Comparator class. Rather reuse than copy.")
- private void makePlacementDecisions(SolrCollection solrCollection, String shardName, ImmutableSet<String> availabilityZones,
+ private void makePlacementDecisions(SolrCollection solrCollection, String shardName, Set<String> availabilityZones,
Replica.ReplicaType replicaType, int numReplicas, final AttributeValues attrValues,
EnumMap<Replica.ReplicaType, Set<Node>> replicaTypeToNodes, Map<Node, Integer> coresOnNodes,
PlacementPlanFactory placementPlanFactory, Set<ReplicaPlacement> replicaPlacements) throws PlacementException {
@@ -356,7 +365,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
// Count existing replicas per AZ. We count only instances the type of replica for which we need to do placement. This
// can be changed in the loop below if we want to count all replicas for the shard.
- Map<String, Integer> azToNumReplicas = Maps.newHashMap();
+ Map<String, Integer> azToNumReplicas = new HashMap<>();
// Add all "interesting" AZ's, i.e. AZ's for which there's a chance we can do placement.
for (String az : availabilityZones) {
azToNumReplicas.put(az, 0);
@@ -391,7 +400,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
// (or try to place) replicas on AZ's that have fewer replicas
// Get the candidate nodes per AZ in order to build (further down) a mapping of AZ to placement candidates.
- Map<String, List<Node>> nodesPerAz = Maps.newHashMap();
+ Map<String, List<Node>> nodesPerAz = new HashMap<>();
for (Node node : candidateNodes) {
String nodeAz = getNodeAZ(node, attrValues);
List<Node> nodesForAz = nodesPerAz.computeIfAbsent(nodeAz, k -> new ArrayList<>());
@@ -450,7 +459,7 @@ public class AffinityPlacementFactory implements PlacementPluginFactory {
// unnecessary imbalance).
// For example, if all nodes have 0 cores and same amount of free disk space, ideally we want to pick a random node
// for placement, not always the same one due to some internal ordering.
- Collections.shuffle(nodes, new Random());
+ Collections.shuffle(nodes, random);
// Sort by increasing number of cores but pushing nodes with low free disk space to the end of the list
nodes.sort(coresAndDiskComparator);
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/RandomPlacementFactory.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/RandomPlacementFactory.java
index b9d3884..27699d8 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/RandomPlacementFactory.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/RandomPlacementFactory.java
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Random;
import java.util.Set;
+import com.google.common.annotations.VisibleForTesting;
import org.apache.solr.cluster.Cluster;
import org.apache.solr.cluster.Node;
import org.apache.solr.cluster.Replica;
@@ -42,7 +43,13 @@ public class RandomPlacementFactory implements PlacementPluginFactory {
return new RandomPlacementPlugin();
}
- static private class RandomPlacementPlugin implements PlacementPlugin {
+ public static class RandomPlacementPlugin implements PlacementPlugin {
+ private Random random = new Random();
+
+ @VisibleForTesting
+ public void setRandom(Random random) {
+ this.random = random;
+ }
public PlacementPlan computePlacement(Cluster cluster, PlacementRequest request, AttributeFetcher attributeFetcher,
PlacementPlanFactory placementPlanFactory) throws PlacementException {
@@ -61,7 +68,7 @@ public class RandomPlacementFactory implements PlacementPluginFactory {
for (String shardName : request.getShardNames()) {
// Shuffle the nodes for each shard so that replicas for a shard are placed on distinct yet random nodes
ArrayList<Node> nodesToAssign = new ArrayList<>(cluster.getLiveNodes());
- Collections.shuffle(nodesToAssign, new Random());
+ Collections.shuffle(nodesToAssign, random);
for (Replica.ReplicaType rt : Replica.ReplicaType.values()) {
placeForReplicaType(request.getCollection(), nodesToAssign, placementPlanFactory, replicaPlacements, shardName, request, rt);
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/AttributeFetcherForTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/cluster/placement/impl/AttributeFetcherForTest.java
rename to solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
index f053d1b..b1cc2a0 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/AttributeFetcherForTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/AttributeFetcherForTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.solr.cluster.placement.impl;
+package org.apache.solr.cluster.placement;
import org.apache.solr.cluster.Node;
import org.apache.solr.cluster.placement.AttributeFetcher;
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/Builders.java b/solr/core/src/test/org/apache/solr/cluster/placement/Builders.java
similarity index 81%
rename from solr/core/src/test/org/apache/solr/cluster/placement/impl/Builders.java
rename to solr/core/src/test/org/apache/solr/cluster/placement/Builders.java
index 1880374..f10135a 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/Builders.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/Builders.java
@@ -1,8 +1,8 @@
-package org.apache.solr.cluster.placement.impl;
+package org.apache.solr.cluster.placement;
import org.apache.solr.cluster.*;
-import org.apache.solr.cluster.placement.AttributeFetcher;
-import org.apache.solr.cluster.placement.AttributeValues;
+import org.apache.solr.cluster.placement.impl.AttributeFetcherImpl;
+import org.apache.solr.cluster.placement.impl.AttributeValuesImpl;
import org.apache.solr.common.util.Pair;
import java.util.*;
@@ -20,11 +20,11 @@ public class Builders {
return new CollectionBuilder(collectionName);
}
- static class ClusterBuilder {
+ public static class ClusterBuilder {
private LinkedList<NodeBuilder> nodeBuilders = new LinkedList<>();
private LinkedList<CollectionBuilder> collectionBuilders = new LinkedList<>();
- ClusterBuilder initializeNodes(int countNodes) {
+ public ClusterBuilder initializeNodes(int countNodes) {
nodeBuilders = new LinkedList<>();
for (int n = 0; n < countNodes; n++) {
nodeBuilders.add(new NodeBuilder().setNodeName("node_" + n)); // Default name, can be changed
@@ -32,21 +32,21 @@ public class Builders {
return this;
}
- LinkedList<NodeBuilder> getNodeBuilders() {
+ public LinkedList<NodeBuilder> getNodeBuilders() {
return nodeBuilders;
}
- ClusterBuilder addCollection(CollectionBuilder collectionBuilder) {
+ public ClusterBuilder addCollection(CollectionBuilder collectionBuilder) {
collectionBuilders.add(collectionBuilder);
return this;
}
- Cluster build() {
+ public Cluster build() {
// TODO if converting all tests to use builders change ClusterImpl ctor to use list of nodes
return new ClusterAbstractionsForTest.ClusterImpl(new HashSet<>(buildLiveNodes()), buildClusterCollections());
}
- List<Node> buildLiveNodes() {
+ public List<Node> buildLiveNodes() {
List<Node> liveNodes = new LinkedList<>();
for (NodeBuilder nodeBuilder : nodeBuilders) {
liveNodes.add(nodeBuilder.build());
@@ -65,7 +65,7 @@ public class Builders {
return clusterCollections;
}
- AttributeFetcher buildAttributeFetcher() {
+ public AttributeFetcher buildAttributeFetcher() {
Map<Node, Integer> nodeToCoreCount = new HashMap<>();
Map<Node, Long> nodeToFreeDisk = new HashMap<>();
Map<String, Map<Node, String>> sysprops = new HashMap<>();
@@ -103,17 +103,17 @@ public class Builders {
}
}
- static class CollectionBuilder {
+ public static class CollectionBuilder {
private final String collectionName;
private LinkedList<ShardBuilder> shardBuilders = new LinkedList<>();
private Map<String, String> customProperties = new HashMap<>();
- private CollectionBuilder(String collectionName) {
+ public CollectionBuilder(String collectionName) {
this.collectionName = collectionName;
}
- private CollectionBuilder addCustomProperty(String name, String value) {
+ public CollectionBuilder addCustomProperty(String name, String value) {
customProperties.put(name, value);
return this;
}
@@ -123,7 +123,7 @@ public class Builders {
* robin to the nodes. The shard leader is the first NRT replica of each shard (or first TLOG is no NRT).
* Shard and replica configuration can be modified afterwards, the returned builder hierarchy is a convenient starting point.
*/
- CollectionBuilder initializeShardsReplicas(int countShards, int countNrtReplicas, int countTlogReplicas,
+ public CollectionBuilder initializeShardsReplicas(int countShards, int countNrtReplicas, int countTlogReplicas,
int countPullReplicas, List<NodeBuilder> nodes) {
Iterator<NodeBuilder> nodeIterator = nodes.iterator();
@@ -174,7 +174,7 @@ public class Builders {
return this;
}
- SolrCollection build() {
+ public SolrCollection build() {
ClusterAbstractionsForTest.SolrCollectionImpl solrCollection = new ClusterAbstractionsForTest.SolrCollectionImpl(collectionName, customProperties);
final LinkedHashMap<String, Shard> shards = new LinkedHashMap<>();
@@ -189,27 +189,27 @@ public class Builders {
}
}
- static class ShardBuilder {
+ public static class ShardBuilder {
private String shardName;
private LinkedList<ReplicaBuilder> replicaBuilders = new LinkedList<>();
private ReplicaBuilder leaderReplicaBuilder;
- ShardBuilder setShardName(String shardName) {
+ public ShardBuilder setShardName(String shardName) {
this.shardName = shardName;
return this;
}
- ShardBuilder setReplicaBuilders(LinkedList<ReplicaBuilder> replicaBuilders) {
+ public ShardBuilder setReplicaBuilders(LinkedList<ReplicaBuilder> replicaBuilders) {
this.replicaBuilders = replicaBuilders;
return this;
}
- ShardBuilder setLeader(ReplicaBuilder leaderReplicaBuilder) {
+ public ShardBuilder setLeader(ReplicaBuilder leaderReplicaBuilder) {
this.leaderReplicaBuilder = leaderReplicaBuilder;
return this;
}
- Shard build(SolrCollection collection) {
+ public Shard build(SolrCollection collection) {
ClusterAbstractionsForTest.ShardImpl shard = new ClusterAbstractionsForTest.ShardImpl(shardName, collection, Shard.ShardState.ACTIVE);
final LinkedHashMap<String, Replica> replicas = new LinkedHashMap<>();
@@ -229,66 +229,66 @@ public class Builders {
}
}
- static class ReplicaBuilder {
+ public static class ReplicaBuilder {
private String replicaName;
private String coreName;
private Replica.ReplicaType replicaType;
private Replica.ReplicaState replicaState;
private NodeBuilder replicaNode;
- ReplicaBuilder setReplicaName(String replicaName) {
+ public ReplicaBuilder setReplicaName(String replicaName) {
this.replicaName = replicaName;
return this;
}
- ReplicaBuilder setCoreName(String coreName) {
+ public ReplicaBuilder setCoreName(String coreName) {
this.coreName = coreName;
return this;
}
- ReplicaBuilder setReplicaType(Replica.ReplicaType replicaType) {
+ public ReplicaBuilder setReplicaType(Replica.ReplicaType replicaType) {
this.replicaType = replicaType;
return this;
}
- ReplicaBuilder setReplicaState(Replica.ReplicaState replicaState) {
+ public ReplicaBuilder setReplicaState(Replica.ReplicaState replicaState) {
this.replicaState = replicaState;
return this;
}
- ReplicaBuilder setReplicaNode(NodeBuilder replicaNode) {
+ public ReplicaBuilder setReplicaNode(NodeBuilder replicaNode) {
this.replicaNode = replicaNode;
return this;
}
- Replica build(Shard shard) {
+ public Replica build(Shard shard) {
return new ClusterAbstractionsForTest.ReplicaImpl(replicaName, coreName, shard, replicaType, replicaState, replicaNode.build());
}
}
- static class NodeBuilder {
+ public static class NodeBuilder {
private String nodeName = null;
private Integer coreCount = null;
private Long freeDiskGB = null;
private Map<String, String> sysprops = null;
private Map<String, Double> metrics = null;
- NodeBuilder setNodeName(String nodeName) {
+ public NodeBuilder setNodeName(String nodeName) {
this.nodeName = nodeName;
return this;
}
- NodeBuilder setCoreCount(Integer coreCount) {
+ public NodeBuilder setCoreCount(Integer coreCount) {
this.coreCount = coreCount;
return this;
}
- NodeBuilder setFreeDiskGB(Long freeDiskGB) {
+ public NodeBuilder setFreeDiskGB(Long freeDiskGB) {
this.freeDiskGB = freeDiskGB;
return this;
}
- NodeBuilder setSysprop(String key, String value) {
+ public NodeBuilder setSysprop(String key, String value) {
if (sysprops == null) {
sysprops = new HashMap<>();
}
@@ -297,7 +297,7 @@ public class Builders {
return this;
}
- NodeBuilder setMetric(AttributeFetcher.NodeMetricRegistry registry, String key, Double value) {
+ public NodeBuilder setMetric(AttributeFetcher.NodeMetricRegistry registry, String key, Double value) {
if (metrics == null) {
metrics = new HashMap<>();
}
@@ -306,23 +306,23 @@ public class Builders {
return this;
}
- Integer getCoreCount() {
+ public Integer getCoreCount() {
return coreCount;
}
- Long getFreeDiskGB() {
+ public Long getFreeDiskGB() {
return freeDiskGB;
}
- Map<String, String> getSysprops() {
+ public Map<String, String> getSysprops() {
return sysprops;
}
- Map<String, Double> getMetrics() {
+ public Map<String, Double> getMetrics() {
return metrics;
}
- Node build() {
+ public Node build() {
// It is ok to build a new instance each time, that instance does the right thing with equals() and hashCode()
return new ClusterAbstractionsForTest.NodeImpl(nodeName);
}
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/ClusterAbstractionsForTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/ClusterAbstractionsForTest.java
similarity index 99%
rename from solr/core/src/test/org/apache/solr/cluster/placement/impl/ClusterAbstractionsForTest.java
rename to solr/core/src/test/org/apache/solr/cluster/placement/ClusterAbstractionsForTest.java
index 059143b..02c1a41 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/ClusterAbstractionsForTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/ClusterAbstractionsForTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.solr.cluster.placement.impl;
+package org.apache.solr.cluster.placement;
import org.apache.solr.cluster.*;
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/AffinityPlacementFactoryTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/cluster/placement/impl/AffinityPlacementFactoryTest.java
rename to solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
index 8f7e130..3869249 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/AffinityPlacementFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
@@ -15,16 +15,19 @@
* limitations under the License.
*/
-package org.apache.solr.cluster.placement.impl;
+package org.apache.solr.cluster.placement.plugins;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.cluster.Cluster;
import org.apache.solr.cluster.Node;
import org.apache.solr.cluster.Replica;
import org.apache.solr.cluster.Shard;
import org.apache.solr.cluster.SolrCollection;
import org.apache.solr.cluster.placement.*;
-import org.apache.solr.cluster.placement.plugins.AffinityPlacementFactory;
-import org.junit.Assert;
+import org.apache.solr.cluster.placement.Builders;
+import org.apache.solr.cluster.placement.impl.PlacementPlanFactoryImpl;
+import org.apache.solr.cluster.placement.impl.PlacementPluginConfigImpl;
+import org.apache.solr.cluster.placement.impl.PlacementRequestImpl;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@@ -40,7 +43,7 @@ import java.util.stream.StreamSupport;
/**
* Unit test for {@link AffinityPlacementFactory}
*/
-public class AffinityPlacementFactoryTest extends Assert {
+public class AffinityPlacementFactoryTest extends SolrTestCaseJ4 {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static PlacementPlugin plugin;
@@ -50,6 +53,7 @@ public class AffinityPlacementFactoryTest extends Assert {
PlacementPluginConfig config = PlacementPluginConfigImpl.createConfigFromProperties(
Map.of("minimalFreeDiskGB", 10L, "deprioritizedFreeDiskGB", 50L));
plugin = new AffinityPlacementFactory().createPluginInstance(config);
+ ((AffinityPlacementFactory.AffinityPlacementPlugin) plugin).setRandom(random());
}
@Test