Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing

final long totalAddressableSpace = calculateTotalAddressableSpace(node, allocation);
final long currentNodeRemoteShardSize = calculateCurrentNodeRemoteShardSize(node, allocation, false);
final long freeSpace = totalAddressableSpace - currentNodeRemoteShardSize;
final long freeSpaceAfterAllocation = freeSpace > shardSize ? freeSpace - shardSize : 0;
final long freeSpace = Math.max(totalAddressableSpace - currentNodeRemoteShardSize, 0);
final long freeSpaceAfterAllocation = Math.max(freeSpace - shardSize, 0);
final long freeSpaceLowThreshold = calculateFreeSpaceLowThreshold(diskThresholdSettings, totalAddressableSpace);

final ByteSizeValue freeSpaceLowThresholdInByteSize = new ByteSizeValue(freeSpaceLowThreshold);
Expand All @@ -145,7 +145,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
return allocation.decision(
Decision.NO,
NAME,
"allocating the shard to this node will bring the node above the low watermark cluster setting [%s=%s] "
"allocating the shard to this node will bring the node above the low watermark cluster setting [%s] "
+ "and cause it to have less than the minimum required [%s] of addressable remote free space (free: [%s], estimated remote shard size: [%s])",
CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(),
freeSpaceLowThresholdInByteSize,
Expand Down Expand Up @@ -183,7 +183,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl

final long totalAddressableSpace = calculateTotalAddressableSpace(node, allocation);
final long currentNodeRemoteShardSize = calculateCurrentNodeRemoteShardSize(node, allocation, true);
final long freeSpace = totalAddressableSpace - currentNodeRemoteShardSize;
final long freeSpace = Math.max(totalAddressableSpace - currentNodeRemoteShardSize, 0);

final long freeSpaceHighThreshold = calculateFreeSpaceHighThreshold(diskThresholdSettings, totalAddressableSpace);

Expand All @@ -200,8 +200,8 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
return allocation.decision(
Decision.NO,
NAME,
"the shard cannot remain on this node because it is above the high watermark cluster setting [%s=%s] "
+ "and there is less than the required [%s%%] free remote addressable space on node, actual free: [%s%%]",
"the shard cannot remain on this node because it is above the high watermark cluster setting [%s] "
+ "and there is less than the required [%s] free remote addressable space on node, actual free: [%s]",
CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(),
freeSpaceHighThresholdInByteSize,
freeSpaceInByteSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public void testCanAllocateInSufficientFreeSpace() {
.build();

final Map<String, Long> shardSizes = new HashMap<>();
shardSizes.put("[test][0][p]", 4000L); // 5000 bytes
shardSizes.put("[test][0][r]", 4000L);
shardSizes.put("[test][0][p]", 5500L); // 5500 bytes shard size and total addressable space - 5000 bytes
shardSizes.put("[test][0][r]", 5500L);
shardSizes.put("[test2][0][p]", 1000L); // 1000 bytes
shardSizes.put("[test2][0][r]", 1000L);

Expand Down Expand Up @@ -354,8 +354,8 @@ public void testCanRemainInsufficientSpace() {
WarmDiskThresholdDecider decider = new WarmDiskThresholdDecider(settings, clusterSettings);

final Map<String, Long> shardSizes = new HashMap<>();
shardSizes.put("[test][0][p]", 4000L); // 4000 bytes
shardSizes.put("[test][0][r]", 4000L);
shardSizes.put("[test][0][p]", 5500L); // Shard size more than total addressable space - 5000 bytes
shardSizes.put("[test][0][r]", 5500L);
shardSizes.put("[test2][0][p]", 1000L); // 1000 bytes
shardSizes.put("[test2][0][r]", 1000L);

Expand Down
Loading