Search in sources :

Example 6 with BridgingHiveMetastore

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

the class TestCachingHiveMetastore method testPartitionCacheValidation.

@Test
public void testPartitionCacheValidation() {
    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 partitionCacheVerificationEnabledMetastore = new CachingHiveMetastore(new BridgingHiveMetastore(mockHiveMetastore, mockPartitionMutator), executor, false, new Duration(5, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), 1000, true, MetastoreCacheScope.PARTITION, 100.0);
    // Warmup the cache
    partitionCacheVerificationEnabledMetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2));
    // Each of the following calls will be a cache hit and verification will be done.
    partitionCacheVerificationEnabledMetastore.getPartition(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, TEST_PARTITION_VALUES1);
    partitionCacheVerificationEnabledMetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1));
    partitionCacheVerificationEnabledMetastore.getPartition(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, TEST_PARTITION_VALUES2);
    partitionCacheVerificationEnabledMetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION2));
}
Also used : MockHiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient) 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 7 with BridgingHiveMetastore

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

the class TestCachingHiveMetastore method setUp.

@BeforeMethod
public void setUp() {
    mockClient = new MockHiveMetastoreClient();
    MockHiveCluster mockHiveCluster = new MockHiveCluster(mockClient);
    ListeningExecutorService executor = listeningDecorator(newCachedThreadPool(daemonThreadsNamed("test-%s")));
    ColumnConverter hiveColumnConverter = new HiveColumnConverter();
    ThriftHiveMetastore thriftHiveMetastore = new ThriftHiveMetastore(mockHiveCluster, new MetastoreClientConfig());
    PartitionMutator hivePartitionMutator = new HivePartitionMutator();
    metastore = new CachingHiveMetastore(new BridgingHiveMetastore(thriftHiveMetastore, hivePartitionMutator), executor, false, new Duration(5, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), 1000, false, MetastoreCacheScope.ALL, 0.0);
    stats = thriftHiveMetastore.getStats();
}
Also used : MockHiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient) PartitionMutator(com.facebook.presto.hive.PartitionMutator) ThriftHiveMetastore(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Duration(io.airlift.units.Duration) ColumnConverter(com.facebook.presto.hive.ColumnConverter) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with BridgingHiveMetastore

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

the class TestCachingHiveMetastore method assertInvalidateCache.

private void assertInvalidateCache(MockPartitionMutator partitionMutator) {
    MockHiveMetastoreClient mockClient = new MockHiveMetastoreClient();
    MockHiveCluster mockHiveCluster = new MockHiveCluster(mockClient);
    ListeningExecutorService executor = listeningDecorator(newCachedThreadPool(daemonThreadsNamed("partition-versioning-test-%s")));
    MockHiveMetastore mockHiveMetastore = new MockHiveMetastore(mockHiveCluster);
    ColumnConverter hiveColumnConverter = new HiveColumnConverter();
    CachingHiveMetastore partitionCachingEnabledmetastore = new CachingHiveMetastore(new BridgingHiveMetastore(mockHiveMetastore, partitionMutator), executor, false, new Duration(5, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), 1000, true, MetastoreCacheScope.PARTITION, 0.0);
    int clientAccessCount = 0;
    for (int i = 0; i < 100; i++) {
        assertEquals(partitionCachingEnabledmetastore.getPartitionNamesByFilter(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableMap.of()), EXPECTED_PARTITIONS);
        assertEquals(mockClient.getAccessCount(), ++clientAccessCount);
        assertEquals(partitionCachingEnabledmetastore.getPartitionsByNames(TEST_METASTORE_CONTEXT, TEST_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2)).size(), 2);
        // Assert that we did not hit cache
        assertEquals(mockClient.getAccessCount(), ++clientAccessCount);
    }
}
Also used : MockHiveMetastoreClient(com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient) 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)

Example 9 with BridgingHiveMetastore

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

the class AbstractTestHiveFileSystem method setup.

