-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Adjust method to transition split state #126179
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
Changes from 4 commits
2226a1b
8a51f62
b001335
80844cf
a7b9f0a
97c5be7
8c52c88
b599126
d8b065e
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.core.Nullable; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.xcontent.ParseField; | ||
|
@@ -207,15 +208,22 @@ public static IndexReshardingMetadata newSplitByMultiple(int shardCount, int mul | |
return new IndexReshardingMetadata(IndexReshardingState.Split.newSplitByMultiple(shardCount, multiple)); | ||
} | ||
|
||
public IndexReshardingMetadata transitionSplitTargetToHandoff(ShardId shardId) { | ||
public static boolean isSplitTarget(ShardId shardId, @Nullable IndexReshardingMetadata reshardingMetadata) { | ||
return reshardingMetadata != null && reshardingMetadata.isSplit() && reshardingMetadata.getSplit().isTargetShard(shardId.id()); | ||
} | ||
|
||
public IndexReshardingMetadata transitionSplitTargetToNewState( | ||
ShardId shardId, | ||
IndexReshardingState.Split.TargetShardState newTargetState | ||
) { | ||
assert state instanceof IndexReshardingState.Split; | ||
IndexReshardingState.Split splitState = (IndexReshardingState.Split) state; | ||
IndexReshardingState.Split.TargetShardState[] newTargets = Arrays.copyOf( | ||
splitState.targetShards(), | ||
splitState.targetShards().length | ||
); | ||
|
||
int i = shardId.getId() - state.shardCountBefore(); | ||
newTargets[i] = IndexReshardingState.Split.TargetShardState.HANDOFF; | ||
newTargets[i] = newTargetState; | ||
Tim-Brooks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return new IndexReshardingMetadata(new IndexReshardingState.Split(splitState.sourceShards(), newTargets)); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.