Skip to content

Commit

Permalink
SOLR-14930: Deprecate rulebased replica placement strategy (remove in…
Browse files Browse the repository at this point in the history
… 9.0) (apache#1980)
  • Loading branch information
noblepaul authored Oct 15, 2020
1 parent 2a3da99 commit 321b4fa
Show file tree
Hide file tree
Showing 23 changed files with 7 additions and 2,265 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Other Changes

* SOLR-10370: ReplicationHandler should fetch index at fixed delay instead of fixed rate (Cao Manh Dat)

* SOLR-14930: Removed rule based replica placement (noble)

Bug Fixes
---------------------
* SOLR-14546: Fix for a relatively hard to hit issue in OverseerTaskProcessor that could lead to out of order execution
Expand Down
1 change: 0 additions & 1 deletion solr/core/src/java/org/apache/solr/cloud/Overseer.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ private List<ZkWriteCommand> processMessage(ClusterState clusterState,
}
break;
case MODIFYCOLLECTION:
CollectionsHandler.verifyRuleParams(zkController.getCoreContainer() ,message.getProperties());
return Collections.singletonList(new CollectionMutator(getSolrCloudManager()).modifyCollection(clusterState,message));
default:
throw new RuntimeException("unknown operation:" + operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.solr.cloud.api.collections;

import static org.apache.solr.cloud.api.collections.OverseerCollectionMessageHandler.CREATE_NODE_SET;
import static org.apache.solr.common.cloud.DocCollection.SNITCH;
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;

import java.io.IOException;
Expand All @@ -27,7 +26,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
Expand All @@ -42,8 +40,6 @@
import org.apache.solr.client.solrj.cloud.AlreadyExistsException;
import org.apache.solr.client.solrj.cloud.BadVersionException;
import org.apache.solr.client.solrj.cloud.VersionedData;
import org.apache.solr.cloud.rule.ReplicaAssigner;
import org.apache.solr.cloud.rule.Rule;
import org.apache.solr.cluster.placement.PlacementPlugin;
import org.apache.solr.cluster.placement.impl.PlacementPluginAssignStrategy;
import org.apache.solr.cluster.placement.impl.PlacementPluginConfigImpl;
Expand Down Expand Up @@ -493,58 +489,6 @@ private ImmutableMap<Replica.Type, Integer> countsPerReplicaType(AssignRequest a
}
}

public static class RulesBasedAssignStrategy implements AssignStrategy {
public List<Rule> rules;
@SuppressWarnings({"rawtypes"})
public List snitches;
public ClusterState clusterState;

public RulesBasedAssignStrategy(List<Rule> rules, @SuppressWarnings({"rawtypes"})List snitches, ClusterState clusterState) {
this.rules = rules;
this.snitches = snitches;
this.clusterState = clusterState;
}

@Override
public List<ReplicaPosition> assign(SolrCloudManager solrCloudManager, AssignRequest assignRequest) throws Assign.AssignmentException, IOException, InterruptedException {
if (assignRequest.numTlogReplicas + assignRequest.numPullReplicas != 0) {
throw new Assign.AssignmentException(
Replica.Type.TLOG + " or " + Replica.Type.PULL + " replica types not supported with placement rules or cluster policies");
}

Map<String, Integer> shardVsReplicaCount = new HashMap<>();
for (String shard : assignRequest.shardNames) shardVsReplicaCount.put(shard, assignRequest.numNrtReplicas);

Map<String, Map<String, Integer>> shardVsNodes = new LinkedHashMap<>();
DocCollection docCollection = solrCloudManager.getClusterStateProvider().getClusterState().getCollectionOrNull(assignRequest.collectionName);
if (docCollection != null) {
for (Slice slice : docCollection.getSlices()) {
LinkedHashMap<String, Integer> n = new LinkedHashMap<>();
shardVsNodes.put(slice.getName(), n);
for (Replica replica : slice.getReplicas()) {
Integer count = n.get(replica.getNodeName());
if (count == null) count = 0;
n.put(replica.getNodeName(), ++count);
}
}
}

List<String> nodesList = assignRequest.nodes == null ? new ArrayList<>(clusterState.getLiveNodes()) : assignRequest.nodes;

ReplicaAssigner replicaAssigner = new ReplicaAssigner(rules,
shardVsReplicaCount,
snitches,
shardVsNodes,
nodesList,
solrCloudManager, clusterState);

Map<ReplicaPosition, String> nodeMappings = replicaAssigner.getNodeMappings();
return nodeMappings.entrySet().stream()
.map(e -> new ReplicaPosition(e.getKey().shard, e.getKey().index, e.getKey().type, e.getValue()))
.collect(Collectors.toList());
}
}

/**
* Creates the appropriate instance of {@link AssignStrategy} based on how the cluster and/or individual collections are
* configured.
Expand All @@ -553,22 +497,10 @@ public static AssignStrategy createAssignStrategy(SolrCloudManager solrCloudMana
PlacementPlugin plugin = PlacementPluginConfigImpl.getPlacementPlugin(solrCloudManager);

if (plugin != null) {
// If a cluster wide placement plugin is configured (and that's the only way to define a placement plugin), it overrides
// per collection configuration (i.e. rules are ignored)
// If a cluster wide placement plugin is configured (and that's the only way to define a placement plugin)
return new PlacementPluginAssignStrategy(collection, plugin);
} else {
@SuppressWarnings({"unchecked", "rawtypes"})
List<Map> ruleMaps = (List<Map>) collection.get(DocCollection.RULE);

if (ruleMaps != null && !ruleMaps.isEmpty()) {
List<Rule> rules = new ArrayList<>();
for (Object map : ruleMaps) rules.add(new Rule((Map) map));
@SuppressWarnings({"rawtypes"})
List snitches = (List) collection.get(SNITCH);
return new RulesBasedAssignStrategy(rules, snitches, clusterState);
} else {
} else {
return new LegacyAssignStrategy();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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;
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
Expand Down Expand Up @@ -145,8 +144,6 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler,
ZkStateReader.NRT_REPLICAS, "1",
ZkStateReader.TLOG_REPLICAS, "0",
ZkStateReader.PULL_REPLICAS, "0",
DocCollection.RULE, null,
SNITCH, null,
WITH_COLLECTION, null,
COLOCATED_WITH, null));

Expand Down
65 changes: 0 additions & 65 deletions solr/core/src/java/org/apache/solr/cloud/rule/ImplicitSnitch.java

This file was deleted.

Loading

0 comments on commit 321b4fa

Please sign in to comment.