Search in sources :

Example 1 with SparkIngestDriver

use of org.locationtech.geowave.core.ingest.spark.SparkIngestDriver 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)

Example 2 with SparkIngestDriver

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

the class SparkToGeoWaveCommand method computeResults.

@Override
public Void computeResults(final OperationParams params) throws Exception {
    // Ensure we have all the required arguments
    if (parameters.size() != 3) {
        throw new ParameterException("Requires arguments: <file or directory> <store name> <comma delimited index list>");
    }
    final String inputPath = parameters.get(0);
    final String inputStoreName = parameters.get(1);
    final String indexList = parameters.get(2);
    // Config file
    final File configFile = getGeoWaveConfigFile(params);
    // Driver
    final SparkIngestDriver driver = new SparkIngestDriver();
    // Execute
    if (!driver.runOperation(configFile, localInputOptions, inputStoreName, indexList, ingestOptions, sparkOptions, inputPath, params.getConsole())) {
        throw new RuntimeException("Ingest failed to execute");
    }
    return null;
}
Also used : ParameterException(com.beust.jcommander.ParameterException) SparkIngestDriver(org.locationtech.geowave.core.ingest.spark.SparkIngestDriver) File(java.io.File)

Example 3 with SparkIngestDriver

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

the class DefaultGeoWaveAWSCredentialsProviderTest method testAnonymousAccess.

@Test
public void testAnonymousAccess() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, URISyntaxException, IOException {
    final File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
    temp.mkdirs();
    final S3Mock mockS3 = new S3Mock.Builder().withPort(8001).withFileBackend(temp.getAbsolutePath()).withInMemoryBackend().build();
    mockS3.start();
    URLIngestUtils.setURLStreamHandlerFactory(URLTYPE.S3);
    final SparkIngestDriver sparkDriver = new SparkIngestDriver();
    final S3FileSystem s3 = sparkDriver.initializeS3FS("s3://s3.amazonaws.com");
    s3.getClient().setEndpoint("http://127.0.0.1:8001");
    s3.getClient().createBucket("testbucket");
    s3.getClient().putObject("testbucket", "test", "content");
    try (Stream<Path> s = Files.list(URLIngestUtils.setupS3FileSystem("s3://testbucket/", "s3://s3.amazonaws.com"))) {
        Assert.assertEquals(1, s.count());
    }
    mockS3.shutdown();
}
Also used : Path(java.nio.file.Path) SparkIngestDriver(org.locationtech.geowave.core.ingest.spark.SparkIngestDriver) File(java.io.File) S3Mock(io.findify.s3mock.S3Mock) S3FileSystem(com.upplication.s3fs.S3FileSystem) Test(org.junit.Test)

Aggregations

File (java.io.File)3 SparkIngestDriver (org.locationtech.geowave.core.ingest.spark.SparkIngestDriver)3 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 S3FileSystem (com.upplication.s3fs.S3FileSystem)1 S3Mock (io.findify.s3mock.S3Mock)1 Path (java.nio.file.Path)1 Properties (java.util.Properties)1 Test (org.junit.Test)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 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