Search in sources :

Example 1 with BridgingHiveMetastore

use of com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore in project presto by prestodb.

the class AbstractTestHiveClient method setup.

protected final void setup(String host, int port, String databaseName, String timeZone) {
    HiveClientConfig hiveClientConfig = getHiveClientConfig();
    CacheConfig cacheConfig = getCacheConfig();
    MetastoreClientConfig metastoreClientConfig = getMetastoreClientConfig();
    hiveClientConfig.setTimeZone(timeZone);
    String proxy = System.getProperty("hive.metastore.thrift.client.socks-proxy");
    if (proxy != null) {
        metastoreClientConfig.setMetastoreSocksProxy(HostAndPort.fromString(proxy));
    }
    HiveCluster hiveCluster = new TestingHiveCluster(metastoreClientConfig, host, port);
    ExtendedHiveMetastore metastore = new CachingHiveMetastore(new BridgingHiveMetastore(new ThriftHiveMetastore(hiveCluster, metastoreClientConfig), new HivePartitionMutator()), executor, false, Duration.valueOf("1m"), Duration.valueOf("15s"), 10000, false, MetastoreCacheScope.ALL, 0.0);
    setup(databaseName, hiveClientConfig, cacheConfig, metastoreClientConfig, metastore);
}
Also used : TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) CachingHiveMetastore(com.facebook.presto.hive.metastore.CachingHiveMetastore) ThriftHiveMetastore(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore) CacheConfig(com.facebook.presto.cache.CacheConfig) HiveCluster(com.facebook.presto.hive.metastore.thrift.HiveCluster) TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) HivePartitionMutator(com.facebook.presto.hive.metastore.HivePartitionMutator) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore)

Example 2 with BridgingHiveMetastore

use of com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore in project presto by prestodb.

the class TestHiveClientInMemoryMetastoreWithFilterPushdown method createMetastore.

@Override
protected ExtendedHiveMetastore createMetastore(File tempDir) {
    File baseDir = new File(tempDir, "metastore");
    InMemoryHiveMetastore hiveMetastore = new InMemoryHiveMetastore(baseDir);
    return new BridgingHiveMetastore(hiveMetastore, new HivePartitionMutator());
}
Also used : InMemoryHiveMetastore(com.facebook.presto.hive.metastore.thrift.InMemoryHiveMetastore) File(java.io.File) HivePartitionMutator(com.facebook.presto.hive.metastore.HivePartitionMutator) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore)

Example 3 with BridgingHiveMetastore

use of com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore in project presto by prestodb.

the class TestCachingHiveMetastore method testCachingWithPartitionVersioning.

