/** * Attempt to aquire a permit to add the object to the pool. * * @param obj object to add to the pool * @return true of the item as added */ public boolean add(final T obj) { return add(obj, 0); }
/** * Attempt to aquire a permit to add the object to the pool. * * @param obj object to add to the pool * @return true of the item as added */ public boolean add(T obj) { return add(obj, 0); }
/** * Attempt to aquire a permit to add the object to the pool. * * @param obj object to add to the pool * @return true of the item as added */ public boolean add(final T obj) { return add(obj, 0); }
@Override public void run() { final Instance obj = supplier.create(); if (obj != null) { final long offset = maxAge > 0 ? (long) (maxAge / maxAgeOffset * min * iteration) % maxAge : 0l; data.getPool().add(obj, offset); } } }
@Override public void run() { final Instance obj = supplier.create(); if (obj != null) { final long offset = maxAge > 0 ? (long) (maxAge / maxAgeOffset * min * iteration) % maxAge : 0l; data.getPool().add(obj, offset); } } }
@Override public void run() { final Instance obj = supplier.create(); if (obj != null) { data.getPool().add(obj, offset); } } }
public void deploy(CoreDeploymentInfo deploymentInfo) { Options options = new Options(deploymentInfo.getProperties()); final Pool.Builder builder = new Pool.Builder(poolBuilder); String timeString = options.get("Timeout", this.timeout.toString()); timeString = options.get("AccessTimeout", timeString); Duration accessTimeout = new Duration(timeString); final ObjectRecipe recipe = PassthroughFactory.recipe(builder); recipe.setAllProperties(deploymentInfo.getProperties()); builder.setSupplier(new StatelessSupplier(deploymentInfo)); builder.setExecutor(executor); Data data = new Data(builder.build(), accessTimeout); deploymentInfo.setContainerData(data); final int min = builder.getMin(); long maxAge = builder.getMaxAge().getTime(TimeUnit.MILLISECONDS); double maxAgeOffset = builder.getMaxAgeOffset(); for (int i = 0; i < min; i++) { Instance obj = createInstance(deploymentInfo); if (obj == null) continue; long offset = maxAge > 0 ? ((long) (maxAge / min * i * maxAgeOffset)) % maxAge : 0l; data.getPool().add(obj, offset); } data.getPool().start(); }