use of org.locationtech.geowave.core.ingest.operations.LocalToGeoWaveCommand in project geowave by locationtech.
the class TestUtils method testLocalIngest.
public static void testLocalIngest(final DataStorePluginOptions dataStore, final DimensionalityType dimensionalityType, final String crsCode, final String ingestFilePath, final String format, final int nthreads, final boolean supportTimeRange) throws Exception {
// ingest a shapefile (geotools type) directly into GeoWave using the
// ingest framework's main method and pre-defined commandline arguments
// Ingest Formats
final IngestFormatPluginOptions ingestFormatOptions = new IngestFormatPluginOptions();
ingestFormatOptions.selectPlugin(format);
// 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);
if (crsCode != null) {
if (indexOption.getDimensionalityOptions() instanceof SpatialOptions) {
((SpatialOptions) indexOption.getDimensionalityOptions()).setCrs(crsCode);
} else if (indexOption.getDimensionalityOptions() instanceof SpatialTemporalOptions) {
((SpatialTemporalOptions) indexOption.getDimensionalityOptions()).setCrs(crsCode);
}
}
if (indexOption.getDimensionalityOptions() instanceof TemporalOptions) {
((TemporalOptions) indexOption.getDimensionalityOptions()).setNoTimeRanges(!supportTimeRange);
}
indexOptions.add(indexOption);
}
final File configFile = File.createTempFile("test_stats", null);
final ManualOperationParams params = new ManualOperationParams();
params.getContext().put(ConfigOptions.PROPERTIES_FILE_CONTEXT, configFile);
// Add Store
final AddStoreCommand addStore = new AddStoreCommand();
addStore.setParameters("test-store");
addStore.setPluginOptions(dataStore);
addStore.execute(params);
final IndexStore indexStore = dataStore.createIndexStore();
final org.locationtech.geowave.core.store.api.DataStore geowaveDataStore = dataStore.createDataStore();
// Add indices
final StringBuilder indexParam = new StringBuilder();
for (int i = 0; i < indexOptions.size(); i++) {
final String indexName = "test-index" + i;
if (indexStore.getIndex(indexName) == null) {
indexOptions.get(i).setName(indexName);
geowaveDataStore.addIndex(indexOptions.get(i).createIndex(geowaveDataStore));
}
indexParam.append(indexName + ",");
}
// Create the command and execute.
final LocalToGeoWaveCommand localIngester = new LocalToGeoWaveCommand();
localIngester.setPluginFormats(ingestFormatOptions);
localIngester.setParameters(ingestFilePath, "test-store", indexParam.toString());
localIngester.setThreads(nthreads);
localIngester.execute(params);
verifyStats(dataStore);
}
use of org.locationtech.geowave.core.ingest.operations.LocalToGeoWaveCommand in project geowave by locationtech.
the class TestUtils method testS3LocalIngest.
public static void testS3LocalIngest(final DataStorePluginOptions dataStore, final DimensionalityType dimensionalityType, final String s3Url, final String ingestFilePath, final String format, final int nthreads) throws Exception {
// ingest a shapefile (geotools type) directly into GeoWave using the
// ingest framework's main method and pre-defined commandline arguments
// Ingest Formats
final IngestFormatPluginOptions ingestFormatOptions = new IngestFormatPluginOptions();
ingestFormatOptions.selectPlugin(format);
// 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);
}
final File configFile = File.createTempFile("test_s3_local_ingest", null);
final ManualOperationParams operationParams = new ManualOperationParams();
operationParams.getContext().put(ConfigOptions.PROPERTIES_FILE_CONTEXT, configFile);
final AddStoreCommand addStore = new AddStoreCommand();
addStore.setParameters("test-store");
addStore.setPluginOptions(dataStore);
addStore.execute(operationParams);
final IndexStore indexStore = dataStore.createIndexStore();
final org.locationtech.geowave.core.store.api.DataStore geowaveDataStore = dataStore.createDataStore();
final StringBuilder indexParam = new StringBuilder();
for (int i = 0; i < indexOptions.size(); i++) {
final String indexName = "test-index" + i;
if (indexStore.getIndex(indexName) == null) {
indexOptions.get(i).setName(indexName);
geowaveDataStore.addIndex(indexOptions.get(i).createIndex(geowaveDataStore));
}
indexParam.append(indexName + ",");
}
final ConfigAWSCommand configS3 = new ConfigAWSCommand();
configS3.setS3UrlParameter(s3Url);
configS3.execute(operationParams);
// Create the command and execute.
final LocalToGeoWaveCommand localIngester = new LocalToGeoWaveCommand();
localIngester.setPluginFormats(ingestFormatOptions);
localIngester.setParameters(ingestFilePath, "test-store", indexParam.toString());
localIngester.setThreads(nthreads);
localIngester.execute(operationParams);
verifyStats(dataStore);
}
use of org.locationtech.geowave.core.ingest.operations.LocalToGeoWaveCommand in project geowave by locationtech.
the class GeoWaveGrpcCoreIngestService method localToGeoWaveCommand.
@Override
public void localToGeoWaveCommand(final org.locationtech.geowave.service.grpc.protobuf.LocalToGeoWaveCommandParametersProtos request, final StreamObserver<org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.VoidResponseProtos> responseObserver) {
final LocalToGeoWaveCommand cmd = new LocalToGeoWaveCommand();
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 LocalToGeowaveCommand...");
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);
}
}
Aggregations