forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move GCP to a core extension (apache#6953)
* Move GCP to a core extension * Don't provide druid-core >.< * Keep AWS and GCP modules separate * Move AWSModule to its own module * Add aws ec2 extension and more modules in more places * Fix bad imports * Fix test jackson module * Include AWS and GCP core in server * Add simple empty method comment * Update version to 15 * One more 0.13.0-->0.15.0 change * Fix multi-binding problem * Grep for s3-extensions and update docs * Update extensions.md
- Loading branch information
Showing
62 changed files
with
657 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...s-common/src/main/resources/META-INF/services/org.apache.druid.initialization.DruidModule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
80 changes: 80 additions & 0 deletions
80
cloud/gcp-common/src/main/java/org/apache/druid/common/gcp/GcpModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...p-common/src/main/resources/META-INF/services/org.apache.druid.initialization.DruidModule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
75 changes: 75 additions & 0 deletions
75
cloud/gcp-common/src/test/java/org/apache/druid/common/gcp/GcpMockModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
cloud/gcp-common/src/test/java/org/apache/druid/common/gcp/GcpModuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.