MosaicWorkflowItem extends HadoopWorkflowItem { static int computeNumReducers(Configuration jobConfig) { Geometry regionGeometry = GeometryUtils.createGeometry(jobConfig.get("calvalus.regionGeometry")); if (regionGeometry != null) { jobConfig.set("calvalus.mosaic.regionGeometry", jobConfig.get("calvalus.regionGeometry")); MosaicGrid mosaicGrid = MosaicGrid.create(jobConfig); final int numPartitions = mosaicGrid.getNumReducers(); System.out.println("numPartitions=" + numPartitions); return numPartitions; } else { MosaicGrid mosaicGrid = MosaicGrid.create(jobConfig); int numXPartitions = jobConfig.getInt("calvalus.mosaic.numXPartitions", 1); return mosaicGrid.getNumMacroTileY() * numXPartitions; } } MosaicWorkflowItem(HadoopProcessingService processingService, String username, String jobName, Configuration jobConfig); @Override String getOutputDir();  }
@Test public void testComputeNumReducers() throws Exception { MosaicGrid mosaicGrid = new MosaicGrid(6, 18, 20, true, 8, 0, null); Configuration conf = new Configuration(); mosaicGrid.saveToConfiguration(conf); assertEquals(3 * 1, MosaicWorkflowItem.computeNumReducers(conf)); conf.setInt("calvalus.mosaic.numXPartitions", 2); assertEquals(3 * 2, MosaicWorkflowItem.computeNumReducers(conf)); conf.setInt("calvalus.mosaic.numXPartitions", 3); assertEquals(3 * 3, MosaicWorkflowItem.computeNumReducers(conf)); conf.setInt("calvalus.mosaic.numXPartitions", 6); assertEquals(3 * 6, MosaicWorkflowItem.computeNumReducers(conf)); mosaicGrid = new MosaicGrid(); conf = new Configuration(); mosaicGrid.saveToConfiguration(conf); assertEquals(36, MosaicWorkflowItem.computeNumReducers(conf)); conf.setInt("calvalus.mosaic.numXPartitions", 4); assertEquals(36 * 4, MosaicWorkflowItem.computeNumReducers(conf)); }