use of com.aerospike.client.async.AsyncConnectorExecutor in project aerospike-client-java by aerospike.
the class Node method createMinConnections.
public final void createMinConnections() {
// Create sync connections.
for (Pool pool : connectionPools) {
if (pool.minSize > 0) {
createConnections(pool, pool.minSize);
}
}
EventState[] eventState = cluster.eventState;
if (eventState == null || cluster.asyncMinConnsPerNode <= 0) {
return;
}
// Create async connections.
final Monitor monitor = new Monitor();
final AtomicInteger eventLoopCount = new AtomicInteger(eventState.length);
final int maxConcurrent = 20 / eventState.length + 1;
for (int i = 0; i < eventState.length; i++) {
final int minSize = asyncConnectionPools[i].minSize;
if (minSize > 0) {
final EventLoop eventLoop = eventState[i].eventLoop;
final Node node = this;
eventLoop.execute(new Runnable() {
public void run() {
try {
new AsyncConnectorExecutor(eventLoop, cluster, node, minSize, maxConcurrent, monitor, eventLoopCount);
} catch (Exception e) {
if (Log.warnEnabled()) {
Log.warn("AsyncConnectorExecutor failed: " + Util.getErrorMessage(e));
}
}
}
});
} else {
AsyncConnectorExecutor.eventLoopComplete(monitor, eventLoopCount);
}
}
// Wait until all async connections are created.
monitor.waitTillComplete();
}
use of com.aerospike.client.async.AsyncConnectorExecutor in project aerospike-client-java by aerospike.
the class Node method balanceAsyncConnections.
public final void balanceAsyncConnections(EventLoop eventLoop) {
AsyncPool pool = asyncConnectionPools[eventLoop.getIndex()];
pool.handleRemove();
int excess = pool.excess();
if (excess > 0) {
closeIdleAsyncConnections(pool, excess);
} else if (excess < 0 && errorCountWithinLimit()) {
// Create connection requests sequentially because they will be done in the
// background and there is no immediate need for them to complete.
new AsyncConnectorExecutor(eventLoop, cluster, this, -excess, 1, null, null);
}
}
Aggregations