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

Deletepit API #3

Open
wants to merge 34 commits into
base: createpit
Choose a base branch
from
Open

Deletepit API #3

wants to merge 34 commits into from

Conversation

bharath-techie
Copy link
Owner

Description

Changes for delete pit api ( single, list and all )

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@bharath-techie bharath-techie force-pushed the deletepit branch 3 times, most recently from 8f23568 to 3e23f9d Compare April 19, 2022 09:19
Signed-off-by: Bharathwaj G <[email protected]>
Copy link

@eirsep eirsep left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes @bharath-techie.

Have comments on few code structuring

Skimmed through PR. Will take a deeper look and review along with test cases once rest tests, functional tests etc. are added.

public static final String FREE_CONTEXT_ACTION_NAME = "indices:data/read/search[free_context]";
public static final String CLEAR_SCROLL_CONTEXTS_ACTION_NAME = "indices:data/read/search[clear_scroll_contexts]";
public static final String DELETE_ALL_PIT_CONTEXTS_ACTION_NAME = "indices:data/read/search[delete_pit_contexts]";
Copy link

Choose a reason for hiding this comment

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

variable name and action name should be consistent for delete all should be consistent with
public static final String FREE_CONTEXT_PIT_ACTION_NAME = "indices:data/read/search[free_context/pit]";

transportService.sendRequest(
connection,
FREE_CONTEXT_PIT_ACTION_NAME,
new ScrollFreeContextRequest(contextId),
Copy link

Choose a reason for hiding this comment

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

why is this ScrollFreeContextRequest

@@ -198,6 +214,16 @@ public void sendClearAllScrollContexts(Transport.Connection connection, final Ac
);
}

public void sendDeleteAllPitContexts(Transport.Connection connection, final ActionListener<TransportResponse> listener) {
Copy link

Choose a reason for hiding this comment

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

let's make it uniform and call it freeAllPitContexts maybe

DELETE_ALL_PIT_CONTEXTS_ACTION_NAME,
TransportRequest.Empty.INSTANCE,
TransportRequestOptions.EMPTY,
new ActionListenerResponseHandler<>(listener, (in) -> TransportResponse.Empty.INSTANCE)
Copy link

Choose a reason for hiding this comment

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

why is this returning an empty transport response?

for (SearchContextIdForNode contextId : contexts) {
final DiscoveryNode node = nodeLookup.apply(contextId.getClusterAlias(), contextId.getNode());
if (node == null) {
groupedListener.onFailure(new OpenSearchException("node not connected"));
Copy link

Choose a reason for hiding this comment

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

"node not found" maybe? How do we know node even exists

/**
* Delete all active PIT reader contexts
*/
void deleteAllPits(ActionListener<DeletePITResponse> listener) {
Copy link

Choose a reason for hiding this comment

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

can we move this to a separate handler class which would enable us to do better functional testing?

/**
* Delete list of pits, return success if all reader contexts are deleted ( or not found ).
*/
void deletePits(List<SearchContextIdForNode> contexts, ActionListener<Integer> listener) {
Copy link

Choose a reason for hiding this comment

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

can we move this to a separate handler class which would enable us to do better functional testing?

Copy link
Owner Author

Choose a reason for hiding this comment

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

unlike create pit (where mocking the transport action didn't give us the desired results), i was able to mock and write functional tests without segregating the methods into a separate file.

}, listener::onFailure);
}

private StepListener<BiFunction<String, String, DiscoveryNode>> getLookupListener(List<SearchContextIdForNode> contexts) {
Copy link

Choose a reason for hiding this comment

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

this seems like a reusable method between create/delete/pit or on those lines. redundant? Maybe all in one service class can harness common functionalities better?

Copy link
Owner Author

Choose a reason for hiding this comment

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

not reusable since signature and hence logic is different between create and delete.

return lookupListener;
}

private ActionListener<DeletePITResponse> getGroupedListener(ActionListener<DeletePITResponse> deletePitListener, int size) {
Copy link

Choose a reason for hiding this comment

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

why a separate method for this if its used only once and is private hence not even being called in unit tests?

Copy link

@eirsep eirsep left a comment

Choose a reason for hiding this comment

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

Meant to mark as request changes.

@bharath-techie bharath-techie changed the base branch from createpit to main May 2, 2022 12:56
@bharath-techie bharath-techie changed the base branch from main to createpit May 2, 2022 12:56
Signed-off-by: Bharathwaj G <[email protected]>
@bharath-techie bharath-techie force-pushed the createpit branch 2 times, most recently from 6cda616 to 730afa8 Compare May 5, 2022 08:12
Signed-off-by: Bharathwaj G <[email protected]>
@bharath-techie bharath-techie force-pushed the createpit branch 5 times, most recently from 7a77f7b to 929800d Compare May 13, 2022 07:48
Signed-off-by: Bharathwaj G <[email protected]>
@bharath-techie bharath-techie force-pushed the createpit branch 3 times, most recently from f65aa43 to 35d8cc4 Compare May 13, 2022 10:57
Signed-off-by: Bharathwaj G <[email protected]>
@bharath-techie bharath-techie force-pushed the deletepit branch 3 times, most recently from 100e1ea to d2e972b Compare May 18, 2022 17:23
dependabot bot and others added 5 commits May 18, 2022 10:31
Bumps com.diffplug.spotless from 6.5.2 to 6.6.1.

---
updated-dependencies:
- dependency-name: com.diffplug.spotless
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…pensearch-project#3361)

* Bump grpc-context from 1.45.1 to 1.46.0 in /plugins/repository-gcs

Bumps [grpc-context](https://github.com/grpc/grpc-java) from 1.45.1 to 1.46.0.
- [Release notes](https://github.com/grpc/grpc-java/releases)
- [Commits](grpc/grpc-java@v1.45.1...v1.46.0)

---
updated-dependencies:
- dependency-name: io.grpc:grpc-context
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Updating SHAs

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Signed-off-by: Bharathwaj G <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants