Search in sources :

Example 1 with LocalToMapReduceToGeoWaveCommand

use of org.locationtech.geowave.core.ingest.operations.LocalToMapReduceToGeoWaveCommand in project geowave by locationtech.

the class MapReduceTestUtils method testMapReduceIngest.

public static void testMapReduceIngest(final DataStorePluginOptions dataStore, final DimensionalityType dimensionalityType, final String format, final String ingestFilePath) throws Exception {
    // ingest gpx data directly into GeoWave using the
    // ingest framework's main method and pre-defined commandline arguments
    LOGGER.warn("Ingesting '" + ingestFilePath + "' - this may take several minutes...");
    final Thread progressLogger = startProgressLogger();
    // Indexes
    final String[] indexTypes = dimensionalityType.getDimensionalityArg().split(",");
    final List<IndexPluginOptions> indexOptions = new ArrayList<>(indexTypes.length);
    for (final String indexType : indexTypes) {
        final IndexPluginOptions indexOption = new IndexPluginOptions();
        indexOption.selectPlugin(indexType);
        indexOptions.add(indexOption);
    }
    // Ingest Formats
    final MapReduceTestEnvironment env = MapReduceTestEnvironment.getInstance();
    final IngestFormatPluginOptions ingestFormatOptions = new IngestFormatPluginOptions();
    ingestFormatOptions.selectPlugin(format);
    // create temporary config file and use it for hdfs FS URL config
    final File configFile = File.createTempFile("test_mr", null);
    final ManualOperationParams operationParams = new ManualOperationParams();
    operationParams.getContext().put(ConfigOptions.PROPERTIES_FILE_CONTEXT, configFile);
    final ConfigHDFSCommand configHdfs = new ConfigHDFSCommand();
    configHdfs.setHdfsUrlParameter(env.getHdfs());
    configHdfs.execute(operationParams);
    final LocalToMapReduceToGeoWaveCommand mrGw = new LocalToMapReduceToGeoWaveCommand();
    final AddStoreCommand addStore = new AddStoreCommand();
    addStore.setParameters("test-store");
    addStore.setPluginOptions(dataStore);
    addStore.execute(operationParams);
    final IndexStore indexStore = dataStore.createIndexStore();
    final DataStore geowaveDataStore = dataStore.createDataStore();
    final StringBuilder indexParam = new StringBuilder();
    for (int i = 0; i < indexOptions.size(); i++) {
        String indexName = "testIndex" + i;
        if (indexStore.getIndex(indexName) == null) {
            indexOptions.get(i).setName(indexName);
            geowaveDataStore.addIndex(indexOptions.get(i).createIndex(geowaveDataStore));
        }
        indexParam.append(indexName + ",");
    }
    mrGw.setPluginFormats(ingestFormatOptions);
    mrGw.setParameters(ingestFilePath, env.getHdfsBaseDirectory(), "test-store", indexParam.toString());
    mrGw.getMapReduceOptions().setJobTrackerHostPort(env.getJobtracker());
    mrGw.execute(operationParams);
    progressLogger.interrupt();
}
Also used : IngestFormatPluginOptions(org.locationtech.geowave.core.ingest.operations.options.IngestFormatPluginOptions) LocalToMapReduceToGeoWaveCommand(org.locationtech.geowave.core.ingest.operations.LocalToMapReduceToGeoWaveCommand) ArrayList(java.util.ArrayList) AddStoreCommand(org.locationtech.geowave.core.store.cli.store.AddStoreCommand) ManualOperationParams(org.locationtech.geowave.core.cli.parser.ManualOperationParams) DataStore(org.locationtech.geowave.core.store.api.DataStore) IndexPluginOptions(org.locationtech.geowave.core.store.index.IndexPluginOptions) ConfigHDFSCommand(org.locationtech.geowave.mapreduce.operations.ConfigHDFSCommand) IndexStore(org.locationtech.geowave.core.store.index.IndexStore)

Example 2 with LocalToMapReduceToGeoWaveCommand

use of org.locationtech.geowave.core.ingest.operations.LocalToMapReduceToGeoWaveCommand in project geowave by locationtech.

the class GeoWaveGrpcCoreIngestService method localToMapReduceToGeoWaveCommand.

@Override
public void localToMapReduceToGeoWaveCommand(final org.locationtech.geowave.service.grpc.protobuf.LocalToMapReduceToGeoWaveCommandParametersProtos request, final StreamObserver<org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.VoidResponseProtos> responseObserver) {
    final LocalToMapReduceToGeoWaveCommand cmd = new LocalToMapReduceToGeoWaveCommand();
    final Map<FieldDescriptor, Object> m = request.getAllFields();
    GeoWaveGrpcServiceCommandUtil.setGrpcToCommandFields(m, cmd);
    final File configFile = GeoWaveGrpcServiceOptions.geowaveConfigFile;
    final OperationParams params = new ManualOperationParams();
    params.getContext().put(ConfigOptions.PROPERTIES_FILE_CONTEXT, configFile);
    cmd.prepare(params);
    LOGGER.info("Executing LocalToMapReduceToGeowaveCommand...");
    try {
        cmd.computeResults(params);
        final VoidResponseProtos resp = VoidResponseProtos.newBuilder().build();
        responseObserver.onNext(resp);
        responseObserver.onCompleted();
    } catch (final Exception e) {
        LOGGER.error("Exception encountered executing command", e);
        responseObserver.onError(e);
    }
}
Also used : VoidResponseProtos(org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.VoidResponseProtos) LocalToMapReduceToGeoWaveCommand(org.locationtech.geowave.core.ingest.operations.LocalToMapReduceToGeoWaveCommand) OperationParams(org.locationtech.geowave.core.cli.api.OperationParams) ManualOperationParams(org.locationtech.geowave.core.cli.parser.ManualOperationParams) File(java.io.File) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) ManualOperationParams(org.locationtech.geowave.core.cli.parser.ManualOperationParams)

Aggregations

ManualOperationParams (org.locationtech.geowave.core.cli.parser.ManualOperationParams)2 LocalToMapReduceToGeoWaveCommand (org.locationtech.geowave.core.ingest.operations.LocalToMapReduceToGeoWaveCommand)2 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 OperationParams (org.locationtech.geowave.core.cli.api.OperationParams)1 IngestFormatPluginOptions (org.locationtech.geowave.core.ingest.operations.options.IngestFormatPluginOptions)1 DataStore (org.locationtech.geowave.core.store.api.DataStore)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 ConfigHDFSCommand (org.locationtech.geowave.mapreduce.operations.ConfigHDFSCommand)1 VoidResponseProtos (org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.VoidResponseProtos)1