Search in sources :

Example 1 with SparkCommandLineOptions

use of org.locationtech.geowave.core.ingest.spark.SparkCommandLineOptions in project geowave by locationtech.

the class TestUtils method testSparkIngest.

public static void testSparkIngest(final DataStorePluginOptions dataStore, final DimensionalityType dimensionalityType, final String s3Url, final String ingestFilePath, final String format) throws Exception {
    // ingest a shapefile (geotools type) directly into GeoWave using the
    // ingest framework's main method and pre-defined commandline arguments
    // Indexes
    final String indexes = dimensionalityType.getDimensionalityArg();
    final File configFile = File.createTempFile("test_spark_ingest", null);
    final ManualOperationParams operationParams = new ManualOperationParams();
    operationParams.getContext().put(ConfigOptions.PROPERTIES_FILE_CONTEXT, configFile);
    final ConfigAWSCommand configS3 = new ConfigAWSCommand();
    configS3.setS3UrlParameter(s3Url);
    configS3.execute(operationParams);
    final LocalInputCommandLineOptions localOptions = new LocalInputCommandLineOptions();
    localOptions.setFormats(format);
    final SparkCommandLineOptions sparkOptions = new SparkCommandLineOptions();
    sparkOptions.setAppName("SparkIngestTest");
    sparkOptions.setMaster("local");
    sparkOptions.setHost("localhost");
    // Create the command and execute.
    final SparkIngestDriver sparkIngester = new SparkIngestDriver();
    final Properties props = new Properties();
    dataStore.save(props, DataStorePluginOptions.getStoreNamespace("test"));
    final AddStoreCommand addStore = new AddStoreCommand();
    addStore.setParameters("test");
    addStore.setPluginOptions(dataStore);
    addStore.execute(operationParams);
    final IndexStore indexStore = dataStore.createIndexStore();
    final org.locationtech.geowave.core.store.api.DataStore geowaveDataStore = dataStore.createDataStore();
    final String[] indexTypes = dimensionalityType.getDimensionalityArg().split(",");
    for (final String indexType : indexTypes) {
        if (indexStore.getIndex(indexType) == null) {
            final IndexPluginOptions pluginOptions = new IndexPluginOptions();
            pluginOptions.selectPlugin(indexType);
            pluginOptions.setName(indexType);
            pluginOptions.save(props, IndexPluginOptions.getIndexNamespace(indexType));
            geowaveDataStore.addIndex(pluginOptions.createIndex(geowaveDataStore));
        }
    }
    props.setProperty(ConfigAWSCommand.AWS_S3_ENDPOINT_URL, s3Url);
    sparkIngester.runOperation(configFile, localOptions, "test", indexes, new VisibilityOptions(), sparkOptions, ingestFilePath, new JCommander().getConsole());
    verifyStats(dataStore);
}
Also used : ConfigAWSCommand(org.locationtech.geowave.core.ingest.operations.ConfigAWSCommand) SparkIngestDriver(org.locationtech.geowave.core.ingest.spark.SparkIngestDriver) Properties(java.util.Properties) AddStoreCommand(org.locationtech.geowave.core.store.cli.store.AddStoreCommand) ManualOperationParams(org.locationtech.geowave.core.cli.parser.ManualOperationParams) VisibilityOptions(org.locationtech.geowave.core.store.cli.VisibilityOptions) SparkCommandLineOptions(org.locationtech.geowave.core.ingest.spark.SparkCommandLineOptions) JCommander(com.beust.jcommander.JCommander) IndexPluginOptions(org.locationtech.geowave.core.store.index.IndexPluginOptions) File(java.io.File) LocalInputCommandLineOptions(org.locationtech.geowave.core.store.ingest.LocalInputCommandLineOptions) IndexStore(org.locationtech.geowave.core.store.index.IndexStore)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 File (java.io.File)1 Properties (java.util.Properties)1 ManualOperationParams (org.locationtech.geowave.core.cli.parser.ManualOperationParams)1 ConfigAWSCommand (org.locationtech.geowave.core.ingest.operations.ConfigAWSCommand)1 SparkCommandLineOptions (org.locationtech.geowave.core.ingest.spark.SparkCommandLineOptions)1 SparkIngestDriver (org.locationtech.geowave.core.ingest.spark.SparkIngestDriver)1 VisibilityOptions (org.locationtech.geowave.core.store.cli.VisibilityOptions)1 AddStoreCommand (org.locationtech.geowave.core.store.cli.store.AddStoreCommand)1 IndexPluginOptions (org.locationtech.geowave.core.store.index.IndexPluginOptions)1 IndexStore (org.locationtech.geowave.core.store.index.IndexStore)1 LocalInputCommandLineOptions (org.locationtech.geowave.core.store.ingest.LocalInputCommandLineOptions)1