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

[QTL][Lookup] lookup module with the snapshot utility #2517

Merged
merged 1 commit into from
Mar 17, 2016

Conversation

b-slim
Copy link
Contributor

@b-slim b-slim commented Feb 22, 2016

This PR

  1. Refactor lookup class into one package and one module.
  2. Add the ability of bootstraping lookup configuration from a snapshot file. The snapshot file will be created and periodically updated by the lookupFactoryRefManager. This will ensure that we dont supply configuration via runtime property file.
  3. @drcrallen config and module classes in this PR need to be merged with [QTL] Query time lookup cluster wide config #1576


|Property|Description|Default|
|--------|-----------|-------|
|`druid.lookup.snapshotWorkingDir`| Working path used to store snapshot of current lookup configuration, leaving this property null will disable snapshot/bootstrap utility|null|
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should be required instead of optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought about it but felt like ppls might chose to not use it. i can set it as mandatory if you feel that we can not use Lookup without this snapshot utility , which in MO not true.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible to use segments without the local segment cache as well, but we force that because it allows the node to be restarted in the exact same state it was in before it went down. This should be the same.

Actually, though, I think it would make sense to maybe make it default to the segmentCache directory + "/lookups" or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cheddar but thought broker doesn't have segment cache property ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call. Yes, it does not...

@b-slim
Copy link
Contributor Author

b-slim commented Feb 24, 2016

@drcrallen can you please take a look at this.

@b-slim b-slim added this to the 0.9.1 milestone Feb 24, 2016
@b-slim b-slim added the Feature label Feb 24, 2016
@b-slim b-slim changed the title lookup module with the snapshot utility [QTL][Lookup] lookup module with the snapshot utility Feb 24, 2016

