timer.stop();
public MovingAverageRateFactory(Timer timer) { this.avgs = new CopyOnWriteArrayList<SampledMovingAverageRate>(); this.timer = timer; Function0<BoxedUnit> sampleTask = new Function0<BoxedUnit>() { public BoxedUnit apply() { sampleAll(); return null; } }; this.timerTask = timer.schedulePeriodically( Time.now(), Duration.fromSeconds(DEFAULT_INTERVAL_SECS), sampleTask); }
public void start(boolean leader) { logger.info("Starting placement policy"); TreeSet<ServerLoad> emptyServerLoads = new TreeSet<ServerLoad>(); for (String server : getServers()) { emptyServerLoads.add(new ServerLoad(server)); } load(emptyServerLoads); //Pre-Load so streams don't NPE if (leader) { //this is the leader shard logger.info("Shard is leader. Scheduling timed refresh."); placementRefreshTimer = new ScheduledThreadPoolTimer(1, "timer", true); placementRefreshTimer.schedule(Time.now(), refreshInterval, new Function0<BoxedUnit>() { @Override public BoxedUnit apply() { refresh(); return BoxedUnit.UNIT; } }); } else { logger.info("Shard is not leader. Watching for server load changes."); placementStateManager.watch(new PlacementStateManager.PlacementCallback() { @Override public void callback(TreeSet<ServerLoad> serverLoads) { if (!serverLoads.isEmpty()) { load(serverLoads); } } }); } }
SpanRecorder(Reporter<Span> reporter, StatsReceiver stats, Timer timer) { this.reporter = reporter; this.unhandledReceiver = stats.scope("record").scope("unhandled"); this.flusher = timer.schedule(ttl.$div(2L), () -> { flush(ttl.ago()); return null; }); }
SpanRecorder(Reporter<zipkin2.Span> reporter, StatsReceiver stats, Timer timer) { this.reporter = reporter; this.unhandledReceiver = stats.scope("record").scope("unhandled"); this.flusher = timer.schedule(ttl.$div(2L), () -> { flush(ttl.ago()); return null; }); }
public void close() { if (placementRefreshTimer != null) { placementRefreshTimer.stop(); } }
SpanRecorder(Reporter<zipkin2.Span> reporter, StatsReceiver stats, Timer timer) { this.reporter = reporter; this.unhandledReceiver = stats.scope("record").scope("unhandled"); this.flusher = timer.schedule(ttl.$div(2L), () -> { flush(ttl.ago()); return null; }); }
timer.stop(); placementPolicy.close();