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

Share common readFrom/writeTo code in AcknowledgeResponse #30983

Merged
merged 7 commits into from
Jun 4, 2018

Conversation

cbuescher
Copy link
Member

The majority of Responses inheriting from AcknowledgeResponse implement
the readFrom and writeTo serialization method in the same way. Moving this
as a default into AcknowledgeResponse and letting the few exceptions that
need a slightly different implementation handle this themselves saves a lot
of duplication.
I don't know if there is/was other reasons about not doing this in the past, if
so I'd like to learn about them.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM. I left a question that can be answered here and resolved if needed in a follow-up.

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
readAcknowledged(in);
Copy link
Member

Choose a reason for hiding this comment

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

I am on mobile so I can not look this up. Is there a reason these read/write methods need to be visible to sub-classes now with this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Unfortunately there are (only) six classes extending AcknowledgedResponse that use those directly at the moment to read/write the acknowledged flag. I just looked at the details and found a problem with bwc with this change because they also use super() and interleave reading/writing the acknowledged flag in s weird way. I'm down to three cases where it might make sense to change the order of serialization in a bwc way to make this change work.

@cbuescher cbuescher force-pushed the cleanup-AckResponse branch from eb53a00 to 6fd0d69 Compare May 31, 2018 12:45
Conflicts:
	server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java
@cbuescher
Copy link
Member Author

I added another commit that fixes some bwc issues for wire compatibility and changes the serialization on master so the acknowledged flag gets written earlier so we can use the super class read/write logic here as well.
@javanna since you just touched one of these classes last, would you mind taking another look at that last commit?

@cbuescher cbuescher requested a review from javanna June 1, 2018 08:32
Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM but we may need some more tests for the bw comp layer? I assume that we already have tests for serialization of all the classes touched, still specific tests for this bw comp layer would be good to have.

rolledOver = in.readBoolean();
readShardsAcknowledged(in);
} else {
oldIndex = in.readString();
Copy link
Member

Choose a reason for hiding this comment

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

here we are lucky that super reads only the acknowledged flag and we get away with effectively not calling super, it's a tricky one ;)

I would probably make a method with this shared code block

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'm not sure I understand which code block to share. Do you mean the part in super() that writes the boolean flag or the common read parts of the two branches here? In the later case this isn't completely possible since in the "old" serialization order the acknowledged field gets read as second-to-last field. Maybe I didn't understand this correctly.

Copy link
Member

Choose a reason for hiding this comment

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

arg I hadn't seen the acknowledged flag, nevermind

out.writeBoolean(dryRun);
out.writeBoolean(rolledOver);
out.writeBoolean(acknowledged);
writeShardsAcknowledged(out);
Copy link
Member

Choose a reason for hiding this comment

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

same here, factor out this shared code block into a method?

Christoph Büscher added 2 commits June 1, 2018 15:43
 Conflicts:
	server/src/main/java/org/elasticsearch/action/ingest/PutPipelineResponse.java
	server/src/main/java/org/elasticsearch/action/ingest/WritePipelineResponse.java
@cbuescher
Copy link
Member Author

@javanna thanks, I added bwc tests for RolloverResponse and ClusterUpdateSettingsResponse. For ClusterRerouteResponse the work needed would be quiet considerable since the test class doesn't really support any of the wireformat and serialization testing so far, and involves quiet complicated setup (contains ClusterState which e.g. doesn't implement equals/hashCode etc...). Adding any kind of serialization testing that makes sense would take quiet a bit of work, so I hope you don't mind if we don't do this in this PR. I count on integration testing in mixed cluster environments to catch any potential issues.

@cbuescher
Copy link
Member Author

test this please

@cbuescher
Copy link
Member Author

