Skip to content

Commit

Permalink
Remove unused HiveConfig from HdfsConfigurationInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Sep 23, 2019
1 parent 55fe640 commit 40fd8ae
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ protected void setup(String host, int port, String databaseName, String awsAcces
this.awsSecretKey = awsSecretKey;
this.writableBucket = writableBucket;

super.setup(host, port, databaseName, this::createHdfsConfiguration, s3SelectPushdownEnabled);
setup(host, port, databaseName, s3SelectPushdownEnabled, createHdfsConfiguration());
}

HdfsConfiguration createHdfsConfiguration(HiveConfig config)
private HdfsConfiguration createHdfsConfiguration()
{
ConfigurationInitializer s3Config = new PrestoS3ConfigurationInitializer(new HiveS3Config()
.setS3AwsAccessKey(awsAccessKey)
.setS3AwsSecretKey(awsSecretKey));
HdfsConfigurationInitializer initializer = new HdfsConfigurationInitializer(config, new HdfsConfig(), ImmutableSet.of(s3Config));
HdfsConfigurationInitializer initializer = new HdfsConfigurationInitializer(new HdfsConfig(), ImmutableSet.of(s3Config));
return new HiveHdfsConfiguration(initializer, ImmutableSet.of());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public class HdfsConfigurationInitializer
private final boolean wireEncryptionEnabled;

@VisibleForTesting
public HdfsConfigurationInitializer(HiveConfig hiveConfig, HdfsConfig hdfsConfig)
public HdfsConfigurationInitializer(HdfsConfig hdfsConfig)
{
this(hiveConfig, hdfsConfig, ImmutableSet.of());
this(hdfsConfig, ImmutableSet.of());
}

@Inject
public HdfsConfigurationInitializer(HiveConfig hiveConfig, HdfsConfig config, Set<ConfigurationInitializer> configurationInitializers)
public HdfsConfigurationInitializer(HdfsConfig config, Set<ConfigurationInitializer> configurationInitializers)
{
checkArgument(config.getDfsTimeout().toMillis() >= 1, "dfsTimeout must be at least 1 ms");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.prestosql.plugin.hive.HdfsEnvironment;
import io.prestosql.plugin.hive.HdfsEnvironment.HdfsContext;
import io.prestosql.plugin.hive.HiveBasicStatistics;
import io.prestosql.plugin.hive.HiveConfig;
import io.prestosql.plugin.hive.HiveHdfsConfiguration;
import io.prestosql.plugin.hive.HiveType;
import io.prestosql.plugin.hive.PartitionNotFoundException;
Expand Down Expand Up @@ -141,7 +140,7 @@ public class FileHiveMetastore
public static FileHiveMetastore createTestingFileHiveMetastore(File catalogDirectory)
{
HdfsConfig hdfsConfig = new HdfsConfig();
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(new HiveConfig(), hdfsConfig), ImmutableSet.of());
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
return new FileHiveMetastore(hdfsEnvironment, catalogDirectory.toURI().toString(), "test");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@
import static io.prestosql.plugin.hive.HiveTableProperties.PARTITIONED_BY_PROPERTY;
import static io.prestosql.plugin.hive.HiveTableProperties.SORTED_BY_PROPERTY;
import static io.prestosql.plugin.hive.HiveTableProperties.STORAGE_FORMAT_PROPERTY;
import static io.prestosql.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT;
import static io.prestosql.plugin.hive.HiveTestUtils.PAGE_SORTER;
import static io.prestosql.plugin.hive.HiveTestUtils.SESSION;
import static io.prestosql.plugin.hive.HiveTestUtils.TYPE_MANAGER;
import static io.prestosql.plugin.hive.HiveTestUtils.arrayType;
import static io.prestosql.plugin.hive.HiveTestUtils.createTestHdfsEnvironment;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveDataStreamFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveFileWriterFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHivePageSourceFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveRecordCursorProvider;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultOrcFileWriterFactory;
import static io.prestosql.plugin.hive.HiveTestUtils.getHiveSession;
Expand Down Expand Up @@ -717,7 +717,7 @@ protected final void setup(String databaseName, HiveConfig hiveConfig, HiveMetas

metastoreClient = hiveMetastore;
HivePartitionManager partitionManager = new HivePartitionManager(TYPE_MANAGER, hiveConfig);
hdfsEnvironment = createTestHdfsEnvironment(hiveConfig);
hdfsEnvironment = HDFS_ENVIRONMENT;
locationService = new HiveLocationService(hdfsEnvironment);
JsonCodec<PartitionUpdate> partitionUpdateCodec = JsonCodec.jsonCodec(PartitionUpdate.class);
metadataFactory = new HiveMetadataFactory(
Expand Down Expand Up @@ -758,7 +758,7 @@ protected final void setup(String databaseName, HiveConfig hiveConfig, HiveMetas
hiveConfig.getMaxSplitsPerSecond(),
false);
pageSinkProvider = new HivePageSinkProvider(
getDefaultHiveFileWriterFactories(hiveConfig),
getDefaultHiveFileWriterFactories(hiveConfig, hdfsEnvironment),
hdfsEnvironment,
PAGE_SORTER,
metastoreClient,
Expand All @@ -771,8 +771,13 @@ protected final void setup(String databaseName, HiveConfig hiveConfig, HiveMetas
new HiveEventClient(),
getHiveSessionProperties(hiveConfig),
new HiveWriterStats(),
getDefaultOrcFileWriterFactory(hiveConfig));
pageSourceProvider = new HivePageSourceProvider(hiveConfig, hdfsEnvironment, getDefaultHiveRecordCursorProvider(hiveConfig), getDefaultHiveDataStreamFactories(hiveConfig), TYPE_MANAGER);
getDefaultOrcFileWriterFactory(hiveConfig, hdfsEnvironment));
pageSourceProvider = new HivePageSourceProvider(
hiveConfig,
hdfsEnvironment,
getDefaultHiveRecordCursorProvider(hiveConfig, hdfsEnvironment),
getDefaultHivePageSourceFactories(hiveConfig, hdfsEnvironment),
TYPE_MANAGER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Iterables.getOnlyElement;
Expand All @@ -90,8 +89,8 @@
import static io.prestosql.plugin.hive.AbstractTestHive.getAllSplits;
import static io.prestosql.plugin.hive.HiveTestUtils.PAGE_SORTER;
import static io.prestosql.plugin.hive.HiveTestUtils.TYPE_MANAGER;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveDataStreamFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveFileWriterFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHivePageSourceFactories;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveRecordCursorProvider;
import static io.prestosql.plugin.hive.HiveTestUtils.getDefaultOrcFileWriterFactory;
import static io.prestosql.plugin.hive.HiveTestUtils.getHiveSession;
Expand Down Expand Up @@ -143,7 +142,7 @@ public void tearDown()

protected abstract Path getBasePath();

protected void setup(String host, int port, String databaseName, Function<HiveConfig, HdfsConfiguration> hdfsConfigurationProvider, boolean s3SelectPushdownEnabled)
protected void setup(String host, int port, String databaseName, boolean s3SelectPushdownEnabled, HdfsConfiguration hdfsConfiguration)
{
database = databaseName;
table = new SchemaTableName(database, "presto_test_external_fs");
Expand All @@ -161,8 +160,6 @@ protected void setup(String host, int port, String databaseName, Function<HiveCo
ExecutorService executor = newCachedThreadPool(daemonThreadsNamed("hive-%s"));
HivePartitionManager hivePartitionManager = new HivePartitionManager(TYPE_MANAGER, config);

HdfsConfiguration hdfsConfiguration = hdfsConfigurationProvider.apply(config);

hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, new HdfsConfig(), new NoHdfsAuthentication());
metastoreClient = new TestingHiveMetastore(
new BridgingHiveMetastore(new ThriftHiveMetastore(metastoreLocator, new ThriftHiveMetastoreConfig())),
Expand Down Expand Up @@ -202,7 +199,7 @@ protected void setup(String host, int port, String databaseName, Function<HiveCo
config.getMaxSplitsPerSecond(),
config.getRecursiveDirWalkerEnabled());
pageSinkProvider = new HivePageSinkProvider(
getDefaultHiveFileWriterFactories(config),
getDefaultHiveFileWriterFactories(config, hdfsEnvironment),
hdfsEnvironment,
PAGE_SORTER,
metastoreClient,
Expand All @@ -215,8 +212,13 @@ protected void setup(String host, int port, String databaseName, Function<HiveCo
new HiveEventClient(),
getHiveSessionProperties(config),
new HiveWriterStats(),
getDefaultOrcFileWriterFactory(config));
pageSourceProvider = new HivePageSourceProvider(config, hdfsEnvironment, getDefaultHiveRecordCursorProvider(config), getDefaultHiveDataStreamFactories(config), TYPE_MANAGER);
getDefaultOrcFileWriterFactory(config, hdfsEnvironment));
pageSourceProvider = new HivePageSourceProvider(
config,
hdfsEnvironment,
getDefaultHiveRecordCursorProvider(config, hdfsEnvironment),
getDefaultHivePageSourceFactories(config, hdfsEnvironment),
TYPE_MANAGER);
}

protected ConnectorSession newSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

import static io.airlift.log.Level.WARN;
import static io.airlift.units.Duration.nanosSince;
import static io.prestosql.plugin.hive.HiveTestUtils.createTestHdfsEnvironment;
import static io.prestosql.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT;
import static io.prestosql.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.prestosql.spi.security.SelectedRole.Type.ROLE;
import static io.prestosql.testing.TestingConnectorSession.SESSION;
Expand Down Expand Up @@ -103,9 +103,7 @@ public static DistributedQueryRunner createQueryRunner(Iterable<TpchTable<?>> ta

File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();

HdfsEnvironment hdfsEnvironment = createTestHdfsEnvironment(new HiveConfig());

FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
FileHiveMetastore metastore = new FileHiveMetastore(HDFS_ENVIRONMENT, baseDir.toURI().toString(), "test");
queryRunner.installPlugin(new HivePlugin(HIVE_CATALOG, Optional.of(metastore)));

Map<String, String> hiveProperties = ImmutableMap.<String, String>builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private HiveTestUtils() {}
private static final Metadata METADATA = createTestMetadataManager();
public static final TypeManager TYPE_MANAGER = new InternalTypeManager(METADATA);

public static final HdfsEnvironment HDFS_ENVIRONMENT = createTestHdfsEnvironment(new HiveConfig());
public static final HdfsEnvironment HDFS_ENVIRONMENT = createTestHdfsEnvironment();

public static final PageSorter PAGE_SORTER = new PagesIndexPageSorter(new PagesIndex.TestingFactory(false));

Expand All @@ -84,39 +84,35 @@ public static HiveSessionProperties getHiveSessionProperties(HiveConfig hiveConf
new ParquetWriterConfig());
}

public static Set<HivePageSourceFactory> getDefaultHiveDataStreamFactories(HiveConfig hiveConfig)
public static Set<HivePageSourceFactory> getDefaultHivePageSourceFactories(HiveConfig hiveConfig, HdfsEnvironment hdfsEnvironment)
{
FileFormatDataSourceStats stats = new FileFormatDataSourceStats();
HdfsEnvironment testHdfsEnvironment = createTestHdfsEnvironment(hiveConfig);
return ImmutableSet.<HivePageSourceFactory>builder()
.add(new RcFilePageSourceFactory(TYPE_MANAGER, testHdfsEnvironment, stats))
.add(new OrcPageSourceFactory(TYPE_MANAGER, hiveConfig, testHdfsEnvironment, stats))
.add(new ParquetPageSourceFactory(TYPE_MANAGER, testHdfsEnvironment, stats))
.add(new RcFilePageSourceFactory(TYPE_MANAGER, hdfsEnvironment, stats))
.add(new OrcPageSourceFactory(TYPE_MANAGER, hiveConfig, hdfsEnvironment, stats))
.add(new ParquetPageSourceFactory(TYPE_MANAGER, hdfsEnvironment, stats))
.build();
}

public static Set<HiveRecordCursorProvider> getDefaultHiveRecordCursorProvider(HiveConfig hiveConfig)
public static Set<HiveRecordCursorProvider> getDefaultHiveRecordCursorProvider(HiveConfig hiveConfig, HdfsEnvironment hdfsEnvironment)
{
HdfsEnvironment testHdfsEnvironment = createTestHdfsEnvironment(hiveConfig);
return ImmutableSet.<HiveRecordCursorProvider>builder()
.add(new GenericHiveRecordCursorProvider(testHdfsEnvironment, hiveConfig))
.add(new GenericHiveRecordCursorProvider(hdfsEnvironment, hiveConfig))
.build();
}

public static Set<HiveFileWriterFactory> getDefaultHiveFileWriterFactories(HiveConfig hiveConfig)
public static Set<HiveFileWriterFactory> getDefaultHiveFileWriterFactories(HiveConfig hiveConfig, HdfsEnvironment hdfsEnvironment)
{
HdfsEnvironment testHdfsEnvironment = createTestHdfsEnvironment(hiveConfig);
return ImmutableSet.<HiveFileWriterFactory>builder()
.add(new RcFileFileWriterFactory(testHdfsEnvironment, TYPE_MANAGER, new NodeVersion("test_version"), hiveConfig, new FileFormatDataSourceStats()))
.add(getDefaultOrcFileWriterFactory(hiveConfig))
.add(new RcFileFileWriterFactory(hdfsEnvironment, TYPE_MANAGER, new NodeVersion("test_version"), hiveConfig, new FileFormatDataSourceStats()))
.add(getDefaultOrcFileWriterFactory(hiveConfig, hdfsEnvironment))
.build();
}

public static OrcFileWriterFactory getDefaultOrcFileWriterFactory(HiveConfig hiveConfig)
public static OrcFileWriterFactory getDefaultOrcFileWriterFactory(HiveConfig hiveConfig, HdfsEnvironment hdfsEnvironment)
{
HdfsEnvironment testHdfsEnvironment = createTestHdfsEnvironment(hiveConfig);
return new OrcFileWriterFactory(
testHdfsEnvironment,
hdfsEnvironment,
TYPE_MANAGER,
new NodeVersion("test_version"),
hiveConfig,
Expand All @@ -138,11 +134,10 @@ public static HiveRecordCursorProvider createGenericHiveRecordCursorProvider(Hdf
return new GenericHiveRecordCursorProvider(hdfsEnvironment, new DataSize(100, MEGABYTE));
}

public static HdfsEnvironment createTestHdfsEnvironment(HiveConfig config)
public static HdfsEnvironment createTestHdfsEnvironment()
{
HdfsConfiguration hdfsConfig = new HiveHdfsConfiguration(
new HdfsConfigurationInitializer(
config,
new HdfsConfig(),
ImmutableSet.of(
new PrestoS3ConfigurationInitializer(new HiveS3Config()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public TestingHdfsEnvironment(List<LocatedFileStatus> files)
{
super(
new HiveHdfsConfiguration(
new HdfsConfigurationInitializer(new HiveConfig(), new HdfsConfig()),
new HdfsConfigurationInitializer(new HdfsConfig()),
ImmutableSet.of()),
new HdfsConfig(),
new NoHdfsAuthentication());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void testFileSystemCache()
throws IOException
{
HdfsEnvironment environment = new HdfsEnvironment(
new HiveHdfsConfiguration(new HdfsConfigurationInitializer(new HiveConfig(), new HdfsConfig()), ImmutableSet.of()),
new HiveHdfsConfiguration(new HdfsConfigurationInitializer(new HdfsConfig()), ImmutableSet.of()),
new HdfsConfig(),
new ImpersonatingHdfsAuthentication(new SimpleHadoopAuthentication()));
FileSystem fs1 = getFileSystem(environment, "user");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.io.File;

import static io.prestosql.plugin.hive.HiveTestUtils.createTestHdfsEnvironment;
import static io.prestosql.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT;

public class TestHiveFileMetastore
extends AbstractTestHiveLocal
Expand All @@ -28,8 +28,7 @@ public class TestHiveFileMetastore
protected HiveMetastore createMetastore(File tempDir)
{
File baseDir = new File(tempDir, "metastore");
HdfsEnvironment hdfsEnvironment = createTestHdfsEnvironment(new HiveConfig());
return new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
return new FileHiveMetastore(HDFS_ENVIRONMENT, baseDir.toURI().toString(), "test");
}

@Override
Expand Down
Loading

0 comments on commit 40fd8ae

Please sign in to comment.