Search in sources :

Example 1 with ScopedJobConfiguration

use of org.locationtech.geowave.analytic.ScopedJobConfiguration in project geowave by locationtech.

the class CentroidManagerGeoWave method init.

private void init(final JobContext context, final Class<?> scope, final Logger logger) throws IOException {
    final ScopedJobConfiguration scopedJob = new ScopedJobConfiguration(context.getConfiguration(), scope, logger);
    try {
        centroidFactory = (AnalyticItemWrapperFactory<T>) CentroidParameters.Centroid.WRAPPER_FACTORY_CLASS.getHelper().getValue(context, scope, CentroidItemWrapperFactory.class);
        centroidFactory.initialize(context, scope, logger);
    } catch (final Exception e1) {
        LOGGER.error("Cannot instantiate " + GeoWaveConfiguratorBase.enumToConfKey(this.getClass(), CentroidParameters.Centroid.WRAPPER_FACTORY_CLASS));
        throw new IOException(e1);
    }
    this.level = scopedJob.getInt(CentroidParameters.Centroid.ZOOM_LEVEL, 1);
    centroidDataTypeId = scopedJob.getString(CentroidParameters.Centroid.DATA_TYPE_ID, "centroid");
    batchId = scopedJob.getString(GlobalParameters.Global.BATCH_ID, Long.toString(Calendar.getInstance().getTime().getTime()));
    final String indexName = scopedJob.getString(CentroidParameters.Centroid.INDEX_NAME, SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions()).getName());
    final PersistableStore store = (PersistableStore) StoreParameters.StoreParam.INPUT_STORE.getHelper().getValue(context, scope, null);
    dataStore = store.getDataStoreOptions().createDataStore();
    indexStore = store.getDataStoreOptions().createIndexStore();
    index = indexStore.getIndex(indexName);
    final PersistentAdapterStore adapterStore = store.getDataStoreOptions().createAdapterStore();
    adapter = (GeotoolsFeatureDataAdapter) adapterStore.getAdapter(store.getDataStoreOptions().createInternalAdapterStore().getAdapterId(centroidDataTypeId)).getAdapter();
}
Also used : ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) PersistableStore(org.locationtech.geowave.analytic.store.PersistableStore) IOException(java.io.IOException) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) MatchingCentroidNotFoundException(org.locationtech.geowave.analytic.clustering.exception.MatchingCentroidNotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 2 with ScopedJobConfiguration

use of org.locationtech.geowave.analytic.ScopedJobConfiguration in project geowave by locationtech.

the class InputToOutputKeyReducer method setup.

@Override
protected void setup(final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveOutputKey, Object>.Context context) throws IOException, InterruptedException {
    super.setup(context);
    internalAdapterStore = GeoWaveOutputFormat.getJobContextInternalAdapterStore(context);
    final ScopedJobConfiguration config = new ScopedJobConfiguration(context.getConfiguration(), InputToOutputKeyReducer.class, LOGGER);
    outputKey = new GeoWaveOutputKey("na", new String[] { config.getString(OutputParameters.Output.INDEX_ID, "na") });
}
Also used : ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) GeoWaveOutputKey(org.locationtech.geowave.mapreduce.output.GeoWaveOutputKey)

Example 3 with ScopedJobConfiguration

use of org.locationtech.geowave.analytic.ScopedJobConfiguration in project geowave by locationtech.

the class GeoWaveAnalyticJobRunner method run.

@SuppressWarnings("rawtypes")
@Override
public int run(final String[] args) throws Exception {
    final Job job = mapReduceIntegrater.getJob(this);
    configure(job);
    final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), getScope());
    final FormatConfiguration inputFormat = configWrapper.getInstance(InputParameters.Input.INPUT_FORMAT, FormatConfiguration.class, null);
    if (inputFormat != null) {
        job.setInputFormatClass((Class<? extends InputFormat>) inputFormat.getFormatClass());
    }
    final FormatConfiguration outputFormat = configWrapper.getInstance(OutputParameters.Output.OUTPUT_FORMAT, FormatConfiguration.class, null);
    if (outputFormat != null) {
        job.setOutputFormatClass((Class<? extends OutputFormat>) outputFormat.getFormatClass());
    }
    job.setNumReduceTasks(configWrapper.getInt(OutputParameters.Output.REDUCER_COUNT, 1));
    job.setJobName(getJobName());
    job.setJarByClass(this.getClass());
    final Counters counters = mapReduceIntegrater.waitForCompletion(job);
    lastCounterSet = counters;
    return (counters == null) ? 1 : 0;
}
Also used : ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) FormatConfiguration(org.locationtech.geowave.analytic.param.FormatConfiguration) Counters(org.apache.hadoop.mapreduce.Counters) Job(org.apache.hadoop.mapreduce.Job)

Example 4 with ScopedJobConfiguration

use of org.locationtech.geowave.analytic.ScopedJobConfiguration in project geowave by locationtech.

the class SimpleFeatureOutputReducer method setup.

