Search in sources :

Example 1 with Partitioner

use of org.locationtech.geowave.analytic.partitioner.Partitioner 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));
}
Also used : GeometryCentroidDistanceFn(org.locationtech.geowave.analytic.distance.GeometryCentroidDistanceFn) Configuration(org.apache.hadoop.conf.Configuration) ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) SequenceFileInputFormatConfiguration(org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration) OrthodromicDistancePartitioner(org.locationtech.geowave.analytic.partitioner.OrthodromicDistancePartitioner) MemoryStoreFactoryFamily(org.locationtech.geowave.core.store.memory.MemoryStoreFactoryFamily) DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) Job(org.apache.hadoop.mapreduce.Job) MapReduceIntegration(org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration) SequenceFileInputFormatConfiguration(org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration) MemoryRequiredOptions(org.locationtech.geowave.core.store.memory.MemoryRequiredOptions) Partitioner(org.locationtech.geowave.analytic.partitioner.Partitioner) OrthodromicDistancePartitioner(org.locationtech.geowave.analytic.partitioner.OrthodromicDistancePartitioner) Tool(org.apache.hadoop.util.Tool) ScopedJobConfiguration(org.locationtech.geowave.analytic.ScopedJobConfiguration) Path(org.apache.hadoop.fs.Path) SequenceFileInputFormat(org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat) PropertyManagement(org.locationtech.geowave.analytic.PropertyManagement) IOException(java.io.IOException) FeatureCentroidDistanceFn(org.locationtech.geowave.analytic.distance.FeatureCentroidDistanceFn) GeometryCentroidDistanceFn(org.locationtech.geowave.analytic.distance.GeometryCentroidDistanceFn) DistanceFn(org.locationtech.geowave.analytic.distance.DistanceFn) IOException(java.io.IOException) GeoWaveAnalyticJobRunner(org.locationtech.geowave.analytic.mapreduce.GeoWaveAnalyticJobRunner) FeatureCentroidDistanceFn(org.locationtech.geowave.analytic.distance.FeatureCentroidDistanceFn) PersistableStore(org.locationtech.geowave.analytic.store.PersistableStore) Counters(org.apache.hadoop.mapreduce.Counters) Before(org.junit.Before)

Aggregations

IOException (java.io.IOException)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 Counters (org.apache.hadoop.mapreduce.Counters)1 Job (org.apache.hadoop.mapreduce.Job)1 SequenceFileInputFormat (org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat)1 Tool (org.apache.hadoop.util.Tool)1 Before (org.junit.Before)1 PropertyManagement (org.locationtech.geowave.analytic.PropertyManagement)1 ScopedJobConfiguration (org.locationtech.geowave.analytic.ScopedJobConfiguration)1 DistanceFn (org.locationtech.geowave.analytic.distance.DistanceFn)1 FeatureCentroidDistanceFn (org.locationtech.geowave.analytic.distance.FeatureCentroidDistanceFn)1 GeometryCentroidDistanceFn (org.locationtech.geowave.analytic.distance.GeometryCentroidDistanceFn)1 GeoWaveAnalyticJobRunner (org.locationtech.geowave.analytic.mapreduce.GeoWaveAnalyticJobRunner)1 MapReduceIntegration (org.locationtech.geowave.analytic.mapreduce.MapReduceIntegration)1 SequenceFileInputFormatConfiguration (org.locationtech.geowave.analytic.mapreduce.SequenceFileInputFormatConfiguration)1 OrthodromicDistancePartitioner (org.locationtech.geowave.analytic.partitioner.OrthodromicDistancePartitioner)1 Partitioner (org.locationtech.geowave.analytic.partitioner.Partitioner)1 PersistableStore (org.locationtech.geowave.analytic.store.PersistableStore)1 DataStorePluginOptions (org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions)1