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();
}
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") });
}
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;
}
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);
}
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);
}
Aggregations