From c3f8db4e34f3ac1c7f604062c45428ad10f20eb8 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 13:00:19 -0400 Subject: [PATCH 1/7] small intellij inspired cleanups in o.a.s.cluster.events --- .../org/apache/solr/cluster/events/ClusterEvent.java | 4 ++-- .../solr/cluster/events/ClusterEventProducerBase.java | 4 +--- .../cluster/events/impl/ClusterEventProducerFactory.java | 9 ++++----- .../events/impl/CollectionsRepairEventListener.java | 6 ++++-- .../events/impl/DelegatingClusterEventProducer.java | 5 ++++- 5 files changed, 15 insertions(+), 13 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 f2fb184fb079..c800ce8b6f0c 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 @@ enum EventType { 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 ee16baf41fe0..376d331c07dd 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 State getState() { @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 e7401940ad7d..e7f57cbcca99 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 ContainerPluginsRegistry.PluginRegistryListener getPluginRegistryListener /** * Create a {@link ClusterEventProducer} based on the current plugin configurations. * - *

NOTE: this method can only be called once because it has side-effects, such as transferring + *

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 @@ private void transferListeners(ClusterEventProducer target, ContainerPluginsRegi 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 0d8c26d6c060..820235d8e495 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 @@ -198,7 +198,7 @@ private void runRepair() { "Exception computing positions for {}/{}: {}", coll.getName(), shard, - e); + e.getMessage()); } }); }); @@ -230,7 +230,9 @@ private void runRepair() { solrClient.request(addReplica); } catch (Exception e) { log.warn( - "Exception calling ADDREPLICA {}: {}", addReplica.getParams().toQueryString(), e); + "Exception calling ADDREPLICA {}: {}", + addReplica.getParams().toQueryString(), + e.getMessage()); } }); } 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 551b9bfd397c..724aae7ed3cb 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,10 @@ public void setDelegate(ClusterEventProducer newDelegate) { 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.getMessage()); } } else { if (log.isDebugEnabled()) { From fb56cdfc4d08a7f9fdfffc60a845dd718b414abc Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 13:41:29 -0400 Subject: [PATCH 2/7] Use modern coding styles, fix typos. --- .../placement/impl/AttributeFetcherImpl.java | 5 +- .../cluster/placement/impl/MetricImpl.java | 6 +- .../placement/impl/NodeMetricImpl.java | 9 --- .../impl/PlacementPluginAssignStrategy.java | 7 +- .../impl/PlacementPluginFactoryLoader.java | 27 +++---- .../impl/SimpleClusterAbstractionsImpl.java | 73 +++++++------------ 6 files changed, 44 insertions(+), 83 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 2aa4203f91af..cca227000f74 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 AttributeValues fetchAttributes() { // 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 @@ private void fetchNodeValues( Map> systemSnitchToNodeToValue, Map, Map> metricSnitchToNodeToValue) { - Set allRequestedTags = new HashSet<>(); Map> tagToMetric = new HashMap<>(); // Add system property tags we need to request - allRequestedTags.addAll(requestedNodeSystemSnitchTags); + Set 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/MetricImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/MetricImpl.java index b3c5782bd13c..f6a64d8eb516 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 implements Metric { /** * 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 MetricImpl(String name, String internalName) { /** * 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 MetricImpl(String name, String internalName, Function converte /** * 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/NodeMetricImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/NodeMetricImpl.java index 75fac2406d0e..4f76896a320b 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 NodeMetricImpl(String key, Function converter) { super(key, key, null, null, converter); } - public NodeMetricImpl( - String name, - String internalName, - String labelKey, - String labelValue, - Function 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 f005dc246411..13e2a0b53a4c 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.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 Map computeReplicaBalancing( 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 4df4616648ae..7e6a4c227c08 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 @@ -108,22 +108,17 @@ public static PlacementPluginFactory getDefaultPlacementPluginFactory() { "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 d1b92ba2a4b1..c63377d8d74e 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,14 @@ private ShardImpl(String shardName, SolrCollection collection, Slice slice) { } 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; + default -> throw new RuntimeException("Unexpected " + state); + }; } @Override @@ -385,31 +379,22 @@ private ReplicaImpl( } 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; + default -> throw new RuntimeException("Unexpected " + type); + }; } 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; + default -> throw new RuntimeException("Unexpected " + state); + }; } @Override @@ -449,16 +434,12 @@ public Node getNode() { * 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; + default -> throw new IllegalArgumentException("Unknown " + type); + }; } @Override From 82ef9b8346e44014f77aabf57ee4b95c8d2f4669 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 13:41:38 -0400 Subject: [PATCH 3/7] Remove unused methods. --- .../impl/ModificationRequestImpl.java | 30 ------------------- 1 file changed, 30 deletions(-) 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 de542fcefe38..1532fc21e646 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.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 static DeleteReplicasRequest createDeleteReplicasRequest( SolrCollection solrCollection = SimpleClusterAbstractionsImpl.SolrCollectionImpl.fromDocCollection(docCollection); Shard shard = solrCollection.getShard(shardName); - Slice slice = docCollection.getSlice(shardName); Set solrReplicas = new HashSet<>(); replicas.forEach( replica -> { @@ -85,31 +82,4 @@ public static DeleteReplicasRequest createDeleteReplicasRequest( }); return createDeleteReplicasRequest(solrCollection, solrReplicas); } - - public static DeleteShardsRequest createDeleteShardsRequest( - SolrCollection collection, Set shardNames) { - return new DeleteShardsRequest() { - @Override - public Set 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 shardNames) { - SolrCollection solrCollection = - SimpleClusterAbstractionsImpl.SolrCollectionImpl.fromDocCollection(docCollection); - return createDeleteShardsRequest(solrCollection, shardNames); - } } From 2f818b6996ea1e8b79f8d51905718dd18a3576b5 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 13:56:53 -0400 Subject: [PATCH 4/7] use of enum means we dont need default --- .../cluster/placement/impl/SimpleClusterAbstractionsImpl.java | 4 ---- 1 file changed, 4 deletions(-) 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 c63377d8d74e..f8af1e418585 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 @@ -257,7 +257,6 @@ private ShardState translateState(Slice.State state) { case CONSTRUCTION -> ShardState.CONSTRUCTION; case RECOVERY -> ShardState.RECOVERY; case RECOVERY_FAILED -> ShardState.RECOVERY_FAILED; - default -> throw new RuntimeException("Unexpected " + state); }; } @@ -383,7 +382,6 @@ private Replica.ReplicaType translateType(org.apache.solr.common.cloud.Replica.T case NRT -> ReplicaType.NRT; case TLOG -> ReplicaType.TLOG; case PULL -> ReplicaType.PULL; - default -> throw new RuntimeException("Unexpected " + type); }; } @@ -393,7 +391,6 @@ private Replica.ReplicaState translateState(State state) { case DOWN -> ReplicaState.DOWN; case RECOVERING -> ReplicaState.RECOVERING; case RECOVERY_FAILED -> ReplicaState.RECOVERY_FAILED; - default -> throw new RuntimeException("Unexpected " + state); }; } @@ -438,7 +435,6 @@ static org.apache.solr.common.cloud.Replica.Type toCloudReplicaType(ReplicaType 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; - default -> throw new IllegalArgumentException("Unknown " + type); }; } From e392a78657b9b1a69d465da67f0bfbe6a05f19ab Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 14:01:19 -0400 Subject: [PATCH 5/7] trying for clearer wording; --- .../cluster/placement/plugins/AffinityPlacementConfig.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 8faa95f2e785..e73ce2c043de 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; From 89e8280792b940d3bc5b64e2f14a76a2ddedd37b Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 15:07:38 -0400 Subject: [PATCH 6/7] small code cleanups --- .../apache/solr/cluster/placement/AttributeFetcher.java | 2 +- .../org/apache/solr/cluster/placement/BalanceRequest.java | 2 -- .../apache/solr/cluster/placement/CollectionMetrics.java | 2 +- .../java/org/apache/solr/cluster/placement/Metric.java | 2 +- .../apache/solr/cluster/placement/PlacementContext.java | 2 +- .../apache/solr/cluster/placement/PlacementException.java | 5 ----- .../cluster/placement/PlacementModificationException.java | 8 -------- .../apache/solr/cluster/placement/PlacementPlugin.java | 2 +- .../org/apache/solr/cluster/placement/ShardMetrics.java | 2 +- .../solr/cluster/placement/impl/BalanceRequestImpl.java | 5 ----- 10 files changed, 6 insertions(+), 26 deletions(-) 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 a751d4bc08de..09186a0afa6d 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 @@ AttributeFetcher requestCollectionMetrics( /** * 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 f967b7fa8080..9dfb0ee56e15 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 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 c6afc8b480d2..d0a8681ccd5f 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.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 afa1040b96a9..5ddd0d0d4561 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 @@ */ public interface Metric { - /** 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 be7b0282a790..ae161610e609 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 bbe49f627463..c50b667ee52b 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 PlacementException(String message, Throwable cause) { 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 30439188a228..cd780d83bcfe 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 @@ public class PlacementModificationException extends PlacementException { private final Map rejectedModifications = new HashMap<>(); - public PlacementModificationException() { - super(); - } - public PlacementModificationException(String message) { super(message); } @@ -39,10 +35,6 @@ public PlacementModificationException(String message, Throwable cause) { 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 d2924d344b86..6bc14205f2e2 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 @@ BalancePlan computeBalancing(BalanceRequest balanceRequest, PlacementContext pla */ 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 0ca45267ff02..3be201f1d6fd 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.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/BalanceRequestImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/BalanceRequestImpl.java index 95454f9dbbea..4a2f39ba8ebb 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 Set getNodes() { return nodes; } - @Override - public int getMaximumBalanceSkew() { - return maximumBalanceSkew; - } - @Override public SolrCollection getCollection() { return solrCollection; From 8ac008abd20cf2458db895301bea0d3f258044d4 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Sat, 27 Jun 2026 16:01:37 -0400 Subject: [PATCH 7/7] fix precommit issue that identified a better way --- .../events/impl/CollectionsRepairEventListener.java | 10 ++-------- .../events/impl/DelegatingClusterEventProducer.java | 5 +---- 2 files changed, 3 insertions(+), 12 deletions(-) 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 820235d8e495..134e3d075e73 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 @@ private void runRepair() { newPositions.put(coll.getName(), positions); } catch (Exception e) { log.warn( - "Exception computing positions for {}/{}: {}", - coll.getName(), - shard, - e.getMessage()); + "Exception computing positions for {}/{}", coll.getName(), shard, e); } }); }); @@ -229,10 +226,7 @@ private void runRepair() { try { solrClient.request(addReplica); } catch (Exception e) { - log.warn( - "Exception calling ADDREPLICA {}: {}", - addReplica.getParams().toQueryString(), - e.getMessage()); + 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 724aae7ed3cb..61fffdf5c98f 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,10 +96,7 @@ public void setDelegate(ClusterEventProducer newDelegate) { log.debug("--- started delegate {}", delegate); } } catch (Exception e) { - log.warn( - "Unable to start the new delegate {}: {}", - delegate.getClass().getName(), - e.getMessage()); + log.warn("Unable to start the new delegate {}", delegate.getClass().getName(), e); } } else { if (log.isDebugEnabled()) {