You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2015/12/10 02:37:01 UTC

mesos git commit: Windows: Added support for `slave/state.cpp`.

Repository: mesos
Updated Branches:
  refs/heads/master 95e48c6cd -> 9759500ef


Windows: Added support for `slave/state.cpp`.

Review: https://reviews.apache.org/r/39219


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9759500e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9759500e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9759500e

Branch: refs/heads/master
Commit: 9759500efd99e75864a6c029949ab20e3c58d267
Parents: 95e48c6
Author: Alex Clemmer <cl...@gmail.com>
Authored: Wed Dec 9 17:18:26 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Dec 9 17:18:26 2015 -0800

----------------------------------------------------------------------
 src/slave/state.cpp | 28 ++++++++++++++++++++--------
 src/slave/state.hpp |  9 ++++++++-
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9759500e/src/slave/state.cpp
----------------------------------------------------------------------
diff --git a/src/slave/state.cpp b/src/slave/state.cpp
index 9e470cb..500b16e 100644
--- a/src/slave/state.cpp
+++ b/src/slave/state.cpp
@@ -14,24 +14,29 @@
 // See the License for the specific language governing permissions and
 // limitations under the License
 
-#include <unistd.h>
-
 #include <glog/logging.h>
 
 #include <iostream>
 
 #include <process/pid.hpp>
 
+#include <stout/check.hpp>
 #include <stout/error.hpp>
 #include <stout/foreach.hpp>
 #include <stout/format.hpp>
 #include <stout/none.hpp>
+#include <stout/nothing.hpp>
 #include <stout/numify.hpp>
-#include <stout/os.hpp>
 #include <stout/path.hpp>
 #include <stout/protobuf.hpp>
 #include <stout/try.hpp>
 
+#include <stout/os/bootid.hpp>
+#include <stout/os/exists.hpp>
+#include <stout/os/ftruncate.hpp>
+#include <stout/os/read.hpp>
+#include <stout/os/realpath.hpp>
+
 #include "messages/messages.hpp"
 
 #include "slave/paths.hpp"
@@ -648,10 +653,13 @@ Try<TaskState> TaskState::recover(
   // NOTE: This is safe even though we ignore partial protobuf read
   // errors above, because the 'fd' is properly set to the end of the
   // last valid update by 'protobuf::read()'.
-  if (ftruncate(fd.get(), offset) != 0) {
+  Try<Nothing> truncated = os::ftruncate(fd.get(), offset);
+
+  if (truncated.isError()) {
     os::close(fd.get());
-    return ErrnoError(
-        "Failed to truncate status updates file '" + path + "'");
+    return Error(
+        "Failed to truncate status updates file '" + path +
+        "': " + truncated.error());
   }
 
   // After reading a non-corrupted updates file, 'record' should be
@@ -726,9 +734,13 @@ Try<ResourcesState> ResourcesState::recover(
   // NOTE: This is safe even though we ignore partial protobuf read
   // errors above, because the 'fd' is properly set to the end of the
   // last valid resource by 'protobuf::read()'.
-  if (ftruncate(fd.get(), offset) != 0) {
+  Try<Nothing> truncated = os::ftruncate(fd.get(), offset);
+
+  if (truncated.isError()) {
     os::close(fd.get());
-    return ErrnoError("Failed to truncate resources file '" + path + "'");
+    return Error(
+      "Failed to truncate resources file '" + path +
+      "': " + truncated.error());
   }
 
   // After reading a non-corrupted resources file, 'record' should be

http://git-wip-us.apache.org/repos/asf/mesos/blob/9759500e/src/slave/state.hpp
----------------------------------------------------------------------
diff --git a/src/slave/state.hpp b/src/slave/state.hpp
index d4235d5..9cc9df2 100644
--- a/src/slave/state.hpp
+++ b/src/slave/state.hpp
@@ -17,7 +17,9 @@
 #ifndef __SLAVE_STATE_HPP__
 #define __SLAVE_STATE_HPP__
 
+#ifndef __WINDOWS__
 #include <unistd.h>
+#endif // __WINDOWS__
 
 #include <vector>
 
@@ -29,13 +31,18 @@
 #include <stout/foreach.hpp>
 #include <stout/hashmap.hpp>
 #include <stout/hashset.hpp>
-#include <stout/os.hpp>
 #include <stout/path.hpp>
 #include <stout/protobuf.hpp>
 #include <stout/strings.hpp>
 #include <stout/utils.hpp>
 #include <stout/uuid.hpp>
 
+#include <stout/os/mkdir.hpp>
+#include <stout/os/mktemp.hpp>
+#include <stout/os/rename.hpp>
+#include <stout/os/rm.hpp>
+#include <stout/os/write.hpp>
+
 #include "messages/messages.hpp"
 
 namespace mesos {