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 2016/03/11 18:05:15 UTC

[1/8] mesos git commit: CMake: [1/3] Added zlib definitions for Windows.

Repository: mesos
Updated Branches:
  refs/heads/master 5ea02aea2 -> ace12c097


CMake: [1/3] Added zlib definitions for Windows.

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


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

Branch: refs/heads/master
Commit: 4a4925c141ed8e737f2be9bb1c146849f79b90f4
Parents: 5ea02ae
Author: Dario Bazan <da...@gmail.com>
Authored: Fri Mar 11 11:28:40 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:02:24 2016 -0500

----------------------------------------------------------------------
 3rdparty/cmake/Versions.cmake    | 1 +
 cmake/CompilationConfigure.cmake | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4a4925c1/3rdparty/cmake/Versions.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/cmake/Versions.cmake b/3rdparty/cmake/Versions.cmake
index 6eac4dc..24490d3 100644
--- a/3rdparty/cmake/Versions.cmake
+++ b/3rdparty/cmake/Versions.cmake
@@ -11,3 +11,4 @@ set(LIBEVENT_VERSION    "2.1.5-beta")
 set(PICOJSON_VERSION    "1.3.0")
 set(PROTOBUF_VERSION    "2.5.0")
 set(ZOOKEEPER_VERSION   "3.4.5")
+set(ZLIB_VERSION        "1.2.8")

http://git-wip-us.apache.org/repos/asf/mesos/blob/4a4925c1/cmake/CompilationConfigure.cmake
----------------------------------------------------------------------
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index f491901..5c7833c 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -93,6 +93,7 @@ endif (WIN32)
 # the clearest and most stable way of accomplishing this.
 if (WIN32)
   add_definitions(-D__WINDOWS__)
+  add_definitions(-DHAVE_LIBZ)
 endif (WIN32)
 
 


[2/8] mesos git commit: CMake: [2/3] Added zlib compilation steps for Windows.

Posted by jo...@apache.org.
CMake: [2/3] Added zlib compilation steps for Windows.

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


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

Branch: refs/heads/master
Commit: fe436bcece30383935c79f75d3085e98e9d7091c
Parents: 4a4925c
Author: Dario Bazan <da...@gmail.com>
Authored: Fri Mar 11 11:28:45 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:03:15 2016 -0500

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/CMakeLists.txt     | 10 ++++++++++
 .../cmake/Process3rdpartyConfigure.cmake        |  7 +++++++
 .../libprocess/cmake/ProcessConfigure.cmake     | 21 ++++++++++++++++++++
 3 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/fe436bce/3rdparty/libprocess/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/CMakeLists.txt b/3rdparty/libprocess/3rdparty/CMakeLists.txt
index b8351ad..6b07aef 100644
--- a/3rdparty/libprocess/3rdparty/CMakeLists.txt
+++ b/3rdparty/libprocess/3rdparty/CMakeLists.txt
@@ -56,6 +56,7 @@ if (WIN32)
   set(GLOG_URL   ${UPSTREAM_URL}/glog-v0.3.4-g4d391fe.tar.gz)
   set(CURL_URL   ${UPSTREAM_URL}/curl-${CURL_VERSION}.tar.gz)
   set(LIBAPR_URL ${UPSTREAM_URL}/libapr-${LIBAPR_VERSION}.tar.gz)
+  set(ZLIB_URL   ${UPSTREAM_URL}/zlib-${ZLIB_VERSION}.tar.gz)
 endif (WIN32)
 
 # Define build/patch/configure commands for third-party libs.
@@ -220,6 +221,15 @@ if (WIN32)
     INSTALL_COMMAND   ${CMAKE_NOOP}
     URL               ${CURL_URL}
   )
+
+  ExternalProject_Add(
+    ${ZLIB_TARGET}
+    PREFIX          ${ZLIB_CMAKE_ROOT}
+    CMAKE_ARGS      -DBUILD_SHARED_LIBS=OFF
+    BUILD_COMMAND   ${GLOG_BUILD_CMD}
+    INSTALL_COMMAND ${CMAKE_NOOP}
+    URL             ${ZLIB_URL}
+  )
 endif (WIN32)
 
 # THIRD-PARTY LIBRARIES FOR TESTS.

