You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/05/29 19:40:45 UTC

[07/35] git commit: Updated libprocess to use '3rdparty' instead of 'third_party'.

Updated libprocess to use '3rdparty' instead of 'third_party'.

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


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

Branch: refs/heads/master
Commit: bc531d3c5b01e76f05143f538172174a1b1b35e1
Parents: 6ff3edf
Author: Benjamin Hindman <be...@twitter.com>
Authored: Sun May 26 23:47:55 2013 -0700
Committer: Benjamin Hindman <be...@twitter.com>
Committed: Tue May 28 14:18:39 2013 -0700

----------------------------------------------------------------------
 third_party/libprocess/3rdparty/Makefile.am        |  170 +++
 .../libprocess/3rdparty/boost-1.53.0.tar.gz        |  Bin 0 -> 988528 bytes
 third_party/libprocess/3rdparty/glog-0.3.1.tar.gz  |  Bin 0 -> 1018372 bytes
 third_party/libprocess/3rdparty/gmock-1.6.0.tar.gz |  Bin 0 -> 1798225 bytes
 .../libprocess/3rdparty/gperftools-2.0.tar.gz      |  Bin 0 -> 1261243 bytes
 third_party/libprocess/3rdparty/libev-4.15.patch   |   11 +
 third_party/libprocess/3rdparty/libev-4.15.tar.gz  |  Bin 0 -> 513919 bytes
 .../libprocess/3rdparty/protobuf-2.4.1.tar.gz      |  Bin 0 -> 1935301 bytes
 .../3rdparty/ry-http-parser-1c3624a.tar.gz         |  Bin 0 -> 24625 bytes
 third_party/libprocess/3rdparty/stout/LICENSE      |  177 +++
 third_party/libprocess/3rdparty/stout/Makefile.am  |   61 +
 third_party/libprocess/3rdparty/stout/README       |   32 +
 third_party/libprocess/3rdparty/stout/bootstrap    |   11 +
 third_party/libprocess/3rdparty/stout/configure.ac |   14 +
 .../3rdparty/stout/include/stout/bytes.hpp         |  160 +++
 .../3rdparty/stout/include/stout/cache.hpp         |  131 ++
 .../3rdparty/stout/include/stout/duration.hpp      |  297 ++++
 .../3rdparty/stout/include/stout/error.hpp         |   72 +
 .../3rdparty/stout/include/stout/exit.hpp          |   37 +
 .../3rdparty/stout/include/stout/fatal.hpp         |   43 +
 .../3rdparty/stout/include/stout/flags.hpp         |   70 +
 .../3rdparty/stout/include/stout/flags/flag.hpp    |   26 +
 .../3rdparty/stout/include/stout/flags/flags.hpp   |  481 +++++++
 .../3rdparty/stout/include/stout/flags/loader.hpp  |  109 ++
 .../3rdparty/stout/include/stout/flags/parse.hpp   |   55 +
 .../3rdparty/stout/include/stout/foreach.hpp       |   51 +
 .../3rdparty/stout/include/stout/format.hpp        |  343 +++++
 .../libprocess/3rdparty/stout/include/stout/fs.hpp |   53 +
 .../3rdparty/stout/include/stout/gtest.hpp         |  122 ++
 .../3rdparty/stout/include/stout/gzip.hpp          |  149 ++
 .../3rdparty/stout/include/stout/hashmap.hpp       |  102 ++
 .../3rdparty/stout/include/stout/hashset.hpp       |   57 +
 .../3rdparty/stout/include/stout/json.hpp          |  202 +++
 .../3rdparty/stout/include/stout/lambda.hpp        |   14 +
 .../3rdparty/stout/include/stout/multihashmap.hpp  |  109 ++
 .../3rdparty/stout/include/stout/multimap.hpp      |  107 ++
 .../3rdparty/stout/include/stout/net.hpp           |  102 ++
 .../3rdparty/stout/include/stout/none.hpp          |   56 +
 .../3rdparty/stout/include/stout/nothing.hpp       |    6 +
 .../3rdparty/stout/include/stout/numify.hpp        |   40 +
 .../3rdparty/stout/include/stout/option.hpp        |   85 ++
 .../libprocess/3rdparty/stout/include/stout/os.hpp | 1081 +++++++++++++++
 .../3rdparty/stout/include/stout/owned.hpp         |   20 +
 .../3rdparty/stout/include/stout/path.hpp          |   76 +
 .../3rdparty/stout/include/stout/preprocessor.hpp  |   29 +
 .../3rdparty/stout/include/stout/proc.hpp          |  478 +++++++
 .../3rdparty/stout/include/stout/protobuf.hpp      |  159 +++
 .../3rdparty/stout/include/stout/result.hpp        |   99 ++
 .../3rdparty/stout/include/stout/stopwatch.hpp     |   70 +
 .../3rdparty/stout/include/stout/stringify.hpp     |  124 ++
 .../3rdparty/stout/include/stout/strings.hpp       |  263 ++++
 .../3rdparty/stout/include/stout/try.hpp           |   88 ++
 .../3rdparty/stout/include/stout/utils.hpp         |   11 +
 .../3rdparty/stout/include/stout/uuid.hpp          |   54 +
 third_party/libprocess/3rdparty/stout/install-sh   |  520 +++++++
 .../libprocess/3rdparty/stout/m4/acx_pthread.m4    |  363 +++++
 .../3rdparty/stout/tests/bytes_tests.cpp           |   38 +
 .../3rdparty/stout/tests/duration_tests.cpp        |   82 ++
 .../3rdparty/stout/tests/error_tests.cpp           |   60 +
 .../3rdparty/stout/tests/flags_tests.cpp           |  349 +++++
 .../libprocess/3rdparty/stout/tests/gzip_tests.cpp |   53 +
 .../3rdparty/stout/tests/hashset_tests.cpp         |   25 +
 .../libprocess/3rdparty/stout/tests/json_tests.cpp |   19 +
 .../libprocess/3rdparty/stout/tests/main.cpp       |   11 +
 .../3rdparty/stout/tests/multimap_tests.cpp        |  168 +++
 .../libprocess/3rdparty/stout/tests/none_tests.cpp |   59 +
 .../libprocess/3rdparty/stout/tests/os_tests.cpp   |  208 +++
 .../libprocess/3rdparty/stout/tests/proc_tests.cpp |  162 +++
 .../3rdparty/stout/tests/strings_tests.cpp         |  255 ++++
 .../libprocess/3rdparty/stout/tests/uuid_tests.cpp |   37 +
 third_party/libprocess/3rdparty/versions.am        |   11 +
 third_party/libprocess/Makefile.am                 |   26 +-
 third_party/libprocess/configure.ac                |   12 +-
 third_party/libprocess/third_party/Makefile.am     |  170 ---
 .../libprocess/third_party/boost-1.53.0.tar.gz     |  Bin 988528 -> 0 bytes
 .../libprocess/third_party/glog-0.3.1.tar.gz       |  Bin 1018372 -> 0 bytes
 .../libprocess/third_party/gmock-1.6.0.tar.gz      |  Bin 1798225 -> 0 bytes
 .../libprocess/third_party/gperftools-2.0.tar.gz   |  Bin 1261243 -> 0 bytes
 .../libprocess/third_party/libev-4.15.patch        |   11 -
 .../libprocess/third_party/libev-4.15.tar.gz       |  Bin 513919 -> 0 bytes
 .../libprocess/third_party/protobuf-2.4.1.tar.gz   |  Bin 1935301 -> 0 bytes
 .../third_party/ry-http-parser-1c3624a.tar.gz      |  Bin 24625 -> 0 bytes
 third_party/libprocess/third_party/stout/LICENSE   |  177 ---
 .../libprocess/third_party/stout/Makefile.am       |   61 -
 third_party/libprocess/third_party/stout/README    |   32 -
 third_party/libprocess/third_party/stout/bootstrap |   11 -
 .../libprocess/third_party/stout/configure.ac      |   14 -
 .../third_party/stout/include/stout/bytes.hpp      |  160 ---
 .../third_party/stout/include/stout/cache.hpp      |  131 --
 .../third_party/stout/include/stout/duration.hpp   |  297 ----
 .../third_party/stout/include/stout/error.hpp      |   72 -
 .../third_party/stout/include/stout/exit.hpp       |   37 -
 .../third_party/stout/include/stout/fatal.hpp      |   43 -
 .../third_party/stout/include/stout/flags.hpp      |   70 -
 .../third_party/stout/include/stout/flags/flag.hpp |   26 -
 .../stout/include/stout/flags/flags.hpp            |  481 -------
 .../stout/include/stout/flags/loader.hpp           |  109 --
 .../stout/include/stout/flags/parse.hpp            |   55 -
 .../third_party/stout/include/stout/foreach.hpp    |   51 -
 .../third_party/stout/include/stout/format.hpp     |  343 -----
 .../third_party/stout/include/stout/fs.hpp         |   53 -
 .../third_party/stout/include/stout/gtest.hpp      |  122 --
 .../third_party/stout/include/stout/gzip.hpp       |  149 --
 .../third_party/stout/include/stout/hashmap.hpp    |  102 --
 .../third_party/stout/include/stout/hashset.hpp    |   57 -
 .../third_party/stout/include/stout/json.hpp       |  202 ---
 .../third_party/stout/include/stout/lambda.hpp     |   14 -
 .../stout/include/stout/multihashmap.hpp           |  109 --
 .../third_party/stout/include/stout/multimap.hpp   |  107 --
 .../third_party/stout/include/stout/net.hpp        |  102 --
 .../third_party/stout/include/stout/none.hpp       |   56 -
 .../third_party/stout/include/stout/nothing.hpp    |    6 -
 .../third_party/stout/include/stout/numify.hpp     |   40 -
 .../third_party/stout/include/stout/option.hpp     |   85 --
 .../third_party/stout/include/stout/os.hpp         | 1081 ---------------
 .../third_party/stout/include/stout/owned.hpp      |   20 -
 .../third_party/stout/include/stout/path.hpp       |   76 -
 .../stout/include/stout/preprocessor.hpp           |   29 -
 .../third_party/stout/include/stout/proc.hpp       |  478 -------
 .../third_party/stout/include/stout/protobuf.hpp   |  159 ---
 .../third_party/stout/include/stout/result.hpp     |   99 --
 .../third_party/stout/include/stout/stopwatch.hpp  |   70 -
 .../third_party/stout/include/stout/stringify.hpp  |  124 --
 .../third_party/stout/include/stout/strings.hpp    |  263 ----
 .../third_party/stout/include/stout/try.hpp        |   88 --
 .../third_party/stout/include/stout/utils.hpp      |   11 -
 .../third_party/stout/include/stout/uuid.hpp       |   54 -
 .../libprocess/third_party/stout/install-sh        |  520 -------
 .../libprocess/third_party/stout/m4/acx_pthread.m4 |  363 -----
 .../third_party/stout/tests/bytes_tests.cpp        |   38 -
 .../third_party/stout/tests/duration_tests.cpp     |   82 --
 .../third_party/stout/tests/error_tests.cpp        |   60 -
 .../third_party/stout/tests/flags_tests.cpp        |  349 -----
 .../third_party/stout/tests/gzip_tests.cpp         |   53 -
 .../third_party/stout/tests/hashset_tests.cpp      |   25 -
 .../third_party/stout/tests/json_tests.cpp         |   19 -
 .../libprocess/third_party/stout/tests/main.cpp    |   11 -
 .../third_party/stout/tests/multimap_tests.cpp     |  168 ---
 .../third_party/stout/tests/none_tests.cpp         |   59 -
 .../third_party/stout/tests/os_tests.cpp           |  208 ---
 .../third_party/stout/tests/proc_tests.cpp         |  162 ---
 .../third_party/stout/tests/strings_tests.cpp      |  255 ----
 .../third_party/stout/tests/uuid_tests.cpp         |   37 -
 third_party/libprocess/third_party/versions.am     |   11 -
 144 files changed, 8546 insertions(+), 8546 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/Makefile.am b/third_party/libprocess/3rdparty/Makefile.am
