@Override protected void doStart() throws Exception { super.doStart(); items.set(new CopyOnWriteArrayList<Sweepable>()); activate(); }
@Override protected void doStop() throws Exception { deactivate(); items.set(null); super.doStop(); }
private void activate() { if (isRunning()) { Scheduler.Task t = scheduler.schedule(this, period, TimeUnit.MILLISECONDS); if (LOG.isDebugEnabled()) LOG.debug("Scheduled in {} ms sweep task {}", period, t); task.set(t); } else { if (LOG.isDebugEnabled()) LOG.debug("Skipping sweep task scheduling"); } }
httpClient.addBean(new Sweeper(httpClient.getScheduler(), SWEEP_PERIOD_MILLIS), true);
@Override protected void doStop() throws Exception { Sweeper sweeper = client.getBean(Sweeper.class); if (sweeper != null && connectionPool instanceof Sweeper.Sweepable) sweeper.remove((Sweeper.Sweepable)connectionPool); super.doStop(); removeBean(connectionPool); }
@Override protected void doStart() throws Exception { this.connectionPool = newConnectionPool(client); addBean(connectionPool); super.doStart(); Sweeper sweeper = client.getBean(Sweeper.class); if (sweeper != null && connectionPool instanceof Sweeper.Sweepable) sweeper.offer((Sweeper.Sweepable)connectionPool); }
httpClient.addBean(new Sweeper(httpClient.getScheduler(), SWEEP_PERIOD_MILLIS), true);
@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }
@Override protected void doStop() throws Exception { deactivate(); items.set(null); super.doStop(); }
private void activate() { if (isRunning()) { Scheduler.Task t = scheduler.schedule(this, period, TimeUnit.MILLISECONDS); if (LOG.isDebugEnabled()) LOG.debug("Scheduled in {} ms sweep task {}", period, t); task.set(t); } else { if (LOG.isDebugEnabled()) LOG.debug("Skipping sweep task scheduling"); } }
@Override protected void doStart() throws Exception { super.doStart(); items.set(new CopyOnWriteArrayList<Sweepable>()); activate(); }
@Override protected void doStop() throws Exception { deactivate(); items.set(null); super.doStop(); }
private void activate() { if (isRunning()) { Scheduler.Task t = scheduler.schedule(this, period, TimeUnit.MILLISECONDS); if (LOG.isDebugEnabled()) LOG.debug("Scheduled in {} ms sweep task {}", period, t); task.set(t); } else { if (LOG.isDebugEnabled()) LOG.debug("Skipping sweep task scheduling"); } }
@Override protected void doStart() throws Exception { super.doStart(); items.set(new CopyOnWriteArrayList<Sweepable>()); activate(); }
@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }
@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }