Skip to content

Commit 216c761

Browse files
MINOR: Remove Dead Code in Routing (elastic#35074)
* MINOR: Remove Dead Code in Routing
1 parent 3ee004c commit 216c761

File tree

7 files changed

+8
-69
lines changed

7 files changed

+8
-69
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
6565
final List<ShardRouting> activeShards;
6666
final List<ShardRouting> assignedShards;
6767
final Set<String> allAllocationIds;
68-
static final List<ShardRouting> NO_SHARDS = Collections.emptyList();
6968
final boolean allShardsStarted;
7069

7170
private volatile Map<AttributesKey, AttributesRoutings> activeShardsByAttributes = emptyMap();
@@ -220,15 +219,6 @@ public List<ShardRouting> assignedShards() {
220219
return this.assignedShards;
221220
}
222221

223-
/**
224-
* Returns a {@link List} of assigned shards
225-
*
226-
* @return a {@link List} of shards
227-
*/
228-
public List<ShardRouting> getAssignedShards() {
229-
return this.assignedShards;
230-
}
231-
232222
public ShardIterator shardsRandomIt() {
233223
return new PlainShardIterator(shardId, shuffler.shuffle(shards));
234224
}

server/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ assert getByAllocationId(failedShard.shardId(), failedShard.allocationId().getId
582582
moveToUnassigned(failedShard, unassignedInfo);
583583
} else {
584584
movePrimaryToUnassignedAndDemoteToReplica(failedShard, unassignedInfo);
585-
promoteReplicaToPrimary(activeReplica, indexMetaData, routingChangesObserver);
585+
promoteReplicaToPrimary(activeReplica, routingChangesObserver);
586586
}
587587
} else {
588588
// initializing shard that is not relocation target, just move to unassigned
@@ -611,7 +611,7 @@ assert getByAllocationId(failedShard.shardId(), failedShard.allocationId().getId
611611
moveToUnassigned(failedShard, unassignedInfo);
612612
} else {
613613
movePrimaryToUnassignedAndDemoteToReplica(failedShard, unassignedInfo);
614-
promoteReplicaToPrimary(activeReplica, indexMetaData, routingChangesObserver);
614+
promoteReplicaToPrimary(activeReplica, routingChangesObserver);
615615
}
616616
} else {
617617
assert failedShard.primary() == false;
@@ -627,8 +627,7 @@ assert node(failedShard.currentNodeId()).getByShardId(failedShard.shardId()) ==
627627
" was matched but wasn't removed";
628628
}
629629

630-
private void promoteReplicaToPrimary(ShardRouting activeReplica, IndexMetaData indexMetaData,
631-
RoutingChangesObserver routingChangesObserver) {
630+
private void promoteReplicaToPrimary(ShardRouting activeReplica, RoutingChangesObserver routingChangesObserver) {
632631
// if the activeReplica was relocating before this call to failShard, its relocation was cancelled earlier when we
633632
// failed initializing replica shards (and moved replica relocation source back to started)
634633
assert activeReplica.started() : "replica relocation should have been cancelled: " + activeReplica;
@@ -832,11 +831,6 @@ public void sort(Comparator<ShardRouting> comparator) {
832831
*/
833832
public int size() { return unassigned.size(); }
834833

835-
/**
836-
* Returns the size of the temporarily marked as ignored unassigned shards
837-
*/
838-
public int ignoredSize() { return ignored.size(); }
839-
840834
/**
841835
* Returns the number of non-ignored unassigned primaries
842836
*/

server/src/main/java/org/elasticsearch/cluster/routing/RoutingTable.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private GroupShardsIterator<ShardIterator> allSatisfyingPredicateShardsGrouped(S
266266
Collections.singletonList(shardRouting.getTargetRelocatingShard())));
267267
}
268268
} else if (includeEmpty) { // we need this for counting properly, just make it an empty one
269-
set.add(new PlainShardIterator(shardRouting.shardId(), Collections.<ShardRouting>emptyList()));
269+
set.add(new PlainShardIterator(shardRouting.shardId(), Collections.emptyList()));
270270
}
271271
}
272272
}
@@ -328,7 +328,7 @@ public GroupShardsIterator<ShardIterator> activePrimaryShardsGrouped(String[] in
328328
if (primary.active()) {
329329
set.add(primary.shardsIt());
330330
} else if (includeEmpty) { // we need this for counting properly, just make it an empty one
331-
set.add(new PlainShardIterator(primary.shardId(), Collections.<ShardRouting>emptyList()));
331+
set.add(new PlainShardIterator(primary.shardId(), Collections.emptyList()));
332332
}
333333
}
334334
}
@@ -567,14 +567,6 @@ public Builder add(IndexRoutingTable.Builder indexRoutingTableBuilder) {
567567
return this;
568568
}
569569

