You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2015/09/04 03:53:53 UTC
mesos git commit: Updated master to send PingSlaveMessage instead of
"PING".
Repository: mesos
Updated Branches:
refs/heads/master df012a241 -> 43e4446c6
Updated master to send PingSlaveMessage instead of "PING".
Review: https://reviews.apache.org/r/38050
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/43e4446c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/43e4446c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/43e4446c
Branch: refs/heads/master
Commit: 43e4446c648947054b31f52d8256435e0a727c19
Parents: df012a2
Author: Yong Qiao Wang <yq...@cn.ibm.com>
Authored: Thu Sep 3 18:52:34 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Thu Sep 3 18:52:34 2015 -0700
----------------------------------------------------------------------
src/master/master.cpp | 25 +++++++++++++------------
src/tests/partition_tests.cpp | 26 +++++++++++++-------------
src/tests/slave_recovery_tests.cpp | 6 +++---
src/tests/slave_tests.cpp | 18 +++++++++---------
4 files changed, 38 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/43e4446c/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 56bcbcc..5589eca 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -118,7 +118,7 @@ using mesos::master::RoleInfo;
using mesos::master::allocator::Allocator;
-class SlaveObserver : public Process<SlaveObserver>
+class SlaveObserver : public ProtobufProcess<SlaveObserver>
{
public:
SlaveObserver(const UPID& _slave,
@@ -142,9 +142,11 @@ public:
pinged(false),
connected(true)
{
- // TODO(vinod): Deprecate this handler in 0.22.0 in favor of a
- // new PongSlaveMessage handler.
- install("PONG", &SlaveObserver::pong);
+ // TODO(Wang Yong Qiao): For backwards compatibility, this handler is kept.
+ // Suggest to remove this handler in 0.26.0.
+ install("PONG", &SlaveObserver::pongOld);
+
+ install<PongSlaveMessage>(&SlaveObserver::pong);
}
void reconnect()
@@ -165,21 +167,20 @@ protected:
void ping()
{
- // TODO(vinod): In 0.22.0, master should send the PingSlaveMessage
- // instead of sending "PING" with the encoded PingSlaveMessage.
- // Currently we do not do this for backwards compatibility with
- // slaves on 0.20.0.
PingSlaveMessage message;
message.set_connected(connected);
- string data;
- CHECK(message.SerializeToString(&data));
- send(slave, "PING", data.data(), data.size());
+ send(slave, message);
pinged = true;
delay(slavePingTimeout, self(), &SlaveObserver::timeout);
}
- void pong(const UPID& from, const string& body)
+ void pongOld(const UPID& from, const string& body)
+ {
+ pong();
+ }
+
+ void pong()
{
timeouts = 0;
pinged = false;
http://git-wip-us.apache.org/repos/asf/mesos/blob/43e4446c/src/tests/partition_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/partition_tests.cpp b/src/tests/partition_tests.cpp
index b7030ad..9356c0b 100644
--- a/src/tests/partition_tests.cpp
+++ b/src/tests/partition_tests.cpp
@@ -76,10 +76,10 @@ TEST_F(PartitionTest, PartitionedSlave)
// Set these expectations up before we spawn the slave so that we
// don't miss the first PING.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
// Drop all the PONGs to simulate slave partition.
- DROP_MESSAGES(Eq("PONG"), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
Try<PID<Slave>> slave = StartSlave();
ASSERT_SOME(slave);
@@ -118,7 +118,7 @@ TEST_F(PartitionTest, PartitionedSlave)
if (pings == masterFlags.max_slave_ping_timeouts) {
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
}
@@ -160,8 +160,8 @@ TEST_F(PartitionTest, PartitionedSlaveReregistration)
// from the slave. Note that we don't match on the master / slave
// PIDs because it's actually the SlaveObserver Process that sends
// the pings.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
- DROP_MESSAGES(Eq("PONG"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
MockExecutor exec(DEFAULT_EXECUTOR_ID);
@@ -245,7 +245,7 @@ TEST_F(PartitionTest, PartitionedSlaveReregistration)
if (pings == masterFlags.max_slave_ping_timeouts) {
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
Clock::settle();
}
@@ -309,8 +309,8 @@ TEST_F(PartitionTest, PartitionedSlaveStatusUpdates)
// from the slave. Note that we don't match on the master / slave
// PIDs because it's actually the SlaveObserver Process that sends
// the pings.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
- DROP_MESSAGES(Eq("PONG"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
Future<SlaveRegisteredMessage> slaveRegisteredMessage =
FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
@@ -362,7 +362,7 @@ TEST_F(PartitionTest, PartitionedSlaveStatusUpdates)
if (pings == masterFlags.max_slave_ping_timeouts) {
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
Clock::settle();
}
@@ -427,8 +427,8 @@ TEST_F(PartitionTest, PartitionedSlaveExitedExecutor)
// from the slave. Note that we don't match on the master / slave
// PIDs because it's actually the SlaveObserver Process that sends
// the pings.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
- DROP_MESSAGES(Eq("PONG"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
MockExecutor exec(DEFAULT_EXECUTOR_ID);
TestContainerizer containerizer(&exec);
@@ -506,7 +506,7 @@ TEST_F(PartitionTest, PartitionedSlaveExitedExecutor)
if (pings == masterFlags.max_slave_ping_timeouts) {
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
Clock::settle();
}
@@ -556,7 +556,7 @@ TEST_F(PartitionTest, OneWayPartitionMasterToSlave)
FUTURE_MESSAGE(Eq(SlaveRegisteredMessage().GetTypeName()), _, _);
// Ensure a ping reaches the slave.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Try<PID<Slave>> slave = StartSlave();
ASSERT_SOME(slave);
http://git-wip-us.apache.org/repos/asf/mesos/blob/43e4446c/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 4d137e0..234e60d 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -2469,10 +2469,10 @@ TYPED_TEST(SlaveRecoveryTest, PartitionedSlave)
// Set these expectations up before we spawn the slave so that we
// don't miss the first PING.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
// Drop all the PONGs to simulate slave partition.
- DROP_MESSAGES(Eq("PONG"), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
slave::Flags flags = this->CreateSlaveFlags();
@@ -2542,7 +2542,7 @@ TYPED_TEST(SlaveRecoveryTest, PartitionedSlave)
if (pings == masterFlags.max_slave_ping_timeouts) {
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
Clock::settle();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/43e4446c/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 2411918..6bc0cba 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -1508,7 +1508,7 @@ TEST_F(SlaveTest, PingTimeoutNoPings)
ASSERT_SOME(master);
// Block all pings to the slave.
- DROP_MESSAGES(Eq("PING"), _, _);
+ DROP_MESSAGES(Eq(PingSlaveMessage().GetTypeName()), _, _);
Future<SlaveRegisteredMessage> slaveRegisteredMessage =
FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
@@ -1562,7 +1562,7 @@ TEST_F(SlaveTest, PingTimeoutSomePings)
Clock::pause();
// Ensure a ping reaches the slave.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
@@ -1571,7 +1571,7 @@ TEST_F(SlaveTest, PingTimeoutSomePings)
// Now block further pings from the master and advance
// the clock to trigger a re-detection and re-registration on
// the slave.
- DROP_MESSAGES(Eq("PING"), _, _);
+ DROP_MESSAGES(Eq(PingSlaveMessage().GetTypeName()), _, _);
Future<Nothing> detected = FUTURE_DISPATCH(_, &Slave::detected);
@@ -1598,10 +1598,10 @@ TEST_F(SlaveTest, RateLimitSlaveShutdown)
// Set these expectations up before we spawn the slave so that we
// don't miss the first PING.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
// Drop all the PONGs to simulate health check timeout.
- DROP_MESSAGES(Eq("PONG"), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
Future<SlaveRegisteredMessage> slaveRegisteredMessage =
FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
@@ -1631,7 +1631,7 @@ TEST_F(SlaveTest, RateLimitSlaveShutdown)
Clock::advance(masterFlags.slave_ping_timeout);
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
}
@@ -1662,10 +1662,10 @@ TEST_F(SlaveTest, CancelSlaveShutdown)
// Set these expectations up before we spawn the slave so that we
// don't miss the first PING.
- Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ Future<Message> ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
// Drop all the PONGs to simulate health check timeout.
- DROP_MESSAGES(Eq("PONG"), _, _);
+ DROP_MESSAGES(Eq(PongSlaveMessage().GetTypeName()), _, _);
// No shutdown should occur during the test!
EXPECT_NO_FUTURE_PROTOBUFS(ShutdownMessage(), _, _);
@@ -1696,7 +1696,7 @@ TEST_F(SlaveTest, CancelSlaveShutdown)
Clock::advance(masterFlags.slave_ping_timeout);
break;
}
- ping = FUTURE_MESSAGE(Eq("PING"), _, _);
+ ping = FUTURE_MESSAGE(Eq(PingSlaveMessage().GetTypeName()), _, _);
Clock::advance(masterFlags.slave_ping_timeout);
}