new file mode 100644
index 0000000..20599ec
--- /dev/null
+++ b/third_party/libprocess/3rdparty/Makefile.am
@@ -0,0 +1,170 @@
+# This Makefile is for building third-party packages from
+# tarballs. For autotools-based packages, we configure each of the
+# packages to build static PIC binaries which we can safely link into
+# a shared libmesos, and build it in-place without installing it (even
+# if one runs 'make install' in this directory). Non-autotools based
+# packages may be special cases; this Makefile is responsible for
+# passing any special make or configure flags that might be required.
+
+SUBDIRS = stout
+
+BUILT_SOURCES = # Initialized to enable using +=.
+
+# We need to add '--srcdir=.' needed because 'make distcheck' adds
+#  '--srcdir=...' when configuring.
+CONFIGURE_ARGS = @CONFIGURE_ARGS@ --enable-shared=no --with-pic --srcdir=.
+
+include versions.am
+
+STOUT = stout
+BOOST = boost-$(BOOST_VERSION)
+GLOG = glog-$(GLOG_VERSION)
+GMOCK = gmock-$(GMOCK_VERSION)
+GPERFTOOLS = gperftools-$(GPERFTOOLS_VERSION)
+GTEST = $(GMOCK)/gtest
+RY_HTTP_PARSER = ry-http-parser-$(RY_HTTP_PARSER_VERSION)
+LIBEV = libev-$(LIBEV_VERSION)
+PROTOBUF = protobuf-$(PROTOBUF_VERSION)
+
+
+EXTRA_DIST =			\
+  $(BOOST).tar.gz		\
+  $(GLOG).tar.gz		\
+  $(GMOCK).tar.gz		\
+  $(GPERFTOOLS).tar.gz		\
+  $(LIBEV).tar.gz		\
+  $(LIBEV).patch		\
+  $(PROTOBUF).tar.gz		\
+  $(RY_HTTP_PARSER).tar.gz
+
+CLEAN_EXTRACTED =	\
+  $(BOOST)		\
+  $(GLOG)		\
+  $(GMOCK)		\
+  $(GPERFTOOLS)		\
+  $(LIBEV)		\
+  $(PROTOBUF)		\
+  $(RY_HTTP_PARSER)
+
+
+# This is where the magic happens: we use stamp files as dependencies
+# which cause the packages to get extracted as necessary. We also
+# apply any patches as appropriate.
+%-stamp: %.tar.gz
+	gzip -d -c $^ | tar xf -
+	test ! -e $(srcdir)/$*.patch || patch -d $* -p1 <$(srcdir)/$*.patch
+	touch $@
+
+
+# Convenience library for Ryan Dahl's HTTP parser.
+noinst_LTLIBRARIES = libry_http_parser.la
+nodist_libry_http_parser_la_SOURCES = $(RY_HTTP_PARSER)/http_parser.c
+libry_http_parser_la_CPPFLAGS = -I$(RY_HTTP_PARSER)
+
+# We list the sources in BUILT_SOURCES to make sure that the package
+# gets unarchived first.
+BUILT_SOURCES += $(nodist_libry_http_parser_la_SOURCES)
+
+
+# Convenience library for gmock/gtest.
+check_LTLIBRARIES = libgmock.la
+nodist_libgmock_la_SOURCES =		\
+  $(GTEST)/src/gtest-all.cc		\
+  $(GMOCK)/src/gmock-all.cc
+libgmock_la_CPPFLAGS =			\
+  -I$(GTEST)/include -I$(GTEST)		\
+  -I$(GMOCK)/include -I$(GMOCK)
+
+# We list the sources in BUILT_SOURCES to make sure that the package
+# gets unarchived first.
+BUILT_SOURCES += $(nodist_libgmock_la_SOURCES)
+
+$(GMOCK)/src/gmock-all.cc: $(GMOCK)-stamp
+$(GTEST)/src/gtest-all.cc: $(GMOCK)-stamp
+
+
+$(BOOST)/boost: $(BOOST)-stamp
+
+$(GLOG)/libglog.la: $(GLOG)-stamp
+	cd $(GLOG) && ./configure $(CONFIGURE_ARGS) && \
+          $(MAKE) $(AM_MAKEFLAGS)
+
+if HAS_GPERFTOOLS
+$(GPERFTOOLS)/libprofiler.la: $(GPERFTOOLS)-build-stamp
+
+$(GPERFTOOLS)-build-stamp: $(GPERFTOOLS)-stamp
+	cd $(GPERFTOOLS) && ./configure  $(CONFIGURE_ARGS) && \
+	  $(MAKE) $(AM_MAKEFLAGS)
+	touch $@
+endif
+
+$(LIBEV)/libev.la: $(LIBEV)-stamp
+	cd $(LIBEV) && ./configure $(CONFIGURE_ARGS) && \
+          $(MAKE) $(AM_MAKEFLAGS)
+
+$(PROTOBUF)/src/protoc $(PROTOBUF)/src/libprotobuf.la: $(PROTOBUF)-build-stamp
+
+$(PROTOBUF)-build-stamp: $(PROTOBUF)-stamp
+	cd $(PROTOBUF) && ./configure $(CONFIGURE_ARGS) && \
+          $(MAKE) $(AM_MAKEFLAGS)
+	touch $@
+
+$(RY_HTTP_PARSER)/http_parser.c: $(RY_HTTP_PARSER)-stamp
+
+
+# Tests for stout.
+check_PROGRAMS = stout-tests
+
+stout_tests_SOURCES =				\
+  $(STOUT)/tests/bytes_tests.cpp		\
+  $(STOUT)/tests/duration_tests.cpp		\
+  $(STOUT)/tests/error_tests.cpp		\
+  $(STOUT)/tests/flags_tests.cpp		\
+  $(STOUT)/tests/gzip_tests.cpp			\
+  $(STOUT)/tests/hashset_tests.cpp		\
+  $(STOUT)/tests/json_tests.cpp			\
+  $(STOUT)/tests/main.cpp			\
+  $(STOUT)/tests/multimap_tests.cpp		\
+  $(STOUT)/tests/none_tests.cpp			\
+  $(STOUT)/tests/os_tests.cpp			\
+  $(STOUT)/tests/strings_tests.cpp		\
+  $(STOUT)/tests/uuid_tests.cpp
+
+if OS_LINUX
+  stout_tests_SOURCES += $(STOUT)/tests/proc_tests.cpp
+endif
+
+stout_tests_CPPFLAGS =				\
+  -I$(srcdir)/$(STOUT)/include			\
+  -I$(BOOST)					\
+  -I$(GLOG)/src					\
+  -I$(GTEST)/include				\
+  -I$(GMOCK)/include				\
+  -I$(PROTOBUF)/src				\
+  $(AM_CPPFLAGS)
+
+stout_tests_LDADD =			\
+  libgmock.la				\
+  $(GLOG)/libglog.la			\
+  $(PROTOBUF)/src/libprotobuf.la
+
+TESTS = stout-tests
+
+# Dependencies for all-local.
+ALL_LOCAL =				\
+  $(STOUT)/Makefile			\
+  $(BOOST)-stamp			\
+  $(GLOG)/libglog.la			\
+  $(LIBEV)/libev.la			\
+  $(PROTOBUF)/src/libprotobuf.la	\
+  $(PROTOBUF)/src/protoc
+
+if HAS_GPERFTOOLS
+ ALL_LOCAL += $(GPERFTOOLS)/libprofiler.la
+endif
+
+all-local: $(ALL_LOCAL)
+
+clean-local:
+	rm -r -f $(CLEAN_EXTRACTED)
+	rm -f *-stamp

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/boost-1.53.0.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/boost-1.53.0.tar.gz b/third_party/libprocess/3rdparty/boost-1.53.0.tar.gz
new file mode 100644
index 0000000..770d837
Binary files /dev/null and b/third_party/libprocess/3rdparty/boost-1.53.0.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/glog-0.3.1.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/glog-0.3.1.tar.gz b/third_party/libprocess/3rdparty/glog-0.3.1.tar.gz
new file mode 100644
index 0000000..19b4b94
Binary files /dev/null and b/third_party/libprocess/3rdparty/glog-0.3.1.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/gmock-1.6.0.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/gmock-1.6.0.tar.gz b/third_party/libprocess/3rdparty/gmock-1.6.0.tar.gz
new file mode 100644
index 0000000..d45d989
Binary files /dev/null and b/third_party/libprocess/3rdparty/gmock-1.6.0.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/gperftools-2.0.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/gperftools-2.0.tar.gz b/third_party/libprocess/3rdparty/gperftools-2.0.tar.gz
new file mode 100644
index 0000000..13b03ca
Binary files /dev/null and b/third_party/libprocess/3rdparty/gperftools-2.0.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/libev-4.15.patch
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/libev-4.15.patch b/third_party/libprocess/3rdparty/libev-4.15.patch
new file mode 100644
index 0000000..2b94532
--- /dev/null
+++ b/third_party/libprocess/3rdparty/libev-4.15.patch
@@ -0,0 +1,11 @@
+diff -rupN libev-4.15/ev.h libev-4.15-patched/ev.h
+--- libev-4.15/ev.h	2013-03-01 03:05:29.000000000 -0800
++++ libev-4.15-patched/ev.h	2013-05-20 16:01:47.000000000 -0700
+@@ -121,7 +121,7 @@ EV_CPP(extern "C" {)
+ # ifdef _WIN32
+ #  define EV_CHILD_ENABLE 0
+ # else
+-#  define EV_CHILD_ENABLE EV_FEATURE_WATCHERS
++#  define EV_CHILD_ENABLE 0
+ #endif
+ #endif

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/libev-4.15.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/libev-4.15.tar.gz b/third_party/libprocess/3rdparty/libev-4.15.tar.gz
new file mode 100644
index 0000000..4c282b5
Binary files /dev/null and b/third_party/libprocess/3rdparty/libev-4.15.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/protobuf-2.4.1.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/protobuf-2.4.1.tar.gz b/third_party/libprocess/3rdparty/protobuf-2.4.1.tar.gz
new file mode 100644
index 0000000..38ec4de
Binary files /dev/null and b/third_party/libprocess/3rdparty/protobuf-2.4.1.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/ry-http-parser-1c3624a.tar.gz
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/ry-http-parser-1c3624a.tar.gz b/third_party/libprocess/3rdparty/ry-http-parser-1c3624a.tar.gz
new file mode 100644
index 0000000..b811b63
Binary files /dev/null and b/third_party/libprocess/3rdparty/ry-http-parser-1c3624a.tar.gz differ

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/LICENSE
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/LICENSE b/third_party/libprocess/3rdparty/stout/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/LICENSE
@@ -0,0 +1,177 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/Makefile.am b/third_party/libprocess/3rdparty/stout/Makefile.am
new file mode 100644
index 0000000..fdd3482
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/Makefile.am
@@ -0,0 +1,61 @@
+# Makefile for stout.
+
+ACLOCAL_AMFLAGS = -I m4
+
+AUTOMAKE_OPTIONS = foreign
+
+EXTRA_DIST =					\
+  include/stout/bytes.hpp			\
+  include/stout/cache.hpp			\
+  include/stout/duration.hpp			\
+  include/stout/error.hpp			\
+  include/stout/exit.hpp			\
+  include/stout/fatal.hpp			\
+  include/stout/flags.hpp			\
+  include/stout/flags/flag.hpp			\
+  include/stout/flags/flags.hpp			\
+  include/stout/flags/loader.hpp		\
+  include/stout/flags/parse.hpp			\
+  include/stout/foreach.hpp			\
+  include/stout/format.hpp			\
+  include/stout/fs.hpp				\
+  include/stout/gtest.hpp			\
+  include/stout/gzip.hpp			\
+  include/stout/hashmap.hpp			\
+  include/stout/hashset.hpp			\
+  include/stout/json.hpp			\
+  include/stout/lambda.hpp			\
+  include/stout/multihashmap.hpp		\
+  include/stout/multimap.hpp			\
+  include/stout/net.hpp				\
+  include/stout/none.hpp			\
+  include/stout/nothing.hpp			\
+  include/stout/numify.hpp			\
+  include/stout/option.hpp			\
+  include/stout/os.hpp				\
+  include/stout/owned.hpp			\
+  include/stout/path.hpp			\
+  include/stout/preprocessor.hpp		\
+  include/stout/proc.hpp			\
+  include/stout/protobuf.hpp			\
+  include/stout/result.hpp			\
+  include/stout/stopwatch.hpp			\
+  include/stout/stringify.hpp			\
+  include/stout/strings.hpp			\
+  include/stout/try.hpp				\
+  include/stout/utils.hpp			\
+  include/stout/uuid.hpp			\
+  tests/bytes_tests.cpp				\
+  tests/duration_tests.cpp			\
+  tests/error_tests.cpp				\
+  tests/flags_tests.cpp				\
+  tests/gzip_tests.cpp				\
+  tests/hashset_tests.cpp			\
+  tests/json_tests.cpp				\
+  tests/main.cpp				\
+  tests/multimap_tests.cpp			\
+  tests/none_tests.cpp				\
+  tests/os_tests.cpp				\
+  tests/proc_tests.cpp				\
+  tests/strings_tests.cpp			\
+  tests/uuid_tests.cpp

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/README
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/README b/third_party/libprocess/3rdparty/stout/README
new file mode 100644
index 0000000..685a4ae
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/README
@@ -0,0 +1,32 @@
+Stout is a header-only C++ library.
+
+No action is needed if you would like to use this library in your
+project. Simply add the include folder to your include path during
+compilation.
+
+Depending on which headers you'd like to use, you may require the
+following third party libraries:
+
+  - Boost
+  - Google's glog (this dependency will be removed in the future).
+  - Google's protobuf.
+  - Google's gmock/gtest.
+
+
+Building Tests
+==============
+
+We'll assume you've got a distribution of gmock and have already built
+a static archive called libgmock.a (see gmock's README to learn
+how). We'll also assume the Boost and glog headers can be found via
+the include paths and libglog.* can be found via the library search
+paths. You can then build the tests via:
+
+$ g++ -I${STOUT}/include -I$(GMOCK)/gtest/include -I$(GMOCK)/include \
+  ${STOUT}/tests/tests.cpp libgmock.a -lglog -o tests
+
+Note that if you want to test the gzip headers you'll need to define
+HAVE_LIBZ and link against libz:
+
+$ g++ -I${STOUT}/include -I$(GMOCK)/gtest/include -I$(GMOCK)/include \
+  -DHAVE_LIBZ ${STOUT}/tests/tests.cpp libgmock.a -lglog -lz -o tests

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/bootstrap
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/bootstrap b/third_party/libprocess/3rdparty/stout/bootstrap
new file mode 100755
index 0000000..89b9bc8
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/bootstrap
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Make sure that we are in the right directory.
+if test ! -f configure.ac; then
+    cat >&2 <<__EOF__
+You must run bootstrap from the root of the distribution.
+__EOF__
+    exit 1
+fi
+
+autoreconf --install -Wall --verbose "${@}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/configure.ac
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/configure.ac b/third_party/libprocess/3rdparty/stout/configure.ac
new file mode 100644
index 0000000..86e1ff3
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/configure.ac
@@ -0,0 +1,14 @@
+# Generated with autoscan, then modified appropriately.
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.61])
+AC_INIT([stout], [0.1.0])
+
+AC_LANG([C++])
+
+# Initialize automake.
+AM_INIT_AUTOMAKE([1.10])
+
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/bytes.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/bytes.hpp b/third_party/libprocess/3rdparty/stout/include/stout/bytes.hpp
new file mode 100644
index 0000000..754fbb2
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/bytes.hpp
@@ -0,0 +1,160 @@
+#ifndef __STOUT_BYTES_HPP__
+#define __STOUT_BYTES_HPP__
+
+#include <ctype.h> // For 'isdigit'.
+#include <stdint.h>
+
+#include <iomanip>
+#include <iostream>
+#include <string>
+
+#include "numify.hpp"
+#include "strings.hpp"
+#include "try.hpp"
+
+
+class Bytes
+{
+public:
+  static Try<Bytes> parse(const std::string& s)
+  {
+    size_t index = 0;
+
+    while (index < s.size()) {
+      if (isdigit(s[index])) {
+        index++;
+        continue;
+      } else if (s[index] == '.') {
+        return Error("Fractional bytes '" + s + "'");
+      }
+
+      Try<uint64_t> value = numify<uint64_t>(s.substr(0, index));
+
+      if (value.isError()) {
+        return Error(value.error());
+      }
+
+      const std::string& unit = strings::upper(s.substr(index));
+
+      if (unit == "B") {
+        return Bytes(value.get(), BYTES);
+      } else if (unit == "KB") {
+        return Bytes(value.get(), KILOBYTES);
+      } else if (unit == "MB") {
+        return Bytes(value.get(), MEGABYTES);
+      } else if (unit == "GB") {
+        return Bytes(value.get(), GIGABYTES);
+      } else if (unit == "TB") {
+        return Bytes(value.get(), TERABYTES);
+      } else {
+        return Error("Unknown bytes unit '" + unit + "'");
+      }
+    }
+    return Error("Invalid bytes '" + s + "'");
+  }
+
+  Bytes(uint64_t bytes = 0) : value(bytes) {}
+  Bytes(uint64_t _value, uint64_t _unit) : value(_value * _unit) {}
+
+  // TODO(bmahler): Consider killing kilobytes to terabyte helpers, given
+  // they implicitly lose precision if not careful.
+  uint64_t bytes()     const { return value; }
+  uint64_t kilobytes() const { return value / KILOBYTES; }
+  uint64_t megabytes() const { return value / MEGABYTES; }
+  uint64_t gigabytes() const { return value / GIGABYTES; }
+  uint64_t terabytes() const { return value / TERABYTES; }
+
+  bool operator <  (const Bytes& that) const { return value <  that.value; }
+  bool operator <= (const Bytes& that) const { return value <= that.value; }
+  bool operator >  (const Bytes& that) const { return value >  that.value; }
+  bool operator >= (const Bytes& that) const { return value >= that.value; }
+  bool operator == (const Bytes& that) const { return value == that.value; }
+  bool operator != (const Bytes& that) const { return value != that.value; }
+
+  Bytes& operator += (const Bytes& that)
+  {
+    value += that.value;
+    return *this;
+  }
+
+  Bytes& operator -= (const Bytes& that)
+  {
+    value -= that.value;
+    return *this;
+  }
+
+protected:
+  static const uint64_t BYTES = 1;
+  static const uint64_t KILOBYTES = 1024 * BYTES;
+  static const uint64_t MEGABYTES = 1024 * KILOBYTES;
+  static const uint64_t GIGABYTES = 1024 * MEGABYTES;
+  static const uint64_t TERABYTES = 1024 * GIGABYTES;
+
+private:
+  uint64_t value;
+};
+
+
+class Kilobytes : public Bytes
+{
+public:
+  explicit Kilobytes(uint64_t value) : Bytes(value, KILOBYTES) {}
+};
+
+
+class Megabytes : public Bytes
+{
+public:
+  explicit Megabytes(uint64_t value) : Bytes(value, MEGABYTES) {}
+};
+
+
+class Gigabytes : public Bytes
+{
+public:
+  explicit Gigabytes(uint64_t value) : Bytes(value, GIGABYTES) {}
+};
+
+
+class Terabytes : public Bytes
+{
+public:
+  explicit Terabytes(uint64_t value) : Bytes(value, TERABYTES) {}
+};
+
+
+inline std::ostream& operator << (std::ostream& stream, const Bytes& bytes)
+{
+  // Only raise the unit when there is no loss of information.
+  if (bytes.bytes() == 0) {
+    return stream << bytes.bytes() << "B";
+  } else if (bytes.bytes() % 1024 != 0) {
+    return stream << bytes.bytes() << "B";
+  } else if (bytes.kilobytes() % 1024 != 0) {
+    return stream << bytes.kilobytes() << "KB";
+  } else if (bytes.megabytes() % 1024 != 0) {
+    return stream << bytes.megabytes() << "MB";
+  } else if (bytes.gigabytes() % 1024 != 0) {
+    return stream << bytes.gigabytes() << "GB";
+  } else {
+    return stream << bytes.terabytes() << "TB";
+  }
+}
+
+
+inline Bytes operator + (const Bytes& lhs, const Bytes& rhs)
+{
+  Bytes sum = lhs;
+  sum += rhs;
+  return sum;
+}
+
+
+inline Bytes operator - (const Bytes& lhs, const Bytes& rhs)
+{
+  Bytes diff = lhs;
+  diff -= rhs;
+  return diff;
+}
+
+#endif // __STOUT_BYTES_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/cache.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/cache.hpp b/third_party/libprocess/3rdparty/stout/include/stout/cache.hpp
new file mode 100644
index 0000000..653507c
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/cache.hpp
@@ -0,0 +1,131 @@
+#ifndef __STOUT_CACHE_HPP__
+#define __STOUT_CACHE_HPP__
+
+#include <functional>
+#include <iostream>
+#include <list>
+#include <map>
+
+#include <tr1/functional>
+#include <tr1/unordered_map>
+
+#include "none.hpp"
+#include "option.hpp"
+
+// Forward declaration.
+template <typename Key, typename Value>
+class cache;
+
+// Outputs the key/value pairs from least to most-recently used.
+template <typename Key, typename Value>
+std::ostream& operator << (
+    std::ostream& stream,
+    const cache<Key, Value>& c);
+
+
+// Provides a least-recently used (LRU) cache of some predefined
+// capacity. A "write" and a "read" both count as uses.
+template <typename Key, typename Value>
+class cache
+{
+public:
+  typedef std::list<Key> list;
+  typedef std::tr1::unordered_map<
+    Key, std::pair<Value, typename list::iterator> > map;
+
+  explicit cache(int _capacity) : capacity(_capacity) {}
+
+  void put(const Key& key, const Value& value)
+  {
+    typename map::iterator i = values.find(key);
+    if (i == values.end()) {
+      insert(key, value);
+    } else {
+      (*i).second.first = value;
+      use(i);
+    }
+  }
+
+  Option<Value> get(const Key& key)
+  {
+    typename map::iterator i = values.find(key);
+
+    if (i != values.end()) {
+      use(i);
+      return (*i).second.first;
+    }
+
+    return None();
+  }
+
+private:
+  // Not copyable, not assignable.
+  cache(const cache&);
+  cache& operator = (const cache&);
+
+  // Give the operator access to our internals.
+  friend std::ostream& operator << <>(
+      std::ostream& stream,
+      const cache<Key, Value>& c);
+
+  // Insert key/value into the cache.
+  void insert(const Key& key, const Value& value)
+  {
+    if (keys.size() == capacity) {
+      evict();
+    }
+
+    // Get a "pointer" into the lru list for efficient update.
+    typename list::iterator i = keys.insert(keys.end(), key);
+
+    // Save key/value and "pointer" into lru list.
+    values.insert(std::make_pair(key, std::make_pair(value, i)));
+  }
+
+  // Updates the LRU ordering in the cache for the given iterator.
+  void use(const typename map::iterator& i)
+  {
+    // Move the "pointer" to the end of the lru list.
+    keys.splice(keys.end(), keys, (*i).second.second);
+
+    // Now update the "pointer" so we can do this again.
+    (*i).second.second = --keys.end();
+  }
+
+  // Evict the least-recently used element from the cache.
+  void evict()
+  {
+    const typename map::iterator& i = values.find(keys.front());
+    CHECK(i != values.end());
+    values.erase(i);
+    keys.pop_front();
+  }
+
+  // Size of the cache.
+  int capacity;
+
+  // Cache of values and "pointers" into the least-recently used list.
+  map values;
+
+  // Keys ordered by least-recently used.
+  list keys;
+};
+
+
+template <typename Key, typename Value>
+std::ostream& operator << (
+    std::ostream& stream,
+    const cache<Key, Value>& c)
+{
+  typename cache<Key, Value>::list::const_iterator i1;
+  for (i1 = c.keys.begin(); i1 != c.keys.end(); i1++) {
+    stream << *i1 << ": ";
+    typename cache<Key, Value>::map::const_iterator i2;
+    i2 = c.values.find(*i1);
+    CHECK(i2 != c.values.end());
+    stream << *i2 << std::endl;
+  }
+  return stream;
+}
+
+#endif // __STOUT_CACHE_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/duration.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/duration.hpp b/third_party/libprocess/3rdparty/stout/include/stout/duration.hpp
new file mode 100644
index 0000000..47e85ff
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/duration.hpp
@@ -0,0 +1,297 @@
+#ifndef __STOUT_DURATION_HPP__
+#define __STOUT_DURATION_HPP__
+
+#include <ctype.h> // For 'isdigit'.
+#include <limits.h> // For 'LLONG_(MAX|MIN)'
+
+#include <iomanip>
+#include <iostream>
+#include <string>
+
+#include "error.hpp"
+#include "numify.hpp"
+#include "try.hpp"
+
+class Duration
+{
+public:
+  static Try<Duration> parse(const std::string& s)
+  {
+    // TODO(benh): Support negative durations (i.e., starts with '-').
+    size_t index = 0;
+    while (index < s.size()) {
+      if (isdigit(s[index]) || s[index] == '.') {
+        index++;
+        continue;
+      }
+
+      Try<double> value = numify<double>(s.substr(0, index));
+
+      if (value.isError()) {
+        return Error(value.error());
+      }
+
+      const std::string& unit = s.substr(index);
+
+      if (unit == "ns") {
+        return Duration(value.get(), NANOSECONDS);
+      } else if (unit == "us") {
+        return Duration(value.get(), MICROSECONDS);
+      } else if (unit == "ms") {
+        return Duration(value.get(), MILLISECONDS);
+      } else if (unit == "secs") {
+        return Duration(value.get(), SECONDS);
+      } else if (unit == "mins") {
+        return Duration(value.get(), MINUTES);
+      } else if (unit == "hrs") {
+        return Duration(value.get(), HOURS);
+      } else if (unit == "days") {
+        return Duration(value.get(), DAYS);
+      } else if (unit == "weeks") {
+        return Duration(value.get(), WEEKS);
+      } else {
+        return Error("Unknown duration unit '" + unit + "'");
+      }
+    }
+    return Error("Invalid duration '" + s + "'");
+  }
+
+  static Try<Duration> create(double seconds);
+
+  Duration() : nanos(0) {}
+
+  int64_t ns() const   { return nanos; }
+  double us() const    { return static_cast<double>(nanos) / MICROSECONDS; }
+  double ms() const    { return static_cast<double>(nanos) / MILLISECONDS; }
+  double secs() const  { return static_cast<double>(nanos) / SECONDS; }
+  double mins() const  { return static_cast<double>(nanos) / MINUTES; }
+  double hrs() const   { return static_cast<double>(nanos) / HOURS; }
+  double days() const  { return static_cast<double>(nanos) / DAYS; }
+  double weeks() const { return static_cast<double>(nanos) / WEEKS; }
+
+  bool operator <  (const Duration& d) const { return nanos <  d.nanos; }
+  bool operator <= (const Duration& d) const { return nanos <= d.nanos; }
+  bool operator >  (const Duration& d) const { return nanos >  d.nanos; }
+  bool operator >= (const Duration& d) const { return nanos >= d.nanos; }
+  bool operator == (const Duration& d) const { return nanos == d.nanos; }
+  bool operator != (const Duration& d) const { return nanos != d.nanos; }
+
+  Duration& operator += (const Duration& that)
+  {
+    nanos += that.nanos;
+    return *this;
+  }
+
+  Duration& operator -= (const Duration& that)
+  {
+    nanos -= that.nanos;
+    return *this;
+  }
+
+  Duration& operator *= (double multiplier)
+  {
+    nanos = static_cast<int64_t>(nanos * multiplier);
+    return *this;
+  }
+
+  Duration& operator /= (double divisor)
+  {
+    nanos = static_cast<int64_t>(nanos / divisor);
+    return *this;
+  }
+
+  Duration operator + (const Duration& that) const
+  {
+    Duration sum = *this;
+    sum += that;
+    return sum;
+  }
+
+  Duration operator - (const Duration& that) const
+  {
+    Duration diff = *this;
+    diff -= that;
+    return diff;
+  }
+
+  Duration operator * (double multiplier) const
+  {
+    Duration product = *this;
+    product *= multiplier;
+    return product;
+  }
+
+  Duration operator / (double divisor) const
+  {
+    Duration quotient = *this;
+    quotient /= divisor;
+    return quotient;
+  }
+
+  // TODO(xujyan): Use constexpr for the following variables after
+  // switching to C++11.
+  // A constant holding the maximum value a Duration can have.
+  static Duration max();
+  // A constant holding the minimum (negative) value a Duration can
+  // have.
+  static Duration min();
+  // A constant holding a Duration of a "zero" value.
+  static Duration zero() { return Duration(); }
+
+protected:
+  static const int64_t NANOSECONDS  = 1;
+  static const int64_t MICROSECONDS = 1000 * NANOSECONDS;
+  static const int64_t MILLISECONDS = 1000 * MICROSECONDS;
+  static const int64_t SECONDS      = 1000 * MILLISECONDS;
+  static const int64_t MINUTES      = 60 * SECONDS;
+  static const int64_t HOURS        = 60 * MINUTES;
+  static const int64_t DAYS         = 24 * HOURS;
+  static const int64_t WEEKS        = 7 * DAYS;
+
+  // For the Seconds, Minutes, Hours, Days & Weeks constructor.
+  Duration(int32_t value, int64_t unit)
+    : nanos(value * unit) {}
+
+  // For the Nanoseconds, Microseconds, Milliseconds constructor.
+  Duration(int64_t value, int64_t unit)
+    : nanos(value * unit) {}
+
+private:
+  // Used only by "parse".
+  Duration(double value, int64_t unit)
+    : nanos(static_cast<int64_t>(value * unit)) {}
+
+  int64_t nanos;
+};
+
+
+class Nanoseconds : public Duration
+{
+public:
+  explicit Nanoseconds(int64_t nanoseconds)
+    : Duration(nanoseconds, NANOSECONDS) {}
+
+  Nanoseconds(const Duration& d) : Duration(d) {}
+};
+
+
+class Microseconds : public Duration
+{
+public:
+  explicit Microseconds(int64_t microseconds)
+    : Duration(microseconds, MICROSECONDS) {}
+
+  Microseconds(const Duration& d) : Duration(d) {}
+};
+
+
+class Milliseconds : public Duration
+{
+public:
+  explicit Milliseconds(int64_t milliseconds)
+    : Duration(milliseconds, MILLISECONDS) {}
+
+  Milliseconds(const Duration& d) : Duration(d) {}
+};
+
+
+class Seconds : public Duration
+{
+public:
+  explicit Seconds(int64_t seconds)
+    : Duration(seconds, SECONDS) {}
+
+  Seconds(const Duration& d) : Duration(d) {}
+};
+
+
+class Minutes : public Duration
+{
+public:
+  explicit Minutes(int32_t minutes)
+    : Duration(minutes, MINUTES) {}
+
+  Minutes(const Duration& d) : Duration(d) {}
+};
+
+
+class Hours : public Duration
+{
+public:
+  explicit Hours(int32_t hours)
+    : Duration(hours, HOURS) {}
+
+  Hours(const Duration& d) : Duration(d) {}
+};
+
+
+class Days : public Duration
+{
+public:
+  explicit Days(int32_t days)
+    : Duration(days, DAYS) {}
+
+  Days(const Duration& d) : Duration(d) {}
+};
+
+
+class Weeks : public Duration
+{
+public:
+  explicit Weeks(int32_t value) : Duration(value, WEEKS) {}
+
+  Weeks(const Duration& d) : Duration(d) {}
+};
+
+
+inline std::ostream& operator << (
+    std::ostream& stream,
+    const Duration& duration)
+{
+  long precision = stream.precision();
+
+  // Output the duration in full double precision.
+  stream.precision(std::numeric_limits<double>::digits10);
+
+  if (duration < Microseconds(1)) {
+    stream << duration.ns() << "ns";
+  } else if (duration < Milliseconds(1)) {
+    stream << duration.us() << "us";
+  } else if (duration < Seconds(1)) {
+    stream << duration.ms() << "ms";
+  } else if (duration < Minutes(1)) {
+    stream << duration.secs() << "secs";
+  } else if (duration < Hours(1)) {
+    stream << duration.mins() << "mins";
+  } else if (duration < Days(1)) {
+    stream << duration.hrs() << "hrs";
+  } else if (duration < Weeks(1)) {
+    stream << duration.days() << "days";
+  } else {
+    stream << duration.weeks() << "weeks";
+  }
+
+  // Return the stream to original formatting state.
+  stream.precision(precision);
+
+  return stream;
+}
+
+
+inline Try<Duration> Duration::create(double seconds)
+{
+  if (seconds * SECONDS > LLONG_MAX) {
+    return Error("Argument larger than the maximum number of seconds that "
+                 "a Duration can represent due to int64_t's size limit.");
+  }
+
+  return Nanoseconds(static_cast<int64_t>(seconds * SECONDS));
+}
+
+
+inline Duration Duration::max() { return Nanoseconds(LLONG_MAX); }
+
+
+inline Duration Duration::min() { return Nanoseconds(LLONG_MIN); }
+
+#endif // __STOUT_DURATION_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/error.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/error.hpp b/third_party/libprocess/3rdparty/stout/include/stout/error.hpp
new file mode 100644
index 0000000..97a5cec
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/error.hpp
@@ -0,0 +1,72 @@
+#ifndef __STOUT_ERROR_HPP__
+#define __STOUT_ERROR_HPP__
+
+#include <errno.h>
+#include <string.h> // For strerror.
+
+#include <string>
+
+#include "result.hpp"
+#include "try.hpp"
+
+// An "error" type that is implicitly convertible to a Try<T> or
+// Result<T> for any T (effectively "syntactic sugar" to make code
+// more readable). The implementation uses cast operators to perform
+// the conversions instead of adding constructors to Try/Result
+// directly. One could imagine revisiting that decision for C++11
+// because the use of rvalue reference could eliminate some
+// unnecessary copies. However, performance is not critical since
+// Error should not get called very often in practice (if so, it's
+// probably being used for things that aren't really errors or there
+// is a more serious problem during execution).
+
+class Error
+{
+public:
+  explicit Error(const std::string& _message) : message(_message) {}
+
+  template <typename T>
+  operator Try<T> () const
+  {
+    return Try<T>::error(message);
+  }
+
+  // Give the compiler some help for nested Try<T>. For example,
+  // enable converting Error to an Option<Try<T>>. Note that this will
+  // bind to the innermost Try<T>.
+  template <template <typename> class S, typename T>
+  operator S<Try<T> > () const
+  {
+    return S<Try<T> >(Try<T>::error(message));
+  }
+
+  template <typename T>
+  operator Result<T> () const
+  {
+    return Result<T>::error(message);
+  }
+
+  // Give the compiler some help for nested Result<T>. For example,
+  // enable converting Error to an Option<Result<T>>. Note that this
+  // will bind to the innermost Result<T>.
+  template <template <typename> class S, typename T>
+  operator S<Result<T> > () const
+  {
+    return S<Result<T> >(Result<T>::error(message));
+  }
+
+  const std::string message;
+};
+
+
+class ErrnoError : public Error
+{
+public:
+  ErrnoError()
+    : Error(std::string(strerror(errno))) {}
+
+  ErrnoError(const std::string& message)
+    : Error(message + ": " + std::string(strerror(errno))) {}
+};
+
+#endif // __STOUT_ERROR_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/exit.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/exit.hpp b/third_party/libprocess/3rdparty/stout/include/stout/exit.hpp
new file mode 100644
index 0000000..e8da726
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/exit.hpp
@@ -0,0 +1,37 @@
+#ifndef __STOUT_EXIT_HPP__
+#define __STOUT_EXIT_HPP__
+
+#include <stdlib.h>
+
+#include <iostream> // For std::cerr.
+#include <ostream>
+#include <sstream>
+#include <string>
+
+// Exit takes an exit status and provides a stream for output prior to
+// exiting. This is like glog's LOG(FATAL) or CHECK, except that it
+// does _not_ print a stack trace.
+//
+// Ex: EXIT(1) << "Cgroups are not present in this system.";
+#define EXIT(status) __Exit(status).stream()
+
+struct __Exit
+{
+  __Exit(int _status) : status(_status) {}
+
+  ~__Exit()
+  {
+    std::cerr << out.str() << std::endl;
+    exit(status);
+  }
+
+  std::ostream& stream()
+  {
+    return out;
+  }
+
+  std::ostringstream out;
+  const int status;
+};
+
+#endif // __STOUT_EXIT_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/fatal.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/fatal.hpp b/third_party/libprocess/3rdparty/stout/include/stout/fatal.hpp
new file mode 100644
index 0000000..eabee3e
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/fatal.hpp
@@ -0,0 +1,43 @@
+#ifndef __STOUT_FATAL_HPP__
+#define __STOUT_FATAL_HPP__
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/*
+ * Like the non-debug version except includes the file name and line
+ * number in the output.
+ */
+#define fatal(fmt...) __fatal(__FILE__, __LINE__, fmt)
+inline void __fatal(const char *file, int line, const char *fmt, ...)
+{
+  va_list args;
+  va_start(args, fmt);
+  vfprintf(stderr, fmt, args);
+  fprintf(stderr, " (%s:%u)\n", file, line);
+  fflush(stderr);
+  va_end(args);
+  exit(1);
+}
+
+
+/*
+ * Like the non-debug version except includes the file name and line
+ * number in the output.
+ */
+#define fatalerror(fmt...) __fatalerror(__FILE__, __LINE__, fmt)
+inline void __fatalerror(const char *file, int line, const char *fmt, ...)
+{
+  va_list args;
+  va_start(args, fmt);
+  vfprintf(stderr, fmt, args);
+  fprintf(stderr, " (%s:%u): ", file, line);
+  perror(NULL);
+  fflush(stderr);
+  va_end(args);
+  exit(1);
+}
+
+#endif // __STOUT_FATAL_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/flags.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/flags.hpp b/third_party/libprocess/3rdparty/stout/include/stout/flags.hpp
new file mode 100644
index 0000000..0efd079
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/flags.hpp
@@ -0,0 +1,70 @@
+#ifndef __STOUT_FLAGS_HPP__
+#define __STOUT_FLAGS_HPP__
+
+#include <stout/flags/flags.hpp>
+
+// An abstraction for application/library "flags". An example is
+// probably best:
+//  -------------------------------------------------------------
+// class MyFlags : public virtual FlagsBase // Use 'virtual' for composition!
+// {
+// public:
+//   Flags()
+//   {
+//     add(&debug,
+//         "debug",
+//         "Help string for debug",
+//         false);
+//
+//     add(&name,
+//         "name",
+//         "Help string for name");
+//   }
+
+//   bool debug;
+//   Option<string> name;
+// };
+//
+// ...
+//
+// map<string, Option<string> > values;
+// values["no-debug"] = None();                       // --no-debug
+// values["debug"] = None();                          // --debug
+// values["debug"] = Option<string>::some("true");    // --debug=true
+// values["debug"] = Option<string>::some("false");   // --debug=false
+// values["name"] = Option<string>::some("frank");    // --name=frank
+//
+// MyFlags flags;
+// flags.load(values);
+// flags.name.isSome() ...
+// flags.debug ...
+//  -------------------------------------------------------------
+//
+// You can also compose flags provided that each has used "virtual
+// inheritance":
+//  -------------------------------------------------------------
+// Flags<MyFlags1, MyFlags2> flags;
+// flags.add(...); // Any other flags you want to throw in there.
+// flags.load(values);
+// flags.flag_from_myflags1 ...
+// flags.flag_from_myflags2 ...
+//  -------------------------------------------------------------
+//
+// "Fail early, fail often":
+//
+// You can not add duplicate flags, this is checked for you at compile
+// time for composite flags (e.g., Flag<MyFlags1, MyFlags2>) and also
+// checked at runtime for any other flags added via inheritance or
+// Flags::add(...).
+//
+// Flags that can not be loaded (e.g., attempting to use the 'no-'
+// prefix for a flag that is not boolean) will print a message to
+// standard error and abort the process.
+
+// TODO(benh): Provide a boolean which specifies whether or not to
+// abort on duplicates or load errors.
+
+// TODO(benh): Make prefix for environment variables configurable
+// (e.g., "MESOS_").
+
+#endif // __STOUT_FLAGS_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/flags/flag.hpp b/third_party/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
new file mode 100644
index 0000000..d31c984
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/flags/flag.hpp
@@ -0,0 +1,26 @@
+#ifndef __STOUT_FLAGS_FLAG_HPP__
+#define __STOUT_FLAGS_FLAG_HPP__
+
+#include <string>
+
+#include <tr1/functional>
+
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+namespace flags {
+
+// Forward declaration.
+class FlagsBase;
+
+struct Flag
+{
+  std::string name;
+  std::string help;
+  bool boolean;
+  std::tr1::function<Try<Nothing>(FlagsBase*, const std::string&)> loader;
+};
+
+} // namespace flags {
+
+#endif // __STOUT_FLAGS_FLAG_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/flags/flags.hpp b/third_party/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
new file mode 100644
index 0000000..77d36e6
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/flags/flags.hpp
@@ -0,0 +1,481 @@
+#ifndef __STOUT_FLAGS_FLAGS_HPP__
+#define __STOUT_FLAGS_FLAGS_HPP__
+
+#include <stdlib.h> // For abort.
+
+#include <map>
+#include <string>
+#include <typeinfo> // For typeid.
+
+#include <tr1/functional>
+
+#include <stout/error.hpp>
+#include <stout/exit.hpp>
+#include <stout/foreach.hpp>
+#include <stout/none.hpp>
+#include <stout/nothing.hpp>
+#include <stout/option.hpp>
+#include <stout/os.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+#include <stout/try.hpp>
+
+#include <stout/flags/flag.hpp>
+#include <stout/flags/loader.hpp>
+#include <stout/flags/parse.hpp>
+
+namespace flags {
+
+class FlagsBase
+{
+public:
+  virtual ~FlagsBase() {}
+
+  // Load any flags from the environment given the variable prefix,
+  // i.e., given prefix 'STOUT_' will load a flag named 'foo' via
+  // environment variables 'STOUT_foo' or 'STOUT_FOO'.
+  virtual Try<Nothing> load(
+      const std::string& prefix,
+      bool unknowns = false);
+
+  // Load any flags from the environment given the variable prefix
+  // (see above) followed by loading from the command line (via 'argc'
+  // and 'argv'). If 'unknowns' is true then we'll ignore unknown
+  // flags we see while loading. If 'duplicates' is true then we'll
+  // ignore any duplicates we see while loading.
+  virtual Try<Nothing> load(
+      const Option<std::string>& prefix,
+      int argc,
+      char** argv,
+      bool unknowns = false,
+      bool duplicates = false);
+
+  Try<Nothing> load(
+      const std::string& prefix,
+      int argc,
+      char** argv,
+      bool unknowns = false,
+      bool duplicates = false);
+
+  virtual Try<Nothing> load(
+      const std::map<std::string, Option<std::string> >& values,
+      bool unknowns = false);
+
+  virtual Try<Nothing> load(
+      const std::map<std::string, std::string>& values,
+      bool unknowns = false);
+
+  // Returns a string describing the flags.
+  std::string usage() const;
+
+  typedef std::map<std::string, Flag>::const_iterator const_iterator;
+
+  const_iterator begin() const { return flags.begin(); }
+  const_iterator end() const { return flags.end(); }
+
+  template <typename T1, typename T2>
+  void add(T1* t1,
+           const std::string& name,
+           const std::string& help,
+           const T2& t2);
+
+  template <typename T>
+  void add(Option<T>* option,
+           const std::string& name,
+           const std::string& help);
+
+protected:
+  template <typename Flags, typename T1, typename T2>
+  void add(T1 Flags::*t1,
+           const std::string& name,
+           const std::string& help,
+           const T2& t2);
+
+  template <typename Flags, typename T>
+  void add(Option<T> Flags::*option,
+           const std::string& name,
+           const std::string& help);
+
+  void add(const Flag& flag);
+
+private:
+  std::map<std::string, Flag> flags;
+};
+
+
+// Need to declare/define some explicit subclasses of FlagsBase so
+// that we can overload the 'Flags::operator FlagsN () const'
+// functions for each possible type.
+class _Flags1 : public virtual FlagsBase {};
+class _Flags2 : public virtual FlagsBase {};
+class _Flags3 : public virtual FlagsBase {};
+class _Flags4 : public virtual FlagsBase {};
+class _Flags5 : public virtual FlagsBase {};
+
+
+// TODO(benh): Add some "type constraints" for template paramters to
+// make sure they are all of type FlagsBase.
+template <typename Flags1 = _Flags1,
+          typename Flags2 = _Flags2,
+          typename Flags3 = _Flags3,
+          typename Flags4 = _Flags4,
+          typename Flags5 = _Flags5>
+class Flags : public virtual Flags1,
+              public virtual Flags2,
+              public virtual Flags3,
+              public virtual Flags4,
+              public virtual Flags5 {};
+
+
+template <typename T1, typename T2>
+void FlagsBase::add(
+    T1* t1,
+    const std::string& name,
+    const std::string& help,
+    const T2& t2)
+{
+  *t1 = t2; // Set the default.
+
+  Flag flag;
+  flag.name = name;
+  flag.help = help;
+  flag.boolean = typeid(T1) == typeid(bool);
+  flag.loader = std::tr1::bind(
+      &Loader<T1>::load,
+      t1,
+      std::tr1::function<Try<T1>(const std::string&)>(
+          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+      name,
+      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
+
+  // Update the help string to include the default value.
+  flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
+    ? " (default: " // On same line, add space.
+    : "(default: "; // On newline.
+  flag.help += stringify(t2);
+  flag.help += ")";
+
+  FlagsBase::add(flag);
+}
+
+
+template <typename T>
+void FlagsBase::add(
+    Option<T>* option,
+    const std::string& name,
+    const std::string& help)
+{
+  Flag flag;
+  flag.name = name;
+  flag.help = help;
+  flag.boolean = typeid(T) == typeid(bool);
+  flag.loader = std::tr1::bind(
+      &OptionLoader<T>::load,
+      option,
+      std::tr1::function<Try<T>(const std::string&)>(
+          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+      name,
+      std::tr1::placeholders::_2); // Use _2 because ignore FlagsBase*.
+
+  FlagsBase::add(flag);
+}
+
+
+template <typename Flags, typename T1, typename T2>
+void FlagsBase::add(
+    T1 Flags::*t1,
+    const std::string& name,
+    const std::string& help,
+    const T2& t2)
+{
+  Flags* flags = dynamic_cast<Flags*>(this);
+  if (flags == NULL) {
+    std::cerr << "Attempted to add flag '" << name
+              << "' with incompatible type" << std::endl;
+    abort();
+  } else {
+    flags->*t1 = t2; // Set the default.
+  }
+
+  Flag flag;
+  flag.name = name;
+  flag.help = help;
+  flag.boolean = typeid(T1) == typeid(bool);
+  flag.loader = std::tr1::bind(
+      &MemberLoader<Flags, T1>::load,
+      std::tr1::placeholders::_1,
+      t1,
+      std::tr1::function<Try<T1>(const std::string&)>(
+          std::tr1::bind(&parse<T1>, std::tr1::placeholders::_1)),
+      name,
+      std::tr1::placeholders::_2);
+
+  // Update the help string to include the default value.
+  flag.help += help.size() > 0 && help.find_last_of("\n\r") != help.size() - 1
+    ? " (default: " // On same line, add space.
+    : "(default: "; // On newline.
+  flag.help += stringify(t2);
+  flag.help += ")";
+
+  add(flag);
+}
+
+
+template <typename Flags, typename T>
+void FlagsBase::add(
+    Option<T> Flags::*option,
+    const std::string& name,
+    const std::string& help)
+{
+  Flags* flags = dynamic_cast<Flags*>(this);
+  if (flags == NULL) {
+    std::cerr << "Attempted to add flag '" << name
+              << "' with incompatible type" << std::endl;
+    abort();
+  }
+
+  Flag flag;
+  flag.name = name;
+  flag.help = help;
+  flag.boolean = typeid(T) == typeid(bool);
+  flag.loader = std::tr1::bind(
+      &OptionMemberLoader<Flags, T>::load,
+      std::tr1::placeholders::_1,
+      option,
+      std::tr1::function<Try<T>(const std::string&)>(
+          std::tr1::bind(&parse<T>, std::tr1::placeholders::_1)),
+      name,
+      std::tr1::placeholders::_2);
+
+  add(flag);
+}
+
+
+inline void FlagsBase::add(const Flag& flag)
+{
+  if (flags.count(flag.name) > 0) {
+    EXIT(1) << "Attempted to add duplicate flag '" << flag.name << "'";
+  } else if (flag.name.find("no-") == 0) {
+    EXIT(1) << "Attempted to add flag '" << flag.name
+            << "' that starts with the reserved 'no-' prefix";
+  }
+
+  flags[flag.name] = flag;
+}
+
+
+// Extract environment variable "flags" with the specified prefix.
+inline std::map<std::string, Option<std::string> > extract(
+    const std::string& prefix)
+{
+  char** environ = os::environ();
+
+  std::map<std::string, Option<std::string> > values;
+
+  for (int i = 0; environ[i] != NULL; i++) {
+    std::string variable = environ[i];
+    if (variable.find(prefix) == 0) {
+      size_t eq = variable.find_first_of("=");
+      if (eq == std::string::npos) {
+        continue; // Not expecting a missing '=', but ignore anyway.
+      }
+      std::string name = variable.substr(prefix.size(), eq - prefix.size());
+      name = strings::lower(name); // Allow PREFIX_NAME or PREFIX_name.
+      std::string value = variable.substr(eq + 1);
+      values[name] = Option<std::string>::some(value);
+    }
+  }
+
+  return values;
+}
+
+
+inline Try<Nothing> FlagsBase::load(
+    const std::string& prefix,
+    bool unknowns)
+{
+  return load(extract(prefix), unknowns);
+}
+
+
+inline Try<Nothing> FlagsBase::load(
+    const Option<std::string>& prefix,
+    int argc,
+    char** argv,
+    bool unknowns,
+    bool duplicates)
+{
+  std::map<std::string, Option<std::string> > values;
+
+  if (prefix.isSome()) {
+    values = extract(prefix.get());
+  }
+
+  // Read flags from the command line.
+  for (int i = 1; i < argc; i++) {
+    const std::string arg(argv[i]);
+
+    std::string name;
+    Option<std::string> value = None();
+    if (arg.find("--") == 0) {
+      size_t eq = arg.find_first_of("=");
+      if (eq == std::string::npos && arg.find("--no-") == 0) { // --no-name
+        name = arg.substr(2);
+      } else if (eq == std::string::npos) {                    // --name
+        name = arg.substr(2);
+      } else {                                                 // --name=value
+        name = arg.substr(2, eq - 2);
+        value = arg.substr(eq + 1);
+      }
+    }
+    name = strings::lower(name);
+
+    if (!duplicates) {
+      if (values.count(name) > 0 ||
+          (name.find("no-") == 0 && values.count(name.substr(3)) > 0)) {
+        return Error("Duplicate flag '" + name + "' on command line");
+      }
+    }
+
+    values[name] = value;
+  }
+
+  return load(values, unknowns);
+}
+
+
+inline Try<Nothing> FlagsBase::load(
+    const std::string& prefix,
+    int argc,
+    char** argv,
+    bool unknowns,
+    bool duplicates)
+{
+  return load(Option<std::string>::some(prefix),
+              argc,
+              argv,
+              unknowns,
+              duplicates);
+}
+
+
+inline Try<Nothing> FlagsBase::load(
+    const std::map<std::string, Option<std::string> >& values,
+    bool unknowns)
+{
+  std::map<std::string, Option<std::string> >::const_iterator iterator;
+
+  for (iterator = values.begin(); iterator != values.end(); ++iterator) {
+    const std::string& name = iterator->first;
+    const Option<std::string>& value = iterator->second;
+
+    if (flags.count(name) > 0) {
+      if (value.isSome()) {                        // --name=value
+        if (flags[name].boolean && value.get() == "") {
+          flags[name].loader(this, "true"); // Should never fail.
+        } else {
+          Try<Nothing> loader = flags[name].loader(this, value.get());
+          if (loader.isError()) {
+            return Error(
+                "Failed to load flag '" + name + "': " + loader.error());
+          }
+        }
+      } else {                                     // --name
+        if (flags[name].boolean) {
+          flags[name].loader(this, "true"); // Should never fail.
+        } else {
+          return Error(
+              "Failed to load non-boolean flag '" + name + "': Missing value");
+        }
+      }
+    } else if (name.find("no-") == 0) {
+      if (flags.count(name.substr(3)) > 0) {       // --no-name
+        if (flags[name.substr(3)].boolean) {
+          if (value.isNone() || value.get() == "") {
+            flags[name.substr(3)].loader(this, "false"); // Should never fail.
+          } else {
+            return Error(
+                "Failed to load boolean flag '" + name.substr(3) +
+                "' via '" + name + "' with value '" + value.get() + "'");
+          }
+        } else {
+          return Error(
+              "Failed to load non-boolean flag '" + name.substr(3) +
+              "' via '" + name + "'");
+        }
+      } else {
+        return Error(
+            "Failed to load unknown flag '" + name.substr(3) +
+            "' via '" + name + "'");
+      }
+    } else if (!unknowns) {
+      return Error("Failed to load unknown flag '" + name + "'");
+    }
+  }
+
+  return Nothing();
+}
+
+
+inline Try<Nothing> FlagsBase::load(
+    const std::map<std::string, std::string>& _values,
+    bool unknowns)
+{
+  std::map<std::string, Option<std::string> > values;
+  std::map<std::string, std::string>::const_iterator iterator;
+  for (iterator = _values.begin(); iterator != _values.end(); ++iterator) {
+    const std::string& name = iterator->first;
+    const std::string& value = iterator->second;
+    values[name] = Option<std::string>::some(value);
+  }
+  return load(values, unknowns);
+}
+
+
+inline std::string FlagsBase::usage() const
+{
+  const int PAD = 5;
+
+  std::string usage;
+
+  std::map<std::string, std::string> col1; // key -> col 1 string
+
+  // Construct string for the first column and store width of column.
+  size_t width = 0;
+
+  foreachvalue (const flags::Flag& flag, *this) {
+    if (flag.boolean) {
+      col1[flag.name] = "  --[no-]" + flag.name;
+    } else {
+      col1[flag.name] = "  --" + flag.name + "=VALUE";
+    }
+    width = std::max(width, col1[flag.name].size());
+  }
+
+  foreachvalue (const flags::Flag& flag, *this) {
+    std::string line = col1[flag.name];
+
+    std::string pad(PAD + width - line.size(), ' ');
+    line += pad;
+
+    size_t pos1 = 0, pos2 = 0;
+    pos2 = flag.help.find_first_of("\n\r", pos1);
+    line += flag.help.substr(pos1, pos2 - pos1) + "\n";
+    usage += line;
+
+    while (pos2 != std::string::npos) {  // Handle multi-line help strings.
+      line = "";
+      pos1 = pos2 + 1;
+      std::string pad2(PAD + width, ' ');
+      line += pad2;
+      pos2 = flag.help.find_first_of("\n\r", pos1);
+      line += flag.help.substr(pos1, pos2 - pos1) + "\n";
+      usage += line;
+    }
+  }
+  return usage;
+}
+
+} // namespace flags {
+
+#endif // __STOUT_FLAGS_FLAGS_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/flags/loader.hpp b/third_party/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
new file mode 100644
index 0000000..e5eaf24
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/flags/loader.hpp
@@ -0,0 +1,109 @@
+#ifndef __STOUT_FLAGS_LOADER_HPP__
+#define __STOUT_FLAGS_LOADER_HPP__
+
+#include <string>
+
+#include <tr1/functional>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/option.hpp>
+#include <stout/try.hpp>
+
+#include <stout/flags/parse.hpp>
+
+namespace flags {
+
+// Forward declaration.
+class FlagsBase;
+
+template <typename T>
+struct Loader
+{
+  static Try<Nothing> load(
+      T* flag,
+      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const std::string& name,
+      const std::string& value)
+  {
+    Try<T> t = parse(value);
+    if (t.isSome()) {
+      *flag = t.get();
+    } else {
+      return Error("Failed to load value '" + value + "': " + t.error());
+    }
+    return Nothing();
+  }
+};
+
+
+template <typename T>
+struct OptionLoader
+{
+  static Try<Nothing> load(
+      Option<T>* flag,
+      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const std::string& name,
+      const std::string& value)
+  {
+    Try<T> t = parse(value);
+    if (t.isSome()) {
+      *flag = Option<T>::some(t.get());
+    } else {
+      return Error("Failed to load value '" + value + "': " + t.error());
+    }
+    return Nothing();
+  }
+};
+
+
+template <typename F, typename T>
+struct MemberLoader
+{
+  static Try<Nothing> load(
+      FlagsBase* base,
+      T F::*flag,
+      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const std::string& name,
+      const std::string& value)
+  {
+    F* f = dynamic_cast<F*>(base);
+    if (f != NULL) {
+      Try<T> t = parse(value);
+      if (t.isSome()) {
+        f->*flag = t.get();
+      } else {
+        return Error("Failed to load value '" + value + "': " + t.error());
+      }
+    }
+    return Nothing();
+  }
+};
+
+
+template <typename F, typename T>
+struct OptionMemberLoader
+{
+  static Try<Nothing> load(
+      FlagsBase* base,
+      Option<T> F::*flag,
+      const std::tr1::function<Try<T>(const std::string&)>& parse,
+      const std::string& name,
+      const std::string& value)
+  {
+    F* f = dynamic_cast<F*>(base);
+    if (f != NULL) {
+      Try<T> t = parse(value);
+      if (t.isSome()) {
+        f->*flag = Option<T>::some(t.get());
+      } else {
+        return Error("Failed to load value '" + value + "': " + t.error());
+      }
+    }
+    return Nothing();
+  }
+};
+
+} // namespace flags {
+
+#endif // __STOUT_FLAGS_LOADER_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/flags/parse.hpp b/third_party/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
new file mode 100644
index 0000000..54eb35c
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/flags/parse.hpp
@@ -0,0 +1,55 @@
+#ifndef __STOUT_FLAGS_PARSE_HPP__
+#define __STOUT_FLAGS_PARSE_HPP__
+
+#include <sstream> // For istringstream.
+#include <string>
+
+#include <tr1/functional>
+
+#include <stout/duration.hpp>
+#include <stout/error.hpp>
+#include <stout/try.hpp>
+
+namespace flags {
+
+template <typename T>
+Try<T> parse(const std::string& value)
+{
+  T t;
+  std::istringstream in(value);
+  in >> t;
+  if (!in.good() && !in.eof()) {
+    return Error("Failed to convert into required type");
+  }
+  return t;
+}
+
+
+template <>
+inline Try<std::string> parse(const std::string& value)
+{
+  return value;
+}
+
+
+template <>
+inline Try<bool> parse(const std::string& value)
+{
+  if (value == "true" || value == "1") {
+    return true;
+  } else if (value == "false" || value == "0") {
+    return false;
+  }
+  return Error("Expecting a boolean (e.g., true or false)");
+}
+
+
+template <>
+inline Try<Duration> parse(const std::string& value)
+{
+  return Duration::parse(value);
+}
+
+} // namespace flags {
+
+#endif // __STOUT_FLAGS_PARSE_HPP__

http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/bc531d3c/third_party/libprocess/3rdparty/stout/include/stout/foreach.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/3rdparty/stout/include/stout/foreach.hpp b/third_party/libprocess/3rdparty/stout/include/stout/foreach.hpp
new file mode 100644
index 0000000..0afe285
--- /dev/null
+++ b/third_party/libprocess/3rdparty/stout/include/stout/foreach.hpp
@@ -0,0 +1,51 @@
+#ifndef __STOUT_FOREACH_HPP__
+#define __STOUT_FOREACH_HPP__
+
+#include <boost/foreach.hpp>
+
+#include <boost/tuple/tuple.hpp>
+
+namespace __foreach__ {
+
+// NOTE: This is a copied from Boost
+// (boost/tuple/detail/tuple_basic_no_partial_spec.hpp) because the
+// new 'boost::tuples::ignore' does not work in our 'foreachkey' and
+// 'foreachvalue'.
+struct swallow_assign {
+  template<typename T>
+  swallow_assign const& operator=(const T&) const {
+    return *this;
+  }
+};
+
+swallow_assign const ignore = swallow_assign();
+
+} // namespace __foreach__ {
+
+#define BOOST_FOREACH_PAIR(VARFIRST, VARSECOND, COL)                                            \
+    BOOST_FOREACH_PREAMBLE()                                                                    \
+    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else   \
+    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
+    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else       \
+    for (bool BOOST_FOREACH_ID(_foreach_continue) = true, BOOST_FOREACH_ID(_foreach_onetime) = true;                                \
+              BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_DONE(COL);                                    \
+              BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_NEXT(COL) : (void)0)                            \
+        if  (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_onetime))) {} else                       \
+        for (VARFIRST = BOOST_FOREACH_DEREF(COL).first;                                         \
+	     !BOOST_FOREACH_ID(_foreach_onetime);                                                                 \
+	     BOOST_FOREACH_ID(_foreach_onetime) = true)                                                           \
+            if  (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else                  \
+            for (VARSECOND = BOOST_FOREACH_DEREF(COL).second;                                   \
+		 !BOOST_FOREACH_ID(_foreach_continue);                                                            \
+		 BOOST_FOREACH_ID(_foreach_continue) = true)
+
+#define foreach BOOST_FOREACH
+#define foreachpair BOOST_FOREACH_PAIR
+
+#define foreachkey(VAR, COL)                    \
+  foreachpair (VAR, __foreach__::ignore, COL)
+
+#define foreachvalue(VAR, COL)                  \
+  foreachpair (__foreach__::ignore, VAR, COL)
+
+#endif // __STOUT_FOREACH_HPP__