| 203 | |
| 204 | |
| 205 | void LogProcess::_recover() |
| 206 | { |
| 207 | CHECK_SOME(recovering); |
| 208 | |
| 209 | Future<Owned<Replica>> future = recovering.get(); |
| 210 | |
| 211 | if (!future.isReady()) { |
| 212 | VLOG(2) << "Log recovery failed"; |
| 213 | |
| 214 | // The 'future' here can only be discarded in 'finalize'. |
| 215 | string failure = future.isFailed() ? |
| 216 | future.failure() : |
| 217 | "The future 'recovering' is unexpectedly discarded"; |
| 218 | |
| 219 | // Mark the failure of the recovery. |
| 220 | recovered.fail(failure); |
| 221 | |
| 222 | foreach (process::Promise<Shared<Replica>>* promise, promises) { |
| 223 | promise->fail(failure); |
| 224 | delete promise; |
| 225 | } |
| 226 | promises.clear(); |
| 227 | } else { |
| 228 | VLOG(2) << "Log recovery completed"; |
| 229 | |
| 230 | // Pull out the replica but need to make a copy since we get a |
| 231 | // 'const &' from 'Try::get'. |
| 232 | replica = Owned<Replica>(future.get()).share(); |
| 233 | |
| 234 | // Mark the success of the recovery. |
| 235 | recovered.set(Nothing()); |
| 236 | |
| 237 | foreach (process::Promise<Shared<Replica>>* promise, promises) { |
| 238 | promise->set(replica); |
| 239 | delete promise; |
| 240 | } |
| 241 | promises.clear(); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | |
| 246 | double LogProcess::_recovered() |