-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows implementations to provide their custom implementation of RemoteS3Facade, e.g. to support multiple S3 endpoints based on bucket / path. The existing RemoteS3Facade implementation is named "default" and provided by default.
- Loading branch information
Showing
22 changed files
with
223 additions
and
114 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
38 changes: 38 additions & 0 deletions
38
trino-aws-proxy-spi/src/main/java/io/trino/aws/proxy/spi/plugin/config/RemoteS3Config.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,38 @@ | ||
/* | ||
* Licensed 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 io.trino.aws.proxy.spi.plugin.config; | ||
|
||
import io.airlift.configuration.Config; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.Optional; | ||
|
||
public class RemoteS3Config | ||
implements PluginIdentifierConfig | ||
{ | ||
private Optional<String> identifier = Optional.of("default"); | ||
|
||
@NotNull | ||
@Override | ||
public Optional<String> getPluginIdentifier() | ||
{ | ||
return identifier; | ||
} | ||
|
||
@Config("remote-s3.type") | ||
public void setPluginIdentifier(String identifier) | ||
{ | ||
this.identifier = Optional.of(identifier); | ||
} | ||
} |
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
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
41 changes: 41 additions & 0 deletions
41
trino-aws-proxy/src/main/java/io/trino/aws/proxy/server/remote/DefaultRemoteS3Facade.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,41 @@ | ||
/* | ||
* Licensed 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 io.trino.aws.proxy.server.remote; | ||
|
||
import com.google.inject.Inject; | ||
import io.trino.aws.proxy.server.remote.DefaultRemoteS3Module.ForDefaultRemoteS3Facade; | ||
import io.trino.aws.proxy.spi.remote.RemoteS3Facade; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
|
||
import java.net.URI; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class DefaultRemoteS3Facade | ||
implements RemoteS3Facade | ||
{ | ||
private final RemoteS3Facade delegate; | ||
|
||
@Inject | ||
public DefaultRemoteS3Facade(@ForDefaultRemoteS3Facade RemoteS3Facade delegate) | ||
{ | ||
this.delegate = requireNonNull(delegate, "delegate is null"); | ||
} | ||
|
||
@Override | ||
public URI buildEndpoint(UriBuilder uriBuilder, String path, String bucket, String region) | ||
{ | ||
return delegate.buildEndpoint(uriBuilder, path, bucket, region); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
trino-aws-proxy/src/main/java/io/trino/aws/proxy/server/remote/DefaultRemoteS3Module.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,55 @@ | ||
/* | ||
* Licensed 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 io.trino.aws.proxy.server.remote; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.BindingAnnotation; | ||
import com.google.inject.Key; | ||
import com.google.inject.Scopes; | ||
import io.airlift.configuration.AbstractConfigurationAwareModule; | ||
import io.trino.aws.proxy.spi.remote.RemoteS3Facade; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static io.airlift.configuration.ConditionalModule.conditionalModule; | ||
import static io.airlift.configuration.ConfigBinder.configBinder; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
public class DefaultRemoteS3Module | ||
extends AbstractConfigurationAwareModule | ||
{ | ||
public static final String DEFAULT_REMOTE_S3_IDENTIFIER = "default"; | ||
|
||
@Override | ||
protected void setup(Binder binder) | ||
{ | ||
configBinder(binder).bindConfig(DefaultRemoteS3Config.class); | ||
install(conditionalModule( | ||
DefaultRemoteS3Config.class, | ||
DefaultRemoteS3Config::getVirtualHostStyle, | ||
innerBinder -> innerBinder.bind(Key.get(RemoteS3Facade.class, ForDefaultRemoteS3Facade.class)) | ||
.to(VirtualHostStyleDefaultRemoteS3Facade.class).in(Scopes.SINGLETON), | ||
innerBinder -> innerBinder.bind(Key.get(RemoteS3Facade.class, ForDefaultRemoteS3Facade.class)) | ||
.to(PathStyleDefaultRemoteS3Facade.class).in(Scopes.SINGLETON))); | ||
} | ||
|
||
@Retention(RUNTIME) | ||
@Target({FIELD, PARAMETER, METHOD}) | ||
@BindingAnnotation | ||
public @interface ForDefaultRemoteS3Facade {} | ||
} |
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
36 changes: 0 additions & 36 deletions
36
trino-aws-proxy/src/main/java/io/trino/aws/proxy/server/remote/RemoteS3Module.java
This file was deleted.
Oops, something went wrong.
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.