http://git-wip-us.apache.org/repos/asf/mesos/blob/fe436bce/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake b/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake
index e42cf19..7b53a49 100644
--- a/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake
+++ b/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake
@@ -40,6 +40,8 @@ elseif (WIN32)
   # package manager), but Windows has no package manager, so we have to go
   # get it.
   EXTERNAL("curl" ${CURL_VERSION} "${PROCESS_3RD_BIN}")
+
+  EXTERNAL("zlib" ${ZLIB_VERSION} "${PROCESS_3RD_BIN}")
 endif (NOT WIN32)
 
 # Intermediate convenience variables for oddly-structured directories.
@@ -65,6 +67,7 @@ if (WIN32)
   set(LIBEVENT_INCLUDE_DIR
     ${LIBEVENT_ROOT}/include
     ${LIBEVENT_ROOT}-build/include)
+  set(ZLIB_INCLUDE_DIR     ${ZLIB_ROOT} ${ZLIB_ROOT}-build)
 else (WIN32)
   set(GLOG_INCLUDE_DIR     ${GLOG_LIB_ROOT}/include)
   set(PROTOBUF_INCLUDE_DIR ${PROTOBUF_LIB_ROOT}/include)
@@ -80,6 +83,7 @@ if (WIN32)
   set(GLOG_LIB_DIR        ${GLOG_ROOT}-build/${CMAKE_BUILD_TYPE})
   set(LIBEVENT_LIB_DIR    ${LIBEVENT_ROOT}-build/lib)
   set(PROTOBUF_LIB_DIR    ${PROTOBUF_ROOT}-build/${CMAKE_BUILD_TYPE})
+  set(ZLIB_LIB_DIR        ${ZLIB_ROOT}-build/${CMAKE_BUILD_TYPE})
 else (WIN32)
   set(HTTP_PARSER_LIB_DIR ${HTTP_PARSER_ROOT}-build)
   set(GLOG_LIB_DIR        ${GLOG_LIB_ROOT}/lib)
@@ -102,6 +106,9 @@ if (WIN32)
   # the library names are generated correctly.
   set(CURL_LFLAG     libcurl)
   set(PROTOBUF_LFLAG libprotobufd)
+
+  # Windows requires a static build of zlib.
+  set(ZLIB_LFLAG     zlibstaticd)
 else (WIN32)
   set(CURL_LFLAG     curl)
   set(DL_LFLAG       dl)

http://git-wip-us.apache.org/repos/asf/mesos/blob/fe436bce/3rdparty/libprocess/cmake/ProcessConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/cmake/ProcessConfigure.cmake b/3rdparty/libprocess/cmake/ProcessConfigure.cmake
index 61edad9..afdb1fe 100755
--- a/3rdparty/libprocess/cmake/ProcessConfigure.cmake
+++ b/3rdparty/libprocess/cmake/ProcessConfigure.cmake
@@ -59,6 +59,13 @@ elseif (ENABLE_LIBEVENT)
   set(PROCESS_DEPENDENCIES ${PROCESS_DEPENDENCIES} ${LIBEVENT_TARGET})
 endif (NOT ENABLE_LIBEVENT)
 
+if (WIN32)
+  set(PROCESS_DEPENDENCIES
+    ${PROCESS_DEPENDENCIES}
+    ${GZIP_TARGET}
+    )
+endif (WIN32)
+
 # Define third-party include directories. Tells compiler toolchain where to get
 # headers for our third party libs (e.g., -I/path/to/glog on Linux).
 ###############################################################################
@@ -79,6 +86,13 @@ if (HAS_GPERFTOOLS)
   set(PROCESS_INCLUDE_DIRS ${PROCESS_INCLUDE_DIRS} ${GPERFTOOLS_INCLUDE_DIR})
 endif (HAS_GPERFTOOLS)
 
