protected void transferConnections(int maxSize, int shrinkNow) { for (int i = 0; i < shrinkNow; i++) { ConnectionInfo killInfo = new ConnectionInfo(pool.get(0)); internalReturn(killInfo, ConnectionReturnAction.DESTROY); } }
protected void transferConnections(int maxSize, int shrinkNow) { List<ConnectionInfo> killList = new ArrayList<ConnectionInfo>(shrinkNow); Iterator<Map.Entry<ManagedConnection, ManagedConnectionInfo>> it = pool.entrySet().iterator(); for (int i = 0; i < shrinkNow; i++) { killList.add(new ConnectionInfo(it.next().getValue())); } for (ConnectionInfo killInfo: killList) { internalReturn(killInfo, ConnectionReturnAction.DESTROY); } }
/** * Releases any managed connections held by a garbage collected connection proxy. * * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(final ConnectionInfo connectionInfo, final String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); final ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
/** * Releases any managed connections held by a garbage collected connection proxy. * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(ConnectionInfo connectionInfo, String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
/** * Releases any managed connections held by a garbage collected connection proxy. * * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(final ConnectionInfo connectionInfo, final String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); final ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
private void returnHandle(ManagedConnectionInfo managedConnectionInfo) { ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.setManagedConnectionInfo(managedConnectionInfo); internalReturn(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); }
public void run() { // protect against interceptor being set to null mid-execution AbstractSinglePoolConnectionInterceptor interceptor = parent; if (interceptor == null) return; interceptor.resizeLock.readLock().lock(); try { long threshold = System.currentTimeMillis() - interceptor.idleTimeoutMilliseconds; List<ManagedConnectionInfo> killList = new ArrayList<ManagedConnectionInfo>(interceptor.getPartitionMaxSize()); interceptor.getExpiredManagedConnectionInfos(threshold, killList); for (ManagedConnectionInfo managedConnectionInfo : killList) { ConnectionInfo killInfo = new ConnectionInfo(managedConnectionInfo); parent.next.returnConnection(killInfo, ConnectionReturnAction.DESTROY); } } catch (Throwable t) { log.error("Error occurred during execution of ExpirationMonitor TimerTask", t); } finally { interceptor.resizeLock.readLock().unlock(); } }
public void run() { resizeLock.readLock().lock(); try { while (connectionCount < minSize) { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, cri); mci.setSubject(subject); ConnectionInfo ci = new ConnectionInfo(mci); try { next.getConnection(ci); } catch (ResourceException e) { return; } boolean added = addToPool(mci); if (!added) { internalReturn(ci, ConnectionReturnAction.DESTROY); return; } } } catch (Throwable t) { log.error("FillTask encountered error in run method", t); } finally { resizeLock.readLock().unlock(); } }
final ManagedConnectionInfo mci = connections.get(invalid); if (mci != null) { stack.returnConnection(new ConnectionInfo(mci), ConnectionReturnAction.DESTROY); continue;
final ManagedConnectionInfo mci = connections.get(invalid); if (mci != null) { stack.returnConnection(new ConnectionInfo(mci), ConnectionReturnAction.DESTROY); continue;
ManagedConnectionInfo kill = (ManagedConnectionInfo) ((Map.Entry) iterator.next()).getValue(); iterator.remove(); ConnectionInfo killInfo = new ConnectionInfo(kill); internalReturn(killInfo, ConnectionReturnAction.DESTROY);
/** * in: non-null connection object, from non-null mcf. * connection object is not associated with a managed connection * out: supplied connection object is assiciated with a non-null ManagedConnection from mcf. */ public void associateConnection(Object connection, ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); ci.setConnectionHandle(connection); getStack().getConnection(ci); }
public void connectionClosed(ConnectionEvent connectionEvent) { if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) { throw new IllegalArgumentException( "ConnectionClosed event received from wrong ManagedConnection. Expected " + managedConnectionInfo.getManagedConnection() + ", actual " + connectionEvent.getSource()); } if (log.isTraceEnabled()) { log.trace("connectionClosed called with " + connectionEvent.getConnectionHandle() + " for MCI: " + managedConnectionInfo + " and MC: " + managedConnectionInfo.getManagedConnection()); } ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo); ci.setConnectionHandle(connectionEvent.getConnectionHandle()); try { stack.returnConnection(ci, ConnectionReturnAction.RETURN_HANDLE); } catch (Throwable e) { if (log.isTraceEnabled()) { log.trace("connectionClosed failed with " + connectionEvent.getConnectionHandle() + " for MCI: " + managedConnectionInfo + " and MC: " + managedConnectionInfo.getManagedConnection(), e); } if (e instanceof Error) { throw (Error)e; } } }
public void connectionErrorOccurred(ConnectionEvent connectionEvent) { if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) { throw new IllegalArgumentException( "ConnectionError event received from wrong ManagedConnection. Expected " + managedConnectionInfo.getManagedConnection() + ", actual " + connectionEvent.getSource()); } log.warn("connectionErrorOccurred called with " + connectionEvent.getConnectionHandle(), connectionEvent.getException()); boolean errorOccurred = this.errorOccurred; this.errorOccurred = true; if (!errorOccurred) { ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo); ci.setConnectionHandle(connectionEvent.getConnectionHandle()); stack.returnConnection(ci, ConnectionReturnAction.DESTROY); } }
public NamedXAResource getNamedXAResource() throws SystemException { try { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, null); ConnectionInfo recoveryConnectionInfo = new ConnectionInfo(mci); recoveryStack.getConnection(recoveryConnectionInfo); // For pooled resources, we may now have a new MCI (not the one constructed above). Make sure we use the correct MCI return new NamedXAResourceWithConnectioninfo((NamedXAResource) recoveryConnectionInfo.getManagedConnectionInfo().getXAResource(), recoveryConnectionInfo); } catch (ResourceException e) { throw (SystemException) new SystemException("Could not get XAResource for recovery for mcf: " + name).initCause(e); } }
} catch (ResourceException e) { ConnectionInfo returnCI = new ConnectionInfo(); returnCI.setManagedConnectionInfo(newMCI); returnConnection(returnCI, ConnectionReturnAction.DESTROY); ConnectionInfo returnCI = new ConnectionInfo(); returnCI.setManagedConnectionInfo(newMCI); returnConnection(returnCI, ConnectionReturnAction.RETURN_HANDLE);
/** * in: mcf != null, is a deployed mcf * out: useable connection object. */ public Object allocateConnection(ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); getStack().getConnection(ci); Object connection = ci.getConnectionProxy(); if (connection == null) { connection = ci.getConnectionHandle(); } else { // connection proxy is used only once so we can be notified // by the garbage collector when a connection is abandoned ci.setConnectionProxy(null); } return connection; }
ConnectionInfo returningConnectionInfo = new ConnectionInfo(); returningConnectionInfo.setManagedConnectionInfo(originalManagedConnectionInfo);