Made MASTER_PING_TIMEOUT a function for fixing MESOS-1673. Review: https://reviews.apache.org/r/24339
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/00634d2c Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/00634d2c Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/00634d2c Branch: refs/heads/master Commit: 00634d2c6da4a615d434b58d04958f35ee2b633e Parents: 1909a06 Author: Jie Yu <[email protected]> Authored: Tue Aug 5 14:32:37 2014 -0700 Committer: Jie Yu <[email protected]> Committed: Tue Aug 5 14:54:32 2014 -0700 ---------------------------------------------------------------------- src/master/constants.hpp | 3 +++ src/slave/constants.cpp | 7 +++++-- src/slave/constants.hpp | 11 +++++++---- src/slave/slave.cpp | 8 +++++--- src/tests/slave_tests.cpp | 4 ++-- 5 files changed, 22 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/00634d2c/src/master/constants.hpp ---------------------------------------------------------------------- diff --git a/src/master/constants.hpp b/src/master/constants.hpp index eadc52b..ce7995b 100644 --- a/src/master/constants.hpp +++ b/src/master/constants.hpp @@ -42,6 +42,9 @@ namespace master { // TODO(vinod): Move constants that are only used in flags to // 'master/flags.hpp'. +// TODO(jieyu): Use static functions for all the constants. See more +// details in MESOS-1023. + // Maximum number of slot offers to have outstanding for each framework. extern const int MAX_OFFERS_PER_FRAMEWORK; http://git-wip-us.apache.org/repos/asf/mesos/blob/00634d2c/src/slave/constants.cpp ---------------------------------------------------------------------- diff --git a/src/slave/constants.cpp b/src/slave/constants.cpp index f00300d..4339c7c 100644 --- a/src/slave/constants.cpp +++ b/src/slave/constants.cpp @@ -32,8 +32,6 @@ const Duration EXECUTOR_REREGISTER_TIMEOUT = Seconds(2); const Duration EXECUTOR_SIGNAL_ESCALATION_TIMEOUT = Seconds(3); const Duration STATUS_UPDATE_RETRY_INTERVAL_MIN = Seconds(10); const Duration STATUS_UPDATE_RETRY_INTERVAL_MAX = Minutes(10); -const Duration MASTER_PING_TIMEOUT = - master::SLAVE_PING_TIMEOUT * master::MAX_SLAVE_PING_TIMEOUTS; const Duration REGISTRATION_BACKOFF_FACTOR = Seconds(1); const Duration REGISTER_RETRY_INTERVAL_MAX = Minutes(1); const Duration GC_DELAY = Weeks(1); @@ -53,6 +51,11 @@ const uint16_t DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER = 16; const std::string DEFAULT_EPHEMERAL_PORTS = "[30001-30999]"; #endif +Duration MASTER_PING_TIMEOUT() +{ + return master::SLAVE_PING_TIMEOUT * master::MAX_SLAVE_PING_TIMEOUTS; +} + } // namespace slave { } // namespace internal { } // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/00634d2c/src/slave/constants.hpp ---------------------------------------------------------------------- diff --git a/src/slave/constants.hpp b/src/slave/constants.hpp index bc16fe5..a6bae1e 100644 --- a/src/slave/constants.hpp +++ b/src/slave/constants.hpp @@ -34,6 +34,9 @@ namespace slave { // So we've moved these to have external linkage but perhaps in the future // we can revert this. +// TODO(jieyu): Use static functions for all the constants. See more +// details in MESOS-1023. + extern const Duration EXECUTOR_REGISTRATION_TIMEOUT; extern const Duration EXECUTOR_SHUTDOWN_GRACE_PERIOD; extern const Duration EXECUTOR_REREGISTER_TIMEOUT; @@ -45,10 +48,6 @@ extern const Duration GC_DELAY; extern const Duration DISK_WATCH_INTERVAL; extern const Duration RESOURCE_MONITORING_INTERVAL; -// If no pings received within this timeout, then the slave will -// trigger a re-detection of the master to cause a re-registration. -extern const Duration MASTER_PING_TIMEOUT; - // Default backoff interval used by the slave to wait before registration. extern const Duration REGISTRATION_BACKOFF_FACTOR; @@ -98,6 +97,10 @@ extern const uint16_t DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER; extern const std::string DEFAULT_EPHEMERAL_PORTS; #endif +// If no pings received within this timeout, then the slave will +// trigger a re-detection of the master to cause a re-registration. +Duration MASTER_PING_TIMEOUT(); + } // namespace slave { } // namespace internal { } // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/00634d2c/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index ef921e1..c56cac8 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -590,7 +590,9 @@ void Slave::detected(const Future<Option<MasterInfo> >& _master) Option<MasterInfo> latest; if (_master.isDiscarded()) { - LOG(INFO) << "No pings from master received within " << MASTER_PING_TIMEOUT; + LOG(INFO) << "No pings from master received within " + << MASTER_PING_TIMEOUT(); + latest = None(); master = None(); } else if (_master.get().isNone()) { @@ -789,7 +791,7 @@ void Slave::registered(const UPID& from, const SlaveID& slaveId) Timer::cancel(pingTimer); pingTimer = delay( - MASTER_PING_TIMEOUT, + MASTER_PING_TIMEOUT(), self(), &Slave::pingTimeout, detection); @@ -2346,7 +2348,7 @@ void Slave::ping(const UPID& from, const string& body) Timer::cancel(pingTimer); pingTimer = delay( - MASTER_PING_TIMEOUT, + MASTER_PING_TIMEOUT(), self(), &Slave::pingTimeout, detection); http://git-wip-us.apache.org/repos/asf/mesos/blob/00634d2c/src/tests/slave_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp index 765d8ce..3a7fee6 100644 --- a/src/tests/slave_tests.cpp +++ b/src/tests/slave_tests.cpp @@ -933,7 +933,7 @@ TEST_F(SlaveTest, PingTimeoutNoPings) Future<SlaveReregisteredMessage> slaveReregisteredMessage = FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _); - Clock::advance(slave::MASTER_PING_TIMEOUT); + Clock::advance(slave::MASTER_PING_TIMEOUT()); AWAIT_READY(detected); AWAIT_READY(slaveReregisteredMessage); @@ -976,7 +976,7 @@ TEST_F(SlaveTest, PingTimeoutSomePings) Future<SlaveReregisteredMessage> slaveReregisteredMessage = FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _); - Clock::advance(slave::MASTER_PING_TIMEOUT); + Clock::advance(slave::MASTER_PING_TIMEOUT()); AWAIT_READY(detected); AWAIT_READY(slaveReregisteredMessage);
