@Override protected ResourcePool contractPool(ResourceRequirement requirement) { ResourcePool superPool = super.contractPool(requirement); return new CopyResourcePool(superPool); }
/** * 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 protected ResourcePool contractPool(ResourceRequirement requirement) { ResourcePool superPool = super.contractPool(requirement); return new CopyResourcePool(superPool); }
/** * 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); } }