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 2017/04/24 21:53:47 UTC
[1/2] mesos git commit: Passed `--zk_session_timeout` to ZK master
contender and detector.
Repository: mesos
Updated Branches:
refs/heads/master d1c6173ab -> 97b2507aa
Passed `--zk_session_timeout` to ZK master contender and detector.
Currently `ZooKeeperMasterContender` and `ZooKeeperMasterDetector` use
hardcoded session timeouts and do not respect `--zk_session_timeout`
option. This patch fixes it.
Review: https://reviews.apache.org/r/58421/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8cf5c51d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8cf5c51d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8cf5c51d
Branch: refs/heads/master
Commit: 8cf5c51d1be75d6c3168cd941ccadc98c57ca79c
Parents: d1c6173
Author: Ilya Pronin <ip...@twopensource.com>
Authored: Mon Apr 24 14:53:07 2017 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Apr 24 14:53:07 2017 -0700
----------------------------------------------------------------------
include/mesos/master/contender.hpp | 4 +++-
include/mesos/master/detector.hpp | 4 +++-
src/master/contender/contender.cpp | 7 +++++--
src/master/contender/zookeeper.cpp | 16 +++++++++++-----
src/master/contender/zookeeper.hpp | 5 ++++-
src/master/detector/detector.cpp | 7 +++++--
src/master/detector/zookeeper.cpp | 17 +++++++++++------
src/master/detector/zookeeper.hpp | 5 ++++-
src/master/main.cpp | 4 ++--
src/tests/master_contender_detector_tests.cpp | 8 +++++---
10 files changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/include/mesos/master/contender.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/master/contender.hpp b/include/mesos/master/contender.hpp
index 2c485ef..6392558 100644
--- a/include/mesos/master/contender.hpp
+++ b/include/mesos/master/contender.hpp
@@ -23,6 +23,7 @@
#include <process/future.hpp>
+#include <stout/duration.hpp>
#include <stout/nothing.hpp>
#include <stout/option.hpp>
#include <stout/try.hpp>
@@ -58,7 +59,8 @@ public:
*/
static Try<MasterContender*> create(
const Option<std::string>& zk,
- const Option<std::string>& masterContenderModule = None());
+ const Option<std::string>& masterContenderModule = None(),
+ const Option<Duration>& zkSessionTimeout = None());
/**
* Note that the contender's membership, if obtained, is scheduled
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/include/mesos/master/detector.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/master/detector.hpp b/include/mesos/master/detector.hpp
index f53c7c0..12eabba 100644
--- a/include/mesos/master/detector.hpp
+++ b/include/mesos/master/detector.hpp
@@ -23,6 +23,7 @@
#include <process/future.hpp>
+#include <stout/duration.hpp>
#include <stout/option.hpp>
#include <stout/try.hpp>
@@ -55,7 +56,8 @@ public:
*/
static Try<MasterDetector*> create(
const Option<std::string>& zk,
- const Option<std::string>& masterDetectorModule = None());
+ const Option<std::string>& masterDetectorModule = None(),
+ const Option<Duration>& zkSessionTimeout = None());
virtual ~MasterDetector() = 0;
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/contender/contender.cpp
----------------------------------------------------------------------
diff --git a/src/master/contender/contender.cpp b/src/master/contender/contender.cpp
index cc486a1..ea7453d 100644
--- a/src/master/contender/contender.cpp
+++ b/src/master/contender/contender.cpp
@@ -36,7 +36,8 @@ namespace contender {
Try<MasterContender*> MasterContender::create(
const Option<string>& zk_,
- const Option<string>& masterContenderModule_)
+ const Option<string>& masterContenderModule_,
+ const Option<Duration>& zkSessionTimeout_)
{
if (masterContenderModule_.isSome()) {
return modules::ModuleManager::create<MasterContender>(
@@ -58,7 +59,9 @@ Try<MasterContender*> MasterContender::create(
return Error(
"Expecting a (chroot) path for ZooKeeper ('/' is not supported)");
}
- return new ZooKeeperMasterContender(url.get());
+ return new ZooKeeperMasterContender(
+ url.get(),
+ zkSessionTimeout_.getOrElse(MASTER_CONTENDER_ZK_SESSION_TIMEOUT));
} else if (strings::startsWith(zk, "file://")) {
// Load the configuration out of a file. While Mesos and related
// programs always use <stout/flags> to process the command line
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/contender/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/master/contender/zookeeper.cpp b/src/master/contender/zookeeper.cpp
index 1aa8f53..6801c91 100644
--- a/src/master/contender/zookeeper.cpp
+++ b/src/master/contender/zookeeper.cpp
@@ -46,7 +46,10 @@ class ZooKeeperMasterContenderProcess
: public Process<ZooKeeperMasterContenderProcess>
{
public:
- explicit ZooKeeperMasterContenderProcess(const zookeeper::URL& url);
+ explicit ZooKeeperMasterContenderProcess(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout);
+
explicit ZooKeeperMasterContenderProcess(Owned<zookeeper::Group> group);
virtual ~ZooKeeperMasterContenderProcess();
@@ -68,9 +71,11 @@ private:
};
-ZooKeeperMasterContender::ZooKeeperMasterContender(const zookeeper::URL& url)
+ZooKeeperMasterContender::ZooKeeperMasterContender(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout)
{
- process = new ZooKeeperMasterContenderProcess(url);
+ process = new ZooKeeperMasterContenderProcess(url, sessionTimeout);
spawn(process);
}
@@ -103,9 +108,10 @@ Future<Future<Nothing>> ZooKeeperMasterContender::contend()
ZooKeeperMasterContenderProcess::ZooKeeperMasterContenderProcess(
- const zookeeper::URL& url)
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout)
: ZooKeeperMasterContenderProcess(Owned<Group>(
- new Group(url, MASTER_CONTENDER_ZK_SESSION_TIMEOUT))) {}
+ new Group(url, sessionTimeout))) {}
ZooKeeperMasterContenderProcess::ZooKeeperMasterContenderProcess(
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/contender/zookeeper.hpp
----------------------------------------------------------------------
diff --git a/src/master/contender/zookeeper.hpp b/src/master/contender/zookeeper.hpp
index becb93f..d280222 100644
--- a/src/master/contender/zookeeper.hpp
+++ b/src/master/contender/zookeeper.hpp
@@ -44,7 +44,10 @@ class ZooKeeperMasterContender : public MasterContender
public:
// Creates a contender that uses ZooKeeper to determine (i.e.,
// elect) a leading master.
- explicit ZooKeeperMasterContender(const zookeeper::URL& url);
+ explicit ZooKeeperMasterContender(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout = MASTER_CONTENDER_ZK_SESSION_TIMEOUT);
+
explicit ZooKeeperMasterContender(process::Owned<zookeeper::Group> group);
virtual ~ZooKeeperMasterContender();
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/detector/detector.cpp
----------------------------------------------------------------------
diff --git a/src/master/detector/detector.cpp b/src/master/detector/detector.cpp
index 0ba29ca..9d2e8c4 100644
--- a/src/master/detector/detector.cpp
+++ b/src/master/detector/detector.cpp
@@ -45,7 +45,8 @@ namespace detector {
Try<MasterDetector*> MasterDetector::create(
const Option<string>& zk_,
- const Option<string>& masterDetectorModule_)
+ const Option<string>& masterDetectorModule_,
+ const Option<Duration>& zkSessionTimeout_)
{
if (masterDetectorModule_.isSome()) {
return modules::ModuleManager::create<MasterDetector>(
@@ -67,7 +68,9 @@ Try<MasterDetector*> MasterDetector::create(
return Error(
"Expecting a (chroot) path for ZooKeeper ('/' is not supported)");
}
- return new ZooKeeperMasterDetector(url.get());
+ return new ZooKeeperMasterDetector(
+ url.get(),
+ zkSessionTimeout_.getOrElse(MASTER_DETECTOR_ZK_SESSION_TIMEOUT));
} else if (strings::startsWith(zk, "file://")) {
// Load the configuration out of a file. While Mesos and related
// programs always use <stout/flags> to process the command line
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/detector/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/master/detector/zookeeper.cpp b/src/master/detector/zookeeper.cpp
index a737d24..1cab567 100644
--- a/src/master/detector/zookeeper.cpp
+++ b/src/master/detector/zookeeper.cpp
@@ -56,7 +56,10 @@ class ZooKeeperMasterDetectorProcess
: public Process<ZooKeeperMasterDetectorProcess>
{
public:
- explicit ZooKeeperMasterDetectorProcess(const zookeeper::URL& url);
+ explicit ZooKeeperMasterDetectorProcess(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout);
+
explicit ZooKeeperMasterDetectorProcess(Owned<Group> group);
~ZooKeeperMasterDetectorProcess();
@@ -86,12 +89,12 @@ private:
};
-// TODO(benh): Get ZooKeeper timeout from configuration.
ZooKeeperMasterDetectorProcess::ZooKeeperMasterDetectorProcess(
- const zookeeper::URL& url)
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout)
: ZooKeeperMasterDetectorProcess(Owned<Group>(
new Group(url.servers,
- MASTER_DETECTOR_ZK_SESSION_TIMEOUT,
+ sessionTimeout,
url.path,
url.authentication))) {}
@@ -263,9 +266,11 @@ void ZooKeeperMasterDetectorProcess::fetched(
}
-ZooKeeperMasterDetector::ZooKeeperMasterDetector(const zookeeper::URL& url)
+ZooKeeperMasterDetector::ZooKeeperMasterDetector(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout)
{
- process = new ZooKeeperMasterDetectorProcess(url);
+ process = new ZooKeeperMasterDetectorProcess(url, sessionTimeout);
spawn(process);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/detector/zookeeper.hpp
----------------------------------------------------------------------
diff --git a/src/master/detector/zookeeper.hpp b/src/master/detector/zookeeper.hpp
index 5b531e0..5d0435e 100644
--- a/src/master/detector/zookeeper.hpp
+++ b/src/master/detector/zookeeper.hpp
@@ -46,7 +46,10 @@ class ZooKeeperMasterDetector : public MasterDetector
public:
// Creates a detector which uses ZooKeeper to determine (i.e.,
// elect) a leading master.
- explicit ZooKeeperMasterDetector(const zookeeper::URL& url);
+ explicit ZooKeeperMasterDetector(
+ const zookeeper::URL& url,
+ const Duration& sessionTimeout = MASTER_DETECTOR_ZK_SESSION_TIMEOUT);
+
// Used for testing purposes.
explicit ZooKeeperMasterDetector(process::Owned<zookeeper::Group> group);
virtual ~ZooKeeperMasterDetector();
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index 95a482b..462ed32 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -400,7 +400,7 @@ int main(int argc, char** argv)
MasterDetector* detector;
Try<MasterContender*> contender_ = MasterContender::create(
- flags.zk, flags.master_contender);
+ flags.zk, flags.master_contender, flags.zk_session_timeout);
if (contender_.isError()) {
EXIT(EXIT_FAILURE)
@@ -410,7 +410,7 @@ int main(int argc, char** argv)
contender = contender_.get();
Try<MasterDetector*> detector_ = MasterDetector::create(
- flags.zk, flags.master_detector);
+ flags.zk, flags.master_detector, flags.zk_session_timeout);
if (detector_.isError()) {
EXIT(EXIT_FAILURE)
http://git-wip-us.apache.org/repos/asf/mesos/blob/8cf5c51d/src/tests/master_contender_detector_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_contender_detector_tests.cpp b/src/tests/master_contender_detector_tests.cpp
index c8c1ea0..f499136 100644
--- a/src/tests/master_contender_detector_tests.cpp
+++ b/src/tests/master_contender_detector_tests.cpp
@@ -469,7 +469,9 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, ContenderDetectorShutdownNetwork)
ASSERT_SOME(url);
- ZooKeeperMasterContender contender(url.get());
+ Duration sessionTimeout = Seconds(15);
+
+ ZooKeeperMasterContender contender(url.get(), sessionTimeout);
PID<Master> pid;
pid.address.ip = net::IP(10000000);
@@ -483,7 +485,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, ContenderDetectorShutdownNetwork)
AWAIT_READY(contended);
Future<Nothing> lostCandidacy = contended.get();
- ZooKeeperMasterDetector detector(url.get());
+ ZooKeeperMasterDetector detector(url.get(), sessionTimeout);
Future<Option<MasterInfo>> leader = detector.detect();
AWAIT_READY(leader);
@@ -497,7 +499,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, ContenderDetectorShutdownNetwork)
// We may need to advance multiple times because we could have
// advanced the clock before the timer in Group starts.
while (lostCandidacy.isPending() || leader.isPending()) {
- Clock::advance(MASTER_CONTENDER_ZK_SESSION_TIMEOUT);
+ Clock::advance(sessionTimeout);
Clock::settle();
}
[2/2] mesos git commit: Updated the high availability doc about ZK
session timeout.
Posted by vi...@apache.org.
Updated the high availability doc about ZK session timeout.
Review: https://reviews.apache.org/r/58506/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/97b2507a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/97b2507a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/97b2507a
Branch: refs/heads/master
Commit: 97b2507aa7ad6d74a193e0ef2165ab451b3059fb
Parents: 8cf5c51
Author: Ilya Pronin <ip...@twopensource.com>
Authored: Mon Apr 24 14:53:18 2017 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon Apr 24 14:53:18 2017 -0700
----------------------------------------------------------------------
docs/high-availability.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/97b2507a/docs/high-availability.md
----------------------------------------------------------------------
diff --git a/docs/high-availability.md b/docs/high-availability.md
index 46bd789..1bad0ee 100644
--- a/docs/high-availability.md
+++ b/docs/high-availability.md
@@ -71,4 +71,4 @@ The notion of the group of leader candidates is implemented in `Group`. This abs
* Session Expiration
* ZNode creation, deletion, updates
-We also explicitly timeout our sessions when disconnected from ZooKeeper for a specified amount of time. See `MASTER_CONTENDER_ZK_SESSION_TIMEOUT` and `MASTER_DETECTOR_ZK_SESSION_TIMEOUT`. This is because the ZooKeeper client libraries only notify of session expiration upon reconnection. These timeouts are of particular interest for network partitions.
+We also explicitly timeout our sessions when disconnected from ZooKeeper for a specified amount of time. See `--zk_session_timeout` configuration option. This is because the ZooKeeper client libraries only notify of session expiration upon reconnection. These timeouts are of particular interest for network partitions.