| 303 | } |
| 304 | |
| 305 | void detected(const Future<Option<MasterInfo>>& _master) |
| 306 | { |
| 307 | if (!running.load()) { |
| 308 | VLOG(1) << "Ignoring the master change because the driver is not" |
| 309 | << " running!"; |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | CHECK(!_master.isDiscarded()); |
| 314 | |
| 315 | if (_master.isFailed()) { |
| 316 | EXIT(EXIT_FAILURE) << "Failed to detect a master: " << _master.failure(); |
| 317 | } |
| 318 | |
| 319 | if (_master->isSome()) { |
| 320 | master = _master->get(); |
| 321 | } else { |
| 322 | master = None(); |
| 323 | } |
| 324 | |
| 325 | if (connected) { |
| 326 | // There are three cases here: |
| 327 | // 1. The master failed. |
| 328 | // 2. The master failed over to a new master. |
| 329 | // 3. The master failed over to the same master. |
| 330 | // In any case, we will reconnect (possibly immediately), so we |
| 331 | // must notify schedulers of the disconnection. |
| 332 | Stopwatch stopwatch; |
| 333 | if (FLAGS_v >= 1) { |
| 334 | stopwatch.start(); |
| 335 | } |
| 336 | |
| 337 | scheduler->disconnected(driver); |
| 338 | |
| 339 | VLOG(1) << "Scheduler::disconnected took " << stopwatch.elapsed(); |
| 340 | } |
| 341 | |
| 342 | connected = false; |
| 343 | |
| 344 | if (master.isSome()) { |
| 345 | LOG(INFO) << "New master detected at " << master->pid(); |
| 346 | link(master->pid()); |
| 347 | |
| 348 | // Cancel the pending registration timer to avoid spurious attempts |
| 349 | // at reregistration. `Clock::cancel` is idempotent, so this call |
| 350 | // is safe even if no timer is active or pending. |
| 351 | Clock::cancel(frameworkRegistrationTimer); |
| 352 | |
| 353 | if (credential.isSome()) { |
| 354 | // Authenticate with the master. |
| 355 | // TODO(adam-mesos): Consider adding an initial delay like we do for |
| 356 | // slave registration, to combat thundering herds on master failover. |
| 357 | authenticate( |
| 358 | flags.authentication_timeout_min, |
| 359 | std::min( |
| 360 | flags.authentication_timeout_min + |
| 361 | flags.authentication_backoff_factor * 2, |
| 362 | flags.authentication_timeout_max)); |
nothing calls this directly
no test coverage detected