@Test
public void testCachingWithPartitionVersioning() {
    MockHiveMetastoreClient mockClient = new MockHiveMetastoreClient();
    MockHiveCluster mockHiveCluster = new MockHiveCluster(mockClient);
    ListeningExecutorService executor = listeningDecorator(newCachedThreadPool(daemonThreadsNamed("partition-versioning-test-%s")));
    MockHiveMetastore mockHiveMetastore = new MockHiveMetastore(mockHiveCluster);
    PartitionMutator mockPartitionMutator = new MockPartitionMutator(identity());
    ColumnConverter hiveColumnConverter = new HiveColumnConverter();
    CachingHiveMetastore partitionCachingEnabledmetastore = new CachingHiveMetastore(new BridgingHiveMetastore(mockHiveMetastore, mockPartitionMutator), executor, false, new Duration(5, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), 1000, true, MetastoreCacheScope.PARTITION, 0.0);
    assertEquals(mockClient.getAccessCount(), 0);
    assertEquals(partitionCachingEnabledmetastore.getPartitionNamesByFilter(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableMap.of()), EXPECTED_PARTITIONS);
    assertEquals(mockClient.getAccessCount(), 1);
    assertEquals(partitionCachingEnabledmetastore.getPartitionNamesByFilter(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableMap.of()), EXPECTED_PARTITIONS);
    // Assert that we did not hit cache
    assertEquals(mockClient.getAccessCount(), 2);
    // Select all of the available partitions and load them into the cache
    assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2)).size(), 2);
    assertEquals(mockClient.getAccessCount(), 3);
    // Now if we fetch any or both of them, they should hit the cache
    assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1)).size(), 1);
    assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION2)).size(), 1);
    assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2)).size(), 2);
    assertEquals(mockClient.getAccessCount(), 3);
    // This call should NOT invalidate the partition cache because partition version is same as before
    assertEquals(partitionCachingEnabledmetastore.getPartitionNamesByFilter(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableMap.of()), EXPECTED_PARTITIONS);
    assertEquals(mockClient.getAccessCount(), 4);
    assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2)).size(), 2);
    // Assert that its a cache hit
    assertEquals(mockClient.getAccessCount(), 4);
    assertInvalidateCache(new MockPartitionMutator(version -> version + 1));
    assertInvalidateCache(new MockPartitionMutator(version -> version - 1));
}
Also used : MockHiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) Iterables(com.google.common.collect.Iterables) UnaryOperator.identity(java.util.function.UnaryOperator.identity) MockHiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) Function(java.util.function.Function) TEST_METASTORE_CONTEXT(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_METASTORE_CONTEXT) Duration(io.airlift.units.Duration) TEST_TABLE(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_TABLE) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) MetastoreCacheScope(com.facebook.presto.hive.metastore.CachingHiveMetastore.MetastoreCacheScope) HiveCluster(com.facebook.presto.hive.metastore.thrift.HiveCluster) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) HiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.HiveMetastoreClient) Assert.assertFalse(org.testng.Assert.assertFalse) MockHiveMetastore(com.facebook.presto.hive.MockHiveMetastore) ThriftHiveMetastore(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore) TEST_PARTITION_VALUES2(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_PARTITION_VALUES2) PartitionMutator(com.facebook.presto.hive.PartitionMutator) ImmutableMap(com.google.common.collect.ImmutableMap) TEST_PARTITION_VALUES1(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_PARTITION_VALUES1) BeforeMethod(org.testng.annotations.BeforeMethod) Assert.assertNotNull(org.testng.Assert.assertNotNull) TEST_DATABASE(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_DATABASE) TimeUnit(java.util.concurrent.TimeUnit) Threads.daemonThreadsNamed(com.facebook.airlift.concurrent.Threads.daemonThreadsNamed) ColumnConverter(com.facebook.presto.hive.ColumnConverter) Builder(com.facebook.presto.hive.metastore.Partition.Builder) Executors.newCachedThreadPool(java.util.concurrent.Executors.newCachedThreadPool) Optional(java.util.Optional) BAD_DATABASE(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.BAD_DATABASE) TEST_ROLES(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_ROLES) Assert.assertTrue(org.testng.Assert.assertTrue) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore) PARTITION_VERSION(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.PARTITION_VERSION) ThriftHiveMetastoreStats(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastoreStats) TEST_PARTITION1(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_PARTITION1) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) TEST_PARTITION2(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient.TEST_PARTITION2) PartitionMutator(com.facebook.presto.hive.PartitionMutator) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Duration(io.airlift.units.Duration) ColumnConverter(com.facebook.presto.hive.ColumnConverter) MockHiveMetastore(com.facebook.presto.hive.MockHiveMetastore) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore) Test(org.testng.annotations.Test)

Example 4 with BridgingHiveMetastore

use of com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore in project presto by prestodb.

the class TestHiveMetadataFileFormatEncryptionSettings method setup.

