| 573 | } |
| 574 | |
| 575 | void backoff() |
| 576 | { |
| 577 | if (state == CONNECTED || state == SUBSCRIBING || state == SUBSCRIBED) { |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | CHECK(state == DISCONNECTED || state == CONNECTING) << state; |
| 582 | |
| 583 | CHECK(checkpoint); |
| 584 | CHECK_SOME(maxBackoff); |
| 585 | |
| 586 | // Linearly backoff by picking a random duration between 0 and |
| 587 | // `maxBackoff`. |
| 588 | Duration backoff = maxBackoff.get() * ((double) os::random() / RAND_MAX); |
| 589 | |
| 590 | VLOG(1) << "Will retry connecting with the agent again in " << backoff; |
| 591 | |
| 592 | connect(); |
| 593 | |
| 594 | delay(backoff, self(), &Self::backoff); |
| 595 | } |
| 596 | |
| 597 | Future<Nothing> _receive() |
| 598 | { |