-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Move GCP to a core extension #6953
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
Changes from all commits
21c31a7
b9d2b96
21e1f2d
a8f322a
0bd304b
d463c00
05b7273
fbbb666
cfb59be
371c66c
23f2842
972d5f6
788e972
47e6a8d
56c6c43
50fba40
15b58ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
|
|
||
| org.apache.druid.common.aws.AWSModule |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>druid-gcp-common</artifactId> | ||
| <name>druid-gcp-common</name> | ||
| <description>Druid GCP Base Module</description> | ||
|
|
||
| <parent> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid</artifactId> | ||
| <version>0.15.0-incubating-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid-core</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.api-client</groupId> | ||
| <artifactId>google-api-client</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.http-client</groupId> | ||
| <artifactId>google-http-client-jackson2</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.module</groupId> | ||
| <artifactId>jackson-module-guice</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- Tests --> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.common.gcp; | ||
|
|
||
| import com.fasterxml.jackson.databind.Module; | ||
| import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; | ||
| import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | ||
| import com.google.api.client.http.HttpRequestInitializer; | ||
| import com.google.api.client.http.HttpTransport; | ||
| import com.google.api.client.json.JsonFactory; | ||
| import com.google.api.client.json.jackson2.JacksonFactory; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.inject.Binder; | ||
| import com.google.inject.Provides; | ||
| import org.apache.druid.guice.LazySingleton; | ||
| import org.apache.druid.initialization.DruidModule; | ||
|
|
||
| import java.io.IOException; | ||
| import java.security.GeneralSecurityException; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class GcpModule implements DruidModule | ||
| { | ||
| @Override | ||
| public List<? extends Module> getJacksonModules() | ||
| { | ||
| return ImmutableList.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public void configure(Binder binder) | ||
| { | ||
| // Nothing to proactively bind | ||
| } | ||
|
|
||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public HttpRequestInitializer getHttpRequestInitializer(HttpTransport transport, JsonFactory factory) | ||
| throws IOException | ||
| { | ||
| GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, factory); | ||
| if (credential.createScopedRequired()) { | ||
| credential = credential.createScoped(Collections.singleton("https://www.googleapis.com/auth/cloud-platform")); | ||
| } | ||
| return credential; | ||
| } | ||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public HttpTransport getHttpTransport() throws GeneralSecurityException, IOException | ||
| { | ||
| return GoogleNetHttpTransport.newTrustedTransport(); | ||
| } | ||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public JsonFactory getJsonFactory() | ||
| { | ||
| return JacksonFactory.getDefaultInstance(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
|
|
||
| org.apache.druid.common.gcp.GcpModule |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.common.gcp; | ||
|
|
||
| import com.fasterxml.jackson.databind.Module; | ||
| import com.google.api.client.googleapis.testing.auth.oauth2.MockGoogleCredential; | ||
| import com.google.api.client.http.HttpRequestInitializer; | ||
| import com.google.api.client.http.HttpTransport; | ||
| import com.google.api.client.json.JsonFactory; | ||
| import com.google.api.client.json.jackson2.JacksonFactory; | ||
| import com.google.api.client.testing.http.MockHttpTransport; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.inject.Binder; | ||
| import com.google.inject.Provides; | ||
| import org.apache.druid.guice.LazySingleton; | ||
| import org.apache.druid.initialization.DruidModule; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class GcpMockModule implements DruidModule | ||
| { | ||
| @Override | ||
| public List<? extends Module> getJacksonModules() | ||
| { | ||
| return ImmutableList.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public void configure(Binder binder) | ||
| { | ||
|
|
||
| } | ||
|
|
||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public HttpRequestInitializer mockRequestInitializer( | ||
| HttpTransport transport, | ||
| JsonFactory factory | ||
| ) | ||
| { | ||
| return new MockGoogleCredential.Builder().setTransport(transport).setJsonFactory(factory).build(); | ||
| } | ||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public HttpTransport buildMockTransport() | ||
| { | ||
| return new MockHttpTransport.Builder().build(); | ||
| } | ||
|
|
||
| @Provides | ||
| @LazySingleton | ||
| public JsonFactory getJsonFactory() | ||
| { | ||
| return JacksonFactory.getDefaultInstance(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.common.gcp; | ||
|
|
||
| import com.google.api.client.googleapis.testing.auth.oauth2.MockGoogleCredential; | ||
| import com.google.api.client.http.HttpRequestInitializer; | ||
| import com.google.api.client.http.HttpTransport; | ||
| import com.google.api.client.testing.http.MockHttpTransport; | ||
| import com.google.inject.Binder; | ||
| import com.google.inject.Guice; | ||
| import com.google.inject.Injector; | ||
| import com.google.inject.Scopes; | ||
| import com.google.inject.util.Modules; | ||
| import org.apache.druid.guice.LazySingleton; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| public class GcpModuleTest | ||
| { | ||
| @Test | ||
| public void testSimpleModuleLoads() | ||
| { | ||
| final Injector injector = Guice.createInjector(Modules.override(new GcpModule()).with(new GcpMockModule() | ||
| { | ||
| @Override | ||
| public void configure(Binder binder) | ||
| { | ||
| binder.bindScope(LazySingleton.class, Scopes.SINGLETON); | ||
| } | ||
| })); | ||
| Assert.assertTrue(injector.getInstance(HttpRequestInitializer.class) instanceof MockGoogleCredential); | ||
| Assert.assertTrue(injector.getInstance(HttpTransport.class) instanceof MockHttpTransport); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ Core extensions are maintained by Druid committers. | |
| |druid-parquet-extensions|Support for data in Apache Parquet data format. Requires druid-avro-extensions to be loaded.|[link](../development/extensions-core/parquet.html)| | ||
| |druid-protobuf-extensions| Support for data in Protobuf data format.|[link](../development/extensions-core/protobuf.html)| | ||
| |druid-s3-extensions|Interfacing with data in AWS S3, and using S3 as deep storage.|[link](../development/extensions-core/s3.html)| | ||
| |druid-ec2-extensions|Interfacing with AWS EC2 for autoscaling middle managers|UNDOCUMENTED| | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is I guess sort of documented at |
||
| |druid-stats|Statistics related module including variance and standard deviation.|[link](../development/extensions-core/stats.html)| | ||
| |mysql-metadata-storage|MySQL metadata store.|[link](../development/extensions-core/mysql.html)| | ||
| |postgresql-metadata-storage|PostgreSQL metadata store.|[link](../development/extensions-core/postgresql.html)| | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any value in allowing the URL to be configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since people can now override
HttpRequestInitializerin an extension, they can do so with a custom extension. This is more laborious than a simple config change though. For a simple config change it could make sense but I don't have a specific use case in mind and would rather leave such a feature add to someone who understands the value of such a feature better.