public void destroyConnection() { this.connectionLifeCycleLock.writeLock().lock(); try { Connection con = this.connection; if (con != null) { if (!con.isDestroyed()) { con.destroy(); this.sender.getProxy().returnConnection(con); } // Reset the connection so the next time through a new one will be // obtained this.connection = null; this.sender.setServerLocation(null); } } finally { this.connectionLifeCycleLock.writeLock().unlock(); } }
private AbstractGatewaySenderEventProcessor getMockedAbstractGatewaySenderEventProcessor( PoolImpl pool, ServerLocation serverLocation) { final AbstractGatewaySender abstractGatewaySender = mock(AbstractGatewaySender.class); doReturn(serverLocation).when(abstractGatewaySender).getServerLocation(); doReturn(pool).when(abstractGatewaySender).getProxy(); final AbstractGatewaySenderEventProcessor eventProcessor = mock(AbstractGatewaySenderEventProcessor.class); doReturn(abstractGatewaySender).when(eventProcessor).getSender(); return eventProcessor; }
gse = new GatewaySenderException(e.getCause()); } else { List<ServerLocation> servers = this.sender.getProxy().getCurrentServers(); String ioMsg; if (servers.size() == 0) {
public void shutdown() { // we need to destroy connection irrespective of we are listening on it or // not. No need to take lock as the reader thread may be blocked and we might not // get chance to destroy unless that returns. Connection conn = connection; if (conn != null) { shutDownAckReaderConnection(conn); if (!conn.isDestroyed()) { conn.destroy(); sender.getProxy().returnConnection(conn); } } this.shutdown = true; boolean interrupted = Thread.interrupted(); try { this.join(15 * 1000); } catch (InterruptedException e) { interrupted = true; } finally { if (interrupted) { Thread.currentThread().interrupt(); } } if (this.isAlive()) { logger.warn("AckReaderThread ignored cancellation"); } }
isRetry = true; SenderProxy sp = new SenderProxy(this.sender.getProxy()); this.connectionLifeCycleLock.readLock().lock(); try {
try { if (this.sender.getProxy() == null || this.sender.getProxy().isDestroyed()) { this.sender.initProxy(); } else { con = this.sender.getProxy().acquireConnection(); logger.debug("ServerLocation is: {}. Connecting to this serverLocation...", server); con = this.sender.getProxy().acquireConnection(server); } else { if (logger.isDebugEnabled()) { logger.debug("ServerLocation is null. Creating new connection. "); con = this.sender.getProxy().acquireConnection();