@Override protected ResourcePool contractPool(ResourceRequirement requirement) { ResourcePool superPool = super.contractPool(requirement); return new CopyResourcePool(superPool); }
@Override public ResourceRequirement.Builder getResourceRequirementBuilder() { return getCopyResourceRequirementBuilder(); }
this.prioritizer = Optional.absent(); this.maxToCopy = CopyResourcePool.fromConfig(ConfigUtils.getConfigOrEmpty(this.config, MAX_COPY_PREFIX));
this.prioritizer = Optional.absent(); this.maxToCopy = CopyResourcePool.fromConfig(ConfigUtils.getConfigOrEmpty(this.config, MAX_COPY_PREFIX));
/** * Parse a {@link CopyResourcePool} from an input {@link Config}. */ public static CopyResourcePool fromConfig(Config limitedScopeConfig) { try { String sizeStr = limitedScopeConfig.hasPath(SIZE_KEY) ? limitedScopeConfig.getString(SIZE_KEY) : DEFAULT_MAX_SIZE; long maxSize = StringParsingUtils.humanReadableToByteCount(sizeStr); int maxEntities = limitedScopeConfig.hasPath(ENTITIES_KEY) ? limitedScopeConfig.getInt(ENTITIES_KEY) : DEFAULT_MAX_ENTITIES; double tolerance = limitedScopeConfig.hasPath(TOLERANCE_KEY) ? limitedScopeConfig.getDouble(TOLERANCE_KEY) : DEFAULT_TOLERANCE; return new CopyResourcePool(ImmutableMap.of(ENTITIES_DIMENSION, (double) maxEntities, BYTES_DIMENSION, (double) maxSize), ImmutableMap.of(ENTITIES_DIMENSION, tolerance, BYTES_DIMENSION, tolerance), ImmutableMap.<String, Double>of()); } catch (StringParsingUtils.FormatException fe) { throw new RuntimeException(fe); } }
@Override public ResourceRequirement estimateRequirement(FileSet<CopyEntity> copyEntityFileSet, ResourcePool pool) { if (!(pool instanceof CopyResourcePool)) { throw new IllegalArgumentException("Must use a " + CopyResourcePool.class.getSimpleName()); } CopyResourcePool copyResourcePool = (CopyResourcePool) pool; return copyResourcePool.getCopyResourceRequirementBuilder().setEntities(copyEntityFileSet.getTotalEntities()) .setBytes(copyEntityFileSet.getTotalSizeInBytes()).build(); }
@Override protected ResourcePool contractPool(ResourceRequirement requirement) { ResourcePool superPool = super.contractPool(requirement); return new CopyResourcePool(superPool); }
@Override public ResourceRequirement.Builder getResourceRequirementBuilder() { return getCopyResourceRequirementBuilder(); }
/** * Parse a {@link CopyResourcePool} from an input {@link Config}. */ public static CopyResourcePool fromConfig(Config limitedScopeConfig) { try { String sizeStr = limitedScopeConfig.hasPath(SIZE_KEY) ? limitedScopeConfig.getString(SIZE_KEY) : DEFAULT_MAX_SIZE; long maxSize = StringParsingUtils.humanReadableToByteCount(sizeStr); int maxEntities = limitedScopeConfig.hasPath(ENTITIES_KEY) ? limitedScopeConfig.getInt(ENTITIES_KEY) : DEFAULT_MAX_ENTITIES; double tolerance = limitedScopeConfig.hasPath(TOLERANCE_KEY) ? limitedScopeConfig.getDouble(TOLERANCE_KEY) : DEFAULT_TOLERANCE; return new CopyResourcePool(ImmutableMap.of(ENTITIES_DIMENSION, (double) maxEntities, BYTES_DIMENSION, (double) maxSize), ImmutableMap.of(ENTITIES_DIMENSION, tolerance, BYTES_DIMENSION, tolerance), ImmutableMap.<String, Double>of()); } catch (StringParsingUtils.FormatException fe) { throw new RuntimeException(fe); } }
@Override public ResourceRequirement estimateRequirement(FileSet<CopyEntity> copyEntityFileSet, ResourcePool pool) { if (!(pool instanceof CopyResourcePool)) { throw new IllegalArgumentException("Must use a " + CopyResourcePool.class.getSimpleName()); } CopyResourcePool copyResourcePool = (CopyResourcePool) pool; return copyResourcePool.getCopyResourceRequirementBuilder().setEntities(copyEntityFileSet.getTotalEntities()) .setBytes(copyEntityFileSet.getTotalSizeInBytes()).build(); }