570-
public Builder indicesRouting(Map<String, IndexRoutingTable> indicesRouting) {
571-
if (indicesRouting == null) {
572-
throw new IllegalStateException("once build is called the builder cannot be reused");
573-
}
574-
this.indicesRouting.putAll(indicesRouting);
575-
return this;
576-
}
577-
578570
public Builder remove(String index) {
579571
if (indicesRouting == null) {
580572
throw new IllegalStateException("once build is called the builder cannot be reused");

server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public class DiskThresholdSettings {
7070
private volatile boolean includeRelocations;
7171
private volatile boolean enabled;
7272
private volatile TimeValue rerouteInterval;
73-
private volatile String floodStageRaw;
7473
private volatile Double freeDiskThresholdFloodStage;
7574
private volatile ByteSizeValue freeBytesThresholdFloodStage;
7675

@@ -80,13 +79,13 @@ public DiskThresholdSettings(Settings settings, ClusterSettings clusterSettings)
8079
final String floodStage = CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING.get(settings);
8180
setHighWatermark(highWatermark);
8281
setLowWatermark(lowWatermark);
83-
setFloodStageRaw(floodStage);
82+
setFloodStage(floodStage);
8483
this.includeRelocations = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.get(settings);
8584
this.rerouteInterval = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.get(settings);
8685
this.enabled = CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
8786
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, this::setLowWatermark);
8887
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, this::setHighWatermark);
89-
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING, this::setFloodStageRaw);
88+
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING, this::setFloodStage);
9089
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, this::setIncludeRelocations);
9190
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, this::setRerouteInterval);
9291
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
@@ -230,9 +229,8 @@ private void setHighWatermark(String highWatermark) {
230229
CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey());
231230
}
232231

233-
private void setFloodStageRaw(String floodStageRaw) {
232+
private void setFloodStage(String floodStageRaw) {
234233
// Watermark is expressed in terms of used data, but we need "free" data watermark
235-
this.floodStageRaw = floodStageRaw;
236234
this.freeDiskThresholdFloodStage = 100.0 - thresholdPercentageFromWatermark(floodStageRaw);
237235
this.freeBytesThresholdFloodStage = thresholdBytesFromWatermark(floodStageRaw,
238236
CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING.getKey());
@@ -276,10 +274,6 @@ public ByteSizeValue getFreeBytesThresholdFloodStage() {
276274
return freeBytesThresholdFloodStage;
277275
}
278276

279-
public String getFloodStageRaw() {
280-
return floodStageRaw;
281-
}
282-
283277
public boolean includeRelocations() {
284278
return includeRelocations;
285279
}

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.lucene.util.IntroSorter;
2525
import org.elasticsearch.cluster.metadata.IndexMetaData;
2626
import org.elasticsearch.cluster.metadata.MetaData;
27-
import org.elasticsearch.cluster.node.DiscoveryNode;
2827
import org.elasticsearch.cluster.routing.RoutingNode;
2928
import org.elasticsearch.cluster.routing.RoutingNodes;
3029
import org.elasticsearch.cluster.routing.ShardRouting;
@@ -447,28 +446,6 @@ private MoveDecision decideRebalance(final ShardRouting shard) {
447446
}
448447
}
449448

450-
public Map<DiscoveryNode, Float> weighShard(ShardRouting shard) {
451-
final ModelNode[] modelNodes = sorter.modelNodes;
452-
final float[] weights = sorter.weights;
453-
454-
buildWeightOrderedIndices();
455-
Map<DiscoveryNode, Float> nodes = new HashMap<>(modelNodes.length);
456-
float currentNodeWeight = 0.0f;
457-
for (int i = 0; i < modelNodes.length; i++) {
458-
if (modelNodes[i].getNodeId().equals(shard.currentNodeId())) {
459-
// If a node was found with the shard, use that weight instead of 0.0
460-
currentNodeWeight = weights[i];
461-
break;
462-
}
463-
}
464-
465-
for (int i = 0; i < modelNodes.length; i++) {
466-
final float delta = currentNodeWeight - weights[i];
467-
nodes.put(modelNodes[i].getRoutingNode().node(), delta);
468-
}
469-
return nodes;
470-
}
471-
472449
/**
473450
* Balances the nodes on the cluster model according to the weight
474451
* function. The configured threshold is the minimum delta between the

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ private Decision underCapacity(ShardRouting shardRouting, RoutingNode node, Rout
207207
currentNodeCount,
208208
requiredCountPerAttribute + leftoverPerAttribute);
209209
}
210-
// all is well, we are below or same as average
211-
if (currentNodeCount <= requiredCountPerAttribute) {
212-
continue;
213-
}
214210
}
215211

216212
return allocation.decision(Decision.YES, NAME, "node meets all awareness attribute requirements");

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ public enum Type implements Writeable {
9292
this.id = id;
9393
}
9494

95-
public static Type resolve(String s) {
96-
return Type.valueOf(s.toUpperCase(Locale.ROOT));
97-
}
98-
9995
public static Type readFrom(StreamInput in) throws IOException {
10096
int i = in.readVInt();
10197
switch (i) {

0 commit comments

Comments
 (0)