| 921 | |
| 922 | |
| 923 | void GroupProcess::retry(const Duration& duration) |
| 924 | { |
| 925 | if (!retrying) { |
| 926 | // Retry could be cancelled before it is scheduled. |
| 927 | return; |
| 928 | } |
| 929 | |
| 930 | // We cancel the retries when the group aborts and when its ZK |
| 931 | // session expires so 'retrying' should be false in the condition |
| 932 | // check above. |
| 933 | CHECK_NONE(error); |
| 934 | |
| 935 | // In order to be retrying, we should be at least CONNECTED. |
| 936 | CHECK(state == CONNECTED || state == AUTHENTICATED || state == READY) |
| 937 | << state; |
| 938 | |
| 939 | // Will reset it to true if another retry is necessary. |
| 940 | retrying = false; |
| 941 | |
| 942 | Try<bool> synced = sync(); |
| 943 | |
| 944 | if (synced.isError()) { |
| 945 | // Non-retryable error. Abort. |
| 946 | abort(synced.error()); |
| 947 | } else if (!synced.get()) { |
| 948 | // Backoff and keep retrying. |
| 949 | retrying = true; |
| 950 | Seconds seconds = std::min(duration * 2, Duration(Seconds(60))); |
| 951 | delay(seconds, self(), &GroupProcess::retry, seconds); |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | |
| 956 | void GroupProcess::abort(const string& message) |