Deprecated ConnectionPool.
This commit is contained in:
parent
3c26ffb227
commit
a6ba51fe24
|
@ -18,425 +18,17 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.client.api.Connection;
|
|
||||||
import org.eclipse.jetty.client.api.Destination;
|
import org.eclipse.jetty.client.api.Destination;
|
||||||
import org.eclipse.jetty.util.BlockingArrayQueue;
|
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.Promise;
|
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
|
||||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
|
||||||
import org.eclipse.jetty.util.thread.Sweeper;
|
|
||||||
|
|
||||||
@ManagedObject("The connection pool")
|
/**
|
||||||
public class ConnectionPool implements Closeable, Dumpable, Sweeper.Sweepable
|
* @deprecated use {@link DuplexConnectionPool} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class ConnectionPool extends DuplexConnectionPool
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(ConnectionPool.class);
|
|
||||||
|
|
||||||
private final AtomicInteger connectionCount = new AtomicInteger();
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
|
||||||
private final Destination destination;
|
|
||||||
private final int maxConnections;
|
|
||||||
private final Callback requester;
|
|
||||||
private final Deque<Connection> idleConnections;
|
|
||||||
private final Queue<Connection> activeConnections;
|
|
||||||
|
|
||||||
public ConnectionPool(Destination destination, int maxConnections, Callback requester)
|
public ConnectionPool(Destination destination, int maxConnections, Callback requester)
|
||||||
{
|
{
|
||||||
this.destination = destination;
|
super(destination, maxConnections, requester);
|
||||||
this.maxConnections = maxConnections;
|
|
||||||
this.requester = requester;
|
|
||||||
this.idleConnections = new LinkedBlockingDeque<>(maxConnections);
|
|
||||||
this.activeConnections = new BlockingArrayQueue<>(maxConnections);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManagedAttribute(value = "The number of connections", readonly = true)
|
|
||||||
public int getConnectionCount()
|
|
||||||
{
|
|
||||||
return connectionCount.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManagedAttribute(value = "The number of idle connections", readonly = true)
|
|
||||||
public int getIdleConnectionCount()
|
|
||||||
{
|
|
||||||
return idleConnections.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManagedAttribute(value = "The number of active connections", readonly = true)
|
|
||||||
public int getActiveConnectionCount()
|
|
||||||
{
|
|
||||||
return activeConnections.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Queue<Connection> getIdleConnections()
|
|
||||||
{
|
|
||||||
return idleConnections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Queue<Connection> getActiveConnections()
|
|
||||||
{
|
|
||||||
return activeConnections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection acquire()
|
|
||||||
{
|
|
||||||
Connection connection = activateIdle();
|
|
||||||
if (connection == null)
|
|
||||||
connection = tryCreate();
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Connection tryCreate()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int current = getConnectionCount();
|
|
||||||
final int next = current + 1;
|
|
||||||
|
|
||||||
if (next > maxConnections)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Max connections {}/{} reached", current, maxConnections);
|
|
||||||
// Try again the idle connections
|
|
||||||
return activateIdle();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connectionCount.compareAndSet(current, next))
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection {}/{} creation", next, maxConnections);
|
|
||||||
|
|
||||||
destination.newConnection(new Promise<Connection>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void succeeded(Connection connection)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
|
|
||||||
|
|
||||||
idleCreated(connection);
|
|
||||||
|
|
||||||
proceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed(Throwable x)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection " + next + "/" + maxConnections + " creation failed", x);
|
|
||||||
|
|
||||||
connectionCount.decrementAndGet();
|
|
||||||
|
|
||||||
requester.failed(x);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Try again the idle connections
|
|
||||||
return activateIdle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void proceed()
|
|
||||||
{
|
|
||||||
requester.succeeded();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void idleCreated(Connection connection)
|
|
||||||
{
|
|
||||||
boolean idle;
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Use "cold" new connections as last.
|
|
||||||
idle = idleConnections.offerLast(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
idle(connection, idle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Connection activateIdle()
|
|
||||||
{
|
|
||||||
boolean acquired;
|
|
||||||
Connection connection;
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection = idleConnections.pollFirst();
|
|
||||||
if (connection == null)
|
|
||||||
return null;
|
|
||||||
acquired = activeConnections.offer(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acquired)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection active {}", connection);
|
|
||||||
acquired(connection);
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection active overflow {}", connection);
|
|
||||||
connection.close();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void acquired(Connection connection)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean release(Connection connection)
|
|
||||||
{
|
|
||||||
boolean idle;
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!activeConnections.remove(connection))
|
|
||||||
return false;
|
|
||||||
// Make sure we use "hot" connections first.
|
|
||||||
idle = offerIdle(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
released(connection);
|
|
||||||
return idle(connection, idle);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean offerIdle(Connection connection)
|
|
||||||
{
|
|
||||||
return idleConnections.offerFirst(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean idle(Connection connection, boolean idle)
|
|
||||||
{
|
|
||||||
if (idle)
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection idle {}", connection);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection idle overflow {}", connection);
|
|
||||||
connection.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void released(Connection connection)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean remove(Connection connection)
|
|
||||||
{
|
|
||||||
return remove(connection, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean remove(Connection connection, boolean force)
|
|
||||||
{
|
|
||||||
boolean activeRemoved;
|
|
||||||
boolean idleRemoved;
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
activeRemoved = activeConnections.remove(connection);
|
|
||||||
idleRemoved = idleConnections.remove(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activeRemoved)
|
|
||||||
released(connection);
|
|
||||||
boolean removed = activeRemoved || idleRemoved || force;
|
|
||||||
if (removed)
|
|
||||||
{
|
|
||||||
int pooled = connectionCount.decrementAndGet();
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive(Connection connection)
|
|
||||||
{
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return activeConnections.contains(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIdle(Connection connection)
|
|
||||||
{
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return idleConnections.contains(connection);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty()
|
|
||||||
{
|
|
||||||
return connectionCount.get() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close()
|
|
||||||
{
|
|
||||||
List<Connection> idles = new ArrayList<>();
|
|
||||||
List<Connection> actives = new ArrayList<>();
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
idles.addAll(idleConnections);
|
|
||||||
idleConnections.clear();
|
|
||||||
actives.addAll(activeConnections);
|
|
||||||
activeConnections.clear();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
connectionCount.set(0);
|
|
||||||
|
|
||||||
for (Connection connection : idles)
|
|
||||||
connection.close();
|
|
||||||
|
|
||||||
// A bit drastic, but we cannot wait for all requests to complete
|
|
||||||
for (Connection connection : actives)
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String dump()
|
|
||||||
{
|
|
||||||
return ContainerLifeCycle.dump(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dump(Appendable out, String indent) throws IOException
|
|
||||||
{
|
|
||||||
List<Connection> actives = new ArrayList<>();
|
|
||||||
List<Connection> idles = new ArrayList<>();
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
actives.addAll(activeConnections);
|
|
||||||
idles.addAll(idleConnections);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
ContainerLifeCycle.dumpObject(out, this);
|
|
||||||
ContainerLifeCycle.dump(out, indent, actives, idles);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sweep()
|
|
||||||
{
|
|
||||||
List<Sweeper.Sweepable> toSweep = new ArrayList<>();
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (Connection connection : getActiveConnections())
|
|
||||||
{
|
|
||||||
if (connection instanceof Sweeper.Sweepable)
|
|
||||||
toSweep.add(((Sweeper.Sweepable)connection));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Sweeper.Sweepable candidate : toSweep)
|
|
||||||
{
|
|
||||||
if (candidate.sweep())
|
|
||||||
{
|
|
||||||
boolean removed = getActiveConnections().remove(candidate);
|
|
||||||
LOG.warn("Connection swept: {}{}{} from active connections{}{}",
|
|
||||||
candidate,
|
|
||||||
System.lineSeparator(),
|
|
||||||
removed ? "Removed" : "Not removed",
|
|
||||||
System.lineSeparator(),
|
|
||||||
dump());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void lock()
|
|
||||||
{
|
|
||||||
lock.lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void unlock()
|
|
||||||
{
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
int activeSize;
|
|
||||||
int idleSize;
|
|
||||||
lock();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
activeSize = activeConnections.size();
|
|
||||||
idleSize = idleConnections.size();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.format("%s[c=%d/%d,a=%d,i=%d]",
|
|
||||||
getClass().getSimpleName(),
|
|
||||||
connectionCount.get(),
|
|
||||||
maxConnections,
|
|
||||||
activeSize,
|
|
||||||
idleSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,442 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.client.api.Connection;
|
||||||
|
import org.eclipse.jetty.client.api.Destination;
|
||||||
|
import org.eclipse.jetty.util.BlockingArrayQueue;
|
||||||
|
import org.eclipse.jetty.util.Callback;
|
||||||
|
import org.eclipse.jetty.util.Promise;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||||
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
import org.eclipse.jetty.util.thread.Sweeper;
|
||||||
|
|
||||||
|
@ManagedObject("The connection pool")
|
||||||
|
public class DuplexConnectionPool implements Closeable, Dumpable, Sweeper.Sweepable
|
||||||
|
{
|
||||||
|
private static final Logger LOG = Log.getLogger(DuplexConnectionPool.class);
|
||||||
|
|
||||||
|
private final AtomicInteger connectionCount = new AtomicInteger();
|
||||||
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
private final Destination destination;
|
||||||
|
private final int maxConnections;
|
||||||
|
private final Callback requester;
|
||||||
|
private final Deque<Connection> idleConnections;
|
||||||
|
private final Queue<Connection> activeConnections;
|
||||||
|
|
||||||
|
public DuplexConnectionPool(Destination destination, int maxConnections, Callback requester)
|
||||||
|
{
|
||||||
|
this.destination = destination;
|
||||||
|
this.maxConnections = maxConnections;
|
||||||
|
this.requester = requester;
|
||||||
|
this.idleConnections = new LinkedBlockingDeque<>(maxConnections);
|
||||||
|
this.activeConnections = new BlockingArrayQueue<>(maxConnections);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute(value = "The number of connections", readonly = true)
|
||||||
|
public int getConnectionCount()
|
||||||
|
{
|
||||||
|
return connectionCount.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute(value = "The number of idle connections", readonly = true)
|
||||||
|
public int getIdleConnectionCount()
|
||||||
|
{
|
||||||
|
return idleConnections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute(value = "The number of active connections", readonly = true)
|
||||||
|
public int getActiveConnectionCount()
|
||||||
|
{
|
||||||
|
return activeConnections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Queue<Connection> getIdleConnections()
|
||||||
|
{
|
||||||
|
return idleConnections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Queue<Connection> getActiveConnections()
|
||||||
|
{
|
||||||
|
return activeConnections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection acquire()
|
||||||
|
{
|
||||||
|
Connection connection = activateIdle();
|
||||||
|
if (connection == null)
|
||||||
|
connection = tryCreate();
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection tryCreate()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int current = getConnectionCount();
|
||||||
|
final int next = current + 1;
|
||||||
|
|
||||||
|
if (next > maxConnections)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Max connections {}/{} reached", current, maxConnections);
|
||||||
|
// Try again the idle connections
|
||||||
|
return activateIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connectionCount.compareAndSet(current, next))
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection {}/{} creation", next, maxConnections);
|
||||||
|
|
||||||
|
destination.newConnection(new Promise<Connection>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void succeeded(Connection connection)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
|
||||||
|
|
||||||
|
idleCreated(connection);
|
||||||
|
|
||||||
|
proceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Throwable x)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection " + next + "/" + maxConnections + " creation failed", x);
|
||||||
|
|
||||||
|
connectionCount.decrementAndGet();
|
||||||
|
|
||||||
|
requester.failed(x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Try again the idle connections
|
||||||
|
return activateIdle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void proceed()
|
||||||
|
{
|
||||||
|
requester.succeeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void idleCreated(Connection connection)
|
||||||
|
{
|
||||||
|
boolean idle;
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Use "cold" new connections as last.
|
||||||
|
idle = idleConnections.offerLast(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
idle(connection, idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection activateIdle()
|
||||||
|
{
|
||||||
|
boolean acquired;
|
||||||
|
Connection connection;
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection = idleConnections.pollFirst();
|
||||||
|
if (connection == null)
|
||||||
|
return null;
|
||||||
|
acquired = activeConnections.offer(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acquired)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection active {}", connection);
|
||||||
|
acquired(connection);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection active overflow {}", connection);
|
||||||
|
connection.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void acquired(Connection connection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean release(Connection connection)
|
||||||
|
{
|
||||||
|
boolean idle;
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!activeConnections.remove(connection))
|
||||||
|
return false;
|
||||||
|
// Make sure we use "hot" connections first.
|
||||||
|
idle = offerIdle(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
released(connection);
|
||||||
|
return idle(connection, idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean offerIdle(Connection connection)
|
||||||
|
{
|
||||||
|
return idleConnections.offerFirst(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean idle(Connection connection, boolean idle)
|
||||||
|
{
|
||||||
|
if (idle)
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection idle {}", connection);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection idle overflow {}", connection);
|
||||||
|
connection.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void released(Connection connection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove(Connection connection)
|
||||||
|
{
|
||||||
|
return remove(connection, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean remove(Connection connection, boolean force)
|
||||||
|
{
|
||||||
|
boolean activeRemoved;
|
||||||
|
boolean idleRemoved;
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
activeRemoved = activeConnections.remove(connection);
|
||||||
|
idleRemoved = idleConnections.remove(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeRemoved)
|
||||||
|
released(connection);
|
||||||
|
boolean removed = activeRemoved || idleRemoved || force;
|
||||||
|
if (removed)
|
||||||
|
{
|
||||||
|
int pooled = connectionCount.decrementAndGet();
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Connection removed {} - pooled: {}", connection, pooled);
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive(Connection connection)
|
||||||
|
{
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return activeConnections.contains(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIdle(Connection connection)
|
||||||
|
{
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return idleConnections.contains(connection);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return connectionCount.get() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
List<Connection> idles = new ArrayList<>();
|
||||||
|
List<Connection> actives = new ArrayList<>();
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
idles.addAll(idleConnections);
|
||||||
|
idleConnections.clear();
|
||||||
|
actives.addAll(activeConnections);
|
||||||
|
activeConnections.clear();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
connectionCount.set(0);
|
||||||
|
|
||||||
|
for (Connection connection : idles)
|
||||||
|
connection.close();
|
||||||
|
|
||||||
|
// A bit drastic, but we cannot wait for all requests to complete
|
||||||
|
for (Connection connection : actives)
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String dump()
|
||||||
|
{
|
||||||
|
return ContainerLifeCycle.dump(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dump(Appendable out, String indent) throws IOException
|
||||||
|
{
|
||||||
|
List<Connection> actives = new ArrayList<>();
|
||||||
|
List<Connection> idles = new ArrayList<>();
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
actives.addAll(activeConnections);
|
||||||
|
idles.addAll(idleConnections);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
ContainerLifeCycle.dumpObject(out, this);
|
||||||
|
ContainerLifeCycle.dump(out, indent, actives, idles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sweep()
|
||||||
|
{
|
||||||
|
List<Sweeper.Sweepable> toSweep = new ArrayList<>();
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (Connection connection : getActiveConnections())
|
||||||
|
{
|
||||||
|
if (connection instanceof Sweeper.Sweepable)
|
||||||
|
toSweep.add(((Sweeper.Sweepable)connection));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Sweeper.Sweepable candidate : toSweep)
|
||||||
|
{
|
||||||
|
if (candidate.sweep())
|
||||||
|
{
|
||||||
|
boolean removed = getActiveConnections().remove(candidate);
|
||||||
|
LOG.warn("Connection swept: {}{}{} from active connections{}{}",
|
||||||
|
candidate,
|
||||||
|
System.lineSeparator(),
|
||||||
|
removed ? "Removed" : "Not removed",
|
||||||
|
System.lineSeparator(),
|
||||||
|
dump());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void lock()
|
||||||
|
{
|
||||||
|
lock.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unlock()
|
||||||
|
{
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
int activeSize;
|
||||||
|
int idleSize;
|
||||||
|
lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
activeSize = activeConnections.size();
|
||||||
|
idleSize = idleConnections.size();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format("%s[c=%d/%d,a=%d,i=%d]",
|
||||||
|
getClass().getSimpleName(),
|
||||||
|
connectionCount.get(),
|
||||||
|
maxConnections,
|
||||||
|
activeSize,
|
||||||
|
idleSize);
|
||||||
|
}
|
||||||
|
}
|
|
@ -994,7 +994,7 @@ public class HttpClient extends ContainerLifeCycle
|
||||||
* anymore and leave space for new destinations.
|
* anymore and leave space for new destinations.
|
||||||
*
|
*
|
||||||
* @param removeIdleDestinations whether destinations that have no connections should be removed
|
* @param removeIdleDestinations whether destinations that have no connections should be removed
|
||||||
* @see org.eclipse.jetty.client.ConnectionPool
|
* @see org.eclipse.jetty.client.DuplexConnectionPool
|
||||||
*/
|
*/
|
||||||
public void setRemoveIdleDestinations(boolean removeIdleDestinations)
|
public void setRemoveIdleDestinations(boolean removeIdleDestinations)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.jetty.util.thread.Sweeper;
|
||||||
@ManagedObject
|
@ManagedObject
|
||||||
public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
|
public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
|
||||||
{
|
{
|
||||||
private final ConnectionPool connectionPool;
|
private final DuplexConnectionPool connectionPool;
|
||||||
|
|
||||||
public PoolingHttpDestination(HttpClient client, Origin origin)
|
public PoolingHttpDestination(HttpClient client, Origin origin)
|
||||||
{
|
{
|
||||||
|
@ -44,13 +44,13 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
|
||||||
sweeper.offer(connectionPool);
|
sweeper.offer(connectionPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new ConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ManagedAttribute(value = "The connection pool", readonly = true)
|
@ManagedAttribute(value = "The connection pool", readonly = true)
|
||||||
public ConnectionPool getConnectionPool()
|
public DuplexConnectionPool getConnectionPool()
|
||||||
{
|
{
|
||||||
return connectionPool;
|
return connectionPool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>A {@link ConnectionPool} that validates connections before
|
* <p>A connection pool that validates connections before
|
||||||
* making them available for use.</p>
|
* making them available for use.</p>
|
||||||
* <p>Connections that have just been opened are not validated.
|
* <p>Connections that have just been opened are not validated.
|
||||||
* Connections that are {@link #release(Connection) released} will
|
* Connections that are {@link #release(Connection) released} will
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class HttpClientExplicitConnectionTest extends AbstractHttpClientServerTe
|
||||||
Assert.assertEquals(200, response.getStatus());
|
Assert.assertEquals(200, response.getStatus());
|
||||||
|
|
||||||
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
|
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
|
||||||
ConnectionPool connectionPool = httpDestination.getConnectionPool();
|
DuplexConnectionPool connectionPool = httpDestination.getConnectionPool();
|
||||||
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
|
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
|
||||||
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
|
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class HttpClientExplicitConnectionTest extends AbstractHttpClientServerTe
|
||||||
Assert.assertFalse(httpConnection.getEndPoint().isOpen());
|
Assert.assertFalse(httpConnection.getEndPoint().isOpen());
|
||||||
|
|
||||||
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
|
HttpDestinationOverHTTP httpDestination = (HttpDestinationOverHTTP)destination;
|
||||||
ConnectionPool connectionPool = httpDestination.getConnectionPool();
|
DuplexConnectionPool connectionPool = httpDestination.getConnectionPool();
|
||||||
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
|
Assert.assertTrue(connectionPool.getActiveConnections().isEmpty());
|
||||||
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
|
Assert.assertTrue(connectionPool.getIdleConnections().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class HttpClientFailureTest
|
||||||
// Expected.
|
// Expected.
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
|
DuplexConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -170,7 +170,7 @@ public class HttpClientFailureTest
|
||||||
Assert.assertTrue(contentLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(contentLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
|
|
||||||
ConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
|
DuplexConnectionPool connectionPool = connectionRef.get().getHttpDestination().getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -61,9 +58,12 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
private final Logger logger = Log.getLogger(HttpClientLoadTest.class);
|
private final Logger logger = Log.getLogger(HttpClientLoadTest.class);
|
||||||
|
@ -100,7 +100,7 @@ public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||||
{
|
{
|
||||||
|
@ -143,15 +143,15 @@ public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), is(0L));
|
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), Matchers.is(0L));
|
||||||
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), is(0L));
|
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), Matchers.is(0L));
|
||||||
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), is(0L));
|
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), Matchers.is(0L));
|
||||||
|
|
||||||
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), is(0L));
|
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), Matchers.is(0L));
|
||||||
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), is(0L));
|
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), Matchers.is(0L));
|
||||||
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), is(0L));
|
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), Matchers.is(0L));
|
||||||
|
|
||||||
assertThat("Connection Leaks", connectionLeaks.get(), is(0L));
|
assertThat("Connection Leaks", connectionLeaks.get(), Matchers.is(0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(Random random, int iterations) throws InterruptedException
|
private void run(Random random, int iterations) throws InterruptedException
|
||||||
|
@ -173,7 +173,7 @@ public class HttpClientLoadTest extends AbstractHttpClientServerTest
|
||||||
for (String host : Arrays.asList("localhost", "127.0.0.1"))
|
for (String host : Arrays.asList("localhost", "127.0.0.1"))
|
||||||
{
|
{
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
for (Connection connection : new ArrayList<>(connectionPool.getActiveConnections()))
|
for (Connection connection : new ArrayList<>(connectionPool.getActiveConnections()))
|
||||||
{
|
{
|
||||||
HttpConnectionOverHTTP active = (HttpConnectionOverHTTP)connection;
|
HttpConnectionOverHTTP active = (HttpConnectionOverHTTP)connection;
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
||||||
Assert.assertEquals(200, response.getStatus());
|
Assert.assertEquals(200, response.getStatus());
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
long start = System.nanoTime();
|
long start = System.nanoTime();
|
||||||
HttpConnectionOverHTTP connection = null;
|
HttpConnectionOverHTTP connection = null;
|
||||||
|
|
|
@ -272,7 +272,7 @@ public class HttpClientUploadDuringServerShutdown
|
||||||
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", connector.getLocalPort());
|
||||||
ConnectionPool pool = destination.getConnectionPool();
|
DuplexConnectionPool pool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, pool.getConnectionCount());
|
Assert.assertEquals(0, pool.getConnectionCount());
|
||||||
Assert.assertEquals(0, pool.getIdleConnections().size());
|
Assert.assertEquals(0, pool.getIdleConnections().size());
|
||||||
Assert.assertEquals(0, pool.getActiveConnections().size());
|
Assert.assertEquals(0, pool.getActiveConnections().size());
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -130,7 +130,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -181,7 +181,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -241,7 +241,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -314,7 +314,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -367,7 +367,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -417,7 +417,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -467,7 +467,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
@ -499,7 +499,7 @@ public class HttpConnectionLifecycleTest extends AbstractHttpClientServerTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, host, port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
|
||||||
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
final Queue<Connection> idleConnections = connectionPool.getIdleConnections();
|
||||||
Assert.assertEquals(0, idleConnections.size());
|
Assert.assertEquals(0, idleConnections.size());
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -135,7 +135,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -182,7 +182,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -225,7 +225,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -289,7 +289,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -344,7 +344,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
@ -454,7 +454,7 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
Assert.assertEquals(0, connectionPool.getIdleConnections().size());
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class ServerConnectionCloseTest
|
||||||
|
|
||||||
// Connection should have been removed from pool.
|
// Connection should have been removed from pool.
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
|
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
|
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class TLSServerConnectionCloseTest
|
||||||
|
|
||||||
// Connection should have been removed from pool.
|
// Connection should have been removed from pool.
|
||||||
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination("http", "localhost", port);
|
||||||
ConnectionPool connectionPool = destination.getConnectionPool();
|
DuplexConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
Assert.assertEquals(0, connectionPool.getConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
|
Assert.assertEquals(0, connectionPool.getIdleConnectionCount());
|
||||||
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
|
Assert.assertEquals(0, connectionPool.getActiveConnectionCount());
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class ValidatingConnectionPoolTest extends AbstractHttpClientServerTest
|
||||||
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new ValidatingConnectionPool(this, client.getMaxConnectionsPerDestination(), this, client.getScheduler(), timeout);
|
return new ValidatingConnectionPool(this, client.getMaxConnectionsPerDestination(), this, client.getScheduler(), timeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.AbstractHttpClientServerTest;
|
import org.eclipse.jetty.client.AbstractHttpClientServerTest;
|
||||||
import org.eclipse.jetty.client.ConnectionPool;
|
import org.eclipse.jetty.client.DuplexConnectionPool;
|
||||||
import org.eclipse.jetty.client.EmptyServerHandler;
|
import org.eclipse.jetty.client.EmptyServerHandler;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.Origin;
|
import org.eclipse.jetty.client.Origin;
|
||||||
|
@ -97,9 +97,9 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
|
||||||
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()))
|
HttpDestinationOverHTTP destination = new HttpDestinationOverHTTP(client, new Origin("http", "localhost", connector.getLocalPort()))
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new ConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void idleCreated(Connection connection)
|
protected void idleCreated(Connection connection)
|
||||||
|
|
|
@ -18,12 +18,9 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.fcgi.server;
|
package org.eclipse.jetty.fcgi.server;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.ConnectionPool;
|
import org.eclipse.jetty.client.DuplexConnectionPool;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.HttpDestination;
|
import org.eclipse.jetty.client.HttpDestination;
|
||||||
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
|
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
|
||||||
|
@ -40,9 +37,12 @@ import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||||
import org.eclipse.jetty.util.LeakDetector;
|
import org.eclipse.jetty.util.LeakDetector;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public abstract class AbstractHttpClientServerTest
|
public abstract class AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
@Rule
|
@Rule
|
||||||
|
@ -71,7 +71,7 @@ public abstract class AbstractHttpClientServerTest
|
||||||
|
|
||||||
QueuedThreadPool executor = new QueuedThreadPool();
|
QueuedThreadPool executor = new QueuedThreadPool();
|
||||||
executor.setName(executor.getName() + "-client");
|
executor.setName(executor.getName() + "-client");
|
||||||
|
|
||||||
client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "")
|
client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,7 +80,7 @@ public abstract class AbstractHttpClientServerTest
|
||||||
return new HttpDestinationOverFCGI(client, origin)
|
return new HttpDestinationOverFCGI(client, origin)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||||
{
|
{
|
||||||
|
@ -105,15 +105,15 @@ public abstract class AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), is(0L));
|
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), Matchers.is(0L));
|
||||||
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), is(0L));
|
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), Matchers.is(0L));
|
||||||
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), is(0L));
|
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), Matchers.is(0L));
|
||||||
|
|
||||||
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), is(0L));
|
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), Matchers.is(0L));
|
||||||
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), is(0L));
|
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), Matchers.is(0L));
|
||||||
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), is(0L));
|
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), Matchers.is(0L));
|
||||||
|
|
||||||
assertThat("Connection Leaks", connectionLeaks.get(), is(0L));
|
assertThat("Connection Leaks", connectionLeaks.get(), Matchers.is(0L));
|
||||||
|
|
||||||
if (client != null)
|
if (client != null)
|
||||||
client.stop();
|
client.stop();
|
||||||
|
|
Loading…
Reference in New Issue