| 445 | } |
| 446 | |
| 447 | void connected( |
| 448 | const id::UUID& _connectionId, |
| 449 | const Future<Connection>& connection1, |
| 450 | const Future<Connection>& connection2) |
| 451 | { |
| 452 | // It is possible that the agent process failed while we have an ongoing |
| 453 | // (re-)connection attempt with the agent. |
| 454 | if (connectionId != _connectionId) { |
| 455 | VLOG(1) << "Ignoring connection attempt from stale connection"; |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | CHECK_EQ(CONNECTING, state); |
| 460 | CHECK_SOME(connectionId); |
| 461 | |
| 462 | if (!connection1.isReady()) { |
| 463 | disconnected(connectionId.get(), |
| 464 | connection1.isFailed() |
| 465 | ? connection1.failure() |
| 466 | : "Subscribe future discarded"); |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | if (!connection2.isReady()) { |
| 471 | disconnected(connectionId.get(), |
| 472 | connection2.isFailed() |
| 473 | ? connection2.failure() |
| 474 | : "Non-subscribe future discarded"); |
| 475 | return; |
| 476 | } |
| 477 | |
| 478 | VLOG(1) << "Connected with the agent"; |
| 479 | |
| 480 | state = CONNECTED; |
| 481 | |
| 482 | connections = Connections {connection1.get(), connection2.get()}; |
| 483 | |
| 484 | connections->subscribe.disconnected() |
| 485 | .onAny(defer(self(), |
| 486 | &Self::disconnected, |
| 487 | connectionId.get(), |
| 488 | "Subscribe connection interrupted")); |
| 489 | |
| 490 | connections->nonSubscribe.disconnected() |
| 491 | .onAny(defer(self(), |
| 492 | &Self::disconnected, |
| 493 | connectionId.get(), |
| 494 | "Non-subscribe connection interrupted")); |
| 495 | |
| 496 | // Cancel the recovery timer if we connected after a disconnection with the |
| 497 | // agent when framework checkpointing is enabled. This ensures that we have |
| 498 | // only one active timer instance at a given point of time. |
| 499 | if (recoveryTimer.isSome()) { |
| 500 | CHECK(checkpoint); |
| 501 | |
| 502 | Clock::cancel(recoveryTimer.get()); |
| 503 | recoveryTimer = None(); |
| 504 | } |
nothing calls this directly
no test coverage detected