@@ -227,13 +227,12 @@ public DiskThresholdDecider(Settings settings, NodeSettingsService nodeSettingsS
227
227
* If subtractShardsMovingAway is set then the size of shards moving away is subtracted from the total size
228
228
* of all shards
229
229
*/
230
- public long sizeOfRelocatingShards (RoutingNode node , RoutingAllocation allocation , Map <String , Long > shardSizes , boolean subtractShardsMovingAway ) {
231
- List <ShardRouting > relocatingShards = allocation .routingTable ().shardsWithState (ShardRoutingState .RELOCATING );
230
+ public long sizeOfRelocatingShards (RoutingNode node , Map <String , Long > shardSizes , boolean subtractShardsMovingAway ) {
232
231
long totalSize = 0 ;
233
- for (ShardRouting routing : relocatingShards ) {
234
- if (routing .relocatingNodeId (). equals ( node . nodeId ()) ) {
232
+ for (ShardRouting routing : node . shardsWithState ( ShardRoutingState . RELOCATING , ShardRoutingState . INITIALIZING ) ) {
233
+ if (routing .initializing () && routing . relocatingNodeId () != null ) {
235
234
totalSize += getShardSize (routing , shardSizes );
236
- } else if (subtractShardsMovingAway && routing .currentNodeId (). equals ( node . nodeId () )) {
235
+ } else if (subtractShardsMovingAway && routing .relocating ( )) {
237
236
totalSize -= getShardSize (routing , shardSizes );
238
237
}
239
238
}
@@ -291,7 +290,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
291
290
}
292
291
293
292
if (includeRelocations ) {
294
- long relocatingShardsSize = sizeOfRelocatingShards (node , allocation , shardSizes , false );
293
+ long relocatingShardsSize = sizeOfRelocatingShards (node , shardSizes , false );
295
294
DiskUsage usageIncludingRelocations = new DiskUsage (node .nodeId (), node .node ().name (),
296
295
usage .getTotalBytes (), usage .getFreeBytes () - relocatingShardsSize );
297
296
if (logger .isTraceEnabled ()) {
@@ -437,7 +436,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
437
436
438
437
if (includeRelocations ) {
439
438
Map <String , Long > shardSizes = clusterInfo .getShardSizes ();
440
- long relocatingShardsSize = sizeOfRelocatingShards (node , allocation , shardSizes , true );
439
+ long relocatingShardsSize = sizeOfRelocatingShards (node , shardSizes , true );
441
440
DiskUsage usageIncludingRelocations = new DiskUsage (node .nodeId (), node .node ().name (),
442
441
usage .getTotalBytes (), usage .getFreeBytes () - relocatingShardsSize );
443
442
if (logger .isTraceEnabled ()) {
0 commit comments