Exhausted pool handling fixed

pull/38/head
Nikita
parent d7bd997e31
commit 9e6ee8dadc

@ -46,12 +46,12 @@ abstract class BaseLoadBalancer implements LoadBalancer {
List<ConnectionEntry> clientsCopy = new ArrayList<ConnectionEntry>(clients); List<ConnectionEntry> clientsCopy = new ArrayList<ConnectionEntry>(clients);
while (true) { while (true) {
if (clientsCopy.isEmpty()) { if (clientsCopy.isEmpty()) {
log.warn("Slave connection pool gets exhausted! Trying to acquire connection ..."); // TODO refactor
long time = System.currentTimeMillis(); log.warn("Slave subscribe-connection pool gets exhausted! Trying to acquire connection again...");
// TODO wait return nextPubSubConnection();
//entry.getPoolSize().acquireUninterruptibly(); // long time = System.currentTimeMillis();
long endTime = System.currentTimeMillis() - time; // long endTime = System.currentTimeMillis() - time;
log.warn("Connection acquired, time spended: {} ms", endTime); // log.warn("Connection acquired, time spended: {} ms", endTime);
} }
int index = getIndex(clientsCopy); int index = getIndex(clientsCopy);
@ -77,12 +77,12 @@ abstract class BaseLoadBalancer implements LoadBalancer {
List<ConnectionEntry> clientsCopy = new ArrayList<ConnectionEntry>(clients); List<ConnectionEntry> clientsCopy = new ArrayList<ConnectionEntry>(clients);
while (true) { while (true) {
if (clientsCopy.isEmpty()) { if (clientsCopy.isEmpty()) {
// TODO refactor
log.warn("Slave connection pool gets exhausted! Trying to acquire connection ..."); log.warn("Slave connection pool gets exhausted! Trying to acquire connection ...");
long time = System.currentTimeMillis(); return nextConnection();
// TODO wait // long time = System.currentTimeMillis();
//entry.getPoolSize().acquireUninterruptibly(); // long endTime = System.currentTimeMillis() - time;
long endTime = System.currentTimeMillis() - time; // log.warn("Connection acquired, time spended: {} ms", endTime);
log.warn("Connection acquired, time spended: {} ms", endTime);
} }
int index = getIndex(clientsCopy); int index = getIndex(clientsCopy);

Loading…
Cancel
Save