boolean isAdded = (null == lookupMap.putIfAbsent(lookupName, lookupExtractorFactory));
if (isAdded && lookupSnapshotTaker != null) {
lookupSnapshotTaker.takeSnapshot(getAllAsList());
Copy link
Contributor

Choose a reason for hiding this comment

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

This works. But, why re-write all of them instead of just appending the new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't expect this will change very frequently and size will be limited so i think let's keep it this way

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to have a snapshot every put instead of just on stop()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes every put you have new changes, like that you make sure if the process crash we have a recent snapshot.

@cheddar
Copy link
Contributor

cheddar commented Feb 24, 2016

I left some comments that I could be taken or could be not taken. I think it's fine as is and am ready to 👍 as is if none of the feedback is taken.

@drcrallen
Copy link
Contributor

FYI there is an issue here hinted at in #1576

If a node is down when a DROP request propagates across the cluster, the coordinator has no idea if the Lookups a node contains when it comes back up are custom added or still present from the failed DROP (since the node was down)

@b-slim b-slim force-pushed the adding_lookup_snapshot_utility branch from ef75638 to 177d6f1 Compare February 24, 2016 20:33
@b-slim
Copy link
Contributor Author

b-slim commented Feb 29, 2016

@drcrallen can you please take look at this one it is sort of easy to pull in.

@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.inject.name.Named;
import com.metamx.common.StringUtils;
import io.druid.query.lookup.LookupExtractor;
Copy link
Contributor

Choose a reason for hiding this comment

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

not used?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh nvmnd, package refactor

@After
public void tearDown()
{
temporaryFolder.delete();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@drcrallen
Copy link
Contributor

General comments:

  • Approach is fine IF this is a path that is desired to go. An alternative approach would be to have a static config and have the node read from that static config independent of the central config management (which is essentially what this PR does)
  • [QTL][Lookup] lookup module with the snapshot utility #2517 (comment) is still not adressed
  • Package refactor is good
  • Needs more clarification and tests around handling error cases (file corruption or failure to write to disk).
  • Suggest moving from List<LookupBean> to Map<String, LookupExtractorFactory>

@b-slim
Copy link
Contributor Author

b-slim commented Mar 8, 2016

Approach is fine IF this is a path that is desired to go. An alternative approach would be to have a static config and have the node read from that static config independent of the central config management (which is essentially what this PR does)

Talked to @cheddar about that and we think that the best way to go is to avoid the static path since it will introduce the case where after restart the old config is out of synch. But as you said it is basically the same thing.

@b-slim
Copy link
Contributor Author

b-slim commented Mar 8, 2016

#2517 (comment) is still not adressed

This will be manage by PR #1576. In my opinion coordinator will have a list of to drop and try to re send the drop request if the current diff show it is still there. That's why i think we should not compare to prior but the the actual view.

@b-slim
Copy link
Contributor Author

b-slim commented Mar 8, 2016

Needs more clarification and tests around handling error cases (file corruption or failure to write to disk).

Sure Will do

@b-slim b-slim force-pushed the adding_lookup_snapshot_utility branch from 177d6f1 to 0239bed Compare March 9, 2016 14:16
@b-slim
Copy link
Contributor Author

b-slim commented Mar 9, 2016

@drcrallen thanks for the review, i have addressed all the comments, please take a look.

LOGGER.debug("Removed lookup [%s]", lookupName);
if (!isClosed() && lookupSnapshotTaker != null) {
// if it is closed the final snapshot will be taken at stop() method
lookupSnapshotTaker.takeSnapshot(getAllAsList());
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes this is protected by the start/stop lock and sometimes it is not. It seems that it should probably be protected here. It is possible to pass isClosed, but have stop remove elements between isClosed and getAllAsList

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 am not sure i get this. For all the put and remove i am asserting that is started and the block is synchronized around lock.

synchronized (lock) {
      assertStarted();

Copy link
Contributor

Choose a reason for hiding this comment

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

put has the code you mention, remove does not

@b-slim
Copy link
Contributor Author

b-slim commented Mar 11, 2016

@drcrallen anything is blocking this ?

@b-slim b-slim force-pushed the adding_lookup_snapshot_utility branch from 0239bed to 877096f Compare March 11, 2016 16:20
@drcrallen
Copy link
Contributor

@b-slim #2517 (comment)

@b-slim
Copy link
Contributor Author

b-slim commented Mar 11, 2016

@drcrallen thanks i have added lock

@b-slim b-slim force-pushed the adding_lookup_snapshot_utility branch from 8e01b45 to 4915f4c Compare March 14, 2016 14:54
@b-slim
Copy link
Contributor Author

b-slim commented Mar 14, 2016

@drcrallen This is squashed and addressed all the comments, can we get this in, it is blocking me please.

public class LookupSnapshotTaker
{
private static final Logger LOGGER = new Logger(LookupSnapshotTaker.class);
private static final String PERSIST_FILE_NAME = "lookupSnapshot.data";
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest .json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@drcrallen
Copy link
Contributor

Minor comments, but for #2517 (comment) can the module be moved into the list of modules per CLIXXX ?

@b-slim
Copy link
Contributor Author

b-slim commented Mar 15, 2016

@drcrallen done.

if (lookupSnapshotTaker != null) {
final List<LookupBean> lookupBeanList = lookupSnapshotTaker.pullExistingSnapshot();
for (LookupBean lookupBean : lookupBeanList
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

formatting looks weird 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.

fixed

@drcrallen
Copy link
Contributor

Overall code is in a very good spot. Minor syntactical comments that I'll leave to the author's discretion, but please squash, and I'm 👍 after squash and travis passes.

@drcrallen
Copy link
Contributor

I'll reconcile this with #2517 as soon as it is merged.

@b-slim b-slim force-pushed the adding_lookup_snapshot_utility branch from d7466fc to 0c86b29 Compare March 17, 2016 14:22
b-slim added a commit that referenced this pull request Mar 17, 2016
[QTL][Lookup] lookup module with the snapshot utility
@b-slim b-slim merged commit cf342d8 into apache:master Mar 17, 2016
@drcrallen
Copy link
Contributor

Reconciled. I had to move the Module into druid-server

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.

None yet

3 participants