| 1673 | |
| 1674 | |
| 1675 | void Slave::registered( |
| 1676 | const UPID& from, |
| 1677 | const SlaveID& slaveId, |
| 1678 | const MasterSlaveConnection& connection) |
| 1679 | { |
| 1680 | if (master != from) { |
| 1681 | LOG(WARNING) << "Ignoring registration message from " << from |
| 1682 | << " because it is not the expected master: " |
| 1683 | << (master.isSome() ? stringify(master.get()) : "None"); |
| 1684 | return; |
| 1685 | } |
| 1686 | |
| 1687 | CHECK_SOME(master); |
| 1688 | |
| 1689 | if (connection.has_total_ping_timeout_seconds()) { |
| 1690 | masterPingTimeout = |
| 1691 | Seconds(static_cast<int64_t>(connection.total_ping_timeout_seconds())); |
| 1692 | } else { |
| 1693 | masterPingTimeout = DEFAULT_MASTER_PING_TIMEOUT(); |
| 1694 | } |
| 1695 | |
| 1696 | switch (state) { |
| 1697 | case DISCONNECTED: { |
| 1698 | LOG(INFO) << "Registered with master " << master.get() |
| 1699 | << "; given agent ID " << slaveId; |
| 1700 | |
| 1701 | state = RUNNING; |
| 1702 | |
| 1703 | // Cancel the pending registration timer to avoid spurious attempts |
| 1704 | // at reregistration. `Clock::cancel` is idempotent, so this call |
| 1705 | // is safe even if no timer is active or pending. |
| 1706 | Clock::cancel(agentRegistrationTimer); |
| 1707 | |
| 1708 | taskStatusUpdateManager->resume(); // Resume status updates. |
| 1709 | |
| 1710 | info.mutable_id()->CopyFrom(slaveId); // Store the slave id. |
| 1711 | |
| 1712 | // Create the slave meta directory. |
| 1713 | paths::createSlaveDirectory(metaDir, slaveId); |
| 1714 | |
| 1715 | // Initialize and resume the operation status update manager. |
| 1716 | // |
| 1717 | // NOTE: There is no need to recover the operation status update manager, |
| 1718 | // because its streams are checkpointed within the slave meta directory |
| 1719 | // which was just created. |
| 1720 | operationStatusUpdateManager.initialize( |
| 1721 | defer(self(), &Self::sendOperationStatusUpdate, lambda::_1), |
| 1722 | std::bind( |
| 1723 | &slave::paths::getSlaveOperationUpdatesPath, |
| 1724 | metaDir, |
| 1725 | info.id(), |
| 1726 | lambda::_1)); |
| 1727 | |
| 1728 | operationStatusUpdateManager.resume(); |
| 1729 | |
| 1730 | // Checkpoint slave info. |
| 1731 | const string path = paths::getSlaveInfoPath(metaDir, slaveId); |
| 1732 |
nothing calls this directly
no test coverage detected