Repository: mesos Updated Branches: refs/heads/master 1fede539e -> 187dc509d
Filter all message events in the Master when not elected. Review: https://reviews.apache.org/r/19374 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9009d564 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9009d564 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9009d564 Branch: refs/heads/master Commit: 9009d564084f31d653afbf03bcdb202b1b7afbd2 Parents: 1fede53 Author: Benjamin Mahler <[email protected]> Authored: Tue Mar 18 11:20:24 2014 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Thu Mar 20 15:13:01 2014 -0700 ---------------------------------------------------------------------- src/master/master.cpp | 44 ++++++++++++++------------------------------ src/master/master.hpp | 1 + 2 files changed, 15 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/9009d564/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index f5d399b..3b28f72 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -61,6 +61,7 @@ using std::vector; using process::wait; // Necessary on some OS's to disambiguate. using process::Clock; using process::Future; +using process::MessageEvent; using process::Owned; using process::PID; using process::Process; @@ -713,6 +714,19 @@ void Master::exited(const UPID& pid) } +void Master::visit(const MessageEvent& event) +{ + // All messages are filtered when non-leading. + if (!elected()) { + LOG(WARNING) << "Dropping '" << event.message->name << "' message since " + << "not elected yet"; + return; + } + + ProtobufProcess<Master>::visit(event); +} + + void Master::fileAttached(const Future<Nothing>& result, const string& path) { if (result.isReady()) { @@ -809,12 +823,6 @@ void Master::registerFramework( return; } - if (!elected()) { - LOG(WARNING) << "Ignoring register framework message from " << from - << " since not elected yet"; - return; - } - if (flags.authenticate && !authenticated.contains(from)) { // This could happen if another authentication request came // through before we are here or if a framework tried to register @@ -889,12 +897,6 @@ void Master::reregisterFramework( return; } - if (!elected()) { - LOG(WARNING) << "Ignoring re-register framework message from " << from - << " since not elected yet"; - return; - } - if (!frameworkInfo.has_id() || frameworkInfo.id() == "") { LOG(ERROR) << "Framework re-registering without an id!"; FrameworkErrorMessage message; @@ -1857,12 +1859,6 @@ void Master::schedulerMessage( void Master::registerSlave(const UPID& from, const SlaveInfo& slaveInfo) { - if (!elected()) { - LOG(WARNING) << "Ignoring register slave message from " - << slaveInfo.hostname() << " since not elected yet"; - return; - } - // Check if this slave is already registered (because it retries). foreachvalue (Slave* slave, slaves.activated) { if (slave->pid == from) { @@ -1904,12 +1900,6 @@ void Master::reregisterSlave( const vector<Task>& tasks, const vector<Archive::Framework>& completedFrameworks) { - if (!elected()) { - LOG(WARNING) << "Ignoring re-register slave message from " - << slaveInfo.hostname() << " since not elected yet"; - return; - } - if (slaveId == "") { LOG(ERROR) << "Shutting down slave " << from << " that re-registered " << "without an id!"; @@ -2356,12 +2346,6 @@ void Master::offer(const FrameworkID& frameworkId, // 'authenticate' message doesn't contain the 'FrameworkID'. void Master::authenticate(const UPID& from, const UPID& pid) { - if (!elected()) { - LOG(WARNING) << "Ignoring authenticate message from " << from - << " since not elected yet"; - return; - } - // Deactivate the framework if it's already registered. foreachvalue (Framework* framework, frameworks.activated) { if (framework->pid == pid) { http://git-wip-us.apache.org/repos/asf/mesos/blob/9009d564/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 0c7c520..a37a2a2 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -197,6 +197,7 @@ protected: virtual void initialize(); virtual void finalize(); virtual void exited(const process::UPID& pid); + virtual void visit(const process::MessageEvent& event); void deactivate(Framework* framework);
