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

SOLR-15060: Introduce DelegatingDirectoryFactory. #2166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bruno-roustant
Copy link
Contributor

For the description, see https://issues.apache.org/jira/browse/SOLR-15060

This PR adds a new method get(String path, DirContext dirContext, String rawLockType, Function<Directory, Directory> wrappingFunction) in DirectoryFactory, with a new wrappingFunction parameter. The existing get(String path, DirContext dirContext, String rawLockType) calls the new one with Function.identity().

I wonder if this change should be 8x or 9x.

Comment on lines -408 to -412
maxWriteMBPerSecFlush = (Double) args.get("maxWriteMBPerSecFlush");
maxWriteMBPerSecMerge = (Double) args.get("maxWriteMBPerSecMerge");
maxWriteMBPerSecRead = (Double) args.get("maxWriteMBPerSecRead");
maxWriteMBPerSecDefault = (Double) args.get("maxWriteMBPerSecDefault");

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this all deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simply noticed that those fields were private and actually never used. I think they should be removed for clarity, but that's not necessary for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at these a week ago. It's lingering left-over stuff from a refactoring McCandless did years ago in where some thresholds are configured.

* Configured with the {@code delegateFactory} parameter which defines the full class name of the delegate
* {@link DirectoryFactory}, plus any additional parameter for the delegate factory.</p>
*/
public class DelegatingDirectoryFactory extends DirectoryFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be abstract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, yes it misses abstract.

*/
@Override
public final Directory get(String path, DirContext dirContext, String rawLockType)
public final Directory get(String path, DirContext dirContext, String rawLockType, Function<Directory, Directory> wrappingFunction)
Copy link
Contributor

Choose a reason for hiding this comment

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

is cachingdirectoryfactory supposed to extend delegatingDF now? I'm confused about the relationship here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think CachingDF should extend DelegatingDF. Here the goal with this new param is to allow the caller to have a hook when the Directory is created internally. Otherwise there is no way a DelegatingDF "A" can delegate to any CachingDF "B" while leveraging the cache inside B and at the same time have control over the class of Directory cached and returned.
Another option could be to first extend the CachingDF with a B' class that overrides the createDirectory() method. But that means a DelegatingDF can only delegate to a specific class B' extending CachingDF. This would be too limiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A sample usage could be a BlobDF extending DelegatingDF to delegate to any configured DF, probably MMapDF which is a CachingDF. BlobDF would need to create BlobDir that delegates to a MMapDir. BlobDir cannot wrap the MMapDir outside of the CachingDF, because for the cache to actually work, it has to cache the BlobDir instance. That's why the idea is to provide a wrapper function to wrap a MMapDir with a BlobDir when it is created internally by the CachingDF.

@dsmiley
Copy link
Contributor

dsmiley commented Jan 13, 2021

The PR is about introducing a low level utility that we expect will be useful for custom DirectoryFactory implementations that we don't even have yet. It's the kind of thing that many of us wouldn't of even created a separate PR for -- it'd show up in a larger PR that introduces the first user of the utility. It's not even worth a CHANGES.txt entry IMO; there's always the commit message. As long as there is no user of this code yet, I'd prefer that we don't merge this yet. Perhaps we may find that the abstraction here isn't quite right.

RE master (9) vs 8x... If we wait till BlobDirectory, it'd almost certainly be 9. If we don't, ehh... I'd just do 9.

@bruno-roustant
Copy link
Contributor Author

Actually I'll need that to simplify the code in BlobDirectory. So based on your remark David, I should rather integrate this code in BlobDirectory code and close this Jira issue.

@dsmiley
Copy link
Contributor

dsmiley commented Jan 13, 2021

An in-between is to leave this issue open until the BlobDirectory is much more ready. It may change in the mean time; who knows. I do like the notion of committing separate pieces instead of one feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants