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 2014/01/23 19:14:38 UTC
[1/2] git commit: Added more overloads for strings::join().
Updated Branches:
refs/heads/master 1acb9e804 -> d25908334
Added more overloads for strings::join().
Review: https://reviews.apache.org/r/17249
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b963263b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b963263b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b963263b
Branch: refs/heads/master
Commit: b963263b49607b16c9deab8beff1297a999f3f5d
Parents: 1acb9e8
Author: Vinod Kone <vi...@twitter.com>
Authored: Thu Jan 23 10:09:04 2014 -0800
Committer: Vinod Kone <vi...@twitter.com>
Committed: Thu Jan 23 10:10:06 2014 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/strings.hpp | 28 ++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b963263b/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
index 931d8ee..08428b8 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/strings.hpp
@@ -194,13 +194,37 @@ inline std::string join(const std::string& separator,
inline std::string join(const std::string& separator,
const std::string& s1,
const std::string& s2,
- const std::string& s4,
- const std::string& s3)
+ const std::string& s3,
+ const std::string& s4)
{
return s1 + separator + s2 + separator + s3 + separator + s4;
}
+inline std::string join(const std::string& separator,
+ const std::string& s1,
+ const std::string& s2,
+ const std::string& s3,
+ const std::string& s4,
+ const std::string& s5)
+{
+ return s1 + separator + s2 + separator + s3 + separator + s4 + separator + s5;
+}
+
+
+inline std::string join(const std::string& separator,
+ const std::string& s1,
+ const std::string& s2,
+ const std::string& s3,
+ const std::string& s4,
+ const std::string& s5,
+ const std::string& s6)
+{
+ return s1 + separator + s2 + separator + s3 + separator + s4 + separator +
+ s5 + separator + s6;
+}
+
+
// Use duck-typing to join any iterable.
template <typename Iterable>
inline std::string join(const std::string& separator, const Iterable& i)
[2/2] git commit: Fixed slave to checkpoint boot id immediately after
recovery.
Posted by vi...@apache.org.
Fixed slave to checkpoint boot id immediately after recovery.
Review: https://reviews.apache.org/r/17229/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d2590833
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d2590833
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d2590833
Branch: refs/heads/master
Commit: d259083342d205a266322017139fdd66807be41c
Parents: b963263
Author: Vinod Kone <vi...@twitter.com>
Authored: Thu Jan 23 10:09:31 2014 -0800
Committer: Vinod Kone <vi...@twitter.com>
Committed: Thu Jan 23 10:10:07 2014 -0800
----------------------------------------------------------------------
src/slave/paths.hpp | 8 +++---
src/slave/slave.cpp | 44 ++++++++++++++-------------------
src/slave/state.cpp | 27 ++++++++++----------
src/tests/slave_recovery_tests.cpp | 2 +-
4 files changed, 36 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d2590833/src/slave/paths.hpp
----------------------------------------------------------------------
diff --git a/src/slave/paths.hpp b/src/slave/paths.hpp
index b1a56a3..70ee0f3 100644
--- a/src/slave/paths.hpp
+++ b/src/slave/paths.hpp
@@ -62,7 +62,7 @@ const std::string LATEST_SLAVE_PATH =
const std::string SLAVE_PATH =
path::join(ROOT_PATH, "slaves", "%s");
const std::string BOOT_ID_PATH =
- path::join(SLAVE_PATH, BOOT_ID_FILE);
+ path::join(ROOT_PATH, BOOT_ID_FILE);
const std::string SLAVE_INFO_PATH =
path::join(SLAVE_PATH, SLAVE_INFO_FILE);
const std::string FRAMEWORK_PATH =
@@ -113,11 +113,9 @@ inline std::string getLatestSlavePath(const std::string& rootDir)
}
-inline std::string getBootIdPath(
- const std::string& rootDir,
- const SlaveID& slaveId)
+inline std::string getBootIdPath(const std::string& rootDir)
{
- return strings::format(BOOT_ID_PATH, rootDir, slaveId).get();
+ return strings::format(BOOT_ID_PATH, rootDir).get();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/d2590833/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 8b83dac..aeecca0 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -550,15 +550,6 @@ void Slave::registered(const UPID& from, const SlaveID& slaveId)
// Create the slave meta directory.
paths::createSlaveDirectory(metaDir, slaveId);
- // Checkpoint boot ID.
- Try<string> bootId = os::bootId();
- if (bootId.isError()) {
- LOG(ERROR) << "Could not retrieve boot id: " << bootId.error();
- } else {
- const string& path = paths::getBootIdPath(metaDir, slaveId);
- CHECK_SOME(state::checkpoint(path, bootId.get()));
- }
-
// Checkpoint slave info.
const string& path = paths::getSlaveInfoPath(metaDir, slaveId);
@@ -2629,12 +2620,7 @@ void Slave::_checkDiskUsage(const Future<Try<double> >& usage)
Future<Nothing> Slave::recover(const Result<SlaveState>& _state)
{
if (_state.isError()) {
- EXIT(1)
- << "Failed to recover slave state: " << _state.error() << "\n"
- << "To remedy this try the following:\n"
- << (flags.strict
- ? "Restart the slave with '--no-strict' flag (partial recovery)"
- : "rm '" + paths::getLatestSlavePath(metaDir) + "' (no recovery)");
+ return Failure(_state.error());
}
// Convert Result<SlaveState> to Option<SlaveState> for convenience.
@@ -2651,17 +2637,14 @@ Future<Nothing> Slave::recover(const Result<SlaveState>& _state)
// the recovered info.
info.mutable_id()->CopyFrom(state.get().id);
if (flags.recover == "reconnect" && !(info == state.get().info.get())) {
- EXIT(1)
- << "Incompatible slave info detected.\n"
- << "------------------------------------------------------------\n"
- << "Old slave info:\n" << state.get().info.get() << "\n"
- << "------------------------------------------------------------\n"
- << "New slave info:\n" << info << "\n"
- << "------------------------------------------------------------\n"
- << "To properly upgrade the slave do as follows:\n"
- << "Step 1: Start the slave with --recover=cleanup.\n"
- << "Step 2: Wait till the slave kills all executors and shuts down.\n"
- << "Step 3: Start the upgraded slave with --recover=reconnect.\n";
+ return Failure(strings::join(
+ "\n",
+ "Incompatible slave info detected.",
+ "------------------------------------------------------------",
+ "Old slave info:\n" + stringify(state.get().info.get()),
+ "------------------------------------------------------------",
+ "New slave info:\n" + stringify(info),
+ "------------------------------------------------------------"));
}
info = state.get().info.get(); // Recover the slave info.
@@ -2771,6 +2754,15 @@ void Slave::__recover(const Future<Nothing>& future)
CHECK_EQ(RECOVERING, state);
state = DISCONNECTED;
+ // Checkpoint boot ID.
+ Try<string> bootId = os::bootId();
+ if (bootId.isError()) {
+ LOG(ERROR) << "Could not retrieve boot id: " << bootId.error();
+ } else {
+ const string& path = paths::getBootIdPath(metaDir);
+ CHECK_SOME(state::checkpoint(path, bootId.get()));
+ }
+
// Schedule all old slave directories for garbage collection.
// TODO(vinod): Do this as part of recovery. This needs a fix
// in the recovery code, to recover all slaves instead of only
http://git-wip-us.apache.org/repos/asf/mesos/blob/d2590833/src/slave/state.cpp
----------------------------------------------------------------------
diff --git a/src/slave/state.cpp b/src/slave/state.cpp
index 93cde0c..6c382cd 100644
--- a/src/slave/state.cpp
+++ b/src/slave/state.cpp
@@ -39,6 +39,20 @@ Result<SlaveState> recover(const string& rootDir, bool strict)
return None();
}
+ // Did the machine reboot?
+ if (os::exists(paths::getBootIdPath(rootDir))) {
+ Try<string> read = os::read(paths::getBootIdPath(rootDir));
+ if (read.isSome()) {
+ Try<string> id = os::bootId();
+ CHECK_SOME(id);
+
+ if (id.get() != strings::trim(read.get())) {
+ LOG(INFO) << "Slave host rebooted";
+ return None();
+ }
+ }
+ }
+
const std::string& latest = paths::getLatestSlavePath(rootDir);
// Check if the "latest" symlink to a slave directory exists.
@@ -61,19 +75,6 @@ Result<SlaveState> recover(const string& rootDir, bool strict)
SlaveID slaveId;
slaveId.set_value(os::basename(directory.get()).get());
- // Did the machine reboot?
- if (os::exists(paths::getBootIdPath(rootDir, slaveId))) {
- Try<string> read = os::read(paths::getBootIdPath(rootDir, slaveId));
- if (read.isSome()) {
- Try<string> id = os::bootId();
- CHECK_SOME(id);
-
- if (id.get() != strings::trim(read.get())) {
- return None(); // Machine rebooted!
- }
- }
- }
-
Try<SlaveState> state = SlaveState::recover(rootDir, slaveId, strict);
if (state.isError()) {
return Error(state.error());
http://git-wip-us.apache.org/repos/asf/mesos/blob/d2590833/src/tests/slave_recovery_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_recovery_tests.cpp b/src/tests/slave_recovery_tests.cpp
index 5a4c4fc..999e598 100644
--- a/src/tests/slave_recovery_tests.cpp
+++ b/src/tests/slave_recovery_tests.cpp
@@ -1406,7 +1406,7 @@ TYPED_TEST(SlaveRecoveryTest, Reboot)
// Modify the boot ID to simulate a reboot.
ASSERT_SOME(os::write(
- paths::getBootIdPath(paths::getMetaRootDir(flags.work_dir), slaveId),
+ paths::getBootIdPath(paths::getMetaRootDir(flags.work_dir)),
"rebooted! ;)"));
Future<RegisterSlaveMessage> registerSlave =