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

Simplify BlobStoreRepository (Flatten Nested Classes) #42833

Merged

Conversation

original-brownbear
Copy link
Member

@original-brownbear original-brownbear commented Jun 4, 2019

  • In the current codebase it is hardly obvious what code operates on a shard and is run by a datanode what code operates on the global metadata and is run on master
    • Fixed by adjusting the method names accordingly
  • The nested context classes don't add much if any value, they simply spread out the parameters that go into a shard snapshot create or delete all over the place since their
    constructors can be inlined in all spots
    • Fixed by flattening the nested classes into BlobStoreRepository
  • Also:
    • Inlined the other single use inner classes

* In the current codebase it is hardly obvious what code operates on a shard and is run by a datanode what code operates on the global metadata and is run on master
   * Fixed by adjusting the method names accordingly
* The nested context classes don't add much if any value, they simply spread out the parameters that go into a shard snapshot create or delete all over the place since their
constructors can be inlined in all spots
   * Fixed by flattening the nested classes into BlobStoreRepository
* Also:
  * Inlined the other single use inner classes
  * Moved all methods related to shard directories together to the bottom of the class
  * Dried up the logic for getting index and shard blob containers
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Contributor

@andrershov andrershov left a comment

Choose a reason for hiding this comment

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

I find it difficult to review this PR, because diffs do not work correctly. Could you please comment on each method of the removed class, what is the replacement method for the removed method and if there are any changes made to it?
Also, probably it makes sense to split this PR into separate PRs. For example, one that just removes nested classes, but makes no other modifications. Another one makes other changes. The splitting might probably produce more readable diffs, at least for the second PR.

}
bytes = bStream.bytes();
}
final XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline builder as it's done with repositoryData.snapshotsToXContent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't do it here since the API is a little different here :( the call to org.elasticsearch.repositories.RepositoryData#incompatibleSnapshotsToXContent returns void.

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 adjusted this now after all to make the API a little more fluent :)

@@ -796,48 +785,6 @@ private void writeAtomic(final String blobName, final BytesReference bytesRef, b
}
}

@Override
public void snapshotShard(Store store, MapperService mapperService, SnapshotId snapshotId, IndexId indexId,
Copy link
Contributor

Choose a reason for hiding this comment

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

Git diff is failing here because seems that this method and the next one are not removed.

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 made this (hopefully) a lot more agreeable to look at now but removing the shuffling of methods.
Try diffing with whitespaces ignored #42833 maybe, then all but this method should come up fine.
In this method nothing really changed except for the fact that I moved to using the cached time thread and moved the counter variables a little closer to usage. Other than that, the method here is equivalent to the snapshot method on the context before (except that the fields on the context are now method parameters).

Hope that helps :)

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/oss-distro-docs

@ywelsch ywelsch requested a review from tlrx June 17, 2019 08:42
Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

This PR is mixing different things, making it hard to review. Can you please split it into multiple smaller PRs? Thanks.

@original-brownbear
Copy link
Member Author

@tlrx sure on it, I'll separate out the smaller pieces and leave the flattening of the class structure in this one.

original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Jun 18, 2019
* Extracted from elastic#42833:
  * Dry up index and shard path handling
  * Shorten XContent handling
@original-brownbear
Copy link
Member Author

Small and unrelated things extracted in #43323 :)

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/1

original-brownbear added a commit that referenced this pull request Jun 18, 2019
* Some Cleanup in BlobStoreRepository

* Extracted from #42833:
  * Dry up index and shard path handling
  * Shorten XContent handling
@original-brownbear original-brownbear requested a review from tlrx June 18, 2019 18:34
@original-brownbear
Copy link
Member Author

@tlrx alrighty, merged in master again. Now there's only nested class inlining/flattening left I think.
With ?w=1 the diff should be more agreeable to read now I hope. If not I could separate out the inlining of the AbortableInputStream and the sliced input stream in another step?

@original-brownbear original-brownbear changed the title Simplify BlobStoreRepository Simplify BlobStoreRepository (Flatten Nested Classes) Jun 21, 2019
@original-brownbear
Copy link
Member Author

Thanks so much for going through this one @tlrx! All points addressed/fixed I think :)

@original-brownbear original-brownbear requested a review from tlrx June 21, 2019 12:25
Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@original-brownbear
Copy link
Member Author

Thank you @tlrx !

@original-brownbear original-brownbear merged commit c1c2ce3 into elastic:master Jun 21, 2019
@original-brownbear original-brownbear deleted the shorten-blobstore-repo-code branch June 21, 2019 14:40
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Jul 7, 2019
* Some Cleanup in BlobStoreRepository

* Extracted from elastic#42833:
  * Dry up index and shard path handling
  * Shorten XContent handling
original-brownbear added a commit that referenced this pull request Jul 7, 2019
* Some Cleanup in BlobStoreRepository

* Extracted from #42833:
  * Dry up index and shard path handling
  * Shorten XContent handling
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Jul 8, 2019
* In the current codebase it is hardly obvious what code operates on a shard and is run by a datanode what code operates on the global metadata and is run on master
   * Fixed by adjusting the method names accordingly
* The nested context classes don't add much if any value, they simply spread out the parameters that go into a shard snapshot create or delete all over the place since their
constructors can be inlined in all spots
   * Fixed by flattening the nested classes into BlobStoreRepository
* Also:
  * Inlined the other single use inner classes
original-brownbear added a commit that referenced this pull request Jul 8, 2019
* In the current codebase it is hardly obvious what code operates on a shard and is run by a datanode what code operates on the global metadata and is run on master
   * Fixed by adjusting the method names accordingly
* The nested context classes don't add much if any value, they simply spread out the parameters that go into a shard snapshot create or delete all over the place since their
constructors can be inlined in all spots
   * Fixed by flattening the nested classes into BlobStoreRepository
* Also:
  * Inlined the other single use inner classes
mkleen added a commit to crate/crate that referenced this pull request Jun 19, 2020
mkleen added a commit to crate/crate that referenced this pull request Jun 19, 2020
mkleen added a commit to crate/crate that referenced this pull request Jun 19, 2020
mergify bot pushed a commit to crate/crate that referenced this pull request Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants