Search in sources :

Example 1 with MetastoreClientConfig

use of com.facebook.presto.hive.MetastoreClientConfig in project presto by prestodb.

the class TestRecordingHiveMetastore method testRecordingHiveMetastore.

@Test
public void testRecordingHiveMetastore() throws IOException {
    MetastoreClientConfig recordingHiveClientConfig = new MetastoreClientConfig().setRecordingPath(File.createTempFile("recording_test", "json").getAbsolutePath()).setRecordingDuration(new Duration(10, TimeUnit.MINUTES));
    RecordingHiveMetastore recordingHiveMetastore = new RecordingHiveMetastore(new TestingHiveMetastore(), recordingHiveClientConfig);
    validateMetadata(recordingHiveMetastore);
    recordingHiveMetastore.dropDatabase(TEST_METASTORE_CONTEXT, "other_database");
    recordingHiveMetastore.writeRecording();
    MetastoreClientConfig replayingHiveClientConfig = recordingHiveClientConfig.setReplay(true);
    recordingHiveMetastore = new RecordingHiveMetastore(new UnimplementedHiveMetastore(), replayingHiveClientConfig);
    recordingHiveMetastore.loadRecording();
    validateMetadata(recordingHiveMetastore);
}
Also used : Duration(io.airlift.units.Duration) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) Test(org.testng.annotations.Test)

Example 2 with MetastoreClientConfig

use of com.facebook.presto.hive.MetastoreClientConfig in project presto by prestodb.

the class TestSpatialJoins method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().setSource(TestSpatialJoins.class.getSimpleName()).setCatalog("hive").setSchema("default").build(), 4);
    queryRunner.installPlugin(new GeoPlugin());
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();
    HiveClientConfig hiveClientConfig = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hiveClientConfig, metastoreClientConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication());
    FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
    ColumnConverterProvider columnConverterProvider = HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER;
    metastore.createDatabase(new MetastoreContext("test_user", "test_queryId", Optional.empty(), Optional.empty(), Optional.empty(), false, columnConverterProvider), Database.builder().setDatabaseName("default").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
    queryRunner.installPlugin(new HivePlugin("hive", Optional.of(metastore)));
    queryRunner.createCatalog("hive", "hive");
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(com.facebook.presto.hive.HdfsConfigurationInitializer) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) HivePlugin(com.facebook.presto.hive.HivePlugin) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) HdfsConfiguration(com.facebook.presto.hive.HdfsConfiguration) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) HdfsEnvironment(com.facebook.presto.hive.HdfsEnvironment) FileHiveMetastore(com.facebook.presto.hive.metastore.file.FileHiveMetastore) File(java.io.File) HiveColumnConverterProvider(com.facebook.presto.hive.HiveColumnConverterProvider) ColumnConverterProvider(com.facebook.presto.hive.ColumnConverterProvider) HiveClientConfig(com.facebook.presto.hive.HiveClientConfig)

Example 3 with MetastoreClientConfig

use of com.facebook.presto.hive.MetastoreClientConfig 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 4 with MetastoreClientConfig

use of com.facebook.presto.hive.MetastoreClientConfig in project presto by prestodb.

the class TestMetastoreClientConfig method testExplicitPropertyMappings.

@Test
public void testExplicitPropertyMappings() {
    Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("hive.metastore.thrift.client.socks-proxy", "localhost:1080").put("hive.metastore-timeout", "20s").put("hive.dfs.verify-checksum", "false").put("hive.dfs.require-hadoop-native", "false").put("hive.metastore-cache-ttl", "2h").put("hive.metastore-refresh-interval", "30m").put("hive.metastore-cache-maximum-size", "5000").put("hive.per-transaction-metastore-cache-maximum-size", "500").put("hive.metastore-refresh-max-threads", "2500").put("hive.metastore-recording-path", "/foo/bar").put("hive.metastore-recoding-duration", "42s").put("hive.replay-metastore-recording", "true").put("hive.partition-versioning-enabled", "true").put("hive.metastore-cache-scope", "PARTITION").put("hive.metastore-impersonation-enabled", "true").put("hive.partition-cache-validation-percentage", "60.0").build();
    MetastoreClientConfig expected = new MetastoreClientConfig().setMetastoreSocksProxy(HostAndPort.fromParts("localhost", 1080)).setMetastoreTimeout(new Duration(20, TimeUnit.SECONDS)).setVerifyChecksum(false).setRequireHadoopNative(false).setMetastoreCacheTtl(new Duration(2, TimeUnit.HOURS)).setMetastoreRefreshInterval(new Duration(30, TimeUnit.MINUTES)).setMetastoreCacheMaximumSize(5000).setPerTransactionMetastoreCacheMaximumSize(500).setMaxMetastoreRefreshThreads(2500).setRecordingPath("/foo/bar").setRecordingDuration(new Duration(42, TimeUnit.SECONDS)).setReplay(true).setPartitionVersioningEnabled(true).setMetastoreCacheScope(MetastoreCacheScope.PARTITION).setMetastoreImpersonationEnabled(true).setPartitionCacheValidationPercentage(60.0);
    ConfigAssertions.assertFullMapping(properties, expected);
}
Also used : Duration(io.airlift.units.Duration) ImmutableMap(com.google.common.collect.ImmutableMap) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) Test(org.testng.annotations.Test)

Example 5 with MetastoreClientConfig

use of com.facebook.presto.hive.MetastoreClientConfig in project presto by prestodb.

the class TestHiveClientGlueMetastore method createMetastore.

/**
 * GlueHiveMetastore currently uses AWS Default Credential Provider Chain,
 * See https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default
 * on ways to set your AWS credentials which will be needed to run this test.
 */
@Override
protected ExtendedHiveMetastore createMetastore(File tempDir) {
    HiveClientConfig hiveClientConfig = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hiveClientConfig, metastoreClientConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication());
    GlueHiveMetastoreConfig glueConfig = new GlueHiveMetastoreConfig();
    glueConfig.setDefaultWarehouseDir(tempDir.toURI().toString());
    return new GlueHiveMetastore(hdfsEnvironment, glueConfig, executor);
}
Also used : HdfsConfigurationInitializer(com.facebook.presto.hive.HdfsConfigurationInitializer) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) HdfsConfiguration(com.facebook.presto.hive.HdfsConfiguration) HiveHdfsConfiguration(com.facebook.presto.hive.HiveHdfsConfiguration) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) MetastoreClientConfig(com.facebook.presto.hive.MetastoreClientConfig) HiveClientConfig(com.facebook.presto.hive.HiveClientConfig) HdfsEnvironment(com.facebook.presto.hive.HdfsEnvironment)

Aggregations

MetastoreClientConfig (com.facebook.presto.hive.MetastoreClientConfig)5 Duration (io.airlift.units.Duration)3 HdfsConfiguration (com.facebook.presto.hive.HdfsConfiguration)2 HdfsConfigurationInitializer (com.facebook.presto.hive.HdfsConfigurationInitializer)2 HdfsEnvironment (com.facebook.presto.hive.HdfsEnvironment)2 HiveClientConfig (com.facebook.presto.hive.HiveClientConfig)2 HiveHdfsConfiguration (com.facebook.presto.hive.HiveHdfsConfiguration)2 NoHdfsAuthentication (com.facebook.presto.hive.authentication.NoHdfsAuthentication)2 Test (org.testng.annotations.Test)2 ColumnConverter (com.facebook.presto.hive.ColumnConverter)1 ColumnConverterProvider (com.facebook.presto.hive.ColumnConverterProvider)1 HiveColumnConverterProvider (com.facebook.presto.hive.HiveColumnConverterProvider)1 HivePlugin (com.facebook.presto.hive.HivePlugin)1 PartitionMutator (com.facebook.presto.hive.PartitionMutator)1 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)1 FileHiveMetastore (com.facebook.presto.hive.metastore.file.FileHiveMetastore)1 BridgingHiveMetastore (com.facebook.presto.hive.metastore.thrift.BridgingHiveMetastore)1 MockHiveMetastoreClient (com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClient)1 ThriftHiveMetastore (com.facebook.presto.hive.metastore.thrift.ThriftHiveMetastore)1 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)1