303
304
// Start starts the fetcher worker
306
>
if !atomic.CompareAndSwapInt32(
307
>
&f.status,
308
>
common.DaemonStatusInitialized,
309
>
common.DaemonStatusStarted,
310
>
) {
311
return
312
}
313
315
>
f.logger.Info("Replication task fetcher worker started.")
316
}
317
318
// Stop stops the fetcher worker
320
>
if !atomic.CompareAndSwapInt32(
321
>
&f.status,
322
>
common.DaemonStatusStarted,
323
>
common.DaemonStatusStopped,
324
>
) {
325
return
326
}
327
328
>
f.logger.Info("Replication task fetcher worker stopped.")
task_fetcher.go
329
}
330
331
// fetchTasks collects getReplicationTasks request from shards and send out aggregated request to source frontend.
332
>
func (f *replicationTaskFetcherWorker) fetchTasks() {
task_fetcher.go
333
>
timer := time.NewTimer(backoff.Jitter(
334
>
f.config.ReplicationTaskFetcherAggregationInterval(),
335
>
f.config.ReplicationTaskFetcherTimerJitterCoefficient(),
336
>
))
337
>
defer timer.Stop()
338
>
339
>
for {
340
>
select {
341
>
case request := <-f.requestChan:
342
>
f.bufferRequests(request)
343
345
>
// When timer fires, we collect all the requests we have so far and attempt to send them to remote.
346
>
err := f.getMessages()
347
>
if err != nil {
348
timer.Reset(backoff.Jitter(
349
f.config.ReplicationTaskFetcherErrorRetryWait(),
350
f.config.ReplicationTaskFetcherTimerJitterCoefficient(),
351
))
353
timer.Reset(backoff.Jitter(
354
f.config.ReplicationTaskFetcherAggregationInterval(),