@SuppressWarnings("unchecked")
@Override
protected void setup(final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context) throws IOException, InterruptedException {
    super.setup(context);
    final ScopedJobConfiguration config = new ScopedJobConfiguration(context.getConfiguration(), SimpleFeatureOutputReducer.class);
    outputDataTypeID = config.getString(ExtractParameters.Extract.OUTPUT_DATA_TYPE_ID, "reduced_features");
    batchID = config.getString(GlobalParameters.Global.BATCH_ID, UUID.randomUUID().toString());
    groupID = config.getString(ExtractParameters.Extract.GROUP_ID, UUID.randomUUID().toString());
    try {
        dimExtractor = config.getInstance(ExtractParameters.Extract.DIMENSION_EXTRACT_CLASS, DimensionExtractor.class, EmptyDimensionExtractor.class);
    } catch (final Exception e1) {
        LOGGER.warn("Failed to instantiate " + GeoWaveConfiguratorBase.enumToConfKey(SimpleFeatureOutputReducer.class, ExtractParameters.Extract.DIMENSION_EXTRACT_CLASS), e1);
        throw new IOException("Invalid configuration for " + GeoWaveConfiguratorBase.enumToConfKey(SimpleFeatureOutputReducer.class, ExtractParameters.Extract.DIMENSION_EXTRACT_CLASS));
    }
    outputAdapter = AnalyticFeature.createGeometryFeatureAdapter(outputDataTypeID, dimExtractor.getDimensionNames(), config.getString(ExtractParameters.Extract.DATA_NAMESPACE_URI, BasicFeatureTypes.DEFAULT_NAMESPACE), ClusteringUtils.CLUSTERING_CRS);
}
Also used : ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) EmptyDimensionExtractor(org.locationtech.geowave.analytic.extract.EmptyDimensionExtractor) EmptyDimensionExtractor(org.locationtech.geowave.analytic.extract.EmptyDimensionExtractor) DimensionExtractor(org.locationtech.geowave.analytic.extract.DimensionExtractor) IOException(java.io.IOException) IOException(java.io.IOException)

Example 5 with ScopedJobConfiguration

use of org.locationtech.geowave.analytic.ScopedJobConfiguration in project geowave by locationtech.

the class GeoWaveAnalyticExtractJobRunner method configure.

@Override
protected void configure(final Job job) throws Exception {
    final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), SimpleFeatureOutputReducer.class);
    reducerCount = Math.max(configWrapper.getInt(ExtractParameters.Extract.REDUCER_COUNT, 8), 1);
    outputBaseDir = configWrapper.getString(MapReduceParameters.MRConfig.HDFS_BASE_DIR, "/tmp");
    LOGGER.info("Output base directory " + outputBaseDir);
    super.configure(job);
    @SuppressWarnings("rawtypes") final Class<? extends DimensionExtractor> dimensionExtractorClass = job.getConfiguration().getClass(GeoWaveConfiguratorBase.enumToConfKey(SimpleFeatureOutputReducer.class, ExtractParameters.Extract.DIMENSION_EXTRACT_CLASS), SimpleFeatureGeometryExtractor.class, DimensionExtractor.class);
    GeoWaveOutputFormat.addDataAdapter(job.getConfiguration(), createAdapter(job.getConfiguration().get(GeoWaveConfiguratorBase.enumToConfKey(SimpleFeatureOutputReducer.class, ExtractParameters.Extract.OUTPUT_DATA_TYPE_ID)), job.getConfiguration().get(GeoWaveConfiguratorBase.enumToConfKey(SimpleFeatureOutputReducer.class, ExtractParameters.Extract.DATA_NAMESPACE_URI)), dimensionExtractorClass));
    job.setJobName("GeoWave Extract (" + dataStoreOptions.getGeoWaveNamespace() + ")");
    job.setReduceSpeculativeExecution(false);
}
Also used : ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) SimpleFeatureOutputReducer(org.locationtech.geowave.analytic.mapreduce.clustering.SimpleFeatureOutputReducer)

Aggregations

ScopedJobConfiguration (org.locationtech.geowave.analytic.ScopedJobConfiguration)9 IOException (java.io.IOException)6 Counters (org.apache.hadoop.mapreduce.Counters)4 Job (org.apache.hadoop.mapreduce.Job)4 PersistableStore (org.locationtech.geowave.analytic.store.PersistableStore)4 Configuration (org.apache.hadoop.conf.Configuration)3 Path (org.apache.hadoop.fs.Path)3 SequenceFileInputFormat (org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat)3 Tool (org.apache.hadoop.util.Tool)3 Before (org.junit.Before)3 PropertyManagement (org.locationtech.geowave.analytic.PropertyManagement)3 GeoWaveAnalyticJobRunner (org.locationtech.geowave.analytic.mapreduce.GeoWaveAnalyticJobRunner)3 MapReduceIntegration (org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration)3 SequenceFileInputFormatConfiguration (org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration)3 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)3 MemoryRequiredOptions (org.locationtech.geowave.core.store.memory.MemoryRequiredOptions)3 MemoryStoreFactoryFamily (org.locationtech.geowave.core.store.memory.MemoryStoreFactoryFamily)3 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)2 AnalyticItemWrapperFactory (org.locationtech.geowave.analytic.AnalyticItemWrapperFactory)2 SimpleFeatureItemWrapperFactory (org.locationtech.geowave.analytic.SimpleFeatureItemWrapperFactory)2