| 102 | |
| 103 | |
| 104 | void LogProcess::initialize() |
| 105 | { |
| 106 | if (group != nullptr) { |
| 107 | // Need to add our replica to the ZooKeeper group! |
| 108 | LOG(INFO) << "Attempting to join replica to ZooKeeper group"; |
| 109 | |
| 110 | membership = group->join(replica->pid()) |
| 111 | .onFailed(defer(self(), &Self::failed, lambda::_1)) |
| 112 | .onDiscarded(defer(self(), &Self::discarded)); |
| 113 | |
| 114 | // We save and pass the pid of the replica to the 'watch' function |
| 115 | // because the field member 'replica' is not available during |
| 116 | // recovery. We need the pid to renew the replicas membership. |
| 117 | group->watch() |
| 118 | .onReady(defer(self(), &Self::watch, replica->pid(), lambda::_1)) |
| 119 | .onFailed(defer(self(), &Self::failed, lambda::_1)) |
| 120 | .onDiscarded(defer(self(), &Self::discarded)); |
| 121 | } |
| 122 | |
| 123 | // Start the recovery. |
| 124 | recover(); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void LogProcess::finalize() |