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

Clarify when a shard search request gets created to be only used locally #7855

Closed

Conversation

javanna
Copy link
Member

@javanna javanna commented Sep 24, 2014

In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called ShardSearchLocalRequest that can and will be only used locally. ShardSearchTransportRequest on the other hand delegates to the local version but extends TransportRequest and is Streamable, which means that it is supposed to be sent over the transport.

This way we can make the OriginalIndices only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in TransportSearchScrollQueryAndFetchAction.

@javanna javanna self-assigned this Sep 24, 2014
@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch from 82b3186 to 3aa887e Compare September 24, 2014 13:57
@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch from 3aa887e to 20e409e Compare September 24, 2014 14:21
@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch from 20e409e to 965950f Compare September 24, 2014 14:28
@s1monw
Copy link
Contributor

s1monw commented Sep 24, 2014

wouldn't it make more sense to have a base class SearchShardRequest and a TransportSearchShardRequest that also implements streamable instead of using factories?

@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch 2 times, most recently from f220806 to b79bdfe Compare September 26, 2014 15:37
@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch from b79bdfe to 316010a Compare September 26, 2014 16:00
@javanna
Copy link
Member Author

javanna commented Sep 26, 2014

Hey @s1monw your comment makes sense to me. It just was not as simple as that given that the transport version needs to extend TransportRequest, not just implement Streamable. I did split the requests but had to make the existing class an interface that is implemented by both. Much much cleaner but slightly bigger change than what I had in mind at first ;) Let me know what you think!

}

@SuppressWarnings("unchecked")
void readFrom(StreamInput in) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make this clean can we make all the members protected and then inside the ShardSearchTransportRequest we have a inner class that extends this local request and defines the readFrom / writeTo methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that this is indeed a local request and doesn't need to be Streamable, but the writeTo is somehow needed to locally build the cache key, that is why I kept the readFrom too in the same class here as they are related, and made them both package private. I agree it could be cleaner, not sure how...since both local and transport request need to write the cache key, which must be the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then this entire thing makes not much sense to me really

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it clarifies things, makes it clear when the shard search request is used locally and when it's sent over the transport. Better than static factories cause you can't now send ShardSearchLocalRequest over the transport at all as it doesn't implement TransportRequest. Also makes it more explicit that the binary representation is used as a cache key.

Maybe if things don't make sense it's because the way we use ShardSearchRequest is confusing per se and this PR doesn't clean it all up. How do you suggest we can improve this further?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well if you use the internal class you can have a static writeTo method that can be used to build a cache key?

@s1monw s1monw removed the review label Oct 7, 2014
@javanna javanna added the review label Oct 8, 2014
@javanna
Copy link
Member Author

javanna commented Oct 8, 2014

I pushed a new commit that should address your comment @s1monw . Can you also double check backwards compatibility please now that 1.4.0.Beta1 is released? We added originalIndices in beta1, but I think it makes no difference since the local variant of the request (where we now removed originalIndices) was never sent over the transport. The cache key does change (since it doesn't contain original indices anymore) but I think that is fine. And now originalIndices appear only where needed and are mandatory there (while before they were optional).

@s1monw
Copy link
Contributor

s1monw commented Oct 8, 2014

LGTM thanks luca

…iant

In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called `ShardSearchLocalRequest` that can and will be only used locally. `ShardSearchTransportRequest` on the other hand delegates to the local version but extends `TransportRequest` and is `Streamable`, which means that it is supposed to be sent over the transport.

This way we can make the `OriginalIndices` only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in `TransportSearchScrollQueryAndFetchAction`.

Closes elastic#7855
@javanna javanna force-pushed the enhancement/shard_search_request_cleanup branch from 71588cf to 021cb84 Compare October 8, 2014 13:58
javanna added a commit to javanna/elasticsearch that referenced this pull request Oct 8, 2014
…iant

In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called `ShardSearchLocalRequest` that can and will be only used locally. `ShardSearchTransportRequest` on the other hand delegates to the local version but extends `TransportRequest` and is `Streamable`, which means that it is supposed to be sent over the transport.

This way we can make the `OriginalIndices` only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in `TransportSearchScrollQueryAndFetchAction`.

Closes elastic#7855
javanna added a commit to javanna/elasticsearch that referenced this pull request Oct 8, 2014
…iant

In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called `ShardSearchLocalRequest` that can and will be only used locally. `ShardSearchTransportRequest` on the other hand delegates to the local version but extends `TransportRequest` and is `Streamable`, which means that it is supposed to be sent over the transport.

This way we can make the `OriginalIndices` only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in `TransportSearchScrollQueryAndFetchAction`.

Closes elastic#7855
@javanna javanna removed the review label Oct 8, 2014
@javanna javanna closed this in 3274e7e Oct 8, 2014
@clintongormley clintongormley changed the title Internal: clarify when a shard search request gets created to be only used locally Internal: Clarify when a shard search request gets created to be only used locally Nov 3, 2014
@clintongormley clintongormley changed the title Internal: Clarify when a shard search request gets created to be only used locally Clarify when a shard search request gets created to be only used locally Jun 7, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…iant

In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called `ShardSearchLocalRequest` that can and will be only used locally. `ShardSearchTransportRequest` on the other hand delegates to the local version but extends `TransportRequest` and is `Streamable`, which means that it is supposed to be sent over the transport.

This way we can make the `OriginalIndices` only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in `TransportSearchScrollQueryAndFetchAction`.

Closes elastic#7855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants