-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allocation service changes for batch assignment #8888
base: main
Are you sure you want to change the base?
Changes from 8 commits
432efc1
eecf79f
c2be078
3bb7dd8
6e645a0
b1994fa
257f36d
1574fc2
d3b1140
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,13 @@ | |
import org.opensearch.common.Nullable; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.gateway.GatewayAllocator; | ||
import org.opensearch.gateway.ShardsBatchGatewayAllocator; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Searches for, and allocates, shards for which there is an existing on-disk copy somewhere in the cluster. The default implementation is | ||
* {@link GatewayAllocator}, but plugins can supply their own implementations too. | ||
* {@link GatewayAllocator} and {@link ShardsBatchGatewayAllocator}, but plugins can supply their own implementations too. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
|
@@ -60,6 +61,26 @@ public interface ExistingShardsAllocator { | |
Setting.Property.PrivateIndex | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Java doc here, we are adding a new public setting. Highly recommend adding multi-line comment explaining the purpose of the setting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack |
||
/** | ||
* Boolean setting to enable/disable batch allocation of unassigned shards already existing on disk. | ||
* This will allow sending all Unassigned Shards to the ExistingShard Allocator to make decision to allocate | ||
* in one or more go. | ||
* | ||
* Enable this setting if your ExistingShardAllocator is implementing the | ||
* {@link ExistingShardsAllocator#allocateAllUnassignedShards(RoutingAllocation, boolean)} method. | ||
* The default implementation of this method is not optimized and assigns shards one by one. | ||
Comment on lines
+69
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By enabling this setting, GatewayAllocator will use batch implementation by default. In case of custom ExistingShardAllocator , the performance benefits will be visible if {@link ExistingShardsAllocator#allocateAllUnassignedShards(RoutingAllocation, boolean)} method is implemented efficiently for batch mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, if custom Allocator is set we wont be even running allocateAllUnassignedShards in AllocationService. This was discussed here |
||
* | ||
* If no plugin overrides {@link ExistingShardsAllocator} then default implementation will be use for it , i.e, | ||
* {@link ShardsBatchGatewayAllocator}. | ||
* | ||
* This setting is experimental at this point. | ||
*/ | ||
Setting<Boolean> EXISTING_SHARDS_ALLOCATOR_BATCH_MODE = Setting.boolSetting( | ||
"cluster.allocator.existing_shards_allocator.batch_enabled", | ||
false, | ||
Setting.Property.NodeScope | ||
shwetathareja marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
/** | ||
* Called before starting a round of allocation, allowing the allocator to invalidate some caches if appropriate. | ||
*/ | ||
|
@@ -80,6 +101,23 @@ void allocateUnassigned( | |
UnassignedAllocationHandler unassignedAllocationHandler | ||
); | ||
|
||
/** | ||
* Allocate all unassigned shards in the given {@link RoutingAllocation} for which this {@link ExistingShardsAllocator} is responsible. | ||
* Default implementation calls {@link #allocateUnassigned(ShardRouting, RoutingAllocation, UnassignedAllocationHandler)} for each Unassigned shard | ||
* and is kept here for backward compatibility. | ||
* | ||
* Allocation service will currently run the default implementation of it implemented by {@link ShardsBatchGatewayAllocator} | ||
*/ | ||
default void allocateAllUnassignedShards(RoutingAllocation allocation, boolean primary) { | ||
RoutingNodes.UnassignedShards.UnassignedIterator iterator = allocation.routingNodes().unassigned().iterator(); | ||
while (iterator.hasNext()) { | ||
ShardRouting shardRouting = iterator.next(); | ||
if (shardRouting.primary() == primary) { | ||
allocateUnassigned(shardRouting, allocation, iterator); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns an explanation for a single unassigned shard. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the check for ==2 here is for GatewayAllocator & BatchGatewayAllocator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version check should be against 3.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.