| 10748 | |
| 10749 | |
| 10750 | void Master::removeSlave( |
| 10751 | Slave* slave, |
| 10752 | const string& message, |
| 10753 | Option<Counter> reason) |
| 10754 | { |
| 10755 | CHECK_NOTNULL(slave); |
| 10756 | |
| 10757 | // It would be better to remove the slave here instead of continuing |
| 10758 | // to mark it unreachable, but probably not worth the complexity. |
| 10759 | if (slaves.markingUnreachable.contains(slave->id)) { |
| 10760 | LOG(WARNING) << "Ignoring removal of agent " << *slave |
| 10761 | << " that is in the process of being marked unreachable"; |
| 10762 | |
| 10763 | return; |
| 10764 | } |
| 10765 | |
| 10766 | if (slaves.markingGone.contains(slave->id)) { |
| 10767 | LOG(WARNING) << "Ignoring removal of agent " << *slave |
| 10768 | << " that is in the process of being marked gone"; |
| 10769 | |
| 10770 | return; |
| 10771 | } |
| 10772 | |
| 10773 | // This should not be possible, but we protect against it anyway for |
| 10774 | // the sake of paranoia. |
| 10775 | if (slaves.removing.contains(slave->id)) { |
| 10776 | LOG(WARNING) << "Ignoring removal of agent " << *slave |
| 10777 | << " that is in the process of being removed"; |
| 10778 | |
| 10779 | return; |
| 10780 | } |
| 10781 | |
| 10782 | slaves.removing.insert(slave->id); |
| 10783 | |
| 10784 | LOG(INFO) << "Removing agent " << *slave << ": " << message; |
| 10785 | |
| 10786 | // Remove this slave from the registrar. Note that we update the |
| 10787 | // registry BEFORE we update the master's in-memory state; this |
| 10788 | // means that until the registry operation has completed, the slave |
| 10789 | // is not considered to be removed (so we might offer its resources |
| 10790 | // to frameworks, etc.). Ensuring that the registry update succeeds |
| 10791 | // before we modify in-memory state ensures that external clients |
| 10792 | // see consistent behavior if the master fails over. |
| 10793 | registrar->apply(Owned<RegistryOperation>(new RemoveSlave(slave->info))) |
| 10794 | .onAny(defer(self(), |
| 10795 | &Self::_removeSlave, |
| 10796 | slave, |
| 10797 | lambda::_1, |
| 10798 | message, |
| 10799 | reason)); |
| 10800 | } |
| 10801 | |
| 10802 | |
| 10803 | void Master::_removeSlave( |