@@ -221,13 +221,12 @@ public DiskThresholdDecider(Settings settings, NodeSettingsService nodeSettingsS
221
221
* If subtractShardsMovingAway is set then the size of shards moving away is subtracted from the total size
222
222
* of all shards
223
223
*/
224
- public long sizeOfRelocatingShards (RoutingNode node , RoutingAllocation allocation , Map <String , Long > shardSizes , boolean subtractShardsMovingAway ) {
225
- List <ShardRouting > relocatingShards = allocation .routingTable ().shardsWithState (ShardRoutingState .RELOCATING );
224
+ public long sizeOfRelocatingShards (RoutingNode node , Map <String , Long > shardSizes , boolean subtractShardsMovingAway ) {
226
225
long totalSize = 0 ;
227
- for (ShardRouting routing : relocatingShards ) {
228
- if (routing .relocatingNodeId (). equals ( node . nodeId ()) ) {
226
+ for (ShardRouting routing : node . shardsWithState ( ShardRoutingState . RELOCATING , ShardRoutingState . INITIALIZING ) ) {
227
+ if (routing .initializing () && routing . relocatingNodeId () != null ) {
229
228
totalSize += getShardSize (routing , shardSizes );
230
- } else if (subtractShardsMovingAway && routing .currentNodeId (). equals ( node . nodeId () )) {
229
+ } else if (subtractShardsMovingAway && routing .relocating ( )) {
231
230
totalSize -= getShardSize (routing , shardSizes );
232
231
}
233
232
}
@@ -285,7 +284,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
285
284
}
286
285
287
286
if (includeRelocations ) {
288
- long relocatingShardsSize = sizeOfRelocatingShards (node , allocation , shardSizes , false );
287
+ long relocatingShardsSize = sizeOfRelocatingShards (node , shardSizes , false );
289
288
DiskUsage usageIncludingRelocations = new DiskUsage (node .nodeId (), node .node ().name (),
290
289
usage .getTotalBytes (), usage .getFreeBytes () - relocatingShardsSize );
291
290
if (logger .isTraceEnabled ()) {
@@ -431,7 +430,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
431
430
432
431
if (includeRelocations ) {
433
432
Map <String , Long > shardSizes = clusterInfo .getShardSizes ();
434
- long relocatingShardsSize = sizeOfRelocatingShards (node , allocation , shardSizes , true );
433
+ long relocatingShardsSize = sizeOfRelocatingShards (node , shardSizes , true );
435
434
DiskUsage usageIncludingRelocations = new DiskUsage (node .nodeId (), node .node ().name (),
436
435
usage .getTotalBytes (), usage .getFreeBytes () - relocatingShardsSize );
437
436
if (logger .isTraceEnabled ()) {
0 commit comments