Skip to content

Commit

Permalink
Extract MetastoreValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
findinpath authored and findepi committed Sep 20, 2022
1 parent faa3087 commit b9b0485
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
Expand Up @@ -14,15 +14,13 @@
package io.trino.plugin.iceberg.catalog;

import com.google.inject.Binder;
import com.google.inject.Inject;
import com.google.inject.Module;
import com.google.inject.Scopes;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.trino.plugin.hive.metastore.DecoratedHiveMetastoreModule;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreFactory;
import io.trino.plugin.hive.metastore.RawHiveMetastoreFactory;
import io.trino.plugin.hive.metastore.cache.SharedHiveMetastoreCache;
import io.trino.plugin.iceberg.CatalogType;
import io.trino.plugin.iceberg.IcebergConfig;
import io.trino.plugin.iceberg.catalog.file.FileMetastoreTableOperationsProvider;
Expand Down Expand Up @@ -66,17 +64,6 @@ protected void setup(Binder binder)
}
}

public static class MetastoreValidator
{
@Inject
public MetastoreValidator(SharedHiveMetastoreCache metastoreCache)
{
if (metastoreCache.isEnabled()) {
throw new RuntimeException("Hive metastore caching must not be enabled for Iceberg");
}
}
}

private void bindCatalogModule(CatalogType catalogType, Module module)
{
install(conditionalModule(
Expand Down
@@ -0,0 +1,28 @@
/*
* 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.iceberg.catalog;

import com.google.inject.Inject;
import io.trino.plugin.hive.metastore.cache.SharedHiveMetastoreCache;

public class MetastoreValidator
{
@Inject
public MetastoreValidator(SharedHiveMetastoreCache metastoreCache)
{
if (metastoreCache.isEnabled()) {
throw new RuntimeException("Hive metastore caching must not be enabled for Iceberg");
}
}
}
Expand Up @@ -20,8 +20,8 @@
import io.trino.plugin.hive.HideDeltaLakeTables;
import io.trino.plugin.hive.metastore.DecoratedHiveMetastoreModule;
import io.trino.plugin.hive.metastore.file.FileMetastoreModule;
import io.trino.plugin.iceberg.catalog.IcebergCatalogModule.MetastoreValidator;
import io.trino.plugin.iceberg.catalog.IcebergTableOperationsProvider;
import io.trino.plugin.iceberg.catalog.MetastoreValidator;
import io.trino.plugin.iceberg.catalog.TrinoCatalogFactory;
import io.trino.plugin.iceberg.catalog.hms.TrinoHiveCatalogFactory;

Expand Down
Expand Up @@ -21,8 +21,8 @@
import io.trino.plugin.hive.metastore.DecoratedHiveMetastoreModule;
import io.trino.plugin.hive.metastore.thrift.ThriftMetastoreModule;
import io.trino.plugin.hive.metastore.thrift.TranslateHiveViews;
import io.trino.plugin.iceberg.catalog.IcebergCatalogModule.MetastoreValidator;
import io.trino.plugin.iceberg.catalog.IcebergTableOperationsProvider;
import io.trino.plugin.iceberg.catalog.MetastoreValidator;
import io.trino.plugin.iceberg.catalog.TrinoCatalogFactory;

public class IcebergHiveMetastoreCatalogModule
Expand Down

0 comments on commit b9b0485

Please sign in to comment.