use of org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration in project geowave by locationtech.
the class NNJobRunnerTest method init.
@Before
public void init() {
jjJobRunner.setMapReduceIntegrater(new MapReduceIntegration() {
@Override
public int submit(final Configuration configuration, final PropertyManagement runTimeProperties, final GeoWaveAnalyticJobRunner tool) throws Exception {
tool.setConf(configuration);
return ToolRunner.run(configuration, tool, new String[] {});
}
@Override
public Counters waitForCompletion(final Job job) throws ClassNotFoundException, IOException, InterruptedException {
Assert.assertEquals(SequenceFileInputFormat.class, job.getInputFormatClass());
Assert.assertEquals(10, job.getNumReduceTasks());
final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), NNMapReduce.class);
Assert.assertEquals("file://foo/bin", job.getConfiguration().get("mapred.input.dir"));
Assert.assertEquals(0.4, configWrapper.getDouble(Partition.MAX_DISTANCE, 0.0), 0.001);
Assert.assertEquals(100, configWrapper.getInt(Partition.MAX_MEMBER_SELECTION, 1));
try {
final Partitioner<?> wrapper = configWrapper.getInstance(Partition.PARTITIONER_CLASS, Partitioner.class, null);
Assert.assertEquals(OrthodromicDistancePartitioner.class, wrapper.getClass());
final Partitioner<?> secondary = configWrapper.getInstance(Partition.SECONDARY_PARTITIONER_CLASS, Partitioner.class, null);
Assert.assertEquals(OrthodromicDistancePartitioner.class, secondary.getClass());
final DistanceFn<?> distancFn = configWrapper.getInstance(CommonParameters.Common.DISTANCE_FUNCTION_CLASS, DistanceFn.class, GeometryCentroidDistanceFn.class);
Assert.assertEquals(FeatureCentroidDistanceFn.class, distancFn.getClass());
} catch (final InstantiationException e) {
throw new IOException("Unable to configure system", e);
} catch (final IllegalAccessException e) {
throw new IOException("Unable to configure system", e);
}
Assert.assertEquals(10, job.getNumReduceTasks());
return new Counters();
}
@Override
public Job getJob(final Tool tool) throws IOException {
return new Job(tool.getConf());
}
@Override
public Configuration getConfiguration(final PropertyManagement runTimeProperties) throws IOException {
return new Configuration();
}
});
jjJobRunner.setInputFormatConfiguration(new SequenceFileInputFormatConfiguration(new Path("file://foo/bin")));
jjJobRunner.setReducerCount(10);
runTimeProperties.store(MRConfig.HDFS_BASE_DIR, "/");
final DataStorePluginOptions pluginOptions = new DataStorePluginOptions();
GeoWaveStoreFinder.getRegisteredStoreFactoryFamilies().put("memory", new MemoryStoreFactoryFamily());
pluginOptions.selectPlugin("memory");
final MemoryRequiredOptions opts = (MemoryRequiredOptions) pluginOptions.getFactoryOptions();
final String namespace = "test_" + getClass().getName() + "_" + name.getMethodName();
opts.setGeoWaveNamespace(namespace);
final PersistableStore store = new PersistableStore(pluginOptions);
runTimeProperties.store(StoreParam.INPUT_STORE, store);
runTimeProperties.store(CommonParameters.Common.DISTANCE_FUNCTION_CLASS, FeatureCentroidDistanceFn.class);
runTimeProperties.store(Partition.PARTITIONER_CLASS, OrthodromicDistancePartitioner.class);
runTimeProperties.store(Partition.SECONDARY_PARTITIONER_CLASS, OrthodromicDistancePartitioner.class);
runTimeProperties.store(Partition.MAX_DISTANCE, Double.valueOf(0.4));
runTimeProperties.store(Partition.MAX_MEMBER_SELECTION, Integer.valueOf(100));
}
use of org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration in project geowave by locationtech.
the class ConvexHullJobRunnerTest method init.
@Before
public void init() {
final SimpleFeatureType ftype = AnalyticFeature.createGeometryFeatureAdapter("centroidtest", new String[] { "extra1" }, BasicFeatureTypes.DEFAULT_NAMESPACE, ClusteringUtils.CLUSTERING_CRS).getFeatureType();
hullRunner.setMapReduceIntegrater(new MapReduceIntegration() {
@Override
public int submit(final Configuration configuration, final PropertyManagement runTimeProperties, final GeoWaveAnalyticJobRunner tool) throws Exception {
tool.setConf(configuration);
((ParameterHelper<Object>) StoreParam.INPUT_STORE.getHelper()).setValue(configuration, ConvexHullMapReduce.class, StoreParam.INPUT_STORE.getHelper().getValue(runTimeProperties));
return tool.run(new String[] {});
}
@Override
public Counters waitForCompletion(final Job job) throws ClassNotFoundException, IOException, InterruptedException {
Assert.assertEquals(SequenceFileInputFormat.class, job.getInputFormatClass());
Assert.assertEquals(10, job.getNumReduceTasks());
final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), ConvexHullMapReduce.class);
Assert.assertEquals("file://foo/bin", job.getConfiguration().get("mapred.input.dir"));
final PersistableStore persistableStore = (PersistableStore) StoreParam.INPUT_STORE.getHelper().getValue(job, ConvexHullMapReduce.class, null);
final IndexStore indexStore = persistableStore.getDataStoreOptions().createIndexStore();
try {
Assert.assertTrue(indexStore.indexExists("spatial"));
final PersistableStore persistableAdapterStore = (PersistableStore) StoreParam.INPUT_STORE.getHelper().getValue(job, ConvexHullMapReduce.class, null);
final PersistentAdapterStore adapterStore = persistableAdapterStore.getDataStoreOptions().createAdapterStore();
Assert.assertTrue(adapterStore.adapterExists(persistableAdapterStore.getDataStoreOptions().createInternalAdapterStore().getAdapterId("centroidtest")));
final Projection<?> projection = configWrapper.getInstance(HullParameters.Hull.PROJECTION_CLASS, Projection.class, SimpleFeatureProjection.class);
Assert.assertEquals(SimpleFeatureProjection.class, projection.getClass());
} catch (final InstantiationException e) {
throw new IOException("Unable to configure system", e);
} catch (final IllegalAccessException e) {
throw new IOException("Unable to configure system", e);
}
Assert.assertEquals(10, job.getNumReduceTasks());
Assert.assertEquals(2, configWrapper.getInt(CentroidParameters.Centroid.ZOOM_LEVEL, -1));
return new Counters();
}
@Override
public Job getJob(final Tool tool) throws IOException {
return new Job(tool.getConf());
}
@Override
public Configuration getConfiguration(final PropertyManagement runTimeProperties) throws IOException {
return new Configuration();
}
});
hullRunner.setInputFormatConfiguration(new SequenceFileInputFormatConfiguration());
runTimeProperties.store(MRConfig.HDFS_BASE_DIR, "/");
runTimeProperties.store(InputParameters.Input.HDFS_INPUT_PATH, new Path("file://foo/bin"));
runTimeProperties.store(GlobalParameters.Global.BATCH_ID, "b1234");
runTimeProperties.store(HullParameters.Hull.DATA_TYPE_ID, "hullType");
runTimeProperties.store(HullParameters.Hull.REDUCER_COUNT, 10);
runTimeProperties.store(HullParameters.Hull.INDEX_NAME, "spatial");
final DataStorePluginOptions pluginOptions = new DataStorePluginOptions();
GeoWaveStoreFinder.getRegisteredStoreFactoryFamilies().put("memory", new MemoryStoreFactoryFamily());
pluginOptions.selectPlugin("memory");
final MemoryRequiredOptions opts = (MemoryRequiredOptions) pluginOptions.getFactoryOptions();
final String namespace = "test_" + getClass().getName() + "_" + name.getMethodName();
opts.setGeoWaveNamespace(namespace);
final PersistableStore store = new PersistableStore(pluginOptions);
runTimeProperties.store(StoreParam.INPUT_STORE, store);
final FeatureDataAdapter adapter = new FeatureDataAdapter(ftype);
pluginOptions.createAdapterStore().addAdapter(adapter.asInternalAdapter(pluginOptions.createInternalAdapterStore().addTypeName(adapter.getTypeName())));
}
use of org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration in project geowave by locationtech.
the class GroupAssigmentJobRunnerTest method init.
@Before
public void init() {
final SimpleFeatureType ftype = AnalyticFeature.createGeometryFeatureAdapter("centroidtest", new String[] { "extra1" }, BasicFeatureTypes.DEFAULT_NAMESPACE, ClusteringUtils.CLUSTERING_CRS).getFeatureType();
runner.setMapReduceIntegrater(new MapReduceIntegration() {
@Override
public int submit(final Configuration configuration, final PropertyManagement runTimeProperties, final GeoWaveAnalyticJobRunner tool) throws Exception {
tool.setConf(configuration);
((ParameterHelper<Object>) StoreParam.INPUT_STORE.getHelper()).setValue(configuration, GroupAssignmentMapReduce.class, StoreParam.INPUT_STORE.getHelper().getValue(runTimeProperties));
return tool.run(new String[] {});
}
@Override
public Counters waitForCompletion(final Job job) throws ClassNotFoundException, IOException, InterruptedException {
Assert.assertEquals(SequenceFileInputFormat.class, job.getInputFormatClass());
Assert.assertEquals(10, job.getNumReduceTasks());
final ScopedJobConfiguration configWrapper = new ScopedJobConfiguration(job.getConfiguration(), GroupAssignmentMapReduce.class);
Assert.assertEquals("file://foo/bin", job.getConfiguration().get("mapred.input.dir"));
Assert.assertEquals(3, configWrapper.getInt(CentroidParameters.Centroid.ZOOM_LEVEL, -1));
Assert.assertEquals("b1234", configWrapper.getString(GlobalParameters.Global.PARENT_BATCH_ID, ""));
Assert.assertEquals("b12345", configWrapper.getString(GlobalParameters.Global.BATCH_ID, ""));
try {
final AnalyticItemWrapperFactory<?> wrapper = configWrapper.getInstance(CentroidParameters.Centroid.WRAPPER_FACTORY_CLASS, AnalyticItemWrapperFactory.class, SimpleFeatureItemWrapperFactory.class);
Assert.assertEquals(SimpleFeatureItemWrapperFactory.class, wrapper.getClass());
final DistanceFn<?> distancFn = configWrapper.getInstance(CommonParameters.Common.DISTANCE_FUNCTION_CLASS, DistanceFn.class, GeometryCentroidDistanceFn.class);
Assert.assertEquals(FeatureCentroidDistanceFn.class, distancFn.getClass());
} catch (final InstantiationException e) {
throw new IOException("Unable to configure system", e);
} catch (final IllegalAccessException e) {
throw new IOException("Unable to configure system", e);
}
return new Counters();
}
@Override
public Job getJob(final Tool tool) throws IOException {
return new Job(tool.getConf());
}
@Override
public Configuration getConfiguration(final PropertyManagement runTimeProperties) throws IOException {
return new Configuration();
}
});
runner.setInputFormatConfiguration(new SequenceFileInputFormatConfiguration(new Path("file://foo/bin")));
runner.setZoomLevel(3);
runner.setReducerCount(10);
runTimeProperties.store(MRConfig.HDFS_BASE_DIR, "/");
runTimeProperties.store(GlobalParameters.Global.BATCH_ID, "b12345");
runTimeProperties.store(GlobalParameters.Global.PARENT_BATCH_ID, "b1234");
runTimeProperties.store(CommonParameters.Common.DISTANCE_FUNCTION_CLASS, FeatureCentroidDistanceFn.class);
final DataStorePluginOptions pluginOptions = new DataStorePluginOptions();
GeoWaveStoreFinder.getRegisteredStoreFactoryFamilies().put("memory", new MemoryStoreFactoryFamily());
pluginOptions.selectPlugin("memory");
final MemoryRequiredOptions opts = (MemoryRequiredOptions) pluginOptions.getFactoryOptions();
final String namespace = "test_" + getClass().getName() + "_" + name.getMethodName();
opts.setGeoWaveNamespace(namespace);
final PersistableStore store = new PersistableStore(pluginOptions);
runTimeProperties.store(StoreParam.INPUT_STORE, store);
final FeatureDataAdapter adapter = new FeatureDataAdapter(ftype);
pluginOptions.createAdapterStore().addAdapter(adapter.asInternalAdapter(pluginOptions.createInternalAdapterStore().addTypeName(adapter.getTypeName())));
}
Aggregations