Skip to content

Conversation

@s1monw
Copy link
Contributor

@s1monw s1monw commented Oct 12, 2016

AbstractSearchAsyncAction has only been tested in integration tests.
The infrastrucutre is rather critical and should be tested on a unittest
level. This change takes the first step

`AbstractSearchAsyncAction` has only been tested in integration tests.
The infrastrucutre is rather critical and should be tested on a unittest
level. This change takes the first step
@s1monw s1monw added >enhancement review :Search/Search Search-related issues that do not fall into other categories v6.0.0-alpha1 v5.1.1 labels Oct 12, 2016
@s1monw
Copy link
Contributor Author

s1monw commented Oct 13, 2016

@jpountz @nik9000 can one of you take a look

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Left some minor suggestions but LGTM.

protected abstract String firstPhaseName();

protected Executor getExecutor() {
return threadPool.executor(ThreadPool.Names.SEARCH);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe pass the Executor in to the ctor instead of ThreadPool? You could keep this method so you can still override it in tests to throw.

protected final SearchRequest request;
protected final ClusterState clusterState;
protected final DiscoveryNodes nodes;
protected final Function<String, DiscoveryNode> nodes;
Copy link
Member

Choose a reason for hiding this comment

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

Can you add javadoc for this? I'm happy to keep it protected but think it'd be nice to have some note on the protected members about how we expect them to be used. Something as simple as /** Used by subclasses to resolve node ids to DiscoveryNodes. **/ would be nice.

SearchPhaseController searchPhaseController, ThreadPool threadPool, SearchRequest request,
ActionListener<SearchResponse> listener) {
protected AbstractSearchAsyncAction(Logger logger, SearchTransportService searchTransportService,
Function<String, DiscoveryNode> nodeLookup, Map<String, String[]> perIndexFilteringAliases,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename nodeLookup to nodeIdToDiscsoveryNode? I love that you've pulled the cluster state stuff out into these functions we can mock out easily in tests but when I first scanned this line I thought "oh, functions that map index name to stuff".

Map<String, DiscoveryNode> lookup = new HashMap<>();
lookup.put(primaryNode.getId(), primaryNode);
AbstractSearchAsyncAction asyncAction = new AbstractSearchAsyncAction<TestSearchPhaseResult>(logger, transportService, lookup::get,
Collections.emptyMap(),
Copy link
Member

Choose a reason for hiding this comment

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

Can you bump the indentation on the parameters one time so they don't line up with the class body?

@s1monw
Copy link
Contributor Author

s1monw commented Oct 13, 2016

thanks @nik9000

@s1monw s1monw merged commit 61fd1cd into elastic:master Oct 13, 2016
@s1monw s1monw deleted the simplify_transport_search_action branch October 13, 2016 14:07
s1monw added a commit that referenced this pull request Oct 13, 2016
#20890)

`AbstractSearchAsyncAction` has only been tested in integration tests.
The infrastructure is rather critical and should be tested on a unit-test
level. This change takes the first step.
@clintongormley clintongormley added >test Issues or PRs that are addressing/adding tests and removed >enhancement labels Oct 17, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 21, 2016
This is a followup to elastic#21689 where we removed a misplaced try catch for IndexMissingException and IndexClosedException which was related to elastic#9047 (at least for the index closed case). The code block within the change was moved as part of elastic#20890, which made the catch redundant. It was somehow used before (e.g. in 5.0) but it doesn't seem that this catch had any effect. Added tests to verify that. In fact a specific catch added to the search api only would defeat the purpose of having common indices options that work throughout all our APIs.

Relates to elastic#21689
javanna added a commit that referenced this pull request Nov 21, 2016
This is a followup to #21689 where we removed a misplaced try catch for IndexMissingException and IndexClosedException which was related to #9047 (at least for the index closed case). The code block within the change was moved as part of #20890, which made the catch redundant. It was somehow used before (e.g. in 5.0) but it doesn't seem that this catch had any effect. Added tests to verify that. In fact a specific catch added to the search api only would defeat the purpose of having common indices options that work throughout all our APIs.

Relates to #21689
javanna added a commit that referenced this pull request Nov 21, 2016
This is a followup to #21689 where we removed a misplaced try catch for IndexMissingException and IndexClosedException which was related to #9047 (at least for the index closed case). The code block within the change was moved as part of #20890, which made the catch redundant. It was somehow used before (e.g. in 5.0) but it doesn't seem that this catch had any effect. Added tests to verify that. In fact a specific catch added to the search api only would defeat the purpose of having common indices options that work throughout all our APIs.

Relates to #21689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Search/Search Search-related issues that do not fall into other categories >test Issues or PRs that are addressing/adding tests v5.1.1 v6.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants