Skip to content
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

Merged
merged 1 commit into from
Jul 16, 2015

Conversation

dakrone
Copy link
Member

@dakrone dakrone commented Jul 14, 2015

Just like specifying ?preference=_primary, this adds the ability to
specify ?preference=_replica or ?preference=_replica_first on
requests that support it.

Resolves #12222

@@ -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()) {
Copy link
Member

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 :)

@kimchy
Copy link
Member

kimchy commented Jul 14, 2015

left a couple of comments, can we also add unit tests to RoutingIteratorTests? I think in that case, we don't really need to have an integration test

@dakrone
Copy link
Member Author

dakrone commented Jul 15, 2015

@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()) {
Copy link
Member

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

Copy link
Member Author

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.

@kimchy
Copy link
Member

kimchy commented Jul 16, 2015

left few minor comments, LGTM

@dakrone dakrone force-pushed the add-replica-preference branch from 5132419 to aca40dd Compare July 16, 2015 15:25
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
@dakrone dakrone force-pushed the add-replica-preference branch from aca40dd to a8391fc Compare July 16, 2015 15:25
@dakrone dakrone merged commit a8391fc into elastic:master Jul 16, 2015
@clintongormley clintongormley added the :Search/Search Search-related issues that do not fall into other categories label Jul 17, 2015
@dakrone dakrone deleted the add-replica-preference branch August 25, 2015 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants