private synchronized static void trackConnections() { Long currentTime = System.currentTimeMillis(); if (connectionCounter.count() == connectionCounter.maxSize()) { Long oldestConnection = connectionCounter.getTailItem(); if (oldestConnection > (currentTime - 4000)) { LOGGER.debug("connection limit reached, throttling " + connectionCounter); try { Thread.sleep(5000 - (currentTime - oldestConnection)); } catch (InterruptedException e) { LOGGER.warn(e.getMessage()); } } } currentTime = System.currentTimeMillis(); connectionCounter.add(currentTime); }
public static void trackConnections() { Long currentTime = System.currentTimeMillis(); if (CONNECTION_COUNTER.count() == CONNECTION_COUNTER.maxSize()) { Long oldestConnection = CONNECTION_COUNTER.getTailItem(); if (oldestConnection > (currentTime - 10000)) { LOGGER.debug("connection limit reached, throttling " + CONNECTION_COUNTER); try { Thread.sleep(11000 - (currentTime - oldestConnection)); } catch (InterruptedException e) { LOGGER.warn(e.getMessage()); } } } currentTime = System.currentTimeMillis(); CONNECTION_COUNTER.add(currentTime); } }
private void trackConnections() { Long currentTime = System.currentTimeMillis(); if (connectionCounter.count() == connectionCounter.maxSize()) { Long oldestConnection = connectionCounter.getTailItem(); if (oldestConnection > (currentTime - 1000)) { LOGGER.debug("connection limit reached, throttling " + connectionCounter); try { Thread.sleep(1100 - (currentTime - oldestConnection)); } catch (InterruptedException e) { LOGGER.warn(e.getMessage()); } } } currentTime = System.currentTimeMillis(); connectionCounter.add(currentTime); }
public static void trackConnections() { Long currentTime = System.currentTimeMillis(); if (CONNECTION_COUNTER.count() == CONNECTION_COUNTER.maxSize()) { Long oldestConnection = CONNECTION_COUNTER.getTailItem(); if (oldestConnection > (currentTime - 15000)) { LOGGER.debug("connection limit reached, throttling " + CONNECTION_COUNTER); try { Thread.sleep(15000 - (currentTime - oldestConnection)); } catch (InterruptedException e) { LOGGER.warn(e.getMessage()); } } } currentTime = System.currentTimeMillis(); CONNECTION_COUNTER.add(currentTime); } }