Skip to content

internal-discovery: interfaces for announcement/discovery, curator based impls#4634

Merged
cheddar merged 9 commits intoapache:masterfrom
himanshug:membership_pr1_1
Aug 16, 2017
Merged

internal-discovery: interfaces for announcement/discovery, curator based impls#4634
cheddar merged 9 commits intoapache:masterfrom
himanshug:membership_pr1_1

Conversation

@himanshug
Copy link
Copy Markdown
Contributor

@himanshug himanshug commented Aug 2, 2017

This PR introduces formal core "internal-discovery" in Druid. It should be used by any Druid node to discover any other node inside druid cluster. a curator/zookeeper based default implementation is included in druid core but it is extensible to provide extension that might not use zookeeper.

  • For all core classes/interfaces , see server/src/main/java/io/druid/discovery/*.java

  • For curator based impls, see server/src/main/java/io/druid/curator/discovery/CuratorDruidNode*.java

  • All CliXXX.java classes are updated to announce themselves in "internal-discovery".

  • RealtimeIndexTask and KafkaIndexTask are updated to announce themselves in "internal-discovery".

  • HttpServerInventoryView is updated to discover data nodes using "internal-discovery"

  • /druid/coordinator/v1/cluster and /druid/coordinator/v1/cluster/<nodeType> endpoints are introduced at coordinator to get a dump of nodes in "internal-discovery", this is intended mostly to be used for manual testing/debugging for now.

TODO:

  • add/update unit tests
  • fix style checks if needed

Follow-up PRs:

@himanshug himanshug added this to the 0.11.0 milestone Aug 2, 2017
@himanshug himanshug requested a review from cheddar August 2, 2017 16:56
@himanshug himanshug force-pushed the membership_pr1_1 branch 10 times, most recently from 7094065 to c00dc2e Compare August 8, 2017 18:25
Copy link
Copy Markdown
Contributor

@cheddar cheddar left a comment

Choose a reason for hiding this comment

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

No docs?

[Himanshu] No new configs are introduced in this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be nicer to take the informatino for this in the task spec instead of runtime config. That would give us the ability to set it on a per-task basis.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lookupTier is something that user might want to override so made it overridable via task context key lookupTier in Realtime and Kafka indexing tasks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I read "/" as "OR" which seems weird where we are both creating and starting. I think the message would be better as just "Creating NodeTypeWatcher" or "Creating and starting NodeTypeWatcher"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think you need to do the get here, just return nodeTypeWatcher

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I hate synchronized methods. It's very easy to overlook and can also blur the boundary of what is being synchronized (if someone external from this class uses this class for synchronization, all of a sudden they will be fighting with the internals of this for mutual exclusion).

I think it would be better to just create a private "lock" Object and synchronize on that instead. I care about it enough to comment, but not enough to actually enforce so do as you will.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed synchronized from method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Collections.unmodifiableSet()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be nice to have endpoints that just return one type of service and stuff do. While maybe not necessary, it would be a relatively simple addition that benefits the operator (I think). Or, take a parameter to filter which types you care about, or something similar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, i added this one quickly just to be able to degugging and manual verification... but more features can be added here.
that said, added another endpoint /druid/coordinator/v1/<nodeType> to return all the nodes for given node type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not asEagerSingleton, asEagerSingleton causes weird oddities in Guice land. Use Lifecycle.register(ForSideEffectsOnlyProvider.Child.class) instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored it , asEagerSingleton() is not used anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do this in the get() call instead of here. Setting this stuff up in the constructor (especially when marked as an eagerSingleton) can lead to weird and interesting interleaving of injections.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored it , asEagerSingleton() is not used anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's kinda annoying that you have a provider in each of these CLIs. The only deviation between these is the node type and the map. You should be able to create a single provider that takes on the constructor a String nodeType, List<Key<DruidService>> services. Move the injections to an

@Inject
public void init(Injector injector, Lifecycle lifecycle, ...)

Then in the get() you would walk the list of Keys, asking the injector to inject them, build the map out of those and then use that to build the discoveryDruidNode.

Once that is setup, your module code would look like

binder.bind(ForSideEffectsOnlyProvider.Child.class).toProvider(new ForSideEffectsOnlyProvider("historical", Arrays.asList(Key.get(DataNodeService.class, LookupNodeService.class)));
LifecycleModule.register(ForSideEffectsOnlyProvider.Child.class);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored it , asEagerSingleton() is not used anymore. Individual CliXXX classes don't have much now.

@himanshug himanshug force-pushed the membership_pr1_1 branch 3 times, most recently from 432b3d3 to adfe788 Compare August 14, 2017 14:50
@himanshug himanshug force-pushed the membership_pr1_1 branch 2 times, most recently from 29a460f to 587d41a Compare August 14, 2017 20:47
@himanshug himanshug changed the title [WIP]internal-discovery: interfaces for announcement/discovery, curator based impls internal-discovery: interfaces for announcement/discovery, curator based impls Aug 14, 2017
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.

2 participants