protected void setup(String host, int port, String databaseName, BiFunction<HiveClientConfig, MetastoreClientConfig, HdfsConfiguration> hdfsConfigurationProvider, boolean s3SelectPushdownEnabled) {
    database = databaseName;
    table = new SchemaTableName(database, "presto_test_external_fs");
    String random = UUID.randomUUID().toString().toLowerCase(ENGLISH).replace("-", "");
    temporaryCreateTable = new SchemaTableName(database, "tmp_presto_test_create_" + random);
    config = new HiveClientConfig().setS3SelectPushdownEnabled(s3SelectPushdownEnabled);
    cacheConfig = new CacheConfig();
    metastoreClientConfig = new MetastoreClientConfig();
    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);
    ExecutorService executor = newCachedThreadPool(daemonThreadsNamed("hive-%s"));
    HivePartitionManager hivePartitionManager = new HivePartitionManager(FUNCTION_AND_TYPE_MANAGER, config);
    HdfsConfiguration hdfsConfiguration = hdfsConfigurationProvider.apply(config, metastoreClientConfig);
    hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication());
    ColumnConverterProvider columnConverterProvider = HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER;
    metastoreClient = new TestingHiveMetastore(new BridgingHiveMetastore(new ThriftHiveMetastore(hiveCluster, metastoreClientConfig), new HivePartitionMutator()), executor, metastoreClientConfig, getBasePath(), hdfsEnvironment);
    locationService = new HiveLocationService(hdfsEnvironment);
    metadataFactory = new HiveMetadataFactory(config, metastoreClientConfig, metastoreClient, hdfsEnvironment, hivePartitionManager, newDirectExecutorService(), FUNCTION_AND_TYPE_MANAGER, locationService, FUNCTION_RESOLUTION, ROW_EXPRESSION_SERVICE, FILTER_STATS_CALCULATOR_SERVICE, new TableParameterCodec(), HiveTestUtils.PARTITION_UPDATE_CODEC, HiveTestUtils.PARTITION_UPDATE_SMILE_CODEC, new HiveTypeTranslator(), new HiveStagingFileCommitter(hdfsEnvironment, listeningDecorator(executor)), new HiveZeroRowFileCreator(hdfsEnvironment, new OutputStreamDataSinkFactory(), listeningDecorator(executor)), new NodeVersion("test_version"), new HivePartitionObjectBuilder(), new HiveEncryptionInformationProvider(ImmutableList.of()), new HivePartitionStats(), new HiveFileRenamer(), columnConverterProvider);
    transactionManager = new HiveTransactionManager();
    splitManager = new HiveSplitManager(transactionManager, new NamenodeStats(), hdfsEnvironment, new CachingDirectoryLister(new HadoopDirectoryLister(), new HiveClientConfig()), new BoundedExecutor(executor, config.getMaxSplitIteratorThreads()), new HiveCoercionPolicy(FUNCTION_AND_TYPE_MANAGER), new CounterStat(), config.getMaxOutstandingSplits(), config.getMaxOutstandingSplitsSize(), config.getMinPartitionBatchSize(), config.getMaxPartitionBatchSize(), config.getSplitLoaderConcurrency(), config.getRecursiveDirWalkerEnabled(), new ConfigBasedCacheQuotaRequirementProvider(cacheConfig), new HiveEncryptionInformationProvider(ImmutableSet.of()));
    pageSinkProvider = new HivePageSinkProvider(getDefaultHiveFileWriterFactories(config, metastoreClientConfig), hdfsEnvironment, PAGE_SORTER, metastoreClient, new GroupByHashPageIndexerFactory(new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig())), FUNCTION_AND_TYPE_MANAGER, config, metastoreClientConfig, locationService, HiveTestUtils.PARTITION_UPDATE_CODEC, HiveTestUtils.PARTITION_UPDATE_SMILE_CODEC, new TestingNodeManager("fake-environment"), new HiveEventClient(), new HiveSessionProperties(config, new OrcFileWriterConfig(), new ParquetFileWriterConfig(), new CacheConfig()), new HiveWriterStats(), getDefaultOrcFileWriterFactory(config, metastoreClientConfig), columnConverterProvider);
    pageSourceProvider = new HivePageSourceProvider(config, hdfsEnvironment, getDefaultHiveRecordCursorProvider(config, metastoreClientConfig), getDefaultHiveBatchPageSourceFactories(config, metastoreClientConfig), getDefaultHiveSelectivePageSourceFactories(config, metastoreClientConfig), FUNCTION_AND_TYPE_MANAGER, ROW_EXPRESSION_SERVICE);
}
Also used : CounterStat(com.facebook.airlift.stats.CounterStat) HivePartitionMutator(com.facebook.presto.hive.metastore.HivePartitionMutator) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) BridgingHiveMetastore(com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) GroupByHashPageIndexerFactory(com.facebook.presto.GroupByHashPageIndexerFactory) TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) OutputStreamDataSinkFactory(com.facebook.presto.hive.datasink.OutputStreamDataSinkFactory) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) TestingHiveCluster(com.facebook.presto.hive.metastore.thrift.TestingHiveCluster) HiveCluster(com.facebook.presto.hive.metastore.thrift.HiveCluster) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) CacheConfig(com.facebook.presto.cache.CacheConfig) ThriftHiveMetastore(com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore) SchemaTableName(com.facebook.presto.spi.SchemaTableName) BoundedExecutor(com.facebook.airlift.concurrent.BoundedExecutor) MoreExecutors.newDirectExecutorService(com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 10 with BridgingHiveMetastore

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

the class TestHiveClientInMemoryMetastore 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)

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