@@ -123,8 +123,8 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
123
123
124
124
final long totalAddressableSpace = calculateTotalAddressableSpace (node , allocation );
125
125
final long currentNodeRemoteShardSize = calculateCurrentNodeRemoteShardSize (node , allocation , false );
126
- final long freeSpace = totalAddressableSpace - currentNodeRemoteShardSize ;
127
- final long freeSpaceAfterAllocation = freeSpace > shardSize ? freeSpace - shardSize : 0 ;
126
+ final long freeSpace = Math . max ( totalAddressableSpace - currentNodeRemoteShardSize , 0 ) ;
127
+ final long freeSpaceAfterAllocation = Math . max ( freeSpace - shardSize , 0 ) ;
128
128
final long freeSpaceLowThreshold = calculateFreeSpaceLowThreshold (diskThresholdSettings , totalAddressableSpace );
129
129
130
130
final ByteSizeValue freeSpaceLowThresholdInByteSize = new ByteSizeValue (freeSpaceLowThreshold );
@@ -145,7 +145,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
145
145
return allocation .decision (
146
146
Decision .NO ,
147
147
NAME ,
148
- "allocating the shard to this node will bring the node above the low watermark cluster setting [%s=%s ] "
148
+ "allocating the shard to this node will bring the node above the low watermark cluster setting [%s] "
149
149
+ "and cause it to have less than the minimum required [%s] of addressable remote free space (free: [%s], estimated remote shard size: [%s])" ,
150
150
CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING .getKey (),
151
151
freeSpaceLowThresholdInByteSize ,
@@ -183,7 +183,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
183
183
184
184
final long totalAddressableSpace = calculateTotalAddressableSpace (node , allocation );
185
185
final long currentNodeRemoteShardSize = calculateCurrentNodeRemoteShardSize (node , allocation , true );
186
- final long freeSpace = totalAddressableSpace - currentNodeRemoteShardSize ;
186
+ final long freeSpace = Math . max ( totalAddressableSpace - currentNodeRemoteShardSize , 0 ) ;
187
187
188
188
final long freeSpaceHighThreshold = calculateFreeSpaceHighThreshold (diskThresholdSettings , totalAddressableSpace );
189
189
@@ -200,8 +200,8 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
200
200
return allocation .decision (
201
201
Decision .NO ,
202
202
NAME ,
203
- "the shard cannot remain on this node because it is above the high watermark cluster setting [%s=%s ] "
204
- + "and there is less than the required [%s%% ] free remote addressable space on node, actual free: [%s%% ]" ,
203
+ "the shard cannot remain on this node because it is above the high watermark cluster setting [%s] "
204
+ + "and there is less than the required [%s] free remote addressable space on node, actual free: [%s]" ,
205
205
CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING .getKey (),
206
206
freeSpaceHighThresholdInByteSize ,
207
207
freeSpaceInByteSize
0 commit comments