This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_10x in repository https://gitbox.apache.org/repos/asf/solr.git
commit 1172e9a7c776d0bacee3653ce879deafe10c631d Author: Eric Pugh <[email protected]> AuthorDate: Wed Jul 22 12:35:19 2026 -0400 Java cleanups in o.a.s.cluster.events files (#4554) (cherry picked from commit 5566b8bd3b45969eafaa7b4304fe8cfa87907b38) --- .../apache/solr/cluster/events/ClusterEvent.java | 4 +- .../cluster/events/ClusterEventProducerBase.java | 4 +- .../events/impl/ClusterEventProducerFactory.java | 9 ++- .../impl/CollectionsRepairEventListener.java | 8 +-- .../impl/DelegatingClusterEventProducer.java | 2 +- .../solr/cluster/placement/AttributeFetcher.java | 2 +- .../solr/cluster/placement/BalanceRequest.java | 2 - .../solr/cluster/placement/CollectionMetrics.java | 2 +- .../org/apache/solr/cluster/placement/Metric.java | 2 +- .../solr/cluster/placement/PlacementContext.java | 2 +- .../solr/cluster/placement/PlacementException.java | 5 -- .../placement/PlacementModificationException.java | 8 --- .../solr/cluster/placement/PlacementPlugin.java | 2 +- .../solr/cluster/placement/ShardMetrics.java | 2 +- .../placement/impl/AttributeFetcherImpl.java | 5 +- .../cluster/placement/impl/BalanceRequestImpl.java | 5 -- .../solr/cluster/placement/impl/MetricImpl.java | 6 +- .../placement/impl/ModificationRequestImpl.java | 30 ---------- .../cluster/placement/impl/NodeMetricImpl.java | 9 --- .../impl/PlacementPluginAssignStrategy.java | 7 +-- .../impl/PlacementPluginFactoryLoader.java | 28 ++++----- .../impl/SimpleClusterAbstractionsImpl.java | 69 ++++++++-------------- .../placement/plugins/AffinityPlacementConfig.java | 5 +- 23 files changed, 59 insertions(+), 159 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEvent.java b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEvent.java index f2fb184fb07..c800ce8b6f0 100644 --- a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEvent.java +++ b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEvent.java @@ -32,8 +32,8 @@ public interface ClusterEvent { COLLECTIONS_REMOVED, /** Cluster properties have changed. */ CLUSTER_PROPERTIES_CHANGED - // other types? eg. Overseer leader change, shard leader change, - // node overload (eg. CPU / MEM circuit breakers tripped)? + // other types? e.g. Overseer leader change, shard leader change, + // node overload (e.g. CPU / MEM circuit breakers tripped)? } /** Get event type. */ diff --git a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java index ee16baf41fe..376d331c07d 100644 --- a/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java +++ b/solr/core/src/java/org/apache/solr/cluster/events/ClusterEventProducerBase.java @@ -84,9 +84,7 @@ public abstract class ClusterEventProducerBase implements ClusterEventProducer { @Override public void close() throws IOException { synchronized (listeners) { - listeners - .values() - .forEach(listenerSet -> listenerSet.forEach(listener -> IOUtils.closeQuietly(listener))); + listeners.values().forEach(listenerSet -> listenerSet.forEach(IOUtils::closeQuietly)); } } diff --git a/solr/core/src/java/org/apache/solr/cluster/events/impl/ClusterEventProducerFactory.java b/solr/core/src/java/org/apache/solr/cluster/events/impl/ClusterEventProducerFactory.java index e7401940ad7..e7f57cbcca9 100644 --- a/solr/core/src/java/org/apache/solr/cluster/events/impl/ClusterEventProducerFactory.java +++ b/solr/core/src/java/org/apache/solr/cluster/events/impl/ClusterEventProducerFactory.java @@ -93,13 +93,13 @@ public class ClusterEventProducerFactory extends ClusterEventProducerBase { /** * Create a {@link ClusterEventProducer} based on the current plugin configurations. * - * <p>NOTE: this method can only be called once because it has side-effects, such as transferring + * <p>NOTE: this method can only be called once because it has side effects, such as transferring * the initially collected listeners to the resulting producer's instance, and installing a {@link * org.apache.solr.api.ContainerPluginsRegistry.PluginRegistryListener}. Calling this method more * than once will result in an exception. * * @param plugins current plugin configurations - * @return configured instance of cluster event producer (with side-effects, see above) + * @return configured instance of cluster event producer (with side effects, see above) */ public DelegatingClusterEventProducer create(ContainerPluginsRegistry plugins) { if (created) { @@ -201,9 +201,8 @@ public class ClusterEventProducerFactory extends ClusterEventProducerBase { plugins.unregisterListener(initialPluginListener); // transfer listeners that are already registered listeners.forEach( - (type, listenersSet) -> { - listenersSet.forEach(listener -> target.registerListener(listener, type)); - }); + (type, listenersSet) -> + listenersSet.forEach(listener -> target.registerListener(listener, type))); listeners.clear(); } } diff --git a/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java b/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java index 0d8c26d6c06..134e3d075e7 100644 --- a/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java +++ b/solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java @@ -195,10 +195,7 @@ public class CollectionsRepairEventListener newPositions.put(coll.getName(), positions); } catch (Exception e) { log.warn( - "Exception computing positions for {}/{}: {}", - coll.getName(), - shard, - e); + "Exception computing positions for {}/{}", coll.getName(), shard, e); } }); }); @@ -229,8 +226,7 @@ public class CollectionsRepairEventListener try { solrClient.request(addReplica); } catch (Exception e) { - log.warn( - "Exception calling ADDREPLICA {}: {}", addReplica.getParams().toQueryString(), e); + log.warn("Exception calling ADDREPLICA {}", addReplica.getParams().toQueryString(), e); } }); } diff --git a/solr/core/src/java/org/apache/solr/cluster/events/impl/DelegatingClusterEventProducer.java b/solr/core/src/java/org/apache/solr/cluster/events/impl/DelegatingClusterEventProducer.java index 551b9bfd397..61fffdf5c98 100644 --- a/solr/core/src/java/org/apache/solr/cluster/events/impl/DelegatingClusterEventProducer.java +++ b/solr/core/src/java/org/apache/solr/cluster/events/impl/DelegatingClusterEventProducer.java @@ -96,7 +96,7 @@ public final class DelegatingClusterEventProducer extends ClusterEventProducerBa log.debug("--- started delegate {}", delegate); } } catch (Exception e) { - log.warn("Unable to start the new delegate {}: {}", delegate.getClass().getName(), e); + log.warn("Unable to start the new delegate {}", delegate.getClass().getName(), e); } } else { if (log.isDebugEnabled()) { diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java index a751d4bc08d..09186a0afa6 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/AttributeFetcher.java @@ -65,7 +65,7 @@ public interface AttributeFetcher { /** * Fetches all requested node attributes from all nodes passed to {@link #fetchFrom(Set)} as well * as non-node attributes (those requested using e.g. {@link - * #requestCollectionMetrics(SolrCollection, Set)}. + * #requestCollectionMetrics(SolrCollection, Set)}). * * @return An instance allowing retrieval of all attributes that could be fetched. */ diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/BalanceRequest.java b/solr/core/src/java/org/apache/solr/cluster/placement/BalanceRequest.java index f967b7fa808..9dfb0ee56e1 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/BalanceRequest.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/BalanceRequest.java @@ -43,6 +43,4 @@ public interface BalanceRequest extends ModificationRequest { * the error itself rather than calling the plugin). */ Set<Node> getNodes(); - - int getMaximumBalanceSkew(); } diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/CollectionMetrics.java b/solr/core/src/java/org/apache/solr/cluster/placement/CollectionMetrics.java index c6afc8b480d..d0a8681ccd5 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/CollectionMetrics.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/CollectionMetrics.java @@ -21,7 +21,7 @@ import java.util.Iterator; import java.util.Optional; /** - * Collection-level metrics. Currently this class is a container just for shard-level metrics but + * Collection-level metrics. Currently, this class is a container just for shard-level metrics but * future versions may add other primitive collection-level metrics. */ public interface CollectionMetrics { diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/Metric.java b/solr/core/src/java/org/apache/solr/cluster/placement/Metric.java index afa1040b96a..5ddd0d0d456 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/Metric.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/Metric.java @@ -23,7 +23,7 @@ package org.apache.solr.cluster.placement; */ public interface Metric<T> { - /** Return the short-hand name that identifies this attribute. */ + /** Return the shorthand name that identifies this attribute. */ String getName(); /** Return the internal name of a Solr metric associated with this attribute. */ diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementContext.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementContext.java index be7b0282a79..ae161610e60 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementContext.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementContext.java @@ -33,7 +33,7 @@ public interface PlacementContext { /** * Factory used by the plugin to fetch additional attributes from the cluster nodes, such as count - * of cores, system properties etc.. + * of cores, system properties etc. */ AttributeFetcher getAttributeFetcher(); diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementException.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementException.java index bbe49f62746..c50b667ee52 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementException.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementException.java @@ -39,9 +39,4 @@ public class PlacementException extends Exception { public PlacementException(Throwable cause) { super(cause); } - - protected PlacementException( - String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } } diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementModificationException.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementModificationException.java index 30439188a22..cd780d83bcf 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementModificationException.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementModificationException.java @@ -27,10 +27,6 @@ import java.util.Map; public class PlacementModificationException extends PlacementException { private final Map<String, String> rejectedModifications = new HashMap<>(); - public PlacementModificationException() { - super(); - } - public PlacementModificationException(String message) { super(message); } @@ -39,10 +35,6 @@ public class PlacementModificationException extends PlacementException { super(message, cause); } - public PlacementModificationException(Throwable cause) { - super(cause); - } - /** * Add information about the modification that cause this exception. * diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java index d2924d344b8..6bc14205f2e 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/PlacementPlugin.java @@ -98,5 +98,5 @@ public interface PlacementPlugin { */ default void verifyAllowedModification( ModificationRequest modificationRequest, PlacementContext placementContext) - throws PlacementException, InterruptedException {} + throws PlacementException {} } diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/ShardMetrics.java b/solr/core/src/java/org/apache/solr/cluster/placement/ShardMetrics.java index 0ca45267ff0..3be201f1d6f 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/ShardMetrics.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/ShardMetrics.java @@ -20,7 +20,7 @@ import java.util.Iterator; import java.util.Optional; /** - * Shard-level metrics. Currently this is just a container for replica-level metrics but future + * Shard-level metrics. Currently, this is just a container for replica-level metrics but future * versions may add other primitive shard-level metrics. */ public interface ShardMetrics { 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 2aa4203f91a..cca227000f7 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 @@ -101,7 +101,7 @@ public class AttributeFetcherImpl implements AttributeFetcher { // In order to match the returned values for the various snitches, we need to keep track of // where each received value goes. Given the target maps are of different types (the maps from // Node to whatever defined above) we instead pass a function taking two arguments, the node and - // the (non null) returned value, that will cast the value into the appropriate type for the + // the (non-null) returned value, that will cast the value into the appropriate type for the // snitch tag and insert it into the appropriate map with the node as the key. for (String sysPropSnitch : requestedNodeSystemSnitchTags) { systemSnitchToNodeToValue.put(sysPropSnitch, new HashMap<>()); @@ -207,11 +207,10 @@ public class AttributeFetcherImpl implements AttributeFetcher { Map<String, Map<Node, String>> systemSnitchToNodeToValue, Map<NodeMetric<?>, Map<Node, Object>> metricSnitchToNodeToValue) { - Set<String> allRequestedTags = new HashSet<>(); Map<String, NodeMetric<?>> tagToMetric = new HashMap<>(); // Add system property tags we need to request - allRequestedTags.addAll(requestedNodeSystemSnitchTags); + Set<String> allRequestedTags = new HashSet<>(requestedNodeSystemSnitchTags); // Add metric tags we need to request for (NodeMetric<?> metric : requestedNodeMetricSnitchTags) { diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/BalanceRequestImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/BalanceRequestImpl.java index 95454f9dbbe..4a2f39ba8eb 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/BalanceRequestImpl.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/BalanceRequestImpl.java @@ -45,11 +45,6 @@ public class BalanceRequestImpl implements BalanceRequest { return nodes; } - @Override - public int getMaximumBalanceSkew() { - return maximumBalanceSkew; - } - @Override public SolrCollection getCollection() { return solrCollection; diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/MetricImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/MetricImpl.java index b3c5782bd13..f6a64d8eb51 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/MetricImpl.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/MetricImpl.java @@ -68,7 +68,7 @@ public abstract class MetricImpl<T> implements Metric<T> { /** * Create a metric attribute. * - * @param name short-hand name that identifies this attribute. + * @param name shorthand name that identifies this attribute. * @param internalName internal name of a Solr metric. */ public MetricImpl(String name, String internalName) { @@ -78,7 +78,7 @@ public abstract class MetricImpl<T> implements Metric<T> { /** * Create a metric attribute. * - * @param name short-hand name that identifies this attribute. + * @param name shorthand name that identifies this attribute. * @param internalName internal name of a Solr metric. * @param converter optional raw value converter. If null then {@link #IDENTITY_CONVERTER} will be * used. @@ -90,7 +90,7 @@ public abstract class MetricImpl<T> implements Metric<T> { /** * Create a metric attribute with labels. * - * @param name short-hand name that identifies this attribute. + * @param name shorthand name that identifies this attribute. * @param internalName internal name of a Solr metric. * @param labelKey optional label key for Prometheus format labeled metrics. * @param labelValue optional label value for Prometheus format labeled metrics. diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/ModificationRequestImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/ModificationRequestImpl.java index de542fcefe3..1532fc21e64 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/ModificationRequestImpl.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/ModificationRequestImpl.java @@ -24,9 +24,7 @@ import org.apache.solr.cluster.Shard; import org.apache.solr.cluster.SolrCollection; import org.apache.solr.cluster.placement.DeleteCollectionRequest; import org.apache.solr.cluster.placement.DeleteReplicasRequest; -import org.apache.solr.cluster.placement.DeleteShardsRequest; import org.apache.solr.common.cloud.DocCollection; -import org.apache.solr.common.cloud.Slice; /** Helper class to create modification request instances. */ public class ModificationRequestImpl { @@ -77,7 +75,6 @@ public class ModificationRequestImpl { SolrCollection solrCollection = SimpleClusterAbstractionsImpl.SolrCollectionImpl.fromDocCollection(docCollection); Shard shard = solrCollection.getShard(shardName); - Slice slice = docCollection.getSlice(shardName); Set<Replica> solrReplicas = new HashSet<>(); replicas.forEach( replica -> { @@ -85,31 +82,4 @@ public class ModificationRequestImpl { }); return createDeleteReplicasRequest(solrCollection, solrReplicas); } - - public static DeleteShardsRequest createDeleteShardsRequest( - SolrCollection collection, Set<String> shardNames) { - return new DeleteShardsRequest() { - @Override - public Set<String> getShardNames() { - return shardNames; - } - - @Override - public SolrCollection getCollection() { - return collection; - } - - @Override - public String toString() { - return "DeleteShardsRequest{collection=" + collection.getName() + ",shards=" + shardNames; - } - }; - } - - public static DeleteShardsRequest createDeleteShardsRequest( - DocCollection docCollection, Set<String> shardNames) { - SolrCollection solrCollection = - SimpleClusterAbstractionsImpl.SolrCollectionImpl.fromDocCollection(docCollection); - return createDeleteShardsRequest(solrCollection, shardNames); - } } diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/NodeMetricImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/NodeMetricImpl.java index 75fac2406d0..4f76896a320 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/NodeMetricImpl.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/NodeMetricImpl.java @@ -56,15 +56,6 @@ public class NodeMetricImpl<T> extends MetricImpl<T> implements NodeMetric<T> { super(key, key, null, null, converter); } - public NodeMetricImpl( - String name, - String internalName, - String labelKey, - String labelValue, - Function<Object, T> converter) { - super(name, internalName, labelKey, labelValue, converter); - } - public NodeMetricImpl(String key) { super(key, key); } diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginAssignStrategy.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginAssignStrategy.java index f005dc24641..13e2a0b53a4 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginAssignStrategy.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginAssignStrategy.java @@ -18,7 +18,6 @@ package org.apache.solr.cluster.placement.impl; import java.io.IOException; -import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -41,14 +40,10 @@ import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.ReplicaPosition; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.util.CollectionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** This assign strategy delegates placement computation to "plugin" code. */ public class PlacementPluginAssignStrategy implements Assign.AssignStrategy { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final PlacementPlugin plugin; public PlacementPluginAssignStrategy(PlacementPlugin plugin) { @@ -127,7 +122,7 @@ public class PlacementPluginAssignStrategy implements Assign.AssignStrategy { private Replica findReplica( SolrCloudManager solrCloudManager, org.apache.solr.cluster.Replica replica) { - DocCollection collection = null; + DocCollection collection; try { collection = solrCloudManager diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginFactoryLoader.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginFactoryLoader.java index 00ee44f67b3..b7f582d01f7 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginFactoryLoader.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/PlacementPluginFactoryLoader.java @@ -109,22 +109,18 @@ public class PlacementPluginFactoryLoader { "Default replica placement plugin set in {} to {}", PLACEMENTPLUGIN_DEFAULT_SYSPROP, defaultPluginId); - switch (defaultPluginId.toLowerCase(Locale.ROOT)) { - case "simple": - return new SimplePlacementFactory(); - case "affinity": - return new AffinityPlacementFactory(); - case "minimizecores": - return new MinimizeCoresPlacementFactory(); - case "random": - return new RandomPlacementFactory(); - default: - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, - "Invalid value for system property '" - + PLACEMENTPLUGIN_DEFAULT_SYSPROP - + "'. Supported values are 'simple', 'random', 'affinity' and 'minimizecores'"); - } + return switch (defaultPluginId.toLowerCase(Locale.ROOT)) { + case "simple" -> new SimplePlacementFactory(); + case "affinity" -> new AffinityPlacementFactory(); + case "minimizecores" -> new MinimizeCoresPlacementFactory(); + case "random" -> new RandomPlacementFactory(); + default -> + throw new SolrException( + SolrException.ErrorCode.SERVER_ERROR, + "Invalid value for system property '" + + PLACEMENTPLUGIN_DEFAULT_SYSPROP + + "'. Supported values are 'simple', 'random', 'affinity' and 'minimizecores'"); + }; } else { // TODO: Consider making the ootb default AffinityPlacementFactory, see // https://issues.apache.org/jira/browse/SOLR-16492 diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java index d1b92ba2a4b..f8af1e41858 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/SimpleClusterAbstractionsImpl.java @@ -251,20 +251,13 @@ class SimpleClusterAbstractionsImpl { } private ShardState translateState(Slice.State state) { - switch (state) { - case ACTIVE: - return ShardState.ACTIVE; - case INACTIVE: - return ShardState.INACTIVE; - case CONSTRUCTION: - return ShardState.CONSTRUCTION; - case RECOVERY: - return ShardState.RECOVERY; - case RECOVERY_FAILED: - return ShardState.RECOVERY_FAILED; - default: - throw new RuntimeException("Unexpected " + state); - } + return switch (state) { + case ACTIVE -> ShardState.ACTIVE; + case INACTIVE -> ShardState.INACTIVE; + case CONSTRUCTION -> ShardState.CONSTRUCTION; + case RECOVERY -> ShardState.RECOVERY; + case RECOVERY_FAILED -> ShardState.RECOVERY_FAILED; + }; } @Override @@ -385,31 +378,20 @@ class SimpleClusterAbstractionsImpl { } private Replica.ReplicaType translateType(org.apache.solr.common.cloud.Replica.Type type) { - switch (type) { - case NRT: - return Replica.ReplicaType.NRT; - case TLOG: - return Replica.ReplicaType.TLOG; - case PULL: - return Replica.ReplicaType.PULL; - default: - throw new RuntimeException("Unexpected " + type); - } + return switch (type) { + case NRT -> ReplicaType.NRT; + case TLOG -> ReplicaType.TLOG; + case PULL -> ReplicaType.PULL; + }; } private Replica.ReplicaState translateState(State state) { - switch (state) { - case ACTIVE: - return Replica.ReplicaState.ACTIVE; - case DOWN: - return Replica.ReplicaState.DOWN; - case RECOVERING: - return Replica.ReplicaState.RECOVERING; - case RECOVERY_FAILED: - return Replica.ReplicaState.RECOVERY_FAILED; - default: - throw new RuntimeException("Unexpected " + state); - } + return switch (state) { + case ACTIVE -> ReplicaState.ACTIVE; + case DOWN -> ReplicaState.DOWN; + case RECOVERING -> ReplicaState.RECOVERING; + case RECOVERY_FAILED -> ReplicaState.RECOVERY_FAILED; + }; } @Override @@ -449,16 +431,11 @@ class SimpleClusterAbstractionsImpl { * an internal SolrCloud implementation class to the plugin API. */ static org.apache.solr.common.cloud.Replica.Type toCloudReplicaType(ReplicaType type) { - switch (type) { - case NRT: - return org.apache.solr.common.cloud.Replica.Type.NRT; - case TLOG: - return org.apache.solr.common.cloud.Replica.Type.TLOG; - case PULL: - return org.apache.solr.common.cloud.Replica.Type.PULL; - default: - throw new IllegalArgumentException("Unknown " + type); - } + return switch (type) { + case NRT -> org.apache.solr.common.cloud.Replica.Type.NRT; + case TLOG -> org.apache.solr.common.cloud.Replica.Type.TLOG; + case PULL -> org.apache.solr.common.cloud.Replica.Type.PULL; + }; } @Override diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java index 8faa95f2e78..e73ce2c043d 100644 --- a/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java +++ b/solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java @@ -135,9 +135,8 @@ public class AffinityPlacementConfig implements PlacementPluginConfig { @JsonProperty public Boolean spreadAcrossDomains = Boolean.FALSE; /** - * Determines the maximum number of replicas of a particular type of a particular shard that can - * be placed within a single domain (as defined by the {@link #SPREAD_DOMAIN_SYSPROP} System - * property). + * Determines the maximum number of replicas of the same type from any given shard that may share + * a single domain (as defined by the {@link #SPREAD_DOMAIN_SYSPROP} System property). */ @JsonProperty public Integer maxReplicasPerShardInDomain = -1;
