-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add _replica and _replica_first as search preference. #12244
Conversation
@@ -312,6 +316,32 @@ public ShardIterator primaryFirstActiveInitializingShardsIt() { | |||
return new PlainShardIterator(shardId, ordered); | |||
} | |||
|
|||
public ShardIterator replicaActiveInitializingShardIt() { | |||
if (!replicas.isEmpty() && !replicas.get(0).active() && !replicas.get(0).initializing()) { |
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.
I wouldn't rely on the order the replicas exist in for this behavior, note it works in the primary case cause there can be only one :)
left a couple of comments, can we also add unit tests to |
@kimchy thanks for taking a look! I think I misunderstood what the iterators were doing previously, but I think I have fixed it now. (and added a unit test to make sure) |
public ShardIterator replicaActiveInitializingShardIt() { | ||
// If the primaries are unassigned, return an empty list (there aren't | ||
// any replicas to query anyway) | ||
if (!primaryAsList.isEmpty() && !primaryAsList.get(0).active() && !primaryAsList.get(0).initializing()) { |
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.
can me extract this into a method, it is used in 3 places
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.
Good idea, I'll do that.
left few minor comments, LGTM |
5132419
to
aca40dd
Compare
Just like specifying `?preference=_primary`, this adds the ability to specify `?preference=_replica` or `?preference=_replica_first` on requests that support it. Resolves elastic#12222
aca40dd
to
a8391fc
Compare
Just like specifying
?preference=_primary
, this adds the ability tospecify
?preference=_replica
or?preference=_replica_first
onrequests that support it.
Resolves #12222