Backport PR: #31071

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 4, 2018
* master:
  Remove usage of explicit type in docs (elastic#29667)
  Share common readFrom/writeTo code in AcknowledgeResponse (elastic#30983)
  Adapt bwc versions after backporting elastic#31045 to 6.x
  Mute MatchPhrase*QueryBuilderTests
  [Docs] Fix typo in watcher conditions documentation (elastic#30989)
  Remove wrong link in index phrases doc
  Move pipeline APIs to ingest namespace (elastic#31027)
  [DOCS] Fixes accounting setting names (elastic#30863)
  [DOCS] Rewords _field_names documentation (elastic#31029)
  Index phrases (elastic#30450)
dnhatn added a commit that referenced this pull request Jun 4, 2018
* master:
  Match phrase queries against non-indexed fields should throw an exception (#31060)
  In the internal highlighter APIs, use the field type as opposed to the mapper. (#31039)
  [DOCS] Removes duplicated authentication pages
  Enable customizing REST tests blacklist (#31074)
  Make sure KeywordFieldMapper#clone preserves split_queries_on_whitespace. (#31049)
  [DOCS] Moves machine learning overview to stack-docs
  [ML] Add secondary sort to ML events (#31063)
  [Rollup] Specialize validation exception for easier management (#30339)
  Adapt bwc versions after backporting #31045 to 6.3
  Remove usage of explicit type in docs (#29667)
  Share common readFrom/writeTo code in AcknowledgeResponse (#30983)
  Adapt bwc versions after backporting #31045 to 6.x
  Mute MatchPhrase*QueryBuilderTests
  [Docs] Fix typo in watcher conditions documentation (#30989)
  Remove wrong link in index phrases doc
  Move pipeline APIs to ingest namespace (#31027)
  [DOCS] Fixes accounting setting names (#30863)
  [DOCS] Rewords _field_names documentation (#31029)
  Index phrases (#30450)
  Remove leftover debugging from PTCMDT
  Fix PTCMDT#testMinVersionSerialization
  Make Persistent Tasks implementations version and feature aware (#31045)
dnhatn added a commit that referenced this pull request Jun 4, 2018
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Jun 5, 2018
)

The majority of Responses inheriting from AcknowledgeResponse implement
the readFrom and writeTo serialization method in the same way. Moving this
as a default into AcknowledgeResponse and letting the few exceptions that
need a slightly different implementation handle this themselves saves a lot
of duplication.
cbuescher pushed a commit that referenced this pull request Jun 5, 2018
The majority of Responses inheriting from AcknowledgeResponse implement
the readFrom and writeTo serialization method in the same way. Moving this
as a default into AcknowledgeResponse and letting the few exceptions that
need a slightly different implementation handle this themselves saves a lot
of duplication.
cbuescher pushed a commit that referenced this pull request Jun 5, 2018
dnhatn added a commit that referenced this pull request Jun 5, 2018
* 6.x:
  Share common readFrom/writeTo code in AcknowledgeResponse (#30983)
  [Tests] Muting RatedRequestsTests#testXContentParsingIsNotLenient
  Fix rest test skip version
  Fix docs build.
  Add a doc value format to binary fields. (#30860)
  Only auto-update license signature if all nodes ready (#30859)
  Add BlobContainer.writeBlobAtomic() (#30902)
  Move caching of the size of a directory to `StoreDirectory`. (#30581)
  Clarify docs about boolean operator precedence. (#30808)
  Docs: remove notes on sparsity. (#30905)
  Improve documentation of dynamic mappings. (#30952)
  Decouple MultiValueMode. (#31075)
  Docs: Clarify constraints on scripted similarities. (#31076)
dnhatn added a commit that referenced this pull request Jun 5, 2018
dnhatn added a commit that referenced this pull request Jun 5, 2018
* master:
  Removing erroneous repeat
  Adapt bwc versions after backporting #30983 to 6.4
  [Tests] Muting RatedRequestsTests#testXContentParsingIsNotLenient
  TEST:  Retry synced-flush if ongoing ops on primary (#30978)
  Fix docs build.
  Only auto-update license signature if all nodes ready (#30859)
  Add BlobContainer.writeBlobAtomic() (#30902)
  Add a doc value format to binary fields. (#30860)
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 5, 2018
* elastic/master:
  Add cors support to NioHttpServerTransport (elastic#30827)
  [DOCS] Fixes security example (elastic#31082)
  Allow terms query in _rollup_search (elastic#30973)
  Removing erroneous repeat
  Adapt bwc versions after backporting elastic#30983 to 6.4
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 5, 2018
* ccr:
  [DOCS] Creates rest-api folder in docs
  [Rollup] Disallow index patterns that match the rollup index (elastic#30491)
  Replace exact numDocs by soft-del count in SegmentInfo (elastic#31086)
  Upgrade to Lucene-7.4.0-snapshot-0a7c3f462f (elastic#31073)
  Add cors support to NioHttpServerTransport (elastic#30827)
  [DOCS] Fixes security example (elastic#31082)
  Allow terms query in _rollup_search (elastic#30973)
  Removing erroneous repeat
  Adapt bwc versions after backporting elastic#30983 to 6.4
  [Tests] Muting RatedRequestsTests#testXContentParsingIsNotLenient
  TEST:  Retry synced-flush if ongoing ops on primary (elastic#30978)
  Fix docs build.
  Only auto-update license signature if all nodes ready (elastic#30859)
  Add BlobContainer.writeBlobAtomic() (elastic#30902)
  Add a doc value format to binary fields. (elastic#30860)
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jun 5, 2018
* ccr:
  [DOCS] Creates rest-api folder in docs
  [Rollup] Disallow index patterns that match the rollup index (elastic#30491)
  Replace exact numDocs by soft-del count in SegmentInfo (elastic#31086)
  Upgrade to Lucene-7.4.0-snapshot-0a7c3f462f (elastic#31073)
  Add cors support to NioHttpServerTransport (elastic#30827)
  [DOCS] Fixes security example (elastic#31082)
  Allow terms query in _rollup_search (elastic#30973)
  Removing erroneous repeat
  Adapt bwc versions after backporting elastic#30983 to 6.4
  [Tests] Muting RatedRequestsTests#testXContentParsingIsNotLenient
  TEST:  Retry synced-flush if ongoing ops on primary (elastic#30978)
  Fix docs build.
  Only auto-update license signature if all nodes ready (elastic#30859)
  Add BlobContainer.writeBlobAtomic() (elastic#30902)
  Add a doc value format to binary fields. (elastic#30860)
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants