You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/03/20 23:35:58 UTC
[1/2] git commit: Filter all message events in the Master when not
elected.
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 <bm...@twitter.com>
Authored: Tue Mar 18 11:20:24 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
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);
[2/2] git commit: Added cache::erase and cache::size.
Posted by bm...@apache.org.
Added cache::erase and cache::size.
Review: https://reviews.apache.org/r/19375
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/187dc509
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/187dc509
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/187dc509
Branch: refs/heads/master
Commit: 187dc509d1d9e40914a62ba715c11b3e3932623f
Parents: 9009d56
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Tue Mar 18 15:05:14 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Mar 20 15:13:35 2014 -0700
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/cache.hpp | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/187dc509/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
index 2bec13b..67b88bc 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/cache.hpp
@@ -45,7 +45,7 @@ public:
typedef boost::unordered_map<
Key, std::pair<Value, typename list::iterator> > map;
- explicit Cache(int _capacity) : capacity(_capacity) {}
+ explicit Cache(size_t _capacity) : capacity(_capacity) {}
void put(const Key& key, const Value& value)
{
@@ -70,6 +70,22 @@ public:
return None();
}
+ Option<Value> erase(const Key& key)
+ {
+ typename map::iterator i = values.find(key);
+
+ if (i != values.end()) {
+ Value value = i->second.first;
+ keys.erase(i->second.second);
+ values.erase(i);
+ return value;
+ }
+
+ return None();
+ }
+
+ size_t size() const { return keys.size(); }
+
private:
// Not copyable, not assignable.
Cache(const Cache&);
@@ -114,7 +130,7 @@ private:
}
// Size of the cache.
- int capacity;
+ const size_t capacity;
// Cache of values and "pointers" into the least-recently used list.
map values;