Skip to content

Refactor handler method#158

Merged
dbwiddis merged 21 commits intoopensearch-project:mainfrom
mloufra:refactor-handler
Sep 30, 2022
Merged

Refactor handler method#158
dbwiddis merged 21 commits intoopensearch-project:mainfrom
mloufra:refactor-handler

Conversation

@mloufra
Copy link
Copy Markdown
Contributor

@mloufra mloufra commented Sep 26, 2022

Description

Create the following five new classes to handle each handler method for refactoring the class in ExtensionsRunner.java.

  • ExtensionsInitRequestHandler handle method handleExtensionInitRequest
  • OpensearchRequestHandler handle method handleOpenSearchRequest
  • ExtensionsIndicesModuleRequestHandler handle method handleIndicesModuleRequest
  • ExtensionsIndicesModuleNameRequestHandler handle method handleIndicesModuleNameRequest
  • ExtenionsRestRequestHandler handle method handleRestExecuteOnExtensionRequest

Issues Resolved

#116

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.

mloufra and others added 12 commits August 26, 2022 16:43
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
@mloufra mloufra requested a review from a team September 26, 2022 23:19
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

I'm not sure why so many variables were changed to static, and suspect there's a better way to handle whatever challenge that was meant to address.

Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
Signed-off-by: mloufra <mloufra@amazon.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 28, 2022

Codecov Report

❌ Patch coverage is 57.14286% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.60%. Comparing base (d7b873c) to head (d3388ef).
⚠️ Report is 317 commits behind head on main.

Files with missing lines Patch % Lines
...rch/sdk/handlers/ExtensionsRestRequestHandler.java 33.33% 11 Missing and 1 partial ⚠️
...main/java/org/opensearch/sdk/ExtensionsRunner.java 53.33% 7 Missing ⚠️
...ers/ExtensionsIndicesModuleNameRequestHandler.java 40.00% 3 Missing ⚠️
...andlers/ExtensionsIndicesModuleRequestHandler.java 40.00% 3 Missing ⚠️
...nsearch/sdk/handlers/OpensearchRequestHandler.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #158      +/-   ##
============================================
+ Coverage     63.69%   64.60%   +0.90%     
- Complexity       90       99       +9     
============================================
  Files            20       25       +5     
  Lines           482      500      +18     
  Branches         18       18              
============================================
+ Hits            307      323      +16     
- Misses          167      169       +2     
  Partials          8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…Handler

Signed-off-by: mloufra <mloufra@amazon.com>
@mloufra mloufra requested a review from dbwiddis September 28, 2022 22:10
* @return A response to OpenSearch for the corresponding API
* @throws Exception if the corresponding handler for the request is not present
*/
public TransportResponse handleOpenSearchRequest(OpenSearchRequest request) throws Exception {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a class for NamedWriteableRegistry and not OpenSearchRequest. Also, we don't need a switch case here. If/else can do the job.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It used to have a lot more cases before we refactored :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can keep this switch case here, it will easier for others adding more case in the future.

Copy link
Copy Markdown
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Looking good with the documentation comments noted!

* @return A response to OpenSearch for the corresponding API
* @throws Exception if the corresponding handler for the request is not present
*/
public TransportResponse handleOpenSearchRequest(OpenSearchRequest request) throws Exception {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It used to have a lot more cases before we refactored :-)

Signed-off-by: mloufra <mloufra@amazon.com>
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

LGTM! Any additional requests please put on the linked issue for the next round, so we can merge this. :)

@dbwiddis dbwiddis merged commit 0bdd6b4 into opensearch-project:main Sep 30, 2022
@dbwiddis dbwiddis deleted the refactor-handler branch September 30, 2022 02:50
kokibas pushed a commit to kokibas/opensearch-sdk-java that referenced this pull request Mar 17, 2023
* issue opensearch-project#28

Signed-off-by: mloufra <mloufra@amazon.com>

* Update the lastest coomit

Signed-off-by: mloufra <mloufra@amazon.com>

* Rename the method and fix the conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* fix merge conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* Add code coverage report

Signed-off-by: mloufra <mloufra@amazon.com>

* Rebase the lastest commit

Signed-off-by: mloufra <mloufra@amazon.com>

* update the lastest commit

Signed-off-by: mloufra <mloufra@amazon.com>

* refactor class for handler method in ExtensionsRunner

Signed-off-by: mloufra <mloufra@amazon.com>

* add documentation for handler

Signed-off-by: mloufra <mloufra@amazon.com>

* fix merge conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* delete all the static

Signed-off-by: mloufra <mloufra@amazon.com>

* fix documentation problem

Signed-off-by: mloufra <mloufra@amazon.com>

* fix NullPointerException bug

Signed-off-by: mloufra <mloufra@amazon.com>

* change RestResponse to ExtensionRestResponse in ExtensionsRestRequestHandler

Signed-off-by: mloufra <mloufra@amazon.com>

* change documentation for ExtensionsRunner

Signed-off-by: mloufra <mloufra@amazon.com>

Signed-off-by: mloufra <mloufra@amazon.com>
caokyhieu pushed a commit to caokyhieu/opensearch-sdk-java that referenced this pull request Aug 15, 2025
* issue opensearch-project#28

Signed-off-by: mloufra <mloufra@amazon.com>

* Update the lastest coomit

Signed-off-by: mloufra <mloufra@amazon.com>

* Rename the method and fix the conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* fix merge conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* Add code coverage report

Signed-off-by: mloufra <mloufra@amazon.com>

* Rebase the lastest commit

Signed-off-by: mloufra <mloufra@amazon.com>

* update the lastest commit

Signed-off-by: mloufra <mloufra@amazon.com>

* refactor class for handler method in ExtensionsRunner

Signed-off-by: mloufra <mloufra@amazon.com>

* add documentation for handler

Signed-off-by: mloufra <mloufra@amazon.com>

* fix merge conflict

Signed-off-by: mloufra <mloufra@amazon.com>

* delete all the static

Signed-off-by: mloufra <mloufra@amazon.com>

* fix documentation problem

Signed-off-by: mloufra <mloufra@amazon.com>

* fix NullPointerException bug

Signed-off-by: mloufra <mloufra@amazon.com>

* change RestResponse to ExtensionRestResponse in ExtensionsRestRequestHandler

Signed-off-by: mloufra <mloufra@amazon.com>

* change documentation for ExtensionsRunner

Signed-off-by: mloufra <mloufra@amazon.com>

Signed-off-by: mloufra <mloufra@amazon.com>
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