I accidentally forgot to amend this commit with the wrapping fixes. Pushed those out separately just now.
On Thu, Apr 9, 2015 at 6:38 PM, <[email protected]> wrote: > Repository: mesos > Updated Branches: > refs/heads/master 5028490f9 -> 743e9e739 > > > Improved compile time of by adding cpp files for flag headers. > > Split the mesos master, slave flags into header + source file to > improve compile time significantly. Should be no functional changes. > > Review: https://reviews.apache.org/r/32558 > > > Project: http://git-wip-us.apache.org/repos/asf/mesos/repo > Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/743e9e73 > Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/743e9e73 > Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/743e9e73 > > Branch: refs/heads/master > Commit: 743e9e739c34ceff59db06725de6185cf64a8838 > Parents: 5028490 > Author: Cody Maloney <[email protected]> > Authored: Thu Apr 9 18:24:44 2015 -0700 > Committer: Benjamin Mahler <[email protected]> > Committed: Thu Apr 9 18:38:17 2015 -0700 > > ---------------------------------------------------------------------- > src/Makefile.am | 3 + > src/logging/flags.cpp | 51 ++++ > src/logging/flags.hpp | 40 +-- > src/master/allocator/allocator.hpp | 1 + > src/master/flags.cpp | 318 ++++++++++++++++++++++++ > src/master/flags.hpp | 345 +------------------------ > src/slave/flags.cpp | 389 +++++++++++++++++++++++++++++ > src/slave/flags.hpp | 428 +------------------------------- > 8 files changed, 769 insertions(+), 806 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/Makefile.am > ---------------------------------------------------------------------- > diff --git a/src/Makefile.am b/src/Makefile.am > index 9c01f5d..fa609da 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -316,10 +316,12 @@ libmesos_no_3rdparty_la_SOURCES = > \ > files/files.cpp \ > hook/manager.cpp \ > local/local.cpp \ > + logging/flags.cpp \ > logging/logging.cpp \ > master/contender.cpp \ > master/constants.cpp \ > master/detector.cpp \ > + master/flags.cpp \ > master/http.cpp \ > master/master.cpp \ > master/metrics.cpp \ > @@ -335,6 +337,7 @@ libmesos_no_3rdparty_la_SOURCES = > \ > scheduler/scheduler.cpp \ > slave/constants.cpp \ > slave/gc.cpp \ > + slave/flags.cpp \ > slave/http.cpp \ > slave/metrics.cpp \ > slave/monitor.cpp \ > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/logging/flags.cpp > ---------------------------------------------------------------------- > diff --git a/src/logging/flags.cpp b/src/logging/flags.cpp > new file mode 100644 > index 0000000..43c4f3c > --- /dev/null > +++ b/src/logging/flags.cpp > @@ -0,0 +1,51 @@ > +/** > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +#include "logging/flags.hpp" > + > + > +mesos::internal::logging::Flags::Flags() > +{ > + add(&Flags::quiet, "quiet", "Disable logging to stderr", false); > + > + add(&Flags::logging_level, "logging_level", > + "Log message at or above this level; possible values: \n" > + "'INFO', 'WARNING', 'ERROR'; if quiet flag is used, this \n" > + "will affect just the logs from log_dir (if specified)", > + "INFO"); > + > + add(&Flags::log_dir, "log_dir", > + "Directory path to put log files (no default, nothing\n" > + "is written to disk unless specified;\n" > + "does not affect logging to stderr).\n" > + "NOTE: 3rd party log messages (e.g. ZooKeeper) are\n" > + "only written to stderr!\n"); > + > + add(&Flags::logbufsecs, "logbufsecs", > + "How many seconds to buffer log messages for", 0); > + > + add(&Flags::initialize_driver_logging, "initialize_driver_logging", > + "Whether to automatically initialize google logging of scheduler\n" > + "and/or executor drivers.", > + true); > + > + add(&Flags::external_log_file, "external_log_file", > + "Specified the externally managed log file. This file will be\n" > + "exposed in the webui and HTTP api. This is useful when using\n" > + "stderr logging as the log file is otherwise unknown to Mesos."); > +} > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/logging/flags.hpp > ---------------------------------------------------------------------- > diff --git a/src/logging/flags.hpp b/src/logging/flags.hpp > index 4facb33..684bc35 100644 > --- a/src/logging/flags.hpp > +++ b/src/logging/flags.hpp > @@ -31,45 +31,7 @@ namespace logging { > class Flags : public virtual flags::FlagsBase > { > public: > - Flags() > - { > - add(&Flags::quiet, > - "quiet", > - "Disable logging to stderr", > - false); > - > - add(&Flags::logging_level, > - "logging_level", > - "Log message at or above this level; possible values: \n" > - "'INFO', 'WARNING', 'ERROR'; if quiet flag is used, this \n" > - "will affect just the logs from log_dir (if specified)", > - "INFO"); > - > - add(&Flags::log_dir, > - "log_dir", > - "Directory path to put log files (no default, nothing\n" > - "is written to disk unless specified;\n" > - "does not affect logging to stderr).\n" > - "NOTE: 3rd party log messages (e.g. ZooKeeper) are\n" > - "only written to stderr!\n"); > - > - add(&Flags::logbufsecs, > - "logbufsecs", > - "How many seconds to buffer log messages for", > - 0); > - > - add(&Flags::initialize_driver_logging, > - "initialize_driver_logging", > - "Whether to automatically initialize google logging of > scheduler\n" > - "and/or executor drivers.", > - true); > - > - add(&Flags::external_log_file, > - "external_log_file", > - "Specified the externally managed log file. This file will be\n" > - "exposed in the webui and HTTP api. This is useful when using\n" > - "stderr logging as the log file is otherwise unknown to Mesos."); > - } > + Flags(); > > bool quiet; > std::string logging_level; > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/master/allocator/allocator.hpp > ---------------------------------------------------------------------- > diff --git a/src/master/allocator/allocator.hpp > b/src/master/allocator/allocator.hpp > index b67b8fd..91f8050 100644 > --- a/src/master/allocator/allocator.hpp > +++ b/src/master/allocator/allocator.hpp > @@ -30,6 +30,7 @@ > #include <stout/option.hpp> > > #include "master/flags.hpp" > +#include "messages/messages.hpp" > > namespace mesos { > namespace internal { > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/master/flags.cpp > ---------------------------------------------------------------------- > diff --git a/src/master/flags.cpp b/src/master/flags.cpp > new file mode 100644 > index 0000000..133d55c > --- /dev/null > +++ b/src/master/flags.cpp > @@ -0,0 +1,318 @@ > +/** > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +#include <stout/flags.hpp> > + > +#include <mesos/type_utils.hpp> > + > +#include "common/parse.hpp" > +#include "master/constants.hpp" > +#include "master/flags.hpp" > + > + > +mesos::internal::master::Flags::Flags() > +{ > + add(&Flags::version, "version", "Show version and exit.", false); > + > + add(&Flags::hostname, "hostname", > + "The hostname the master should advertise in ZooKeeper.\n" > + "If left unset, the hostname is resolved from the IP address\n" > + "that the master binds to."); > + > + add(&Flags::root_submissions, "root_submissions", > + "Can root submit frameworks?", true); > + > + add(&Flags::work_dir, "work_dir", > + "Directory path to store the persistent information stored in the > \n" > + "Registry. (example: /var/lib/mesos/master)"); > + > + // TODO(bmahler): Consider removing 'in_memory' as it was only > + // used before 'replicated_log' was implemented. > + add(&Flags::registry, "registry", > + "Persistence strategy for the registry;\n" > + "available options are 'replicated_log', 'in_memory' (for > testing).", > + "replicated_log"); > + > + // TODO(vinod): Instead of specifying the quorum size consider > + // specifying the number of masters or the list of masters. > + add(&Flags::quorum, "quorum", > + "The size of the quorum of replicas when using 'replicated_log' > based\n" > + "registry. It is imperative to set this value to be a majority of\n" > + "masters i.e., quorum > (number of masters)/2."); > + > + add(&Flags::zk_session_timeout, "zk_session_timeout", > + "ZooKeeper session timeout.", ZOOKEEPER_SESSION_TIMEOUT); > + > + // TODO(bmahler): Set the default to true in 0.20.0. > + add(&Flags::registry_strict, "registry_strict", > + "Whether the Master will take actions based on the persistent\n" > + "information stored in the Registry. Setting this to false means\n" > + "that the Registrar will never reject the admission, readmission,\n" > + "or removal of a slave. Consequently, 'false' can be used to\n" > + "bootstrap the persistent state on a running cluster.\n" > + "NOTE: This flag is *experimental* and should not be used in\n" > + "production yet.", > + false); > + > + add(&Flags::registry_fetch_timeout, "registry_fetch_timeout", > + "Duration of time to wait in order to fetch data from the > registry\n" > + "after which the operation is considered a failure.", > + Seconds(60)); > + > + add(&Flags::registry_store_timeout, "registry_store_timeout", > + "Duration of time to wait in order to store data in the registry\n" > + "after which the operation is considered a failure.", > + Seconds(5)); > + > + add(&Flags::log_auto_initialize, "log_auto_initialize", > + "Whether to automatically initialize the replicated log used for > the\n" > + "registry. If this is set to false, the log has to be manually\n" > + "initialized when used for the very first time.", > + true); > + > + add(&Flags::slave_reregister_timeout, "slave_reregister_timeout", > + "The timeout within which all slaves are expected to re-register\n" > + "when a new master is elected as the leader. Slaves that do not\n" > + "re-register within the timeout will be removed from the registry\n" > + "and will be shutdown if they attempt to communicate with master.\n" > + "NOTE: This value has to be atleast " + > + stringify(MIN_SLAVE_REREGISTER_TIMEOUT) + ".", > + MIN_SLAVE_REREGISTER_TIMEOUT); > + > + // TODO(bmahler): Add a 'Percentage' abstraction for flags. > + // TODO(bmahler): Add a --production flag for production defaults. > + add(&Flags::recovery_slave_removal_limit, > "recovery_slave_removal_limit", > + "For failovers, limit on the percentage of slaves that can be > removed\n" > + "from the registry *and* shutdown after the re-registration > timeout\n" > + "elapses. If the limit is exceeded, the master will fail over > rather\n" > + "than remove the slaves.\n" > + "This can be used to provide safety guarantees for production\n" > + "environments. Production environments may expect that across > Master\n" > + "failovers, at most a certain percentage of slaves will fail\n" > + "permanently (e.g. due to rack-level failures).\n" > + "Setting this limit would ensure that a human needs to get\n" > + "involved should an unexpected widespread failure of slaves occur\n" > + "in the cluster.\n" > + "Values: [0%-100%]", > + stringify(RECOVERY_SLAVE_REMOVAL_PERCENT_LIMIT * 100.0) + "%"); > + > + // TODO(vinod): Add a 'Rate' abstraction in stout and the > + // corresponding parser for flags. > + add(&Flags::slave_removal_rate_limit, "slave_removal_rate_limit", > + "The maximum rate (e.g., 1/10mins, 2/3hrs, etc) at which slaves > will\n" > + "be removed from the master when they fail health checks. By > default\n" > + "slaves will be removed as soon as they fail the health checks.\n" > + "The value is of the form <Number of slaves>/<Duration>."); > + > + add(&Flags::webui_dir, "webui_dir", > + "Directory path of the webui files/assets", PKGDATADIR "/webui"); > + > + add(&Flags::whitelist, "whitelist", > + "Path to a file with a list of slaves\n" > + "(one per line) to advertise offers for.\n" > + "Path could be of the form 'file:///path/to/file' or > '/path/to/file'."); > + > + add(&Flags::user_sorter, "user_sorter", > + "Policy to use for allocating resources\n" > + "between users. May be one of:\n" > + " dominant_resource_fairness (drf)", > + "drf"); > + > + add(&Flags::framework_sorter, "framework_sorter", > + "Policy to use for allocating resources\n" > + "between a given user's frameworks. Options\n" > + "are the same as for user_allocator.", > + "drf"); > + > + add(&Flags::allocation_interval, "allocation_interval", > + "Amount of time to wait between performing\n" > + " (batch) allocations (e.g., 500ms, 1sec, etc).", > + Seconds(1)); > + > + add(&Flags::cluster, "cluster", > + "Human readable name for the cluster,\n" > + "displayed in the webui."); > + > + // TODO(vinod): Deprecate this in favor of '--acls'. > + add(&Flags::roles, "roles", > + "A comma separated list of the allocation\n" > + "roles that frameworks in this cluster may\n" > + "belong to."); > + > + add(&Flags::weights, "weights", > + "A comma separated list of role/weight pairs\n" > + "of the form 'role=weight,role=weight'. Weights\n" > + "are used to indicate forms of priority."); > + > + // TODO(adam-mesos): Deprecate --authenticate for > --authenticate_frameworks. > + add(&Flags::authenticate_frameworks, "authenticate", > + "If authenticate is 'true' only authenticated frameworks are > allowed\n" > + "to register. If 'false' unauthenticated frameworks are also\n" > + "allowed to register.", > + false); > + > + add(&Flags::authenticate_slaves, "authenticate_slaves", > + "If 'true' only authenticated slaves are allowed to register.\n" > + "If 'false' unauthenticated slaves are also allowed to register.", > + false); > + > + add(&Flags::credentials, "credentials", > + "Either a path to a text file with a list of credentials,\n" > + "each line containing 'principal' and 'secret' separated by " > + "whitespace,\n" > + "or, a path to a JSON-formatted file containing credentials.\n" > + "Path could be of the form 'file:///path/to/file' or > '/path/to/file'." > + "\n" > + "JSON file Example:\n" > + "{\n" > + " \"credentials\": [\n" > + " {\n" > + " \"principal\": \"sherman\",\n" > + " \"secret\": \"kitesurf\",\n" > + " }\n" > + " ]\n" > + "}\n" > + "Text file Example:\n" > + "username secret\n"); > + > + add(&Flags::acls, "acls", > + "The value could be a JSON formatted string of ACLs\n" > + "or a file path containing the JSON formatted ACLs used\n" > + "for authorization. Path could be of the form > 'file:///path/to/file'\n" > + "or '/path/to/file'.\n" > + "\n" > + "See the ACLs protobuf in mesos.proto for the expected format.\n" > + "\n" > + "Example:\n" > + "{\n" > + " \"register_frameworks\": [\n" > + " {\n" > + " \"principals\": { \"type\": \"ANY\" },\n" > + " \"roles\": { \"values\": [\"a\"] }\n" > + " }\n" > + " ],\n" > + " \"run_tasks\": [\n" > + " {\n" > + " \"principals\": { \"values\": [\"a\", \"b\"] > },\n" > + " \"users\": { \"values\": [\"c\"] }\n" > + " }\n" > + " ],\n" > + " \"shutdown_frameworks\": [\n" > + " {\n" > + " \"principals\": { \"values\": [\"a\", \"b\"] > },\n" > + " \"framework_principals\": { \"values\": [\"c\"] > }\n" > + " }\n" > + " ]\n" > + "}"); > + > + add(&Flags::rate_limits, "rate_limits", > + "The value could be a JSON formatted string of rate limits\n" > + "or a file path containing the JSON formatted rate limits used\n" > + "for framework rate limiting.\n" > + "Path could be of the form 'file:///path/to/file'\n" > + "or '/path/to/file'.\n" > + "\n" > + "See the RateLimits protobuf in mesos.proto for the expected > format.\n" > + "\n" > + "Example:\n" > + "{\n" > + " \"limits\": [\n" > + " {\n" > + " \"principal\": \"foo\",\n" > + " \"qps\": 55.5\n" > + " },\n" > + " {\n" > + " \"principal\": \"bar\"\n" > + " }\n" > + " ],\n" > + " \"aggregate_default_qps\": 33.3\n" > + "}"); > + > +#ifdef WITH_NETWORK_ISOLATOR > + add(&Flags::max_executors_per_slave, "max_executors_per_slave", > + "Maximum number of executors allowed per slave. The network\n" > + "monitoring/isolation technique imposes an implicit resource\n" > + "acquisition on each executor (# ephemeral ports), as a result\n" > + "one can only run a certain number of executors on each slave."); > +#endif // WITH_NETWORK_ISOLATOR > + > + // TODO(karya): When we have optimistic offers, this will only > + // benefit frameworks that accidentally lose an offer. > + add(&Flags::offer_timeout, "offer_timeout", > + "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."); > + > + // This help message for --modules flag is the same for > + // {master,slave,tests}/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" > + "}"); > + > + add(&Flags::authenticators, "authenticators", > + "Authenticator implementation to use when authenticating > frameworks\n" > + "and/or slaves. Use the default '" + > + DEFAULT_AUTHENTICATOR + > + "', or\n" > + "load an alternate authenticator module using --modules.", > + DEFAULT_AUTHENTICATOR); > + > + add(&Flags::hooks, "hooks", > + "A comma separated list of hook modules to be\n" > + "installed inside master."); > +} > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/master/flags.hpp > ---------------------------------------------------------------------- > diff --git a/src/master/flags.hpp b/src/master/flags.hpp > index 85ce328..996cf38 100644 > --- a/src/master/flags.hpp > +++ b/src/master/flags.hpp > @@ -21,27 +21,15 @@ > > #include <string> > > -#include <mesos/mesos.hpp> > - > -#include <mesos/module/module.hpp> > - > #include <stout/duration.hpp> > -#include <stout/flags.hpp> > -#include <stout/json.hpp> > #include <stout/option.hpp> > #include <stout/path.hpp> > -#include <stout/protobuf.hpp> > > -#include "common/parse.hpp" > +#include <mesos/mesos.hpp> > +#include <mesos/module/module.hpp> > > #include "logging/flags.hpp" > > -#include "master/constants.hpp" > - > -#include "mesos/mesos.hpp" > - > -#include "messages/messages.hpp" > - > namespace mesos { > namespace internal { > namespace master { > @@ -49,334 +37,7 @@ namespace master { > class Flags : public logging::Flags > { > public: > - Flags() > - { > - add(&Flags::version, > - "version", > - "Show version and exit.", > - false); > - > - add(&Flags::hostname, > - "hostname", > - "The hostname the master should advertise in ZooKeeper.\n" > - "If left unset, the hostname is resolved from the IP address\n" > - "that the master binds to."); > - > - add(&Flags::root_submissions, > - "root_submissions", > - "Can root submit frameworks?", > - true); > - > - add(&Flags::work_dir, > - "work_dir", > - "Directory path to store the persistent information stored in the > \n" > - "Registry. (example: /var/lib/mesos/master)"); > - > - // TODO(bmahler): Consider removing 'in_memory' as it was only > - // used before 'replicated_log' was implemented. > - add(&Flags::registry, > - "registry", > - "Persistence strategy for the registry;\n" > - "available options are 'replicated_log', 'in_memory' (for > testing).", > - "replicated_log"); > - > - // TODO(vinod): Instead of specifying the quorum size consider > - // specifying the number of masters or the list of masters. > - add(&Flags::quorum, > - "quorum", > - "The size of the quorum of replicas when using 'replicated_log' > based\n" > - "registry. It is imperative to set this value to be a majority > of\n" > - "masters i.e., quorum > (number of masters)/2."); > - > - add(&Flags::zk_session_timeout, > - "zk_session_timeout", > - "ZooKeeper session timeout.", > - ZOOKEEPER_SESSION_TIMEOUT); > - > - // TODO(bmahler): Set the default to true in 0.20.0. > - add(&Flags::registry_strict, > - "registry_strict", > - "Whether the Master will take actions based on the persistent\n" > - "information stored in the Registry. Setting this to false > means\n" > - "that the Registrar will never reject the admission, > readmission,\n" > - "or removal of a slave. Consequently, 'false' can be used to\n" > - "bootstrap the persistent state on a running cluster.\n" > - "NOTE: This flag is *experimental* and should not be used in\n" > - "production yet.", > - false); > - > - add(&Flags::registry_fetch_timeout, > - "registry_fetch_timeout", > - "Duration of time to wait in order to fetch data from the > registry\n" > - "after which the operation is considered a failure.", > - Seconds(60)); > - > - add(&Flags::registry_store_timeout, > - "registry_store_timeout", > - "Duration of time to wait in order to store data in the > registry\n" > - "after which the operation is considered a failure.", > - Seconds(5)); > - > - add(&Flags::log_auto_initialize, > - "log_auto_initialize", > - "Whether to automatically initialize the replicated log used for > the\n" > - "registry. If this is set to false, the log has to be manually\n" > - "initialized when used for the very first time.", > - true); > - > - add(&Flags::slave_reregister_timeout, > - "slave_reregister_timeout", > - "The timeout within which all slaves are expected to > re-register\n" > - "when a new master is elected as the leader. Slaves that do not\n" > - "re-register within the timeout will be removed from the > registry\n" > - "and will be shutdown if they attempt to communicate with > master.\n" > - "NOTE: This value has to be atleast " + > - stringify(MIN_SLAVE_REREGISTER_TIMEOUT) + ".", > - MIN_SLAVE_REREGISTER_TIMEOUT); > - > - // TODO(bmahler): Add a 'Percentage' abstraction for flags. > - // TODO(bmahler): Add a --production flag for production defaults. > - add(&Flags::recovery_slave_removal_limit, > - "recovery_slave_removal_limit", > - "For failovers, limit on the percentage of slaves that can be > removed\n" > - "from the registry *and* shutdown after the re-registration > timeout\n" > - "elapses. If the limit is exceeded, the master will fail over > rather\n" > - "than remove the slaves.\n" > - "This can be used to provide safety guarantees for production\n" > - "environments. Production environments may expect that across > Master\n" > - "failovers, at most a certain percentage of slaves will fail\n" > - "permanently (e.g. due to rack-level failures).\n" > - "Setting this limit would ensure that a human needs to get\n" > - "involved should an unexpected widespread failure of slaves > occur\n" > - "in the cluster.\n" > - "Values: [0%-100%]", > - stringify(RECOVERY_SLAVE_REMOVAL_PERCENT_LIMIT * 100.0) + "%"); > - > - // TODO(vinod): Add a 'Rate' abstraction in stout and the > - // corresponding parser for flags. > - add(&Flags::slave_removal_rate_limit, > - "slave_removal_rate_limit", > - "The maximum rate (e.g., 1/10mins, 2/3hrs, etc) at which slaves > will\n" > - "be removed from the master when they fail health checks. By > default\n" > - "slaves will be removed as soon as they fail the health checks.\n" > - "The value is of the form <Number of slaves>/<Duration>."); > - > - add(&Flags::webui_dir, > - "webui_dir", > - "Directory path of the webui files/assets", > - PKGDATADIR "/webui"); > - > - add(&Flags::whitelist, > - "whitelist", > - "Path to a file with a list of slaves\n" > - "(one per line) to advertise offers for.\n" > - "Path could be of the form 'file:///path/to/file' or > '/path/to/file'."); > - > - add(&Flags::user_sorter, > - "user_sorter", > - "Policy to use for allocating resources\n" > - "between users. May be one of:\n" > - " dominant_resource_fairness (drf)", > - "drf"); > - > - add(&Flags::framework_sorter, > - "framework_sorter", > - "Policy to use for allocating resources\n" > - "between a given user's frameworks. Options\n" > - "are the same as for user_allocator.", > - "drf"); > - > - add(&Flags::allocation_interval, > - "allocation_interval", > - "Amount of time to wait between performing\n" > - " (batch) allocations (e.g., 500ms, 1sec, etc).", > - Seconds(1)); > - > - add(&Flags::cluster, > - "cluster", > - "Human readable name for the cluster,\n" > - "displayed in the webui."); > - > - // TODO(vinod): Deprecate this in favor of '--acls'. > - add(&Flags::roles, > - "roles", > - "A comma separated list of the allocation\n" > - "roles that frameworks in this cluster may\n" > - "belong to."); > - > - add(&Flags::weights, > - "weights", > - "A comma separated list of role/weight pairs\n" > - "of the form 'role=weight,role=weight'. Weights\n" > - "are used to indicate forms of priority."); > - > - // TODO(adam-mesos): Deprecate --authenticate for > --authenticate_frameworks. > - add(&Flags::authenticate_frameworks, > - "authenticate", > - "If authenticate is 'true' only authenticated frameworks are > allowed\n" > - "to register. If 'false' unauthenticated frameworks are also\n" > - "allowed to register.", > - false); > - > - add(&Flags::authenticate_slaves, > - "authenticate_slaves", > - "If 'true' only authenticated slaves are allowed to register.\n" > - "If 'false' unauthenticated slaves are also allowed to register.", > - false); > - > - add(&Flags::credentials, > - "credentials", > - "Either a path to a text file with a list of credentials,\n" > - "each line containing 'principal' and 'secret' separated by " > - "whitespace,\n" > - "or, a path to a JSON-formatted file containing credentials.\n" > - "Path could be of the form 'file:///path/to/file' or > '/path/to/file'." > - "\n" > - "JSON file Example:\n" > - "{\n" > - " \"credentials\": [\n" > - " {\n" > - " \"principal\": \"sherman\",\n" > - " \"secret\": \"kitesurf\",\n" > - " }\n" > - " ]\n" > - "}\n" > - "Text file Example:\n" > - "username secret\n" > - ); > - > - add(&Flags::acls, > - "acls", > - "The value could be a JSON formatted string of ACLs\n" > - "or a file path containing the JSON formatted ACLs used\n" > - "for authorization. Path could be of the form > 'file:///path/to/file'\n" > - "or '/path/to/file'.\n" > - "\n" > - "See the ACLs protobuf in mesos.proto for the expected format.\n" > - "\n" > - "Example:\n" > - "{\n" > - " \"register_frameworks\": [\n" > - " {\n" > - " \"principals\": { \"type\": \"ANY\" > },\n" > - " \"roles\": { \"values\": [\"a\"] }\n" > - " }\n" > - " ],\n" > - " \"run_tasks\": [\n" > - " {\n" > - " \"principals\": { \"values\": [\"a\", > \"b\"] },\n" > - " \"users\": { \"values\": [\"c\"] }\n" > - " }\n" > - " ],\n" > - " \"shutdown_frameworks\": [\n" > - " {\n" > - " \"principals\": { \"values\": [\"a\", \"b\"] > },\n" > - " \"framework_principals\": { \"values\": > [\"c\"] }\n" > - " }\n" > - " ]\n" > - "}"); > - > - add(&Flags::rate_limits, > - "rate_limits", > - "The value could be a JSON formatted string of rate limits\n" > - "or a file path containing the JSON formatted rate limits used\n" > - "for framework rate limiting.\n" > - "Path could be of the form 'file:///path/to/file'\n" > - "or '/path/to/file'.\n" > - "\n" > - "See the RateLimits protobuf in mesos.proto for the expected > format.\n" > - "\n" > - "Example:\n" > - "{\n" > - " \"limits\": [\n" > - " {\n" > - " \"principal\": \"foo\",\n" > - " \"qps\": 55.5\n" > - " },\n" > - " {\n" > - " \"principal\": \"bar\"\n" > - " }\n" > - " ],\n" > - " \"aggregate_default_qps\": 33.3\n" > - "}"); > - > -#ifdef WITH_NETWORK_ISOLATOR > - add(&Flags::max_executors_per_slave, > - "max_executors_per_slave", > - "Maximum number of executors allowed per slave. The network\n" > - "monitoring/isolation technique imposes an implicit resource\n" > - "acquisition on each executor (# ephemeral ports), as a result\n" > - "one can only run a certain number of executors on each slave."); > -#endif // WITH_NETWORK_ISOLATOR > - > - // TODO(karya): When we have optimistic offers, this will only > - // benefit frameworks that accidentally lose an offer. > - add(&Flags::offer_timeout, > - "offer_timeout", > - "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."); > - > - // This help message for --modules flag is the same for > - // {master,slave,tests}/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" > - "}"); > - > - add(&Flags::authenticators, > - "authenticators", > - "Authenticator implementation to use when authenticating > frameworks\n" > - "and/or slaves. Use the default '" + DEFAULT_AUTHENTICATOR + "', > or\n" > - "load an alternate authenticator module using --modules.", > - DEFAULT_AUTHENTICATOR); > - > - add(&Flags::hooks, > - "hooks", > - "A comma separated list of hook modules to be\n" > - "installed inside master."); > - } > - > + Flags(); > bool version; > Option<std::string> hostname; > bool root_submissions; > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/slave/flags.cpp > ---------------------------------------------------------------------- > diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp > new file mode 100644 > index 0000000..35f5625 > --- /dev/null > +++ b/src/slave/flags.cpp > @@ -0,0 +1,389 @@ > +/** > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +#include <stout/flags.hpp> > + > +#include <mesos/type_utils.hpp> > + > +#include "common/parse.hpp" > +#include "slave/constants.hpp" > +#include "slave/flags.hpp" > + > + > +mesos::internal::slave::Flags::Flags() > +{ > + add(&Flags::hostname, "hostname", > + "The hostname the slave should report.\n" > + "If left unset, the hostname is resolved from the IP address\n" > + "that the slave binds to."); > + > + add(&Flags::version, "version", "Show version and exit.", false); > + > + // TODO(benh): Is there a way to specify units for the resources? > + add(&Flags::resources, "resources", > + "Total consumable resources per slave, in\n" > + "the form 'name(role):value;name(role):value...'."); > + > + add(&Flags::isolation, "isolation", > + "Isolation mechanisms to use, e.g., 'posix/cpu,posix/mem', or\n" > + "'cgroups/cpu,cgroups/mem', or network/port_mapping\n" > + "(configure with flag: --with-network-isolator to enable),\n" > + "or 'external', or load an alternate isolator module using\n" > + "the --modules flag.", > + "posix/cpu,posix/mem"); > + > + add(&Flags::default_role, "default_role", > + "Any resources in the --resources flag that\n" > + "omit a role, as well as any resources that\n" > + "are not present in --resources but that are\n" > + "automatically detected, will be assigned to\n" > + "this role.", > + "*"); > + > + add(&Flags::attributes, "attributes", > + "Attributes of machine, in the form:\n" > + "rack:2 or 'rack:2;u:1'"); > + > + add(&Flags::work_dir, "work_dir", > + "Directory path to place framework work directories\n", > "/tmp/mesos"); > + > + add(&Flags::launcher_dir, // TODO(benh): This needs a better name. > + "launcher_dir", "Directory path of Mesos binaries", PKGLIBEXECDIR); > + > + add(&Flags::hadoop_home, "hadoop_home", > + "Path to find Hadoop installed (for\n" > + "fetching framework executors from HDFS)\n" > + "(no default, look for HADOOP_HOME in\n" > + "environment or find hadoop on PATH)", > + ""); > + > + add(&Flags::switch_user, "switch_user", > + "Whether to run tasks as the user who\n" > + "submitted them rather than the user running\n" > + "the slave (requires setuid permission)", > + true); > + > + add(&Flags::frameworks_home, "frameworks_home", > + "Directory path prepended to relative executor URIs", ""); > + > + add(&Flags::registration_backoff_factor, "registration_backoff_factor", > + "Slave initially picks a random amount of time between [0, b], > where\n" > + "b = registration_backoff_factor, to (re-)register with a new > master.\n" > + "Subsequent retries are exponentially backed off based on this\n" > + "interval (e.g., 1st retry uses a random value between [0, b * > 2^1],\n" > + "2nd retry between [0, b * 2^2], 3rd retry between [0, b * 2^3] > etc)\n" > + "up to a maximum of " + > + stringify(REGISTER_RETRY_INTERVAL_MAX), > + REGISTRATION_BACKOFF_FACTOR); > + > + add(&Flags::executor_registration_timeout, > "executor_registration_timeout", > + "Amount of time to wait for an executor\n" > + "to register with the slave before considering it hung and\n" > + "shutting it down (e.g., 60secs, 3mins, etc)", > + EXECUTOR_REGISTRATION_TIMEOUT); > + > + add(&Flags::executor_shutdown_grace_period, > "executor_shutdown_grace_period", > + "Amount of time to wait for an executor\n" > + "to shut down (e.g., 60secs, 3mins, etc)", > + EXECUTOR_SHUTDOWN_GRACE_PERIOD); > + > + add(&Flags::gc_delay, "gc_delay", > + "Maximum amount of time to wait before cleaning up\n" > + "executor directories (e.g., 3days, 2weeks, etc).\n" > + "Note that this delay may be shorter depending on\n" > + "the available disk usage.", > + GC_DELAY); > + > + add(&Flags::gc_disk_headroom, "gc_disk_headroom", > + "Adjust disk headroom used to calculate maximum executor\n" > + "directory age. Age is calculated by:\n" > + "gc_delay * max(0.0, (1.0 - gc_disk_headroom - disk usage))\n" > + "every --disk_watch_interval duration. gc_disk_headroom must\n" > + "be a value between 0.0 and 1.0", > + GC_DISK_HEADROOM); > + > + add(&Flags::disk_watch_interval, "disk_watch_interval", > + "Periodic time interval (e.g., 10secs, 2mins, etc)\n" > + "to check the overall disk usage managed by the slave.\n" > + "This drives the garbage collection of archived\n" > + "information and sandboxes.", > + DISK_WATCH_INTERVAL); > + > + add(&Flags::resource_monitoring_interval, > "resource_monitoring_interval", > + "Periodic time interval for monitoring executor\n" > + "resource usage (e.g., 10secs, 1min, etc)", > + RESOURCE_MONITORING_INTERVAL); > + > + add(&Flags::recover, "recover", > + "Whether to recover status updates and reconnect with old > executors.\n" > + "Valid values for 'recover' are\n" > + "reconnect: Reconnect with any old live executors.\n" > + "cleanup : Kill any old live executors and exit.\n" > + " Use this option when doing an incompatible slave\n" > + " or executor upgrade!).", > + "reconnect"); > + > + add(&Flags::recovery_timeout, "recovery_timeout", > + "Amount of time alloted for the slave to recover. If the slave > takes\n" > + "longer than recovery_timeout to recover, any executors that are\n" > + "waiting to reconnect to the slave will self-terminate.\n", > + RECOVERY_TIMEOUT); > + > + add(&Flags::strict, "strict", > + "If strict=true, any and all recovery errors are considered > fatal.\n" > + "If strict=false, any expected errors (e.g., slave cannot recover\n" > + "information about an executor, because the slave died right > before\n" > + "the executor registered.) during recovery are ignored and as > much\n" > + "state as possible is recovered.\n", > + true); > + > +#ifdef __linux__ > + add(&Flags::cgroups_hierarchy, "cgroups_hierarchy", > + "The path to the cgroups hierarchy root\n", "/sys/fs/cgroup"); > + > + add(&Flags::cgroups_root, "cgroups_root", "Name of the root cgroup\n", > + "mesos"); > + > + add(&Flags::cgroups_enable_cfs, "cgroups_enable_cfs", > + "Cgroups feature flag to enable hard limits on CPU resources\n" > + "via the CFS bandwidth limiting subfeature.\n", > + false); > + > + // TODO(antonl): Set default to true in future releases. > + add(&Flags::cgroups_limit_swap, "cgroups_limit_swap", > + "Cgroups feature flag to enable memory limits on both memory and\n" > + "swap instead of just memory.\n", > + false); > + > + add(&Flags::cgroups_cpu_enable_pids_and_tids_count, > + "cgroups_cpu_enable_pids_and_tids_count", > + "Cgroups feature flag to enable counting of processes and threads\n" > + "inside a container.\n", > + false); > + > + add(&Flags::slave_subsystems, "slave_subsystems", > + "List of comma-separated cgroup subsystems to run the slave > binary\n" > + "in, e.g., 'memory,cpuacct'. The default is none.\n" > + "Present functionality is intended for resource monitoring and\n" > + "no cgroup limits are set, they are inherited from the root mesos\n" > + "cgroup."); > + > + add(&Flags::perf_events, "perf_events", > + "List of command-separated perf events to sample for each > container\n" > + "when using the perf_event isolator. Default is none.\n" > + "Run command 'perf list' to see all events. Event names are\n" > + "sanitized by downcasing and replacing hyphens with underscores\n" > + "when reported in the PerfStatistics protobuf, e.g., cpu-cycles\n" > + "becomes cpu_cycles; see the PerfStatistics protobuf for all > names."); > + > + add(&Flags::perf_interval, "perf_interval", > + "Interval between the start of perf stat samples. Perf samples > are\n" > + "obtained periodically according to perf_interval and the most\n" > + "recently obtained sample is returned rather than sampling on\n" > + "demand. For this reason, perf_interval is independent of the\n" > + "resource monitoring interval", > + Seconds(60)); > + > + add(&Flags::perf_duration, "perf_duration", > + "Duration of a perf stat sample. The duration must be less\n" > + "that the perf_interval.", > + Seconds(10)); > +#endif > + > + add(&Flags::credential, "credential", > + "Either a path to a text with a single line\n" > + "containing 'principal' and 'secret' separated by " > + "whitespace.\n" > + "Or a path containing the JSON " > + "formatted information used for one credential.\n" > + "Path could be of the form 'file:///path/to/file' or > '/path/to/file'." > + "\n" > + "Example:\n" > + "{\n" > + " \"principal\": \"username\",\n" > + " \"secret\": \"secret\",\n" > + "}"); > + > + add(&Flags::containerizer_path, "containerizer_path", > + "The path to the external containerizer executable used when\n" > + "external isolation is activated (--isolation=external).\n"); > + > + add(&Flags::containerizers, "containerizers", > + "Comma separated list of containerizer implementations\n" > + "to compose in order to provide containerization.\n" > + "Available options are 'mesos', 'external', and\n" > + "'docker' (on Linux). The order the containerizers\n" > + "are specified is the order they are tried\n" > + "(--containerizers=mesos).\n", > + "mesos"); > + > + add(&Flags::default_container_image, "default_container_image", > + "The default container image to use if not specified by a task,\n" > + "when using external containerizer.\n"); > + > + // Docker containerizer flags. > + add(&Flags::docker, "docker", > + "The absolute path to the docker executable for docker\n" > + "containerizer.\n", > + "docker"); > + > + add(&Flags::docker_sandbox_directory, "docker_sandbox_directory", > + "The absolute path for the directory in the container where the\n" > + "sandbox is mapped to.\n", > + "/mnt/mesos/sandbox"); > + > + add(&Flags::docker_remove_delay, "docker_remove_delay", > + "The amount of time to wait before removing docker containers\n" > + "(e.g., 3days, 2weeks, etc).\n", > + DOCKER_REMOVE_DELAY); > + > + add(&Flags::default_container_info, "default_container_info", > + "JSON formatted ContainerInfo that will be included into\n" > + "any ExecutorInfo that does not specify a ContainerInfo.\n" > + "\n" > + "See the ContainerInfo protobuf in mesos.proto for\n" > + "the expected format.\n" > + "\n" > + "Example:\n" > + "{\n" > + "\"type\": \"MESOS\",\n" > + "\"volumes\": [\n" > + " {\n" > + " \"host_path\": \"./.private/tmp\",\n" > + " \"container_path\": \"/tmp\",\n" > + " \"mode\": \"RW\"\n" > + " }\n" > + " ]\n" > + "}"); > + > + add(&Flags::docker_stop_timeout, "docker_stop_timeout", > + "The time as a duration for docker to wait after stopping an > instance\n" > + "before it kills that instance.", > + Seconds(0)); > + > +#ifdef WITH_NETWORK_ISOLATOR > + add(&Flags::ephemeral_ports_per_container, > "ephemeral_ports_per_container", > + "Number of ephemeral ports allocated to a container by the > network\n" > + "isolator. This number has to be a power of 2. This flag is used\n" > + "for the 'network/port_mapping' isolator.", > + DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER); > + > + add(&Flags::eth0_name, "eth0_name", > + "The name of the public network interface (e.g., eth0). If it is\n" > + "not specified, the network isolator will try to guess it based\n" > + "on the host default gateway. This flag is used for the\n" > + "'network/port_mapping' isolator."); > + > + add(&Flags::lo_name, "lo_name", > + "The name of the loopback network interface (e.g., lo). If it is\n" > + "not specified, the network isolator will try to guess it. This\n" > + "flag is used for the 'network/port_mapping' isolator."); > + > + add(&Flags::egress_rate_limit_per_container, > + "egress_rate_limit_per_container", > + "The limit of the egress traffic for each container, in Bytes/s.\n" > + "If not specified or specified as zero, the network isolator will\n" > + "impose no limits to containers' egress traffic throughput.\n" > + "This flag uses the Bytes type (defined in stout) and is used for\n" > + "the 'network/port_mapping' isolator."); > + > + add(&Flags::network_enable_socket_statistics_summary, > + "network_enable_socket_statistics_summary", > + "Whether to collect socket statistics summary for each container.\n" > + "This flag is used for the 'network/port_mapping' isolator.", > + false); > + > + add(&Flags::network_enable_socket_statistics_details, > + "network_enable_socket_statistics_details", > + "Whether to collect socket statistics details (e.g., TCP RTT) for\n" > + "each container. This flag is used for the 'network/port_mapping'\n" > + "isolator.", > + false); > + > +#endif // WITH_NETWORK_ISOLATOR > + > + add(&Flags::container_disk_watch_interval, > "container_disk_watch_interval", > + "The interval between disk quota checks for containers. This flag > is\n" > + "used for the 'posix/disk' isolator.", > + Seconds(15)); > + > + // TODO(jieyu): Consider enabling this flag by default. Remember > + // to update the user doc if we decide to do so. > + add(&Flags::enforce_container_disk_quota, > "enforce_container_disk_quota", > + "Whether to enable disk quota enforcement for containers. This > flag\n" > + "is used for the 'posix/disk' isolator.", > + false); > + > + // This help message for --modules flag is the same for > + // {master,slave,tests}/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" > + "}"); > + > + add(&Flags::authenticatee, "authenticatee", > + "Authenticatee implementation to use when authenticating against > the\n" > + "master. Use the default '" + > + DEFAULT_AUTHENTICATEE + > + "', or\n" > + "load an alternate authenticatee module using --modules.", > + DEFAULT_AUTHENTICATEE); > + > + add(&Flags::hooks, "hooks", > + "A comma separated list of hook modules to be\n" > + "installed inside the slave."); > +} > > > http://git-wip-us.apache.org/repos/asf/mesos/blob/743e9e73/src/slave/flags.hpp > ---------------------------------------------------------------------- > diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp > index 3da71af..d3b1ce1 100644 > --- a/src/slave/flags.hpp > +++ b/src/slave/flags.hpp > @@ -21,24 +21,15 @@ > > #include <string> > > -#include <mesos/mesos.hpp> > -#include <mesos/type_utils.hpp> > - > -#include <mesos/module/module.hpp> > - > #include <stout/bytes.hpp> > #include <stout/duration.hpp> > -#include <stout/flags.hpp> > #include <stout/option.hpp> > +#include <stout/path.hpp> > > -#include "common/parse.hpp" > +#include <mesos/module/module.hpp> > > #include "logging/flags.hpp" > > -#include "messages/messages.hpp" > - > -#include "slave/constants.hpp" > - > namespace mesos { > namespace internal { > namespace slave { > @@ -46,420 +37,7 @@ namespace slave { > class Flags : public logging::Flags > { > public: > - Flags() > - { > - add(&Flags::hostname, > - "hostname", > - "The hostname the slave should report.\n" > - "If left unset, the hostname is resolved from the IP address\n" > - "that the slave binds to."); > - > - add(&Flags::version, > - "version", > - "Show version and exit.", > - false); > - > - // TODO(benh): Is there a way to specify units for the resources? > - add(&Flags::resources, > - "resources", > - "Total consumable resources per slave, in\n" > - "the form 'name(role):value;name(role):value...'."); > - > - add(&Flags::isolation, > - "isolation", > - "Isolation mechanisms to use, e.g., 'posix/cpu,posix/mem', or\n" > - "'cgroups/cpu,cgroups/mem', or network/port_mapping\n" > - "(configure with flag: --with-network-isolator to enable),\n" > - "or 'external', or load an alternate isolator module using\n" > - "the --modules flag.", > - "posix/cpu,posix/mem"); > - > - add(&Flags::default_role, > - "default_role", > - "Any resources in the --resources flag that\n" > - "omit a role, as well as any resources that\n" > - "are not present in --resources but that are\n" > - "automatically detected, will be assigned to\n" > - "this role.", > - "*"); > - > - add(&Flags::attributes, > - "attributes", > - "Attributes of machine, in the form:\n" > - "rack:2 or 'rack:2;u:1'"); > - > - add(&Flags::work_dir, > - "work_dir", > - "Directory path to place framework work directories\n", > - "/tmp/mesos"); > - > - add(&Flags::launcher_dir, // TODO(benh): This needs a better name. > - "launcher_dir", > - "Directory path of Mesos binaries", > - PKGLIBEXECDIR); > - > - add(&Flags::hadoop_home, > - "hadoop_home", > - "Path to find Hadoop installed (for\n" > - "fetching framework executors from HDFS)\n" > - "(no default, look for HADOOP_HOME in\n" > - "environment or find hadoop on PATH)", > - ""); > - > - add(&Flags::switch_user, > - "switch_user", > - "Whether to run tasks as the user who\n" > - "submitted them rather than the user running\n" > - "the slave (requires setuid permission)", > - true); > - > - add(&Flags::frameworks_home, > - "frameworks_home", > - "Directory path prepended to relative executor URIs", > - ""); > - > - add(&Flags::registration_backoff_factor, > - "registration_backoff_factor", > - "Slave initially picks a random amount of time between [0, b], > where\n" > - "b = registration_backoff_factor, to (re-)register with a new > master.\n" > - "Subsequent retries are exponentially backed off based on this\n" > - "interval (e.g., 1st retry uses a random value between [0, b * > 2^1],\n" > - "2nd retry between [0, b * 2^2], 3rd retry between [0, b * 2^3] > etc)\n" > - "up to a maximum of " + stringify(REGISTER_RETRY_INTERVAL_MAX), > - REGISTRATION_BACKOFF_FACTOR); > - > - add(&Flags::executor_registration_timeout, > - "executor_registration_timeout", > - "Amount of time to wait for an executor\n" > - "to register with the slave before considering it hung and\n" > - "shutting it down (e.g., 60secs, 3mins, etc)", > - EXECUTOR_REGISTRATION_TIMEOUT); > - > - add(&Flags::executor_shutdown_grace_period, > - "executor_shutdown_grace_period", > - "Amount of time to wait for an executor\n" > - "to shut down (e.g., 60secs, 3mins, etc)", > - EXECUTOR_SHUTDOWN_GRACE_PERIOD); > - > - add(&Flags::gc_delay, > - "gc_delay", > - "Maximum amount of time to wait before cleaning up\n" > - "executor directories (e.g., 3days, 2weeks, etc).\n" > - "Note that this delay may be shorter depending on\n" > - "the available disk usage.", > - GC_DELAY); > - > - add(&Flags::gc_disk_headroom, > - "gc_disk_headroom", > - "Adjust disk headroom used to calculate maximum executor\n" > - "directory age. Age is calculated by:\n" > - "gc_delay * max(0.0, (1.0 - gc_disk_headroom - disk usage))\n" > - "every --disk_watch_interval duration. gc_disk_headroom must\n" > - "be a value between 0.0 and 1.0", > - GC_DISK_HEADROOM); > - > - add(&Flags::disk_watch_interval, > - "disk_watch_interval", > - "Periodic time interval (e.g., 10secs, 2mins, etc)\n" > - "to check the overall disk usage managed by the slave.\n" > - "This drives the garbage collection of archived\n" > - "information and sandboxes.", > - DISK_WATCH_INTERVAL); > - > - add(&Flags::resource_monitoring_interval, > - "resource_monitoring_interval", > - "Periodic time interval for monitoring executor\n" > - "resource usage (e.g., 10secs, 1min, etc)", > - RESOURCE_MONITORING_INTERVAL); > - > - add(&Flags::recover, > - "recover", > - "Whether to recover status updates and reconnect with old > executors.\n" > - "Valid values for 'recover' are\n" > - "reconnect: Reconnect with any old live executors.\n" > - "cleanup : Kill any old live executors and exit.\n" > - " Use this option when doing an incompatible slave\n" > - " or executor upgrade!).", > - "reconnect"); > - > - add(&Flags::recovery_timeout, > - "recovery_timeout", > - "Amount of time alloted for the slave to recover. If the slave > takes\n" > - "longer than recovery_timeout to recover, any executors that > are\n" > - "waiting to reconnect to the slave will self-terminate.\n", > - RECOVERY_TIMEOUT); > - > - add(&Flags::strict, > - "strict", > - "If strict=true, any and all recovery errors are considered > fatal.\n" > - "If strict=false, any expected errors (e.g., slave cannot > recover\n" > - "information about an executor, because the slave died right > before\n" > - "the executor registered.) during recovery are ignored and as > much\n" > - "state as possible is recovered.\n", > - true); > - > -#ifdef __linux__ > - add(&Flags::cgroups_hierarchy, > - "cgroups_hierarchy", > - "The path to the cgroups hierarchy root\n", > - "/sys/fs/cgroup"); > - > - add(&Flags::cgroups_root, > - "cgroups_root", > - "Name of the root cgroup\n", > - "mesos"); > - > - add(&Flags::cgroups_enable_cfs, > - "cgroups_enable_cfs", > - "Cgroups feature flag to enable hard limits on CPU resources\n" > - "via the CFS bandwidth limiting subfeature.\n", > - false); > - > - // TODO(antonl): Set default to true in future releases. > - add(&Flags::cgroups_limit_swap, > - "cgroups_limit_swap", > - "Cgroups feature flag to enable memory limits on both memory > and\n" > - "swap instead of just memory.\n", > - false); > - > - add(&Flags::cgroups_cpu_enable_pids_and_tids_count, > - "cgroups_cpu_enable_pids_and_tids_count", > - "Cgroups feature flag to enable counting of processes and > threads\n" > - "inside a container.\n", > - false); > - > - add(&Flags::slave_subsystems, > - "slave_subsystems", > - "List of comma-separated cgroup subsystems to run the slave > binary\n" > - "in, e.g., 'memory,cpuacct'. The default is none.\n" > - "Present functionality is intended for resource monitoring and\n" > - "no cgroup limits are set, they are inherited from the root > mesos\n" > - "cgroup."); > - > - add(&Flags::perf_events, > - "perf_events", > - "List of command-separated perf events to sample for each > container\n" > - "when using the perf_event isolator. Default is none.\n" > - "Run command 'perf list' to see all events. Event names are\n" > - "sanitized by downcasing and replacing hyphens with underscores\n" > - "when reported in the PerfStatistics protobuf, e.g., cpu-cycles\n" > - "becomes cpu_cycles; see the PerfStatistics protobuf for all > names."); > - > - add(&Flags::perf_interval, > - "perf_interval", > - "Interval between the start of perf stat samples. Perf samples > are\n" > - "obtained periodically according to perf_interval and the most\n" > - "recently obtained sample is returned rather than sampling on\n" > - "demand. For this reason, perf_interval is independent of the\n" > - "resource monitoring interval", > - Seconds(60)); > - > - add(&Flags::perf_duration, > - "perf_duration", > - "Duration of a perf stat sample. The duration must be less\n" > - "that the perf_interval.", > - Seconds(10)); > -#endif > - > - add(&Flags::credential, > - "credential", > - "Either a path to a text with a single line\n" > - "containing 'principal' and 'secret' separated by " > - "whitespace.\n" > - "Or a path containing the JSON " > - "formatted information used for one credential.\n" > - "Path could be of the form 'file:///path/to/file' or > '/path/to/file'." > - "\n" > - "Example:\n" > - "{\n" > - " \"principal\": \"username\",\n" > - " \"secret\": \"secret\",\n" > - "}"); > - > - add(&Flags::containerizer_path, > - "containerizer_path", > - "The path to the external containerizer executable used when\n" > - "external isolation is activated (--isolation=external).\n"); > - > - add(&Flags::containerizers, > - "containerizers", > - "Comma separated list of containerizer implementations\n" > - "to compose in order to provide containerization.\n" > - "Available options are 'mesos', 'external', and\n" > - "'docker' (on Linux). The order the containerizers\n" > - "are specified is the order they are tried\n" > - "(--containerizers=mesos).\n", > - "mesos"); > - > - add(&Flags::default_container_image, > - "default_container_image", > - "The default container image to use if not specified by a task,\n" > - "when using external containerizer.\n"); > - > - // Docker containerizer flags. > - add(&Flags::docker, > - "docker", > - "The absolute path to the docker executable for docker\n" > - "containerizer.\n", > - "docker"); > - > - add(&Flags::docker_sandbox_directory, > - "docker_sandbox_directory", > - "The absolute path for the directory in the container where the\n" > - "sandbox is mapped to.\n", > - "/mnt/mesos/sandbox"); > - > - add(&Flags::docker_remove_delay, > - "docker_remove_delay", > - "The amount of time to wait before removing docker containers\n" > - "(e.g., 3days, 2weeks, etc).\n", > - DOCKER_REMOVE_DELAY); > - > - add(&Flags::default_container_info, > - "default_container_info", > - "JSON formatted ContainerInfo that will be included into\n" > - "any ExecutorInfo that does not specify a ContainerInfo.\n" > - "\n" > - "See the ContainerInfo protobuf in mesos.proto for\n" > - "the expected format.\n" > - "\n" > - "Example:\n" > - "{\n" > - "\"type\": \"MESOS\",\n" > - "\"volumes\": [\n" > - " {\n" > - " \"host_path\": \"./.private/tmp\",\n" > - " \"container_path\": \"/tmp\",\n" > - " \"mode\": \"RW\"\n" > - " }\n" > - " ]\n" > - "}" > - ); > - > - add(&Flags::docker_stop_timeout, > - "docker_stop_timeout", > - "The time as a duration for docker to wait after stopping an > instance\n" > - "before it kills that instance.", > - Seconds(0)); > - > -#ifdef WITH_NETWORK_ISOLATOR > - add(&Flags::ephemeral_ports_per_container, > - "ephemeral_ports_per_container", > - "Number of ephemeral ports allocated to a container by the > network\n" > - "isolator. This number has to be a power of 2. This flag is > used\n" > - "for the 'network/port_mapping' isolator.", > - DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER); > - > - add(&Flags::eth0_name, > - "eth0_name", > - "The name of the public network interface (e.g., eth0). If it > is\n" > - "not specified, the network isolator will try to guess it based\n" > - "on the host default gateway. This flag is used for the\n" > - "'network/port_mapping' isolator."); > - > - add(&Flags::lo_name, > - "lo_name", > - "The name of the loopback network interface (e.g., lo). If it > is\n" > - "not specified, the network isolator will try to guess it. This\n" > - "flag is used for the 'network/port_mapping' isolator."); > - > - add(&Flags::egress_rate_limit_per_container, > - "egress_rate_limit_per_container", > - "The limit of the egress traffic for each container, in > Bytes/s.\n" > - "If not specified or specified as zero, the network isolator > will\n" > - "impose no limits to containers' egress traffic throughput.\n" > - "This flag uses the Bytes type (defined in stout) and is used > for\n" > - "the 'network/port_mapping' isolator."); > - > - add(&Flags::network_enable_socket_statistics_summary, > - "network_enable_socket_statistics_summary", > - "Whether to collect socket statistics summary for each > container.\n" > - "This flag is used for the 'network/port_mapping' isolator.", > - false); > - > - add(&Flags::network_enable_socket_statistics_details, > - "network_enable_socket_statistics_details", > - "Whether to collect socket statistics details (e.g., TCP RTT) > for\n" > - "each container. This flag is used for the > 'network/port_mapping'\n" > - "isolator.", > - false); > - > -#endif // WITH_NETWORK_ISOLATOR > - > - add(&Flags::container_disk_watch_interval, > - "container_disk_watch_interval", > - "The interval between disk quota checks for containers. This flag > is\n" > - "used for the 'posix/disk' isolator.", > - Seconds(15)); > - > - // TODO(jieyu): Consider enabling this flag by default. Remember > - // to update the user doc if we decide to do so. > - add(&Flags::enforce_container_disk_quota, > - "enforce_container_disk_quota", > - "Whether to enable disk quota enforcement for containers. This > flag\n" > - "is used for the 'posix/disk' isolator.", > - false); > - > - // This help message for --modules flag is the same for > - // {master,slave,tests}/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" > - "}"); > - > - add(&Flags::authenticatee, > - "authenticatee", > - "Authenticatee implementation to use when authenticating against > the\n" > - "master. Use the default '" + DEFAULT_AUTHENTICATEE + "', or\n" > - "load an alternate authenticatee module using --modules.", > - DEFAULT_AUTHENTICATEE); > - > - add(&Flags::hooks, > - "hooks", > - "A comma separated list of hook modules to be\n" > - "installed inside the slave."); > - } > - > + Flags(); > bool version; > Option<std::string> hostname; > Option<std::string> resources; > >
