| 181 | } |
| 182 | |
| 183 | void error(const string& message) |
| 184 | { |
| 185 | // Logically an executor cannot receive any response from an agent if it |
| 186 | // is not connected. Since we have received `error`, we assume we are |
| 187 | // connected and trigger the `connected` callback to enable event delivery. |
| 188 | // This satisfies the invariant of the v1 interface that an executor can |
| 189 | // receive an event only after successfully connecting with the agent. |
| 190 | if (!connected) { |
| 191 | LOG(INFO) << "Implicitly connecting the executor to send an error"; |
| 192 | callbacks.connected(); |
| 193 | connected = true; |
| 194 | } |
| 195 | |
| 196 | Event event; |
| 197 | event.set_type(Event::ERROR); |
| 198 | |
| 199 | Event::Error* error = event.mutable_error(); |
| 200 | |
| 201 | error->set_message(message); |
| 202 | |
| 203 | received(event); |
| 204 | } |
| 205 | |
| 206 | void send(ExecutorDriver* driver, const Call& call) |
| 207 | { |