@Override protected void setup( final Reducer<Text, CountofDoubleWritable, GeoWaveOutputKey, DistortionEntry>.Context context) throws IOException, InterruptedException { super.setup(context); final ScopedJobConfiguration config = new ScopedJobConfiguration( context.getConfiguration(), KMeansDistortionMapReduce.class, KMeansDistortionMapReduce.LOGGER); final int k = config.getInt(JumpParameters.Jump.COUNT_OF_CENTROIDS, -1); if (k > 0) { expectedK = k; } try { centroidManager = new CentroidManagerGeoWave<Object>( context, KMeansDistortionMapReduce.class, KMeansDistortionMapReduce.LOGGER); } catch (final Exception e) { KMeansDistortionMapReduce.LOGGER.warn("Unable to initialize centroid manager", e); throw new IOException("Unable to initialize centroid manager", e); } batchId = config.getString(GlobalParameters.Global.PARENT_BATCH_ID, centroidManager.getBatchId()); }
@Override public Object getValue( final JobContext context, final Class<?> scope, final Object defaultValue) { final ScopedJobConfiguration scopedConfig = new ScopedJobConfiguration(context.getConfiguration(), scope); if (baseClass.isAssignableFrom(Integer.class)) { return Integer.valueOf( scopedConfig.getInt(parent.self(), ((Integer) defaultValue).intValue())); } else if (baseClass.isAssignableFrom(String.class)) { return scopedConfig.getString(parent.self(), defaultValue.toString()); } else if (baseClass.isAssignableFrom(Double.class)) { return scopedConfig.getDouble(parent.self(), (Double) defaultValue); } else if (baseClass.isAssignableFrom(byte[].class)) { return scopedConfig.getBytes(parent.self()); } else if ((defaultValue == null) || (defaultValue instanceof Class)) { try { return scopedConfig.getInstance(parent.self(), baseClass, (Class) defaultValue); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("Unable to get instance from job context", e); } } return null; }