Repository: mesos Updated Branches: refs/heads/master 88b56261e -> 913b65326
Added --module flag for Mesos master. Review: https://reviews.apache.org/r/26508 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/913b6532 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/913b6532 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/913b6532 Branch: refs/heads/master Commit: 913b653268d8622bd2ec3c251fc92f8cbc1c8671 Parents: 88b5626 Author: Kapil Arya <[email protected]> Authored: Fri Oct 10 15:33:22 2014 -0700 Committer: Niklas Q. Nielsen <[email protected]> Committed: Fri Oct 10 16:03:07 2014 -0700 ---------------------------------------------------------------------- src/common/parse.hpp | 16 ++++++++++++++++ src/common/type_utils.hpp | 8 ++++++++ src/master/flags.hpp | 27 +++++++++++++++++++++++++++ src/master/main.cpp | 12 ++++++++++++ src/module/manager.hpp | 5 +++-- 5 files changed, 66 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/913b6532/src/common/parse.hpp ---------------------------------------------------------------------- diff --git a/src/common/parse.hpp b/src/common/parse.hpp index e6153d8..c9ca30f 100644 --- a/src/common/parse.hpp +++ b/src/common/parse.hpp @@ -23,6 +23,8 @@ #include <stout/flags/parse.hpp> +#include "messages/messages.hpp" + namespace flags { template<> @@ -52,6 +54,20 @@ inline Try<mesos::RateLimits> parse(const std::string& value) return protobuf::parse<mesos::RateLimits>(json.get()); } + +template<> +inline Try<mesos::internal::Modules> parse(const std::string& value) +{ + // Convert from string or file to JSON. + Try<JSON::Object> json = parse<JSON::Object>(value); + if (json.isError()) { + return Error(json.error()); + } + + // Convert from JSON to Protobuf. + return protobuf::parse<mesos::internal::Modules>(json.get()); +} + } // namespace flags { #endif // __COMMON_PARSE_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/913b6532/src/common/type_utils.hpp ---------------------------------------------------------------------- diff --git a/src/common/type_utils.hpp b/src/common/type_utils.hpp index 480c088..f10b2d3 100644 --- a/src/common/type_utils.hpp +++ b/src/common/type_utils.hpp @@ -340,6 +340,14 @@ inline std::ostream& operator << ( << StatusUpdateRecord::Type_descriptor()->FindValueByNumber(type)->name(); } + +inline std::ostream& operator << ( + std::ostream& stream, + const Modules& modules) +{ + return stream << modules.DebugString(); +} + } // namespace internal { } // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/913b6532/src/master/flags.hpp ---------------------------------------------------------------------- diff --git a/src/master/flags.hpp b/src/master/flags.hpp index b8b59a2..44249f8 100644 --- a/src/master/flags.hpp +++ b/src/master/flags.hpp @@ -35,6 +35,8 @@ #include "mesos/mesos.hpp" +#include "messages/messages.hpp" + namespace mesos { namespace internal { namespace master { @@ -298,6 +300,30 @@ public: "Duration of time before an offer is rescinded from a framework.\n" "This helps fairness when running frameworks that hold on to offers,\n" "or frameworks that accidentally drop offers.\n"); + + add(&Flags::modules, + "modules", + "List of modules to be loaded and be available to the internal\n" + "subsystems.\n" + "\n" + "Use --module=filepath to specify the list of modules via a\n" + "file containing a JSON formatted string. 'filepath' can be\n" + "of the form 'file:///path/to/file' or '/path/to/file'.\n" + "\n" + "Use --module=\"{...}\" to specify the list of modules inline.\n" + "\n" + "Example:\n" + "{\n" + " \"libraries\": [\n" + " {\n" + " \"file\": \"/path/to/libfoo.so\",\n" + " \"modules\": [\n" + " \"org_apache_mesos_bar\",\n" + " \"org_apache_mesos_baz\"\n" + " ]\n" + " }\n" + " ]\n" + "}"); } bool version; @@ -327,6 +353,7 @@ public: Option<ACLs> acls; Option<RateLimits> rate_limits; Option<Duration> offer_timeout; + Option<Modules> modules; #ifdef WITH_NETWORK_ISOLATOR Option<size_t> max_executors_per_slave; http://git-wip-us.apache.org/repos/asf/mesos/blob/913b6532/src/master/main.cpp ---------------------------------------------------------------------- diff --git a/src/master/main.cpp b/src/master/main.cpp index 018f803..72e243a 100644 --- a/src/master/main.cpp +++ b/src/master/main.cpp @@ -53,6 +53,8 @@ #include "master/registrar.hpp" #include "master/repairer.hpp" +#include "module/manager.hpp" + #include "state/in_memory.hpp" #include "state/log.hpp" #include "state/protobuf.hpp" @@ -141,6 +143,16 @@ int main(int argc, char** argv) exit(1); } + // Initialize modules. Note that since other subsystems may depend + // upon modules, we should initialize modules before anything else. + if (flags.modules.isSome()) { + Try<Nothing> result = ModuleManager::load(flags.modules.get()); + if (result.isError()) { + cerr << "Error loading modules: " << result.error() << endl; + exit(1); + } + } + // Initialize libprocess. if (ip.isSome()) { os::setenv("LIBPROCESS_IP", ip.get()); http://git-wip-us.apache.org/repos/asf/mesos/blob/913b6532/src/module/manager.hpp ---------------------------------------------------------------------- diff --git a/src/module/manager.hpp b/src/module/manager.hpp index 8275fd0..797728a 100644 --- a/src/module/manager.hpp +++ b/src/module/manager.hpp @@ -27,6 +27,9 @@ #include <glog/logging.h> +#include <mesos/mesos.hpp> +#include <mesos/module.hpp> + #include <messages/messages.hpp> #include <process/owned.hpp> @@ -37,8 +40,6 @@ #include "common/lock.hpp" -#include "mesos/mesos.hpp" - namespace mesos { namespace internal {
