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 lookups to be more chill to router #7222

Merged
merged 12 commits into from
Apr 5, 2019

Conversation

clintropolis
Copy link
Member

@clintropolis clintropolis commented Mar 10, 2019

This PR introduces LookupSerdeModule which allows the router to perform query serde but without having to load lookups as happens using the stock LookupModule with default settings. To achieve this, an interface has been extracted from LookupReferencesManager, the very java named LookupExtractorFactoryContainerProvider, which is now used everywhere LookupReferencesManager was previously used, except for LookupListeningResource. I think this is a bit nicer, because now all query processing stuff no longer has obvious access to methods to load and drop lookups, only the method to get the LookupExtractorFactoryContainer needed to do the transforms. Additionally, this has allowed many of these types to be migrated into druid-processing which seems like a more appropriate home for them (including the new LookupExtractorFactoryContainerProvider interface).

Now in druid-processing:

  • LookupDimensionSpec
  • LookupExprMacro
  • LookupExtractorFactoryContainerProvider
  • RegisteredLookupExtractionFn

An integration test has been added to the wiki tests, which loads a simple json lookup, and tests queries against brokers and routers. This also means there is now an integration test that is testing lookups! I've also tested this on a small test cluster spun up on my laptop.

The router will proxy requests to the lookup introspection API it was previously serving, so if the router was being queried to introspect lookups things should still function, it will just be proxied to a default broker now.

I suspect it wasn't too much of an issue, because that API didn't appear functional because didn't have auth checks performed, and would throw an exception of the form

2019-03-10T00:15:20,298 WARN [qtp2080864181-118] org.eclipse.jetty.server.HttpChannel - /druid/v1/lookups/introspect/simple-wiki
org.apache.druid.java.util.common.ISE: Request did not have an authorization check performed.
    at org.apache.druid.server.security.PreResponseAuthorizationCheckFilter.handleAuthorizationCheckError(PreResponseAuthorizationCheckFilter.java:156) ~[classes/:?]
    at org.apache.druid.server.security.PreResponseAuthorizationCheckFilter.doFilter(PreResponseAuthorizationCheckFilter.java:89) ~[classes/:?]
...

So I've included a fix for that as well.

I also made some minor adjustments to the integration tests configurations, switching gc from cms to g1, and lowering some thread pool sizes to maybe result in a slightly lighter footprint.

@clintropolis
Copy link
Member Author

clintropolis commented Mar 10, 2019

Oops, test failures is legit, fixing the LookupIntrospectionResource auth check error has broken LookupIntrospectionResourceImplTest, will fix.

@clintropolis
Copy link
Member Author

Fixed and combined both LookupIntrospectionResource tests, reworking LookupIntrospectionResourceImplTest by borrowing some ideas from past me and putting into a utility class, WebserverTestUtils, to help make a test webserver that works with both jersey and guice injections in order to continue test API function like LookupIntrospectionResourceImplTest was doing. Hopefully this should make writing other tests of this manner a bit easier than requiring full integration tests.

@fjy fjy added this to the 0.15.0 milestone Mar 11, 2019
@clintropolis
Copy link
Member Author

Would the module introduced in this PR also be a good solution to the problem of #5727 since it would allow lookup serde without loading lookups? Perhaps I could rename RouterLookupModule to something more generic if so.

…torFactoryContainerProvider to NoopLookupExtractorFactoryContainerProvider
@clintropolis
Copy link
Member Author

Perhaps I could rename RouterLookupModule to something more generic if so.

Renamed to LookupSerdeModule

@yurmix
Copy link
Contributor

yurmix commented Mar 21, 2019

This is interesting.
@drcrallen, is this the interface extraction you were referring to in Re: Druid module separation (And a related lookups question)?
I wonder this pr now makes it possible to migrate LookupDimensionSpec to druid-processing. It will help me with the implementation of multi-value lookups.

@clintropolis
Copy link
Member Author

This is interesting.
@drcrallen, is this the interface extraction you were referring to in Re: Druid module separation (And a related lookups question)?

Ah, sorry I hadn't got around to that dev list thread yet, I'll have a look and see if I can move some stuff around since I have to fix up conflicts anyway.

@clintropolis
Copy link
Member Author

clintropolis commented Mar 21, 2019

@yurmix @drcrallen With this refactor I was able to move these things to the druid-processing module since most lookup things just refer to the LookupExtractorFactoryContainerProvider interface introduced in this PR:

  • LookupDimensionSpec
  • LookupExprMacro
  • LookupExtractorFactoryContainerProvider
  • RegisteredLookupExtractionFn

@yurmix
Copy link
Contributor

yurmix commented Mar 21, 2019

Wow, thanks so much! Now I'm going to reinitiate my efforts on multi-value lookups.

@jon-wei jon-wei merged commit 76b4a5c into apache:master Apr 5, 2019
@clintropolis clintropolis deleted the router-lookup-module branch April 5, 2019 22:06
gianm pushed a commit to implydata/druid-public that referenced this pull request Apr 10, 2019
* refactor lookups to be more chill to router

* remove accidental change

* fix and combine LookupIntrospectionResourceTest

* fix inspection

* rename RouterLookupModule to LookupSerdeModule and RouterLookupExtractorFactoryContainerProvider to NoopLookupExtractorFactoryContainerProvider

* make comment generic

* use ConfigResourceFilter instead of StateResourceFilter

* fix indentation

* unused import

* another unused import

* refactor some stuff into processing module, split up LookupModule.java classes into their own files
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/router");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(8888);
binder.bindConstant().annotatedWith(Names.named("tlsServicePort")).to(9088);
binder -> {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure an anonymous class conversion to a lambda makes code better in this case. You lose visibility into the fact that this lambda is a Module and that the method is configure(), making the code more cryptic, IMO.

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.

None yet

5 participants