Tabnine Logo
GenericObjectPool.allocate
Code IndexAdd Tabnine to your IDE (free)

How to use
allocate
method
in
org.apache.commons.pool.impl.GenericObjectPool

Best Java code snippets using org.apache.commons.pool.impl.GenericObjectPool.allocate (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: commons-pool/commons-pool

/**
 * Sets the cap on the number of objects that can be allocated by the pool
 * (checked out to clients, or idle awaiting checkout) at a given time. Use
 * a negative value for no limit.
 *
 * @param maxActive The cap on the total number of object instances managed by the pool.
 * Negative values mean that there is no limit to the number of objects allocated
 * by the pool.
 * @see #getMaxActive
 */
public void setMaxActive(int maxActive) {
  synchronized(this) {
    _maxActive = maxActive;
  }
  allocate();
}
origin: commons-pool/commons-pool

/**
 * Sets the minimum number of objects allowed in the pool
 * before the evictor thread (if active) spawns new objects.
 * Note that no objects are created when
 * <code>numActive + numIdle >= maxActive.</code>
 * This setting has no effect if the idle object evictor is disabled
 * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
 *
 * @param minIdle The minimum number of objects.
 * @see #getMinIdle
 * @see #getTimeBetweenEvictionRunsMillis()
 */
public void setMinIdle(int minIdle) {
  synchronized(this) {
    _minIdle = minIdle;
  }
  allocate();
}
origin: commons-pool/commons-pool

/**
 * Sets the cap on the number of "idle" instances in the pool.
 * If maxIdle is set too low on heavily loaded systems it is possible you
 * will see objects being destroyed and almost immediately new objects
 * being created. This is a result of the active threads momentarily
 * returning objects faster than they are requesting them them, causing the
 * number of idle objects to rise above maxIdle. The best value for maxIdle
 * for heavily loaded system will vary but the default is a good starting
 * point.
 * @param maxIdle The cap on the number of "idle" instances in the pool.
 * Use a negative value to indicate an unlimited number of idle instances.
 * @see #getMaxIdle
 */
public void setMaxIdle(int maxIdle) {
  synchronized(this) {
    _maxIdle = maxIdle;
  }
  allocate();
}
origin: commons-pool/commons-pool

/**
 * Sets the maximum amount of time (in milliseconds) the
 * {@link #borrowObject} method should block before throwing
 * an exception when the pool is exhausted and the
 * {@link #setWhenExhaustedAction "when exhausted" action} is
 * {@link #WHEN_EXHAUSTED_BLOCK}.
 *
 * When less than or equal to 0, the {@link #borrowObject} method
 * may block indefinitely.
 *
 * @param maxWait maximum number of milliseconds to block when borrowing an object.
 * @see #getMaxWait
 * @see #setWhenExhaustedAction
 * @see #WHEN_EXHAUSTED_BLOCK
 */
public void setMaxWait(long maxWait) {
  synchronized(this) {
    _maxWait = maxWait;
  }
  allocate();
}
origin: commons-pool/commons-pool

/**
 * Sets the action to take when the {@link #borrowObject} method
 * is invoked when the pool is exhausted (the maximum number
 * of "active" objects has been reached).
 *
 * @param whenExhaustedAction the action code, which must be one of
 *        {@link #WHEN_EXHAUSTED_BLOCK}, {@link #WHEN_EXHAUSTED_FAIL},
 *        or {@link #WHEN_EXHAUSTED_GROW}
 * @see #getWhenExhaustedAction
 */
public void setWhenExhaustedAction(byte whenExhaustedAction) {
  synchronized(this) {
    switch(whenExhaustedAction) {
      case WHEN_EXHAUSTED_BLOCK:
      case WHEN_EXHAUSTED_FAIL:
      case WHEN_EXHAUSTED_GROW:
        _whenExhaustedAction = whenExhaustedAction;
        break;
      default:
        throw new IllegalArgumentException("whenExhaustedAction " + whenExhaustedAction + " not recognized.");
    }
  }
  allocate();
}
origin: commons-pool/commons-pool

/**
 * {@inheritDoc}
 * <p>Activation of this method decrements the active count and attempts to destroy the instance.</p>
 * 
 * @throws Exception if the configured {@link PoolableObjectFactory} throws an exception destroying obj
 */
@Override
public void invalidateObject(T obj) throws Exception {
  try {
    if (_factory != null) {
      _factory.destroyObject(obj);
    }
  } finally {
    synchronized (this) {
      _numActive--;
    }
    allocate();
  }
}
origin: commons-pool/commons-pool

/**
 * Private method to destroy all the objects in a collection using the 
 * supplied object factory.  Assumes that objects in the collection are
 * instances of ObjectTimestampPair and that the object instances that
 * they wrap were created by the factory.
 * 
 * @param c Collection of objects to destroy
 * @param factory PoolableConnectionFactory used to destroy the objects
 */
private void destroy(Collection<ObjectTimestampPair<T>> c, PoolableObjectFactory<T> factory) {
  for (Iterator<ObjectTimestampPair<T>> it = c.iterator(); it.hasNext();) {
    try {
      factory.destroyObject(it.next().value);
    } catch(Exception e) {
      // ignore error, keep destroying the rest
    } finally {
      synchronized(this) {
        _numInternalProcessing--;
      }
      allocate();
    }
  }
}
origin: commons-pool/commons-pool

  _numActive--;
allocate();
origin: commons-pool/commons-pool

/**
 * Check to see if we are below our minimum number of objects
 * if so enough to bring us back to our minimum.
 *
 * @throws Exception when {@link #addObject()} fails.
 */
private void ensureMinIdle() throws Exception {
  // this method isn't synchronized so the
  // calculateDeficit is done at the beginning
  // as a loop limit and a second time inside the loop
  // to stop when another thread already returned the
  // needed objects
  int objectDeficit = calculateDeficit(false);
  for ( int j = 0 ; j < objectDeficit && calculateDeficit(true) > 0 ; j++ ) {
    try {
      addObject();
    } finally {
      synchronized (this) {
        _numInternalProcessing--;
      }
      allocate();
    }
  }
}
origin: commons-pool/commons-pool

allocate();
              allocate();
        allocate();
    allocate();
    if(newlyCreated) {
      throw new NoSuchElementException("Could not create a validated object, cause: " + e.getMessage());
origin: commons-pool/commons-pool

allocate();
    _numActive--;
  allocate();
origin: commons-pool/commons-pool

/**
 * Sets my configuration.
 *
 * @param conf configuration to use.
 * @see GenericObjectPool.Config
 */
public void setConfig(GenericObjectPool.Config conf) {
  synchronized (this) {
    setMaxIdle(conf.maxIdle);
    setMinIdle(conf.minIdle);
    setMaxActive(conf.maxActive);
    setMaxWait(conf.maxWait);
    setWhenExhaustedAction(conf.whenExhaustedAction);
    setTestOnBorrow(conf.testOnBorrow);
    setTestOnReturn(conf.testOnReturn);
    setTestWhileIdle(conf.testWhileIdle);
    setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun);
    setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
    setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
    setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis);
    setLifo(conf.lifo);
  }
  allocate();
}
origin: commons-pool/commons-pool

allocate();
origin: org.apache.commons/com.springsource.org.apache.commons.pool

/**
 * Sets the cap on the number of objects that can be allocated by the pool
 * (checked out to clients, or idle awaiting checkout) at a given time. Use
 * a negative value for no limit.
 *
 * @param maxActive The cap on the total number of object instances managed by the pool.
 * Negative values mean that there is no limit to the number of objects allocated
 * by the pool.
 * @see #getMaxActive
 */
public synchronized void setMaxActive(int maxActive) {
  _maxActive = maxActive;
  allocate();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool

/**
 * Sets the cap on the number of objects that can be allocated by the pool
 * (checked out to clients, or idle awaiting checkout) at a given time. Use
 * a negative value for no limit.
 *
 * @param maxActive The cap on the total number of object instances managed by the pool.
 * Negative values mean that there is no limit to the number of objects allocated
 * by the pool.
 * @see #getMaxActive
 */
public synchronized void setMaxActive(int maxActive) {
  _maxActive = maxActive;
  allocate();
}
origin: org.apache.openjpa/openjpa-all

/**
 * Sets the cap on the number of objects that can be allocated by the pool
 * (checked out to clients, or idle awaiting checkout) at a given time. Use
 * a negative value for no limit.
 *
 * @param maxActive The cap on the total number of object instances managed by the pool.
 * Negative values mean that there is no limit to the number of objects allocated
 * by the pool.
 * @see #getMaxActive
 */
public void setMaxActive(int maxActive) {
  synchronized(this) {
    _maxActive = maxActive;
  }
  allocate();
}
origin: org.apache.commons/com.springsource.org.apache.commons.pool

/**
 * Sets the minimum number of objects allowed in the pool
 * before the evictor thread (if active) spawns new objects.
 * Note that no objects are created when
 * <code>numActive + numIdle >= maxActive.</code>
 * This setting has no effect if the idle object evictor is disabled
 * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
 *
 * @param minIdle The minimum number of objects.
 * @see #getMinIdle
 * @see #getTimeBetweenEvictionRunsMillis()
 */
public synchronized void setMinIdle(int minIdle) {
  _minIdle = minIdle;
  allocate();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool

/**
 * Sets the minimum number of objects allowed in the pool
 * before the evictor thread (if active) spawns new objects.
 * Note that no objects are created when
 * <code>numActive + numIdle >= maxActive.</code>
 * This setting has no effect if the idle object evictor is disabled
 * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
 *
 * @param minIdle The minimum number of objects.
 * @see #getMinIdle
 * @see #getTimeBetweenEvictionRunsMillis()
 */
public synchronized void setMinIdle(int minIdle) {
  _minIdle = minIdle;
  allocate();
}
origin: org.apache.commons/pool

/**
 * Sets the cap on the number of objects that can be allocated by the pool
 * (checked out to clients, or idle awaiting checkout) at a given time. Use
 * a negative value for no limit.
 *
 * @param maxActive The cap on the total number of object instances managed by the pool.
 * Negative values mean that there is no limit to the number of objects allocated
 * by the pool.
 * @see #getMaxActive
 */
public void setMaxActive(int maxActive) {
  synchronized(this) {
    _maxActive = maxActive;
  }
  allocate();
}
origin: org.apache.commons/com.springsource.org.apache.commons.pool

/**
 * Sets the maximum amount of time (in milliseconds) the
 * {@link #borrowObject} method should block before throwing
 * an exception when the pool is exhausted and the
 * {@link #setWhenExhaustedAction "when exhausted" action} is
 * {@link #WHEN_EXHAUSTED_BLOCK}.
 *
 * When less than or equal to 0, the {@link #borrowObject} method
 * may block indefinitely.
 *
 * @param maxWait maximum number of milliseconds to block when borrowing an object.
 * @see #getMaxWait
 * @see #setWhenExhaustedAction
 * @see #WHEN_EXHAUSTED_BLOCK
 */
public synchronized void setMaxWait(long maxWait) {
  _maxWait = maxWait;
  allocate();
}
org.apache.commons.pool.implGenericObjectPoolallocate

Javadoc

Allocate available instances to latches in the allocation queue. Then set _mayCreate to true for as many additional latches remaining in queue as _maxActive allows.

Popular methods of GenericObjectPool

  • <init>
    Create a new GenericObjectPool using the specified values.
  • returnObject
    Returns an object instance to the pool. If #getMaxIdle() is set to a positive value and the number
  • borrowObject
    Borrows an object from the pool. If there is an idle instance available in the pool, then either th
  • setMaxActive
    Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or
  • close
    Closes the pool. Once the pool is closed, #borrowObject()will fail with IllegalStateException, but #
  • setMaxIdle
    Sets the cap on the number of "idle" instances in the pool. If maxIdle is set too low on heavily loa
  • setMinIdle
    Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns
  • setTimeBetweenEvictionRunsMillis
    Sets the number of milliseconds to sleep between runs of the idle object evictor thread. When non-po
  • setMinEvictableIdleTimeMillis
    Sets the minimum amount of time an object may sit idle in the pool before it is eligible for evictio
  • setMaxWait
    Sets the maximum amount of time (in milliseconds) the #borrowObject method should block before throw
  • setTestOnBorrow
    When true, objects will be PoolableObjectFactory#validateObjectbefore being returned by the #borrowO
  • setWhenExhaustedAction
    Sets the action to take when the #borrowObject method is invoked when the pool is exhausted (the max
  • setTestOnBorrow,
  • setWhenExhaustedAction,
  • getNumActive,
  • getNumIdle,
  • setTestWhileIdle,
  • setNumTestsPerEvictionRun,
  • setTestOnReturn,
  • invalidateObject,
  • clear,
  • addObject

Popular in Java

  • Finding current android device location
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Collectors (java.util.stream)
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JFileChooser (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now