From c6d19dec548ecf652ab881bfae0a8262d355db9e Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 9 Oct 2023 16:20:06 -0700 Subject: [PATCH] Consolidate Delta Lake synchronizer bindings --- .../deltalake/DeltaLakeAzureModule.java | 35 ------------------- .../plugin/deltalake/DeltaLakeGcsModule.java | 32 ----------------- ....java => DeltaLakeSynchronizerModule.java} | 22 ++++++++---- .../InternalDeltaLakeConnectorFactory.java | 4 +-- 4 files changed, 17 insertions(+), 76 deletions(-) delete mode 100644 plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeAzureModule.java delete mode 100644 plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeGcsModule.java rename plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/{DeltaLakeS3Module.java => DeltaLakeSynchronizerModule.java} (54%) diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeAzureModule.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeAzureModule.java deleted file mode 100644 index 2846ae1ff4e0..000000000000 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeAzureModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.plugin.deltalake; - -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.Scopes; -import com.google.inject.multibindings.MapBinder; -import io.trino.plugin.deltalake.transactionlog.writer.AzureTransactionLogSynchronizer; -import io.trino.plugin.deltalake.transactionlog.writer.TransactionLogSynchronizer; - -import static com.google.inject.multibindings.MapBinder.newMapBinder; - -public class DeltaLakeAzureModule - implements Module -{ - @Override - public void configure(Binder binder) - { - MapBinder logSynchronizerMapBinder = newMapBinder(binder, String.class, TransactionLogSynchronizer.class); - logSynchronizerMapBinder.addBinding("abfs").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON); - logSynchronizerMapBinder.addBinding("abfss").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON); - } -} diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeGcsModule.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeGcsModule.java deleted file mode 100644 index ee77d5be5986..000000000000 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeGcsModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.plugin.deltalake; - -import com.google.inject.Binder; -import com.google.inject.Scopes; -import io.airlift.configuration.AbstractConfigurationAwareModule; -import io.trino.plugin.deltalake.transactionlog.writer.GcsTransactionLogSynchronizer; -import io.trino.plugin.deltalake.transactionlog.writer.TransactionLogSynchronizer; - -import static com.google.inject.multibindings.MapBinder.newMapBinder; - -public class DeltaLakeGcsModule - extends AbstractConfigurationAwareModule -{ - @Override - protected void setup(Binder binder) - { - newMapBinder(binder, String.class, TransactionLogSynchronizer.class).addBinding("gs").to(GcsTransactionLogSynchronizer.class).in(Scopes.SINGLETON); - } -} diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeS3Module.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSynchronizerModule.java similarity index 54% rename from plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeS3Module.java rename to plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSynchronizerModule.java index fb3ece84d57e..bca3e6e25e75 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeS3Module.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSynchronizerModule.java @@ -16,23 +16,33 @@ import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Scopes; -import com.google.inject.multibindings.MapBinder; +import io.trino.plugin.deltalake.transactionlog.writer.AzureTransactionLogSynchronizer; +import io.trino.plugin.deltalake.transactionlog.writer.GcsTransactionLogSynchronizer; import io.trino.plugin.deltalake.transactionlog.writer.S3NativeTransactionLogSynchronizer; import io.trino.plugin.deltalake.transactionlog.writer.TransactionLogSynchronizer; import static com.google.inject.multibindings.MapBinder.newMapBinder; import static io.airlift.json.JsonCodecBinder.jsonCodecBinder; -public class DeltaLakeS3Module +public class DeltaLakeSynchronizerModule implements Module { @Override public void configure(Binder binder) { - MapBinder logSynchronizerMapBinder = newMapBinder(binder, String.class, TransactionLogSynchronizer.class); + var synchronizerBinder = newMapBinder(binder, String.class, TransactionLogSynchronizer.class); + + // Azure + synchronizerBinder.addBinding("abfs").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + synchronizerBinder.addBinding("abfss").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + + // GCS + synchronizerBinder.addBinding("gs").to(GcsTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + + // S3 jsonCodecBinder(binder).bindJsonCodec(S3NativeTransactionLogSynchronizer.LockFileContents.class); - logSynchronizerMapBinder.addBinding("s3").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); - logSynchronizerMapBinder.addBinding("s3a").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); - logSynchronizerMapBinder.addBinding("s3n").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + synchronizerBinder.addBinding("s3").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + synchronizerBinder.addBinding("s3a").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); + synchronizerBinder.addBinding("s3n").to(S3NativeTransactionLogSynchronizer.class).in(Scopes.SINGLETON); } } diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java index c3a82ca67c84..5285c6c74f12 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java @@ -88,15 +88,13 @@ public static Connector createConnector( new JsonModule(), new MBeanServerModule(), new HdfsModule(), - new DeltaLakeS3Module(), - new DeltaLakeAzureModule(), new HiveGcsModule(), - new DeltaLakeGcsModule(), new HdfsAuthenticationModule(), new CatalogNameModule(catalogName), metastoreModule.orElse(new DeltaLakeMetastoreModule()), new DeltaLakeModule(), new DeltaLakeSecurityModule(), + new DeltaLakeSynchronizerModule(), fileSystemFactory .map(factory -> (Module) binder -> binder.bind(TrinoFileSystemFactory.class).toInstance(factory)) .orElseGet(FileSystemModule::new),