| 129 | |
| 130 | |
| 131 | Future<Option<MasterInfo>> ZooKeeperMasterDetectorProcess::detect( |
| 132 | const Option<MasterInfo>& previous) |
| 133 | { |
| 134 | // Return immediately if the detector is no longer operational due |
| 135 | // to a non-retryable error. |
| 136 | if (error.isSome()) { |
| 137 | return Failure(error->message); |
| 138 | } |
| 139 | |
| 140 | if (leader != previous) { |
| 141 | return leader; |
| 142 | } |
| 143 | |
| 144 | Promise<Option<MasterInfo>>* promise = new Promise<Option<MasterInfo>>(); |
| 145 | |
| 146 | promise->future() |
| 147 | .onDiscard(defer(self(), &Self::discard, promise->future())); |
| 148 | |
| 149 | promises.insert(promise); |
| 150 | return promise->future(); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | void ZooKeeperMasterDetectorProcess::detected( |