diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveCatalogName.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveCatalogName.java new file mode 100644 index 0000000000000..cb2fb016fc003 --- /dev/null +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveCatalogName.java @@ -0,0 +1,32 @@ +/* + * 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.prestosql.plugin.hive; + +import static java.util.Objects.requireNonNull; + +public class HiveCatalogName +{ + private final String catalogName; + + public HiveCatalogName(String catalogName) + { + this.catalogName = requireNonNull(catalogName, "catalogName is null"); + } + + @Override + public String toString() + { + return catalogName; + } +} diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java index 506c9d86b4921..da96ad621c329 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveClientModule.java @@ -47,17 +47,9 @@ public class HiveClientModule implements Module { - private final String connectorId; - - public HiveClientModule(String connectorId) - { - this.connectorId = connectorId; - } - @Override public void configure(Binder binder) { - binder.bind(HiveConnectorId.class).toInstance(new HiveConnectorId(connectorId)); binder.bind(TypeTranslator.class).toInstance(new HiveTypeTranslator()); binder.bind(CoercionPolicy.class).to(HiveCoercionPolicy.class).in(Scopes.SINGLETON); @@ -119,19 +111,19 @@ public void configure(Binder binder) @ForHiveClient @Singleton @Provides - public ExecutorService createHiveClientExecutor(HiveConnectorId hiveClientId) + public ExecutorService createHiveClientExecutor(HiveCatalogName catalogName) { - return newCachedThreadPool(daemonThreadsNamed("hive-" + hiveClientId + "-%s")); + return newCachedThreadPool(daemonThreadsNamed("hive-" + catalogName + "-%s")); } @ForCachingHiveMetastore @Singleton @Provides - public ExecutorService createCachingHiveMetastoreExecutor(HiveConnectorId hiveClientId, HiveConfig hiveConfig) + public ExecutorService createCachingHiveMetastoreExecutor(HiveCatalogName catalogName, HiveConfig hiveConfig) { return newFixedThreadPool( hiveConfig.getMaxMetastoreRefreshThreads(), - daemonThreadsNamed("hive-metastore-" + hiveClientId + "-%s")); + daemonThreadsNamed("hive-metastore-" + catalogName + "-%s")); } @Singleton diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorFactory.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorFactory.java index 845a0dbb1a572..40bfd75b25bd0 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorFactory.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorFactory.java @@ -99,7 +99,7 @@ public Connector create(String catalogName, Map config, Connecto new MBeanModule(), new ConnectorObjectNameGeneratorModule(catalogName), new JsonModule(), - new HiveClientModule(catalogName), + new HiveClientModule(), new HiveS3Module(), new HiveGcsModule(), new HiveMetastoreModule(metastore), @@ -114,6 +114,7 @@ public Connector create(String catalogName, Map config, Connecto binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory()); binder.bind(PageSorter.class).toInstance(context.getPageSorter()); + binder.bind(HiveCatalogName.class).toInstance(new HiveCatalogName(catalogName)); }); Injector injector = app diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorId.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorId.java deleted file mode 100644 index 1d98bc7f999e9..0000000000000 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConnectorId.java +++ /dev/null @@ -1,56 +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.prestosql.plugin.hive; - -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -public class HiveConnectorId -{ - private final String connectorId; - - public HiveConnectorId(String connectorId) - { - requireNonNull(connectorId, "connectorId is null"); - checkArgument(!connectorId.isEmpty(), "connectorId is empty"); - this.connectorId = connectorId; - } - - @Override - public int hashCode() - { - return Objects.hash(connectorId); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - HiveConnectorId other = (HiveConnectorId) obj; - return Objects.equals(this.connectorId, other.connectorId); - } - - @Override - public String toString() - { - return connectorId; - } -} diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/security/SqlStandardAccessControl.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/security/SqlStandardAccessControl.java index b3d778577affd..e8be146a8dad1 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/security/SqlStandardAccessControl.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/security/SqlStandardAccessControl.java @@ -13,7 +13,7 @@ */ package io.prestosql.plugin.hive.security; -import io.prestosql.plugin.hive.HiveConnectorId; +import io.prestosql.plugin.hive.HiveCatalogName; import io.prestosql.plugin.hive.HiveTransactionHandle; import io.prestosql.plugin.hive.metastore.Database; import io.prestosql.plugin.hive.metastore.HivePrincipal; @@ -86,7 +86,7 @@ public class SqlStandardAccessControl @Inject public SqlStandardAccessControl( - HiveConnectorId connectorId, + HiveCatalogName connectorId, Function metastoreProvider) { this.connectorId = requireNonNull(connectorId, "connectorId is null").toString();