@BeforeClass
public void setup() {
    baseDirectory = new File(Files.createTempDir(), "metastore");
    metastore = new BridgingHiveMetastore(new InMemoryHiveMetastore(baseDirectory), new HivePartitionMutator());
    executor = newCachedThreadPool(daemonThreadsNamed("hive-encryption-test-%s"));
    transactionManager = new HiveTransactionManager();
    metadataFactory = new HiveMetadataFactory(metastore, HDFS_ENVIRONMENT, new HivePartitionManager(FUNCTION_AND_TYPE_MANAGER, HIVE_CLIENT_CONFIG), DateTimeZone.forTimeZone(TimeZone.getTimeZone(ZoneId.of(HIVE_CLIENT_CONFIG.getTimeZone()))), true, false, false, false, true, true, HIVE_CLIENT_CONFIG.getMaxPartitionBatchSize(), HIVE_CLIENT_CONFIG.getMaxPartitionsPerScan(), false, FUNCTION_AND_TYPE_MANAGER, new HiveLocationService(HDFS_ENVIRONMENT), FUNCTION_RESOLUTION, ROW_EXPRESSION_SERVICE, FILTER_STATS_CALCULATOR_SERVICE, new TableParameterCodec(), PARTITION_UPDATE_CODEC, PARTITION_UPDATE_SMILE_CODEC, listeningDecorator(executor), new HiveTypeTranslator(), new HiveStagingFileCommitter(HDFS_ENVIRONMENT, listeningDecorator(executor)), new HiveZeroRowFileCreator(HDFS_ENVIRONMENT, new OutputStreamDataSinkFactory(), listeningDecorator(executor)), TEST_SERVER_VERSION, new HivePartitionObjectBuilder(), new HiveEncryptionInformationProvider(ImmutableList.of(new TestDwrfEncryptionInformationSource())), new HivePartitionStats(), new HiveFileRenamer(), HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER);
    metastore.createDatabase(METASTORE_CONTEXT, Database.builder().setDatabaseName(TEST_DB_NAME).setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
}
Also used : OutputStreamDataSinkFactory(com.facebook.presto.hive.datasink.OutputStreamDataSinkFactory) HivePartitionMutator(com.facebook.presto.hive.metastore.HivePartitionMutator) InMemoryHiveMetastore(com.facebook.presto.hive.metastore.thrift.InMemoryHiveMetastore) File(java.io.File) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with BridgingHiveMetastore

use of com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore in project presto by prestodb.

the class TestingSemiTransactionalHiveMetastore method create.

public static TestingSemiTransactionalHiveMetastore create() {
    // none of these values matter, as we never use them
    HiveClientConfig config = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config, metastoreClientConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication());
    HiveCluster hiveCluster = new TestingHiveCluster(metastoreClientConfig, HOST, PORT);
    ColumnConverterProvider columnConverterProvider = HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER;
    ExtendedHiveMetastore delegate = new BridgingHiveMetastore(new ThriftHiveMetastore(hiveCluster, metastoreClientConfig), new HivePartitionMutator());
    ExecutorService executor = newCachedThreadPool(daemonThreadsNamed("hive-%s"));
    ListeningExecutorService renameExecutor = listeningDecorator(executor);
    return new TestingSemiTransactionalHiveMetastore(hdfsEnvironment, delegate, renameExecutor, false, false, true, columnConverterProvider);
}
Also used : TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) ThriftHiveMetastore(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) HiveCluster(com.facebook.presto.hive.metastore.thrift.HiveCluster) TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) HivePartitionMutator(com.facebook.presto.hive.metastore.HivePartitionMutator) ExecutorService(java.util.concurrent.ExecutorService) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore)

Aggregations

BridgingHiveMetastore (com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore)10 HivePartitionMutator (com.facebook.presto.hive.metastore.HivePartitionMutator)6 ThriftHiveMetastore (com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore)5 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)5 ColumnConverter (com.facebook.presto.hive.ColumnConverter)4 HiveCluster (com.facebook.presto.hive.metastore.thrift.HiveCluster)4 MockHiveMetastoreClient (com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient)4 Duration (io.airlift.units.Duration)4 MockHiveMetastore (com.facebook.presto.hive.MockHiveMetastore)3 PartitionMutator (com.facebook.presto.hive.PartitionMutator)3 InMemoryHiveMetastore (com.facebook.presto.hive.metastore.thrift.InMemoryHiveMetastore)3 TestingHiveCluster (com.facebook.presto.hive.metastore.thrift.TestingHiveCluster)3 File (java.io.File)3 CacheConfig (com.facebook.presto.cache.CacheConfig)2 MetastoreClientConfig (com.facebook.presto.hive.MetastoreClientConfig)2 NoHdfsAuthentication (com.facebook.presto.hive.authentication.NoHdfsAuthentication)2 OutputStreamDataSinkFactory (com.facebook.presto.hive.datasink.OutputStreamDataSinkFactory)2 ExtendedHiveMetastore (com.facebook.presto.hive.metastore.ExtendedHiveMetastore)2 BoundedExecutor (com.facebook.airlift.concurrent.BoundedExecutor)1 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)1