| 186 | } |
| 187 | |
| 188 | void received(const Event& event) |
| 189 | { |
| 190 | LOG(INFO) << "Received " << event.type() << " event"; |
| 191 | |
| 192 | switch (event.type()) { |
| 193 | case Event::SUBSCRIBED: { |
| 194 | LOG(INFO) << "Subscribed executor on " |
| 195 | << event.subscribed().slave_info().hostname(); |
| 196 | |
| 197 | frameworkInfo = event.subscribed().framework_info(); |
| 198 | state = SUBSCRIBED; |
| 199 | break; |
| 200 | } |
| 201 | |
| 202 | case Event::LAUNCH: { |
| 203 | launch(event.launch().task()); |
| 204 | break; |
| 205 | } |
| 206 | |
| 207 | case Event::LAUNCH_GROUP: { |
| 208 | LOG(ERROR) << "LAUNCH_GROUP event is not supported"; |
| 209 | // Shut down because this is unexpected; `LAUNCH_GROUP` event |
| 210 | // should only ever go to a group-capable default executor and |
| 211 | // not the command executor. |
| 212 | shutdown(); |
| 213 | break; |
| 214 | } |
| 215 | |
| 216 | case Event::KILL: { |
| 217 | Option<KillPolicy> override = event.kill().has_kill_policy() |
| 218 | ? Option<KillPolicy>(event.kill().kill_policy()) |
| 219 | : None(); |
| 220 | |
| 221 | kill(event.kill().task_id(), override); |
| 222 | break; |
| 223 | } |
| 224 | |
| 225 | case Event::ACKNOWLEDGED: { |
| 226 | const id::UUID uuid = |
| 227 | id::UUID::fromBytes(event.acknowledged().uuid()).get(); |
| 228 | |
| 229 | if (!unacknowledgedUpdates.contains(uuid)) { |
| 230 | LOG(WARNING) << "Received acknowledgement " << uuid |
| 231 | << " for unknown status update"; |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | // Terminate if we receive the ACK for the terminal status update. |
| 236 | // NOTE: The executor receives an ACK iff it uses the HTTP library. |
| 237 | // No ACK will be received if V0ToV1Adapter is used. |
| 238 | if (mesos::internal::protobuf::isTerminalState( |
| 239 | unacknowledgedUpdates[uuid].status().state())) { |
| 240 | terminate(self()); |
| 241 | } |
| 242 | |
| 243 | // Remove the corresponding update. |
| 244 | unacknowledgedUpdates.erase(uuid); |
| 245 |
nothing calls this directly
no test coverage detected