public void startBroadcasting() { // send the first broadcast "right away" (i.e., in 2 gossip heartbeats, when we should have someone to talk to); // after that send every BROADCAST_INTERVAL. Runnable runnable = new Runnable() { public void run() { if (logger.isTraceEnabled()) logger.trace("Disseminating load info ..."); Gossiper.instance.addLocalApplicationState(ApplicationState.LOAD, StorageService.instance.valueFactory.load(StorageMetrics.load.getCount())); } }; ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(runnable, 2 * Gossiper.intervalInMillis, BROADCAST_INTERVAL, TimeUnit.MILLISECONDS); } }
public void startBroadcasting() { // send the first broadcast "right away" (i.e., in 2 gossip heartbeats, when we should have someone to talk to); // after that send every BROADCAST_INTERVAL. Runnable runnable = new Runnable() { public void run() { if (logger.isTraceEnabled()) logger.trace("Disseminating load info ..."); Gossiper.instance.addLocalApplicationState(ApplicationState.LOAD, StorageService.instance.valueFactory.load(StorageMetrics.load.getCount())); } }; ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(runnable, 2 * Gossiper.intervalInMillis, BROADCAST_INTERVAL, TimeUnit.MILLISECONDS); } }
public void startBroadcasting() { // send the first broadcast "right away" (i.e., in 2 gossip heartbeats, when we should have someone to talk to); // after that send every BROADCAST_INTERVAL. Runnable runnable = new Runnable() { public void run() { if (logger.isTraceEnabled()) logger.trace("Disseminating load info ..."); Gossiper.instance.addLocalApplicationState(ApplicationState.LOAD, StorageService.instance.valueFactory.load(StorageMetrics.load.getCount())); } }; ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(runnable, 2 * Gossiper.intervalInMillis, BROADCAST_INTERVAL, TimeUnit.MILLISECONDS); } }
public void startBroadcasting() { // send the first broadcast "right away" (i.e., in 2 gossip heartbeats, when we should have someone to talk to); // after that send every BROADCAST_INTERVAL. Runnable runnable = new Runnable() { public void run() { if (logger.isDebugEnabled()) logger.debug("Disseminating load info ..."); Gossiper.instance.addLocalApplicationState(ApplicationState.LOAD, StorageService.instance.valueFactory.load(StorageService.instance.getLoad())); } }; ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(runnable, 2 * Gossiper.intervalInMillis, BROADCAST_INTERVAL, TimeUnit.MILLISECONDS); } }
public void scheduleSaving(int savePeriodInSeconds, final int keysToSave) { if (saveTask != null) { saveTask.cancel(false); // Do not interrupt an in-progress save saveTask = null; } if (savePeriodInSeconds > 0) { Runnable runnable = new Runnable() { public void run() { submitWrite(keysToSave); } }; saveTask = ScheduledExecutors.optionalTasks.scheduleWithFixedDelay(runnable, savePeriodInSeconds, savePeriodInSeconds, TimeUnit.SECONDS); } }
public synchronized void startDispatch() { if (isShutDown) throw new IllegalStateException("HintsService is shut down and cannot be restarted"); isDispatchPaused.set(false); HintsDispatchTrigger trigger = new HintsDispatchTrigger(catalog, writeExecutor, dispatchExecutor, isDispatchPaused); // triggering hint dispatch is now very cheap, so we can do it more often - every 10 seconds vs. every 10 minutes, // previously; this reduces mean time to delivery, and positively affects batchlog delivery latencies, too triggerDispatchFuture = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(trigger, 10, 10, TimeUnit.SECONDS); }
public synchronized void startDispatch() { if (isShutDown) throw new IllegalStateException("HintsService is shut down and cannot be restarted"); isDispatchPaused.set(false); HintsDispatchTrigger trigger = new HintsDispatchTrigger(catalog, writeExecutor, dispatchExecutor, isDispatchPaused); // triggering hint dispatch is now very cheap, so we can do it more often - every 10 seconds vs. every 10 minutes, // previously; this reduces mean time to delivery, and positively affects batchlog delivery latencies, too triggerDispatchFuture = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(trigger, 10, 10, TimeUnit.SECONDS); }
public static void watch(String resource, Runnable callback, int period) { ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(new WatchedResource(resource, callback), period, period, TimeUnit.MILLISECONDS); }
public static void watch(String resource, Runnable callback, int period) { ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(new WatchedResource(resource, callback), period, period, TimeUnit.MILLISECONDS); }
public static void watch(String resource, Runnable callback, int period) { ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(new WatchedResource(resource, callback), period, period, TimeUnit.MILLISECONDS); }
public synchronized void startDispatch() { if (isShutDown) throw new IllegalStateException("HintsService is shut down and cannot be restarted"); isDispatchPaused.set(false); HintsDispatchTrigger trigger = new HintsDispatchTrigger(catalog, writeExecutor, dispatchExecutor, isDispatchPaused); // triggering hint dispatch is now very cheap, so we can do it more often - every 10 seconds vs. every 10 minutes, // previously; this reduces mean time to delivery, and positively affects batchlog delivery latencies, too triggerDispatchFuture = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(trigger, 10, 10, TimeUnit.SECONDS); }
public static void watch(String resource, Runnable callback, int period) { ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(new WatchedResource(resource, callback), period, period, TimeUnit.MILLISECONDS); }
private MonitoringTask(int reportIntervalMillis, int maxOperations) { this.failedOperationsQueue = new OperationsQueue(maxOperations); this.slowOperationsQueue = new OperationsQueue(maxOperations); this.lastLogTime = ApproximateTime.currentTimeMillis(); logger.info("Scheduling monitoring task with report interval of {} ms, max operations {}", reportIntervalMillis, maxOperations); this.reportingTask = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(() -> logOperations(ApproximateTime.currentTimeMillis()), reportIntervalMillis, reportIntervalMillis, TimeUnit.MILLISECONDS); }
private MonitoringTask(int reportIntervalMillis, int maxOperations) { this.failedOperationsQueue = new OperationsQueue(maxOperations); this.slowOperationsQueue = new OperationsQueue(maxOperations); this.lastLogTime = ApproximateTime.currentTimeMillis(); logger.info("Scheduling monitoring task with report interval of {} ms, max operations {}", reportIntervalMillis, maxOperations); this.reportingTask = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(() -> logOperations(ApproximateTime.currentTimeMillis()), reportIntervalMillis, reportIntervalMillis, TimeUnit.MILLISECONDS); }
private MonitoringTask(int reportIntervalMillis, int maxOperations) { this.failedOperationsQueue = new OperationsQueue(maxOperations); this.slowOperationsQueue = new OperationsQueue(maxOperations); this.lastLogTime = ApproximateTime.currentTimeMillis(); logger.info("Scheduling monitoring task with report interval of {} ms, max operations {}", reportIntervalMillis, maxOperations); this.reportingTask = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(() -> logOperations(ApproximateTime.currentTimeMillis()), reportIntervalMillis, reportIntervalMillis, TimeUnit.MILLISECONDS); }
/** * Start the gossiper with the generation number, preloading the map of application states before starting */ public void start(int generationNbr, Map<ApplicationState, VersionedValue> preloadLocalStates) { buildSeedsList(); /* initialize the heartbeat state for this localEndpoint */ maybeInitializeLocalState(generationNbr); EndpointState localState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); localState.addApplicationStates(preloadLocalStates); //notify snitches that Gossiper is about to start DatabaseDescriptor.getEndpointSnitch().gossiperStarting(); if (logger.isTraceEnabled()) logger.trace("gossip started with generation {}", localState.getHeartBeatState().getGeneration()); scheduledGossipTask = executor.scheduleWithFixedDelay(new GossipTask(), Gossiper.intervalInMillis, Gossiper.intervalInMillis, TimeUnit.MILLISECONDS); }
/** * Start the gossiper with the generation number, preloading the map of application states before starting */ public void start(int generationNbr, Map<ApplicationState, VersionedValue> preloadLocalStates) { buildSeedsList(); /* initialize the heartbeat state for this localEndpoint */ maybeInitializeLocalState(generationNbr); EndpointState localState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); localState.addApplicationStates(preloadLocalStates); //notify snitches that Gossiper is about to start DatabaseDescriptor.getEndpointSnitch().gossiperStarting(); if (logger.isTraceEnabled()) logger.trace("gossip started with generation {}", localState.getHeartBeatState().getGeneration()); scheduledGossipTask = executor.scheduleWithFixedDelay(new GossipTask(), Gossiper.intervalInMillis, Gossiper.intervalInMillis, TimeUnit.MILLISECONDS); }
@VisibleForTesting HintsService(IFailureDetector failureDetector) { File hintsDirectory = DatabaseDescriptor.getHintsDirectory(); int maxDeliveryThreads = DatabaseDescriptor.getMaxHintsDeliveryThreads(); catalog = HintsCatalog.load(hintsDirectory, createDescriptorParams()); writeExecutor = new HintsWriteExecutor(catalog); int bufferSize = Math.max(DatabaseDescriptor.getMaxMutationSize() * 2, MIN_BUFFER_SIZE); bufferPool = new HintsBufferPool(bufferSize, writeExecutor::flushBuffer); isDispatchPaused = new AtomicBoolean(true); dispatchExecutor = new HintsDispatchExecutor(hintsDirectory, maxDeliveryThreads, isDispatchPaused, failureDetector::isAlive); // periodically empty the current content of the buffers int flushPeriod = DatabaseDescriptor.getHintsFlushPeriodInMS(); triggerFlushingFuture = ScheduledExecutors.optionalTasks.scheduleWithFixedDelay(() -> writeExecutor.flushBufferPool(bufferPool), flushPeriod, flushPeriod, TimeUnit.MILLISECONDS); metrics = new HintedHandoffMetrics(); }
@VisibleForTesting HintsService(IFailureDetector failureDetector) { File hintsDirectory = DatabaseDescriptor.getHintsDirectory(); int maxDeliveryThreads = DatabaseDescriptor.getMaxHintsDeliveryThreads(); catalog = HintsCatalog.load(hintsDirectory, createDescriptorParams()); writeExecutor = new HintsWriteExecutor(catalog); int bufferSize = Math.max(DatabaseDescriptor.getMaxMutationSize() * 2, MIN_BUFFER_SIZE); bufferPool = new HintsBufferPool(bufferSize, writeExecutor::flushBuffer); isDispatchPaused = new AtomicBoolean(true); dispatchExecutor = new HintsDispatchExecutor(hintsDirectory, maxDeliveryThreads, isDispatchPaused, failureDetector::isAlive); // periodically empty the current content of the buffers int flushPeriod = DatabaseDescriptor.getHintsFlushPeriodInMS(); triggerFlushingFuture = ScheduledExecutors.optionalTasks.scheduleWithFixedDelay(() -> writeExecutor.flushBufferPool(bufferPool), flushPeriod, flushPeriod, TimeUnit.MILLISECONDS); metrics = new HintedHandoffMetrics(); }
@VisibleForTesting HintsService(IFailureDetector failureDetector) { File hintsDirectory = DatabaseDescriptor.getHintsDirectory(); int maxDeliveryThreads = DatabaseDescriptor.getMaxHintsDeliveryThreads(); catalog = HintsCatalog.load(hintsDirectory, createDescriptorParams()); writeExecutor = new HintsWriteExecutor(catalog); int bufferSize = Math.max(DatabaseDescriptor.getMaxMutationSize() * 2, MIN_BUFFER_SIZE); bufferPool = new HintsBufferPool(bufferSize, writeExecutor::flushBuffer); isDispatchPaused = new AtomicBoolean(true); dispatchExecutor = new HintsDispatchExecutor(hintsDirectory, maxDeliveryThreads, isDispatchPaused, failureDetector::isAlive); // periodically empty the current content of the buffers int flushPeriod = DatabaseDescriptor.getHintsFlushPeriodInMS(); triggerFlushingFuture = ScheduledExecutors.optionalTasks.scheduleWithFixedDelay(() -> writeExecutor.flushBufferPool(bufferPool), flushPeriod, flushPeriod, TimeUnit.MILLISECONDS); metrics = new HintedHandoffMetrics(); }