+if (WIN32)
+  set(PROCESS_INCLUDE_DIRS
+    ${PROCESS_INCLUDE_DIRS}
+    ${ZLIB_INCLUDE_DIR}
+  )
+endif (WIN32)
+
 # Define third-party lib install directories. Used to tell the compiler
 # toolchain where to find our third party libs (e.g., -L/path/to/glog on
 # Linux).
@@ -95,6 +109,13 @@ elseif (ENABLE_LIBEVENT)
   set(PROCESS_LIB_DIRS ${PROCESS_LIB_DIRS} ${LIBEVENT_LIB_DIR})
 endif (NOT ENABLE_LIBEVENT)
 
+if (WIN32)
+  set(PROCESS_LIB_DIRS
+    ${PROCESS_LIB_DIRS}
+    ${ZLIB_LIB_DIR}
+    )
+endif (WIN32)
+
 # Define third-party libs. Used to generate flags that the linker uses to
 # include our third-party libs (e.g., -lglog on Linux).
 #########################################################################


[5/8] mesos git commit: Windows: Libevent: Used `evutil_socket_t` typedef for sockets.

Posted by jo...@apache.org.
Windows: Libevent: Used `evutil_socket_t` typedef for sockets.

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


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

Branch: refs/heads/master
Commit: ae873f298df2d9aa978a4f53b4403e9f48064132
Parents: 8806544
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:29:13 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:03:59 2016 -0500

----------------------------------------------------------------------
 3rdparty/libprocess/src/libevent.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ae873f29/3rdparty/libprocess/src/libevent.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent.cpp b/3rdparty/libprocess/src/libevent.cpp
index c787fa9..c4a8da8 100644
--- a/3rdparty/libprocess/src/libevent.cpp
+++ b/3rdparty/libprocess/src/libevent.cpp
@@ -40,7 +40,7 @@ std::queue<lambda::function<void()>>* functions =
 THREAD_LOCAL bool* _in_event_loop_ = NULL;
 
 
-void async_function(int socket, short which, void* arg)
+void async_function(evutil_socket_t socket, short which, void* arg)
 {
   event* ev = reinterpret_cast<event*>(arg);
   event_free(ev);
@@ -128,7 +128,7 @@ struct Delay
   event* timer;
 };
 
-void handle_delay(int, short, void* arg)
+void handle_delay(evutil_socket_t, short, void* arg)
 {
   Delay* delay = reinterpret_cast<Delay*>(arg);
   delay->function();


[4/8] mesos git commit: Windows: Fixed `UUID::random` and added utime/touch to stout/os.hpp.

Posted by jo...@apache.org.
Windows: Fixed `UUID::random` and added utime/touch to stout/os.hpp.

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


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

Branch: refs/heads/master
Commit: 8806544b336555479904427bf50b5961549ba1fb
Parents: 7b8d989
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:28:59 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:03:47 2016 -0500

----------------------------------------------------------------------
 .../libprocess/3rdparty/stout/include/stout/os.hpp   |  2 ++
 .../3rdparty/stout/include/stout/posix/os.hpp        |  2 --
 .../libprocess/3rdparty/stout/include/stout/uuid.hpp |  4 ++++
 .../3rdparty/stout/include/stout/windows.hpp         | 15 ++++++++++++++-
 4 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8806544b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index a3c21e4..79e30ca 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -56,6 +56,8 @@
 #include <stout/os/shell.hpp>
 #include <stout/os/stat.hpp>
 #include <stout/os/su.hpp>
+#include <stout/os/touch.hpp>
+#include <stout/os/utime.hpp>
 
 // For readability, we minimize the number of #ifdef blocks in the code by
 // splitting platform specifc system calls into separate directories.

http://git-wip-us.apache.org/repos/asf/mesos/blob/8806544b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
index 0b23957..9ee233b 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
@@ -64,8 +64,6 @@
 #include <stout/os/sendfile.hpp>
 #include <stout/os/signals.hpp>
 #include <stout/os/strerror.hpp>
-#include <stout/os/touch.hpp>
-#include <stout/os/utime.hpp>
 #include <stout/os/write.hpp>
 
 #ifdef __FreeBSD__

http://git-wip-us.apache.org/repos/asf/mesos/blob/8806544b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
index 6256365..e3cf21f 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/uuid.hpp
@@ -24,6 +24,10 @@
 
 #include <stout/thread_local.hpp>
 
+#ifdef __WINDOWS__
+#include <stout/windows.hpp>
+#endif // __WINDOWS__
+
 // NOTE: This namespace is necessary because the standard Windows headers
 // define a UUID struct in the global namespace for the DCE RPC API. We put
 // this in the `id::` namespace to avoid collisions. Note also that we include

http://git-wip-us.apache.org/repos/asf/mesos/blob/8806544b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
index d3ba0b4..ee13d12 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
@@ -112,7 +112,20 @@ inline BOOL GetMessage(
 {
   return GetMessageWindows(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
 }
-#endif
+#endif // GetMessage
+
+
+// Zookeeper's native `winconfig.h` defines a macro `random` to point at
+// `rand`. This inteferes with `UUID::rand`, so we redfine it as a global
+// function in a manner similar to the `GetMessage` macro above. See the
+// accompanying comment for rationale.
+#ifdef random
+#undef random
+inline int random()
+{
+  return rand();
+}
+#endif // random
 
 
 // Define constants used for Windows compat. Allows a lot of code on


[3/8] mesos git commit: CMake: [3/3] Enabled zlib compression tests.

Posted by jo...@apache.org.
CMake: [3/3] Enabled zlib compression tests.

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


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

Branch: refs/heads/master
Commit: 7b8d98950558ce8f87af55a094d01b0b624e72f5
Parents: fe436bc
Author: Dario Bazan <da...@gmail.com>
Authored: Fri Mar 11 11:28:52 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:03:28 2016 -0500

----------------------------------------------------------------------
 .../3rdparty/stout/cmake/StoutConfigure.cmake   |   4 +
 .../3rdparty/stout/include/Makefile.am          |   2 -
 .../3rdparty/stout/include/stout/gzip.hpp       | 137 ++++++++++++++++-
 .../3rdparty/stout/include/stout/posix/gzip.hpp | 149 -------------------
 .../stout/include/stout/windows/gzip.hpp        |  46 ------
 .../3rdparty/stout/tests/CMakeLists.txt         |   2 +-
 6 files changed, 135 insertions(+), 205 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake b/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
index 40482e6..aa28c1b 100644
--- a/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
+++ b/3rdparty/libprocess/3rdparty/stout/cmake/StoutConfigure.cmake
@@ -42,6 +42,7 @@ if (WIN32)
   set(STOUT_DEPENDENCIES
     ${STOUT_DEPENDENCIES}
     ${CURL_TARGET}
+    ${ZLIB_TARGET}
     )
 endif (WIN32)
 
@@ -64,6 +65,7 @@ if (WIN32)
   set(STOUT_INCLUDE_DIRS
     ${STOUT_INCLUDE_DIRS}
     ${CURL_INCLUDE_DIR}
+    ${ZLIB_INCLUDE_DIR}
     )
 endif (WIN32)
 
@@ -83,6 +85,7 @@ if (WIN32)
   set(STOUT_LIB_DIRS
     ${STOUT_LIB_DIRS}
     ${CURL_LIB_DIR}
+    ${ZLIB_LIB_DIR}
     )
 endif (WIN32)
 
@@ -101,6 +104,7 @@ set(STOUT_LIBS
 if (WIN32)
   set(STOUT_LIBS
     ${STOUT_LIBS}
+    ${ZLIB_LFLAG}
     ws2_32
     Mswsock
     )

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index c10c6d9..d713f18 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -138,7 +138,6 @@ nobase_include_HEADERS =		\
   stout/protobuf.hpp			\
   stout/posix/dynamiclibrary.hpp	\
   stout/posix/fs.hpp			\
-  stout/posix/gzip.hpp			\
   stout/posix/os.hpp			\
   stout/recordio.hpp			\
   stout/representation.hpp			\
@@ -165,5 +164,4 @@ nobase_include_HEADERS =		\
   stout/windows/error.hpp		\
   stout/windows/format.hpp		\
   stout/windows/fs.hpp			\
-  stout/windows/gzip.hpp		\
   stout/windows/os.hpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
index 3d074a5..b78a8a3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
@@ -13,14 +13,137 @@
 #ifndef __STOUT_GZIP_HPP__
 #define __STOUT_GZIP_HPP__
 
+#include <zlib.h>
 
-// For readability, we minimize the number of #ifdef blocks in the code by
-// splitting platform specifc system calls into separate directories.
-#ifdef __WINDOWS__
-#include <stout/windows/gzip.hpp>
-#else
-#include <stout/posix/gzip.hpp>
-#endif // __WINDOWS__
+#include <string>
 
+#include <stout/error.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
+
+
+// Compression utilities.
+// TODO(bmahler): Provide streaming compression / decompression as well.
+namespace gzip {
+
+// We use a 16KB buffer with zlib compression / decompression.
+#define GZIP_BUFFER_SIZE 16384
+
+// Returns a gzip compressed version of the provided string.
+// The compression level should be within the range [-1, 9].
+// See zlib.h:
+//   #define Z_NO_COMPRESSION         0
+//   #define Z_BEST_SPEED             1
+//   #define Z_BEST_COMPRESSION       9
+//   #define Z_DEFAULT_COMPRESSION  (-1)
+inline Try<std::string> compress(
+    const std::string& decompressed,
+    int level = Z_DEFAULT_COMPRESSION)
+{
+  // Verify the level is within range.
+  if (!(level == Z_DEFAULT_COMPRESSION ||
+      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
+    return Error("Invalid compression level: " + stringify(level));
+  }
+
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
+  stream.avail_in = decompressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = deflateInit2(
+      &stream,
+      level,          // Compression level.
+      Z_DEFLATED,     // Compression method.
+      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
+      8,              // Default memLevel value.
+      Z_DEFAULT_STRATEGY);
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the compressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      deflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = deflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+
+// Returns a gzip decompressed version of the provided string.
+inline Try<std::string> decompress(const std::string& compressed)
+{
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
+  stream.avail_in = compressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = inflateInit2(
+      &stream,
+      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the decompressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      inflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = inflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+} // namespace gzip {
 
 #endif // __STOUT_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
deleted file mode 100644
index eb52beb..0000000
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
+++ /dev/null
@@ -1,149 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//  http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef __STOUT_POSIX_GZIP_HPP__
-#define __STOUT_POSIX_GZIP_HPP__
-
-#include <zlib.h>
-
-#include <string>
-
-#include <stout/error.hpp>
-#include <stout/stringify.hpp>
-#include <stout/try.hpp>
-
-
-// Compression utilities.
-// TODO(bmahler): Provide streaming compression / decompression as well.
-namespace gzip {
-
-// We use a 16KB buffer with zlib compression / decompression.
-#define GZIP_BUFFER_SIZE 16384
-
-// Returns a gzip compressed version of the provided string.
-// The compression level should be within the range [-1, 9].
-// See zlib.h:
-//   #define Z_NO_COMPRESSION         0
-//   #define Z_BEST_SPEED             1
-//   #define Z_BEST_COMPRESSION       9
-//   #define Z_DEFAULT_COMPRESSION  (-1)
-inline Try<std::string> compress(
-    const std::string& decompressed,
-    int level = Z_DEFAULT_COMPRESSION)
-{
-  // Verify the level is within range.
-  if (!(level == Z_DEFAULT_COMPRESSION ||
-      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
-    return Error("Invalid compression level: " + stringify(level));
-  }
-
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
-  stream.avail_in = decompressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = deflateInit2(
-      &stream,
-      level,          // Compression level.
-      Z_DEFLATED,     // Compression method.
-      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
-      8,              // Default memLevel value.
-      Z_DEFAULT_STRATEGY);
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the compressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      deflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = deflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-
-// Returns a gzip decompressed version of the provided string.
-inline Try<std::string> decompress(const std::string& compressed)
-{
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
-  stream.avail_in = compressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = inflateInit2(
-      &stream,
-      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the decompressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      inflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = inflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-} // namespace gzip {
-
-#endif // __STOUT_POSIX_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
deleted file mode 100644
index 8698e99..0000000
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//  http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef __STOUT_WINDOWS_GZIP_HPP__
-#define __STOUT_WINDOWS_GZIP_HPP__
-
-#include <string>
-
-#include <stout/try.hpp>
-
-
-namespace gzip {
-
-// Returns a gzip compressed version of the provided string.
-// The compression level should be within the range [-1, 9].
-// See zlib.h:
-//   #define Z_NO_COMPRESSION         0
-//   #define Z_BEST_SPEED             1
-//   #define Z_BEST_COMPRESSION       9
-//   #define Z_DEFAULT_COMPRESSION  (-1)
-inline Try<std::string> compress(
-    const std::string& decompressed,
-    int level = Z_DEFAULT_COMPRESSION)
-{
-  UNIMPLEMENTED;
-}
-
-
-// Returns a gzip decompressed version of the provided string.
-inline Try<std::string> decompress(const std::string& compressed)
-{
-  UNIMPLEMENTED;
-}
-
-} // namespace gzip {
-
-#endif // __STOUT_WINDOWS_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/7b8d9895/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
index 03e09fb..c9d331d 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
+++ b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt
@@ -25,6 +25,7 @@ set(STOUT_TESTS_SRC
   duration_tests.cpp
   dynamiclibrary_tests.cpp
   error_tests.cpp
+  gzip_tests.cpp
   hashmap_tests.cpp
   hashset_tests.cpp
   interval_tests.cpp
@@ -53,7 +54,6 @@ if (NOT WIN32)
   set(STOUT_TESTS_SRC
     ${STOUT_TESTS_SRC}
     flags_tests.cpp
-    gzip_tests.cpp
     mac_tests.cpp
     os_tests.cpp
     path_tests.cpp


[6/8] mesos git commit: Windows: [1/3] Add platform-dependent `os::execlp`.

Posted by jo...@apache.org.
Windows: [1/3] Add platform-dependent `os::execlp`.

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


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

Branch: refs/heads/master
Commit: e48794b8b0c8a97682825793e416242d1e79ec38
Parents: ae873f2
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:29:20 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:04:13 2016 -0500

----------------------------------------------------------------------
 .../stout/include/stout/os/posix/shell.hpp      | 30 +++++++++++---------
 .../stout/include/stout/os/windows/shell.hpp    | 30 ++++++++++++--------
 2 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e48794b8/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
index e0039fd..76af655 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
@@ -30,6 +30,17 @@
 
 namespace os {
 
+namespace Shell {
+// Canonical constants used as platform-dependent args to `exec` calls.
+// name() is the command name, arg0() is the first argument received
+// by the callee, usualy the command name and arg1() is the second
+// command argument received by the callee.
+
+  constexpr const char* name = "sh";
+  constexpr const char* arg0 = "sh";
+  constexpr const char* arg1 = "-c";
+} // namespace Shell {
+
 /**
  * Runs a shell command with optional arguments.
  *
@@ -101,19 +112,6 @@ Try<std::string> shell(const std::string& fmt, const T&... t)
   return stdout.str();
 }
 
-
-// Canonical constants used as platform-dependent args to `exec` calls.
-// name() is the command name, arg0() is the first argument received
-// by the callee, usualy the command name and arg1() is the second
-// command argument received by the callee.
-struct Shell
-{
-  static constexpr const char* name = "sh";
-  static constexpr const char* arg0 = "sh";
-  static constexpr const char* arg1 = "-c";
-};
-
-
 // Executes a command by calling "/bin/sh -c <command>", and returns
 // after the command has been completed. Returns 0 if succeeds, and
 // return -1 on error (e.g., fork/exec/waitpid failed). This function
@@ -143,6 +141,12 @@ inline int system(const std::string& command)
   }
 }
 
+template<typename... T>
+inline int execlp(const char* file, T... t)
+{
+  return ::execlp(file, t...);
+}
+
 } // namespace os {
 
 #endif // __STOUT_OS_POSIX_SHELL_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/e48794b8/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
index 42e2ee1..3dbe624 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
@@ -23,26 +23,26 @@
 
 namespace os {
 
+namespace Shell {
+// Canonical constants used as platform-dependent args to `exec` calls.
+// name() is the command name, arg0() is the first argument received
+// by the callee, usualy the command name and arg1() is the second
+// command argument received by the callee.
+
+  constexpr const char* name = "sh";
+  constexpr const char* arg0 = "sh";
+  constexpr const char* arg1 = "-c";
+} // namespace Shell {
+
 // Runs a shell command formatted with varargs and return the return value
 // of the command. Optionally, the output is returned via an argument.
 // TODO(vinod): Pass an istream object that can provide input to the command.
 template <typename... T>
-Try<std::string> shell(const std::string& fmt, const T&... t)
+Try<std::string> shell(const std::string& fmt, const T... t)
 {
   UNIMPLEMENTED;
 }
 
-// Canonical constants used as platform-dependent args to `exec` calls.
-// name() is the command name, arg0() is the first argument received
-// by the callee, usualy the command name and arg1() is the second
-// command argument received by the callee.
-struct Shell
-{
-  static constexpr const char* name = "cmd.exe";
-  static constexpr const char* arg0 = "cmd.exe";
-  static constexpr const char* arg1 = "/c";
-};
-
 // Executes a command by calling "cmd /c <command>", and returns
 // after the command has been completed. Returns 0 if succeeds, and
 // return -1 on error
@@ -52,6 +52,12 @@ inline int system(const std::string& command)
       _P_WAIT, Shell::name, Shell::arg0, Shell::arg1, command.c_str());
 }
 
+template<typename... T>
+inline int execlp(const char* file, T... t)
+{
+  exit(::_spawnlp(_P_WAIT, file, t...));
+}
+
 } // namespace os {
 
 #endif // __STOUT_OS_WINDOWS_SHELL_HPP__


[7/8] mesos git commit: Windows: [2/3] Used `os::execlp` in launch.cpp.

Posted by jo...@apache.org.
Windows: [2/3] Used `os::execlp` in launch.cpp.

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


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

Branch: refs/heads/master
Commit: 81e893d5cdb8a5873dd0c61ad7eceaa323aff466
Parents: e48794b
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:29:27 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:04:24 2016 -0500

----------------------------------------------------------------------
 src/slave/containerizer/mesos/launch.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/81e893d5/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp
index 9fb55aa..dc7bebf 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -16,7 +16,6 @@
 
 #include <errno.h>
 #include <string.h>
-#include <unistd.h>
 
 #include <iostream>
 
@@ -287,9 +286,10 @@ int MesosContainerizerLaunch::execute()
 
   if (command.get().shell()) {
     // Execute the command using shell.
-    execlp("sh", "sh", "-c", command.get().value().c_str(), (char*) NULL);
+    os::execlp(os::Shell::name, os::Shell::arg0,
+               os::Shell::arg1, command.get().value().c_str(), (char*) NULL);
   } else {
-    // Use os::execvpe to launch the command.
+    // Use execvp to launch the command.
     char** argv = new char*[command.get().arguments().size() + 1];
     for (int i = 0; i < command.get().arguments().size(); i++) {
       argv[i] = strdup(command.get().arguments(i).c_str());


[8/8] mesos git commit: Windows: [3/3] Transitioned Windows `system` to use `os::execlp`.

Posted by jo...@apache.org.
Windows: [3/3] Transitioned Windows `system` to use `os::execlp`.

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


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

Branch: refs/heads/master
Commit: ace12c09786921665cde457d936f00a46ecd74ee
Parents: 81e893d
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:29:40 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:04:51 2016 -0500

----------------------------------------------------------------------
 .../libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ace12c09/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
index 3dbe624..18a9784 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
@@ -48,8 +48,8 @@ Try<std::string> shell(const std::string& fmt, const T... t)
 // return -1 on error
 inline int system(const std::string& command)
 {
-  return ::_spawnl(
-      _P_WAIT, Shell::name, Shell::arg0, Shell::arg1, command.c_str());
+  return ::_spawnlp(
+      _P_WAIT, Shell::name, Shell::arg0, Shell::arg1, command.c_str(), NULL);
 }
 
 template<typename... T>