Repository: mesos Updated Branches: refs/heads/master be1d6833e -> 02097c821
Added module loading to scheduler driver. Review: https://reviews.apache.org/r/27806 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/167f1b34 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/167f1b34 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/167f1b34 Branch: refs/heads/master Commit: 167f1b348bb1890b0de9aa4a864f31109a75f5c3 Parents: be1d683 Author: Till Toenshoff <[email protected]> Authored: Wed Nov 12 14:54:44 2014 -0800 Committer: Adam B <[email protected]> Committed: Wed Nov 12 14:54:44 2014 -0800 ---------------------------------------------------------------------- src/sched/flags.hpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ src/sched/sched.cpp | 14 +++++++++++++ 2 files changed, 66 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/167f1b34/src/sched/flags.hpp ---------------------------------------------------------------------- diff --git a/src/sched/flags.hpp b/src/sched/flags.hpp index 62a634b..e1c1c25 100644 --- a/src/sched/flags.hpp +++ b/src/sched/flags.hpp @@ -21,8 +21,12 @@ #include <stout/flags.hpp> +#include "common/parse.hpp" + #include "logging/flags.hpp" +#include "messages/messages.hpp" + #include "sched/constants.hpp" namespace mesos { @@ -43,9 +47,57 @@ public: "failover timeout/10, if failover timeout is specified) or " + stringify(REGISTRATION_RETRY_INTERVAL_MAX) + ", whichever is smaller", REGISTRATION_BACKOFF_FACTOR); + + // This help message for --modules flag is the same for + // {master,slave,tests,sched}/flags.hpp and should always be kept + // in sync. + // TODO(karya): Remove the JSON example and add reference to the + // doc file explaining the --modules flag. + add(&Flags::modules, + "modules", + "List of modules to be loaded and be available to the internal\n" + "subsystems.\n" + "\n" + "Use --modules=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 --modules=\"{...}\" to specify the list of modules inline.\n" + "\n" + "Example:\n" + "{\n" + " \"libraries\": [\n" + " {\n" + " \"file\": \"/path/to/libfoo.so\",\n" + " \"modules\": [\n" + " {\n" + " \"name\": \"org_apache_mesos_bar\",\n" + " \"parameters\": [\n" + " {\n" + " \"key\": \"X\",\n" + " \"value\": \"Y\"\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"org_apache_mesos_baz\"\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"qux\",\n" + " \"modules\": [\n" + " {\n" + " \"name\": \"org_apache_mesos_norf\"\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}"); } Duration registration_backoff_factor; + Option<Modules> modules; }; } // namespace scheduler { http://git-wip-us.apache.org/repos/asf/mesos/blob/167f1b34/src/sched/sched.cpp ---------------------------------------------------------------------- diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index d662182..aef88ac 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -31,6 +31,7 @@ #include <sstream> #include <mesos/mesos.hpp> +#include <mesos/module.hpp> #include <mesos/scheduler.hpp> #include <process/defer.hpp> @@ -75,6 +76,8 @@ #include "messages/messages.hpp" +#include "module/manager.hpp" + #include "sched/constants.hpp" #include "sched/flags.hpp" @@ -1278,6 +1281,17 @@ Status MesosSchedulerDriver::start() return status; } + // 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 = modules::ModuleManager::load(flags.modules.get()); + if (result.isError()) { + status = DRIVER_ABORTED; + scheduler->error(this, "Error loading modules: " + result.error()); + return status; + } + } + CHECK(process == NULL); if (credential == NULL) {
