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

[Extensions] Create writeable implementations for parser #6364

Merged
merged 4 commits into from
Feb 21, 2023

Conversation

mloufra
Copy link
Contributor

@mloufra mloufra commented Feb 17, 2023

Signed-off-by: Frank Lou [email protected]

Description

Create writeable implementations for parser that implement both Function<String, T> and Writeable interfaces for all existing setting implementations that use parsers.

Issues Resolved

Fixes opensearch-project/opensearch-sdk-java#349

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
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

Signed-off-by: Frank Lou <[email protected]>
Signed-off-by: Frank Lou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2023

Codecov Report

Merging #6364 (70c5fda) into main (c772596) will increase coverage by 0.11%.
The diff coverage is 68.53%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #6364      +/-   ##
============================================
+ Coverage     70.58%   70.69%   +0.11%     
- Complexity    58841    59015     +174     
============================================
  Files          4799     4799              
  Lines        282421   282721     +300     
  Branches      40717    40770      +53     
============================================
+ Hits         199341   199871     +530     
+ Misses        66584    66484     -100     
+ Partials      16496    16366     -130     
Impacted Files Coverage Δ
...g/opensearch/common/settings/WriteableSetting.java 71.58% <55.78%> (-19.07%) ⬇️
...dex/store/remote/file/OnDemandBlockIndexInput.java 79.13% <61.81%> (+6.12%) ⬆️
...n/java/org/opensearch/common/settings/Setting.java 86.34% <75.44%> (-3.90%) ⬇️
...e/remote/file/OnDemandBlockSnapshotIndexInput.java 72.34% <100.00%> (+0.91%) ⬆️
...g/opensearch/index/analysis/CharFilterFactory.java 0.00% <0.00%> (-100.00%) ⬇️
...adonly/AddIndexBlockClusterStateUpdateRequest.java 0.00% <0.00%> (-75.00%) ⬇️
...readonly/TransportVerifyShardIndexBlockAction.java 9.75% <0.00%> (-73.18%) ⬇️
...rch/test/junit/listeners/ReproduceInfoPrinter.java 9.52% <0.00%> (-68.26%) ⬇️
...n/admin/indices/readonly/AddIndexBlockRequest.java 17.85% <0.00%> (-53.58%) ⬇️
...ch/transport/ReceiveTimeoutTransportException.java 50.00% <0.00%> (-50.00%) ⬇️
... and 523 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
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 with a few suggestions:

  • document what happens with a null parser
  • either use the BooleanParser or get rid of it.

@@ -138,6 +152,7 @@ private Setting<?> createSetting(
SettingType type,
String key,
Object defaultValue,
Object parser,
Copy link
Member

Choose a reason for hiding this comment

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

If the parser is not Writeable (for example someone uses the constructor directly assigning parser) this could be null. Since that happens way back in lines 98-107 it's not obvious here. Recommend you add @Nullable annotation to this parameter to make it clear (and gain the benefit of code analysis tools double-checking the needed null checks).

In addition it's not obvious (I had to look it up) that the parser instanceof Writeable calls effectively do the null checks. It would be helpful to add a comment at the beginning of this method (about line 159) stating that, to aid people maintaining this code in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

@@ -147,33 +162,96 @@ private Setting<?> createSetting(
? Setting.boolSetting(key, (boolean) defaultValue, propertyArray)
Copy link
Member

Choose a reason for hiding this comment

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

We don't use the BooleanParser here. That's okay because boolSetting() uses the key and propertyArray to recreate it.

However we still use the BooleanParser in logic elsewhere in the code, creating dead code that will never execute, for example the writeParser switch/case for boolean (which means it will never be read by the StreamInput constructor either.

So I'd suggest either creating the (Writeable) BooleanParser here so the other code is actually used, or removing the Boolean case from the reading and writing switches later in this code and deleting the entire BooleanParser code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we are not using the BooleanParser, I think we can delete it.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Frank Lou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.snapshots.DedicatedClusterSnapshotRestoreIT.testIndexDeletionDuringSnapshotCreationInQueue

CHANGELOG.md Outdated
@@ -97,6 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add a setting to control auto release of OpenSearch managed index creation block ([#6277](https:/opensearch-project/OpenSearch/pull/6277))
- Fix timeout error when adding a document to an index with extension running ([#6275](https:/opensearch-project/OpenSearch/pull/6275))
- Clean up temporary files created during segment merge incase segment merge fails ([#6324](https:/opensearch-project/OpenSearch/pull/6324))
- Create writeable implementations for parser([#6364](https:/opensearch-project/OpenSearch/pull/5838))
Copy link
Member

Choose a reason for hiding this comment

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

Let's skip the changelog for this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean on skip? Are we going to merge another PR first? or just remove this changelog?

Copy link
Member

Choose a reason for hiding this comment

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

Remove this changelog and add skip changelog label

Copy link
Contributor Author

@mloufra mloufra Feb 21, 2023

Choose a reason for hiding this comment

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

you mean add another label like ###Skip and move this changelog under skip label?

Copy link
Member

Choose a reason for hiding this comment

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

You can delete this entry in the changelog and add the skip-changelog label to your PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks

Copy link
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, great work @mloufra

Signed-off-by: Frank Lou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@ryanbogan ryanbogan merged commit cadba4d into opensearch-project:main Feb 21, 2023
@ryanbogan ryanbogan added the backport 2.x Backport to 2.x branch label Feb 21, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 21, 2023
* make parser writeable

Signed-off-by: Frank Lou <[email protected]>

* add PR link to CHANGELOG

Signed-off-by: Frank Lou <[email protected]>

* address commit

Signed-off-by: Frank Lou <[email protected]>

* remove changelog

Signed-off-by: Frank Lou <[email protected]>

---------

Signed-off-by: Frank Lou <[email protected]>
(cherry picked from commit cadba4d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@mloufra mloufra deleted the writeable-parser branch February 21, 2023 20:27
ryanbogan pushed a commit that referenced this pull request Mar 10, 2023
* make parser writeable



* add PR link to CHANGELOG



* address commit



* remove changelog



---------


(cherry picked from commit cadba4d)

Signed-off-by: Frank Lou <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Create writeable implementations for parser
5 participants