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

Refactor internal engine #27082

Merged
merged 3 commits into from
Oct 30, 2017
Merged

Conversation

jasontedor
Copy link
Member

This commit is a minor refactoring of internal engine to move hooks for generating sequence numbers into the engine itself. As such, we refactor tests that relied on this hook to use the new hook, and remove the hook from the sequence number service itself.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

I left some comments.

}

@FunctionalInterface
protected interface SeqNoServiceSupplier {
Copy link
Member

Choose a reason for hiding this comment

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

why not use java.util.function.BiFunction?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good catch. This is a product of the fact that I initially started with the supplier being a function of more parameters (the shard ID, the allocation ID, etc.) but collapsed these into the two that are left and did not see until you pointed it out that we can go all the way and remove the interface. Thank you.

@@ -2008,8 +2031,7 @@ public MergeStats getMergeStats() {
return mergeScheduler.stats();
}

@Override
public SequenceNumbersService seqNoService() {
public final SequenceNumbersService seqNoService() {
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering: Is it possible to move seqNoService field to Engine make the seqNoService() method there final? The SeqNoServiceSupplier (or BiFunction) should then also be moved as an constructor parameter to Engine.

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 don't think we can do this cleanly right now. It means that the sequence number service has to be available immediately (to pass to the super constructor) but we are also trying to initialize the index writer at the same time that we initialize the sequence number service.

Copy link
Member

Choose a reason for hiding this comment

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

I see, that makes it trickier. Thanks for explaining that.

import static java.util.Collections.emptyMap;
import static org.elasticsearch.index.mapper.SourceToParse.source;

public class TranslogHandler implements EngineConfig.TranslogRecoveryRunner {
Copy link
Member

@martijnvg martijnvg Oct 23, 2017

Choose a reason for hiding this comment

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

nit: maybe add class jdoc here about what the purpose of this implementation is?

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

From my side this LGTM.

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

I am curious where this goes, the refactoring LGTM. I wonder if we should do this in master rather than in a branch. looks generic enough?

@jasontedor
Copy link
Member Author

@s1monw I'm happy to pull this into master/6.x rather than a long-running feature branch, it will require maintenance on the feature branch then. 😇

@jasontedor jasontedor changed the base branch from ccr to master October 30, 2017 16:36
This commit is a minor refactoring of internal engine to move hooks for
generating sequence numbers into the engine itself. As such, we refactor
tests that relied on this hook to use the new hook, and remove the hook
from the sequence number service itself.
@jasontedor jasontedor merged commit a566942 into elastic:master Oct 30, 2017
jasontedor added a commit that referenced this pull request Oct 30, 2017
This commit is a minor refactoring of internal engine to move hooks for
generating sequence numbers into the engine itself. As such, we refactor
tests that relied on this hook to use the new hook, and remove the hook
from the sequence number service itself.

Relates #27082
@jasontedor jasontedor deleted the following-engine branch October 30, 2017 17:22
@clintongormley clintongormley added :Distributed Indexing/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Engine :Distributed Indexing/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. >enhancement v6.1.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants