Mesos源码分析(2): Mesos Master的启动之一

Mesos Master的启动参数如下:

/usr/sbin/mesos-master --zk=zk://127.0.0.1:2181/mesos --port=5050 --log_dir=/var/log/mesos --hostname=192.168.56.101 --hostname_lookup=false --ip=192.168.56.101 --quorum=1 --registry=replicated_log --work_dir=/var/lib/mesos/master

 

Mesos Master的启动可以包含很多的参数,参考文档http://mesos.apache.org/documentation/latest/configuration/

 

Mesos Master的参数可以通过下面两种方式指定:

  • 通过命令行参数:--option_name=value
  • 通过环境变量:MESOS_OPTION_NAME

 

Mesos Master的启动从代码src/master/main.cpp开始的。

 

1. master::Flags flags 解析命令行参数和环境变量

 

  1. master::Flags flags;
  2.  
  3. // The following flags are executable specific (e.g., since we only
  4. // have one instance of libprocess per execution, we only want to
  5. // advertise the IP and port option once, here).
  6. Option<string> ip;
  7. flags.add(&ip,
  8.           "ip",
  9.           "IP address to listen on. This cannot be used in conjunction\n"
  10.           "with `--ip_discovery_command`.");
  11.  
  12. uint16_t port;
  13. flags.add(&port,
  14.           "port",
  15.           "Port to listen on.",
  16.           MasterInfo().port());
  17.  
  18. Option<string> advertise_ip;
  19. flags.add(&advertise_ip,
  20.           "advertise_ip",
  21.           "IP address advertised to reach this Mesos master.\n"
  22.           "The master does not bind using this IP address.\n"
  23.           "However, this IP address may be used to access this master.");
  24.  
  25. Option<string> advertise_port;
  26. flags.add(&advertise_port,
  27.           "advertise_port",
  28.           "Port advertised to reach Mesos master (along with\n"
  29.           "`advertise_ip`). The master does not bind to this port.\n"
  30.           "However, this port (along with `advertise_ip`) may be used to\n"
  31.           "access this master.");
  32.  
  33. Option<string> zk;
  34. flags.add(&zk,
  35.           "zk",
  36.           "ZooKeeper URL (used for leader election amongst masters)\n"
  37.           "May be one of:\n"
  38.           " `zk://host1:port1,host2:port2,.../path`\n"
  39.           " `zk://username:password@host1:port1,host2:port2,.../path`\n"
  40.           " `file:///path/to/file` (where file contains one of the above)\n"
  41.           "NOTE: Not required if master is run in standalone mode (non-HA).");
  42.  
  43. // Optional IP discover script that will set the Master IP.
  44. // If set, its output is expected to be a valid parseable IP string.
  45. Option<string> ip_discovery_command;
  46. flags.add(&ip_discovery_command,
  47.           "ip_discovery_command",
  48.           "Optional IP discovery binary: if set, it is expected to emit\n"
  49.           "the IP address which the master will try to bind to.\n"
  50.           "Cannot be used in conjunction with `--ip`.");

 

上面便是解析命令行参数的代码。

 

接下来,需要解析环境变量的参数了。

  1. Try<flags::Warnings> load = flags.load("MESOS_", argc, argv);

 

那Flags是个什么东西呢,能做这件事情,参考文档https://mesosphere.com/blog/2015/05/14/using-stout-to-parse-command-line-options

 

Almost every program needs to parse some form of command-line argument. Often, this is a pretty large set of possible options, and the management of the various options is usually pretty tedious while adding virtually no value to the program's functionality.

Google's gflags are thus a very welcome contribution in that they remove the tediousness. They let program developers give their users a fairly complex set of options to choose from, without wasting time re-inventing the wheel.

However, the use of macros and certain other quirks within gflags led the team developing Apache Mesos to create a more object-oriented approach to the same problem. This new approach yields a more familiar pattern to the programmer (and those familiar with Python's 'argparse' library will see several similarities there too).

Stout is a header-only library that can be used independently from Mesos. However, the most up-to-date and recent version should be extracted from the Apache Mesos 3rdparty folder.

Beyond Flags, Stout offers a wealth of modern abstractions that make coding in C++ a more pleasant experience, especially for folks used to the facilities offered "natively" by other languages such as Scala or Python: 'Try'/'Option' classes (see also below); facilities to deal with Hashmaps; IP/MAC addresses manipulation; the 'Duration' class for time units (which will look very familiar to users of Joda Time) and the nifty 'Stopwatch' utility.

In the following, we show how to use Stout to simplify management of command-line argument flags, but we invite you to explore the library and find out how it can make your coding life easier.

Use

To use Stout_ CLI arguments ("flags") all we have to do is include the header file and derive our custom flags' class from 'FlagsBase.' In 'FlagsXxxx, add the (appropriately typed) fields that will be, at runtime, populated with the correct values from the command line (or the given default values, if any):

#include <stout/flags/flags.hpp>

using std::string;

// Program flags, allows user to run the tests (--test) or the Scheduler

// against a Mesos Master at --master IP:PORT; or the Executor, which will

// invoke Mongo using the --config FILE configuration file.

//

// All the flags are optional, but at least ONE (and at most one) MUST be

// present.

class MongoFlags: public flags::FlagsBase

{

public:

MongoFlags();

Option<string> master;

Option<string> config;

string role;

bool test;

};

In the class's constructor, the actual value of the flag (the '–flag') is defined along with a simple help message and, where necessary, a default value:

MongoFlags::MongoFlags()

{

add(&MongoFlags::master, "master", "The host address of the Mesos Master.");

add(&MongoFlags::config, "config", "The location of the configuration file,"

" on the Worker node (this file MUST exist).");

add(&MongoFlags::role, "role", "The role for the executor", "*");

add(&MongoFlags::test, "test", "Will only run unit tests and exit.", false);

}

One convenient feature is that flags gives you a 'usage()' method that generates a nicely-formatted string that is suitable to be emitted to the user (either upon request, or if something goes wrong):

void printUsage(const string& prog, const MongoFlags& flags)

{

cout << "Usage: " << os::basename(prog).get() << " [options]\n\n"

"One (and only one) of the following options MUST be present.\n\n"

"Options:\n" << flags.usage() << endl;

}

Finally, in your 'main()' you simply call the FlagsBase::load()' method to initialize the class's members, which can then be used as you would normally:

int main(int argc, char** argv)

{

MongoFlags flags;

bool help;

 

// flags can be also added outside the Flags class:

flags.add(&help, "help", "Prints this help message", false);

 

Try<Nothing> load = flags.load(None(), argc, argv);

 

if (load.isError()) {

std::cerr << "Failed to load flags: " << load.error() << std::endl;

return -1;

}

 

if (!help) {

if (flags.test) {

cout << "Running unit tests for Playground App\n";

return test(argc, argv);

}

if (flags.config.isSome()) {

return run_executor(flags.config.get());

}

 

if (flags.master.isSome()) {

string uri = os::realpath(argv[0]).get();

auto masterIp = flags.master.get();

cout << "MongoExecutor starting - launching Scheduler rev. "

<< MongoScheduler::REV << " starting Executor at: " << uri << '\n';

return run_scheduler(uri, masterIp);

}

}

printUsage(argv[0], flags);

}

For a full-fledged (and extensive) use of 'stout/flags,' see the 'master.cpp and associated header file in the 'src/master' folder of the Apache Mesos repo.

Optional Values

Optional arguments can be wrapped in Stout's 'Option type, which is an extremely convenient abstraction of objects that may optionally be unassigned. That means circumventing all the awkwardness of using 'NULL' — which, in fact, you should avoid at all costs in your code.

The customary pattern of usage for an 'Option' object is exemplified in the snippet:

void doSomething(const std::string& widget) {

// as far as this method is concerned, strings are all there is

// ...

}

 

// in another part of your program

 

Option<std::string> foo;

 

// other code that may (or may not) set foo to some value

 

if (foo.isSome()) {

doSomething(foo.get());

}

Again, more examples can be found in several places in the source code of Mesos (see, for example, 'main.cpp' in the same source folder as above).

 

Mesos就是封装了Google的gflags来解析命令行参数和环境变量

 

在src/master/flags.cpp里面下面的代码:

  1. mesos::internal::master::Flags::Flags()
  2. {
  3.   add(&Flags::version,
  4.       "version",
  5.       "Show version and exit.",
  6.       false);
  7.  
  8.   add(&Flags::hostname,
  9.       "hostname",
  10.       "The hostname the master should advertise in ZooKeeper.\n"
  11.       "If left unset, the hostname is resolved from the IP address\n"
  12.       "that the agent binds to; unless the user explicitly prevents\n"
  13.       "that, using `--no-hostname_lookup`, in which case the IP itself\n"
  14.       "is used.");
  15.  
  16.   add(&Flags::hostname_lookup,
  17.       "hostname_lookup",
  18.       "Whether we should execute a lookup to find out the server's hostname,\n"
  19.       "if not explicitly set (via, e.g., `--hostname`).\n"
  20.       "True by default; if set to `false` it will cause Mesos\n"
  21.       "to use the IP address, unless the hostname is explicitly set.",
  22.       true);
  23.  
  24.   add(&Flags::root_submissions,
  25.       "root_submissions",
  26.       "Can root submit frameworks?",
  27.       true);
  28.  
  29.   add(&Flags::work_dir,
  30.       "work_dir",
  31.       "Path of the master work directory. This is where the persistent\n"
  32.       "information of the cluster will be stored. Note that locations like\n"
  33.       "`/tmp` which are cleaned automatically are not suitable for the work\n"
  34.       "directory when running in production, since long-running masters could\n"
  35.       "lose data when cleanup occurs. (Example: `/var/lib/mesos/master`)");
  36.  
  37.   // TODO(bmahler): Consider removing `in_memory` as it was only
  38.   // used before `replicated_log` was implemented.
  39.   add(&Flags::registry,
  40.       "registry",
  41.       "Persistence strategy for the registry;\n"
  42.       "available options are `replicated_log`, `in_memory` (for testing).",
  43.       "replicated_log");
  44.  
  45.   // TODO(vinod): Instead of specifying the quorum size consider
  46.   // specifying the number of masters or the list of masters.
  47.   add(&Flags::quorum,
  48.       "quorum",
  49.       "The size of the quorum of replicas when using `replicated_log` based\n"
  50.       "registry. It is imperative to set this value to be a majority of\n"
  51.       "masters i.e., `quorum > (number of masters)/2`.\n"
  52.       "NOTE: Not required if master is run in standalone mode (non-HA).");
  53.  
  54.   add(&Flags::zk_session_timeout,
  55.       "zk_session_timeout",
  56.       "ZooKeeper session timeout.",
  57.       ZOOKEEPER_SESSION_TIMEOUT);
  58.  
  59.   // TODO(bmahler): Set the default to true in 0.20.0.
  60.   add(&Flags::registry_strict,
  61.       "registry_strict",
  62.       "Whether the master will take actions based on the persistent\n"
  63.       "information stored in the Registry. Setting this to false means\n"
  64.       "that the Registrar will never reject the admission, readmission,\n"
  65.       "or removal of an agent. Consequently, `false` can be used to\n"
  66.       "bootstrap the persistent state on a running cluster.\n"
  67.       "NOTE: This flag is *experimental* and should not be used in\n"
  68.       "production yet.",
  69.       false);
  70.  
  71.   add(&Flags::registry_fetch_timeout,
  72.       "registry_fetch_timeout",
  73.       "Duration of time to wait in order to fetch data from the registry\n"
  74.       "after which the operation is considered a failure.",
  75.       Seconds(60));
  76.  
  77.   add(&Flags::registry_store_timeout,
  78.       "registry_store_timeout",
  79.       "Duration of time to wait in order to store data in the registry\n"
  80.       "after which the operation is considered a failure.",
  81.       Seconds(20));
  82.  
  83.   add(&Flags::log_auto_initialize,
  84.       "log_auto_initialize",
  85.       "Whether to automatically initialize the replicated log used for the\n"
  86.       "registry. If this is set to false, the log has to be manually\n"
  87.       "initialized when used for the very first time.",
  88.       true);
  89.  
  90.   add(&Flags::agent_reregister_timeout,
  91.       "agent_reregister_timeout",
  92.       flags::DeprecatedName("slave_reregister_timeout"),
  93.       "The timeout within which all agents are expected to re-register\n"
  94.       "when a new master is elected as the leader. Agents that do not\n"
  95.       "re-register within the timeout will be removed from the registry\n"
  96.       "and will be shutdown if they attempt to communicate with master.\n"
  97.       "NOTE: This value has to be at least " +
  98.         stringify(MIN_AGENT_REREGISTER_TIMEOUT) + ".",
  99.       MIN_AGENT_REREGISTER_TIMEOUT);
  100.  
  101.   // TODO(bmahler): Add a `Percentage` abstraction for flags.
  102.   // TODO(bmahler): Add a `--production` flag for production defaults.
  103.   add(&Flags::recovery_agent_removal_limit,
  104.       "recovery_agent_removal_limit",
  105.       flags::DeprecatedName("recovery_slave_removal_limit"),
  106.       "For failovers, limit on the percentage of agents that can be removed\n"
  107.       "from the registry *and* shutdown after the re-registration timeout\n"
  108.       "elapses. If the limit is exceeded, the master will fail over rather\n"
  109.       "than remove the agents.\n"
  110.       "This can be used to provide safety guarantees for production\n"
  111.       "environments. Production environments may expect that across master\n"
  112.       "failovers, at most a certain percentage of agents will fail\n"
  113.       "permanently (e.g. due to rack-level failures).\n"
  114.       "Setting this limit would ensure that a human needs to get\n"
  115.       "involved should an unexpected widespread failure of agents occur\n"
  116.       "in the cluster.\n"
  117.       "Values: [0%-100%]",
  118.       stringify(RECOVERY_AGENT_REMOVAL_PERCENT_LIMIT * 100.0) + "%");
  119.  
  120.   // TODO(vinod): Add a `Rate` abstraction in stout and the
  121.   // corresponding parser for flags.
  122.   add(&Flags::agent_removal_rate_limit,
  123.       "agent_removal_rate_limit",
  124.       flags::DeprecatedName("slave_removal_rate_limit"),
  125.       "The maximum rate (e.g., `1/10mins`, `2/3hrs`, etc) at which agents\n"
  126.       "will be removed from the master when they fail health checks.\n"
  127.       "By default, agents will be removed as soon as they fail the health\n"
  128.       "checks. The value is of the form `(Number of agents)/(Duration)`.");
  129.  
  130.   add(&Flags::webui_dir,
  131.       "webui_dir",
  132.       "Directory path of the webui files/assets",
  133.       PKGDATADIR "/webui");
  134.  
  135.   add(&Flags::whitelist,
  136.       "whitelist",
  137.       "Path to a file which contains a list of agents (one per line) to\n"
  138.       "advertise offers for. The file is watched, and periodically re-read to\n"
  139.       "refresh the agent whitelist. By default there is no whitelist / all\n"
  140.       "machines are accepted. Path could be of the form\n"
  141.       "`file:///path/to/file` or `/path/to/file`.\n");
  142.  
  143.   add(&Flags::user_sorter,
  144.       "user_sorter",
  145.       "Policy to use for allocating resources\n"
  146.       "between users. May be one of:\n"
  147.       " dominant_resource_fairness (drf)",
  148.       "drf");
  149.  
  150.   add(&Flags::framework_sorter,
  151.       "framework_sorter",
  152.       "Policy to use for allocating resources\n"
  153.       "between a given user's frameworks. Options\n"
  154.       "are the same as for user_allocator.",
  155.       "drf");
  156.  
  157.   add(&Flags::allocation_interval,
  158.       "allocation_interval",
  159.       "Amount of time to wait between performing\n"
  160.       " (batch) allocations (e.g., 500ms, 1sec, etc).",
  161.       DEFAULT_ALLOCATION_INTERVAL);
  162.  
  163.   add(&Flags::cluster,
  164.       "cluster",
  165.       "Human readable name for the cluster, displayed in the webui.");
  166.  
  167.   add(&Flags::roles,
  168.       "roles",
  169.       "A comma-separated list of the allocation roles that frameworks\n"
  170.       "in this cluster may belong to. This flag is deprecated;\n"
  171.       "if it is not specified, any role name can be used.");
  172.  
  173.   add(&Flags::weights,
  174.       "weights",
  175.       "A comma-separated list of role/weight pairs of the form\n"
  176.       "`role=weight,role=weight`. Weights can be used to control the\n"
  177.       "relative share of cluster resources that is offered to different\n"
  178.       "roles. This flag is deprecated. Instead, operators should configure\n"
  179.       "weights dynamically using the `/weights` HTTP endpoint.");
  180.  
  181.   // TODO(adam-mesos): Deprecate --authenticate for --authenticate_frameworks.
  182.   // See MESOS-4386 for details.
  183.   add(&Flags::authenticate_frameworks,
  184.       "authenticate_frameworks",
  185.       flags::DeprecatedName("authenticate"),
  186.       "If `true`, only authenticated frameworks are allowed to register. If\n"
  187.       "`false`, unauthenticated frameworks are also allowed to register. For\n"
  188.       "HTTP based frameworks use the `--authenticate_http_frameworks` flag.",
  189.       false);
  190.  
  191.   add(&Flags::authenticate_agents,
  192.       "authenticate_agents",
  193.       flags::DeprecatedName("authenticate_slaves"),
  194.       "If `true`, only authenticated agents are allowed to register.\n"
  195.       "If `false`, unauthenticated agents are also allowed to register.",
  196.       false);
  197.  
  198.   add(&Flags::authenticate_http,
  199.       "authenticate_http",
  200.       "If `true`, only authenticated requests for HTTP endpoints supporting\n"
  201.       "authentication are allowed. If `false`, unauthenticated requests to\n"
  202.       "HTTP endpoints are also allowed.\n",
  203.       false);
  204.  
  205.   add(&Flags::authenticate_http_frameworks,
  206.       "authenticate_http_frameworks",
  207.       "If `true`, only authenticated HTTP frameworks are allowed to register.\n"
  208.       "If `false`, HTTP frameworks are not authenticated.",
  209.       false);
  210.  
  211.   add(&Flags::credentials,
  212.       "credentials",
  213.       "Path to a JSON-formatted file containing credentials.\n"
  214.       "Path could be of the form `file:///path/to/file` or `/path/to/file`."
  215.       "\n"
  216.       "Example:\n"
  217.       "{\n"
  218.       " \"credentials\": [\n"
  219.       " {\n"
  220.       " \"principal\": \"sherman\",\n"
  221.       " \"secret\": \"kitesurf\"\n"
  222.       " }\n"
  223.       " ]\n"
  224.       "}");
  225.  
  226.   add(&Flags::acls,
  227.       "acls",
  228.       "The value could be a JSON-formatted string of ACLs\n"
  229.       "or a file path containing the JSON-formatted ACLs used\n"
  230.       "for authorization. Path could be of the form `file:///path/to/file`\n"
  231.       "or `/path/to/file`.\n"
  232.       "\n"
  233.       "Note that if the flag `--authorizers` is provided with a value\n"
  234.       "different than `" + string(DEFAULT_AUTHORIZER) + "`, the ACLs contents\n"
  235.       "will be ignored.\n"
  236.       "\n"
  237.       "See the ACLs protobuf in acls.proto for the expected format.\n"
  238.       "\n"
  239.       "Example:\n"
  240.       "{\n"
  241.       " \"register_frameworks\": [\n"
  242.       " {\n"
  243.       " \"principals\": { \"type\": \"ANY\" },\n"
  244.       " \"roles\": { \"values\": [\"a\"] }\n"
  245.       " }\n"
  246.       " ],\n"
  247.       " \"run_tasks\": [\n"
  248.       " {\n"
  249.       " \"principals\": { \"values\": [\"a\", \"b\"] },\n"
  250.       " \"users\": { \"values\": [\"c\"] }\n"
  251.       " }\n"
  252.       " ],\n"
  253.       " \"teardown_frameworks\": [\n"
  254.       " {\n"
  255.       " \"principals\": { \"values\": [\"a\", \"b\"] },\n"
  256.       " \"framework_principals\": { \"values\": [\"c\"] }\n"
  257.       " }\n"
  258.       " ],\n"
  259.       " \"set_quotas\": [\n"
  260.       " {\n"
  261.       " \"principals\": { \"values\": [\"a\"] },\n"
  262.       " \"roles\": { \"values\": [\"a\", \"b\"] }\n"
  263.       " }\n"
  264.       " ],\n"
  265.       " \"remove_quotas\": [\n"
  266.       " {\n"
  267.       " \"principals\": { \"values\": [\"a\"] },\n"
  268.       " \"quota_principals\": { \"values\": [\"a\"] }\n"
  269.       " }\n"
  270.       " ]\n"
  271.       "}");
  272.  
  273.   add(&Flags::firewall_rules,
  274.       "firewall_rules",
  275.       "The value could be a JSON-formatted string of rules or a\n"
  276.       "file path containing the JSON-formatted rules used in the endpoints\n"
  277.       "firewall. Path must be of the form `file:///path/to/file`\n"
  278.       "or `/path/to/file`.\n"
  279.       "\n"
  280.       "See the `Firewall` message in `flags.proto` for the expected format.\n"
  281.       "\n"
  282.       "Example:\n"
  283.       "{\n"
  284.       " \"disabled_endpoints\" : {\n"
  285.       " \"paths\" : [\n"
  286.       " \"/files/browse\",\n"
  287.       " \"/metrics/snapshot\"\n"
  288.       " ]\n"
  289.       " }\n"
  290.       "}");
  291.  
  292.   add(&Flags::rate_limits,
  293.       "rate_limits",
  294.       "The value could be a JSON-formatted string of rate limits\n"
  295.       "or a file path containing the JSON-formatted rate limits used\n"
  296.       "for framework rate limiting.\n"
  297.       "Path could be of the form `file:///path/to/file`\n"
  298.       "or `/path/to/file`.\n"
  299.       "\n"
  300.       "See the RateLimits protobuf in mesos.proto for the expected format.\n"
  301.       "\n"
  302.       "Example:\n"
  303.       "{\n"
  304.       " \"limits\": [\n"
  305.       " {\n"
  306.       " \"principal\": \"foo\",\n"
  307.       " \"qps\": 55.5\n"
  308.       " },\n"
  309.       " {\n"
  310.       " \"principal\": \"bar\"\n"
  311.       " }\n"
  312.       " ],\n"
  313.       " \"aggregate_default_qps\": 33.3\n"
  314.       "}");
  315.  
  316. #ifdef WITH_NETWORK_ISOLATOR
  317.   add(&Flags::max_executors_per_agent,
  318.       "max_executors_per_agent",
  319.       flags::DeprecatedName("max_executors_per_slave"),
  320.       "Maximum number of executors allowed per agent. The network\n"
  321.       "monitoring/isolation technique imposes an implicit resource\n"
  322.       "acquisition on each executor (# ephemeral ports), as a result\n"
  323.       "one can only run a certain number of executors on each agent.");
  324. #endif // WITH_NETWORK_ISOLATOR
  325.  
  326.   // TODO(karya): When we have optimistic offers, this will only
  327.   // benefit frameworks that accidentally lose an offer.
  328.   add(&Flags::offer_timeout,
  329.       "offer_timeout",
  330.       "Duration of time before an offer is rescinded from a framework.\n"
  331.       "This helps fairness when running frameworks that hold on to offers,\n"
  332.       "or frameworks that accidentally drop offers.\n"
  333.       "If not set, offers do not timeout.");
  334.  
  335.   // This help message for --modules flag is the same for
  336.   // {master,slave,sched,tests}/flags.[ch]pp and should always be kept in
  337.   // sync.
  338.   // TODO(karya): Remove the JSON example and add reference to the
  339.   // doc file explaining the --modules flag.
  340.   add(&Flags::modules,
  341.       "modules",
  342.       "List of modules to be loaded and be available to the internal\n"
  343.       "subsystems.\n"
  344.       "\n"
  345.       "Use `--modules=filepath` to specify the list of modules via a\n"
  346.       "file containing a JSON-formatted string. `filepath` can be\n"
  347.       "of the form `file:///path/to/file` or `/path/to/file`.\n"
  348.       "\n"
  349.       "Use `--modules=\"{...}\"` to specify the list of modules inline.\n"
  350.       "\n"
  351.       "Example:\n"
  352.       "{\n"
  353.       " \"libraries\": [\n"
  354.       " {\n"
  355.       " \"file\": \"/path/to/libfoo.so\",\n"
  356.       " \"modules\": [\n"
  357.       " {\n"
  358.       " \"name\": \"org_apache_mesos_bar\",\n"
  359.       " \"parameters\": [\n"
  360.       " {\n"
  361.       " \"key\": \"X\",\n"
  362.       " \"value\": \"Y\"\n"
  363.       " }\n"
  364.       " ]\n"
  365.       " },\n"
  366.       " {\n"
  367.       " \"name\": \"org_apache_mesos_baz\"\n"
  368.       " }\n"
  369.       " ]\n"
  370.       " },\n"
  371.       " {\n"
  372.       " \"name\": \"qux\",\n"
  373.       " \"modules\": [\n"
  374.       " {\n"
  375.       " \"name\": \"org_apache_mesos_norf\"\n"
  376.       " }\n"
  377.       " ]\n"
  378.       " }\n"
  379.       " ]\n"
  380.       "}\n\n"
  381.       "Cannot be used in conjunction with --modules_dir.\n");
  382.  
  383.   // This help message for --modules_dir flag is the same for
  384.   // {master,slave,sched,tests}/flags.[ch]pp and should always be kept in
  385.   // sync.
  386.   add(&Flags::modulesDir,
  387.       "modules_dir",
  388.       "Directory path of the module manifest files.\n"
  389.       "The manifest files are processed in alphabetical order.\n"
  390.       "(See --modules for more information on module manifest files)\n"
  391.       "Cannot be used in conjunction with --modules.\n");
  392.  
  393.   add(&Flags::authenticators,
  394.       "authenticators",
  395.       "Authenticator implementation to use when authenticating frameworks\n"
  396.       "and/or agents. Use the default `" + string(DEFAULT_AUTHENTICATOR) + "`\n"
  397.       "or load an alternate authenticator module using `--modules`.",
  398.       DEFAULT_AUTHENTICATOR);
  399.  
  400.   add(&Flags::allocator,
  401.       "allocator",
  402.       "Allocator to use for resource allocation to frameworks.\n"
  403.       "Use the default `" + string(DEFAULT_ALLOCATOR) + "` allocator, or\n"
  404.       "load an alternate allocator module using `--modules`.",
  405.       DEFAULT_ALLOCATOR);
  406.  
  407.   add(&Flags::fair_sharing_excluded_resource_names,
  408.       "fair_sharing_excluded_resource_names",
  409.       "A comma-separated list of the resource names (e.g. 'gpus')\n"
  410.       "that will be excluded from fair sharing constraints.\n"
  411.       "This may be useful in cases where the fair sharing\n"
  412.       "implementation currently has limitations. E.g. See the\n"
  413.       "problem of \"scarce\" resources:\n"
  414.       " http://www.mail-archive.com/dev@mesos.apache.org/msg35631.html\n"
  415.       " https://issues.apache.org/jira/browse/MESOS-5377");
  416.  
  417.   add(&Flags::hooks,
  418.       "hooks",
  419.       "A comma-separated list of hook modules to be\n"
  420.       "installed inside master.");
  421.  
  422.   add(&Flags::agent_ping_timeout,
  423.       "agent_ping_timeout",
  424.       flags::DeprecatedName("slave_ping_timeout"),
  425.       "The timeout within which each agent is expected to respond to a\n"
  426.       "ping from the master. Agents that do not respond within\n"
  427.       "max_agent_ping_timeouts ping retries will be asked to shutdown.\n"
  428.       "NOTE: The total ping timeout (`agent_ping_timeout` multiplied by\n"
  429.       "`max_agent_ping_timeouts`) should be greater than the ZooKeeper\n"
  430.       "session timeout to prevent useless re-registration attempts.\n",
  431.       DEFAULT_AGENT_PING_TIMEOUT,
  432.       [](const Duration& value) -> Option<Error> {
  433.         if (value < Seconds(1) || value > Minutes(15)) {
  434.           return Error("Expected `--agent_ping_timeout` to be between " +
  435.                        stringify(Seconds(1)) + " and " +
  436.                        stringify(Minutes(15)));
  437.         }
  438.         return None();
  439.       });
  440.  
  441.   add(&Flags::max_agent_ping_timeouts,
  442.       "max_agent_ping_timeouts",
  443.       flags::DeprecatedName("max_slave_ping_timeouts"),
  444.       "The number of times an agent can fail to respond to a\n"
  445.       "ping from the master. Agents that do not respond within\n"
  446.       "`max_agent_ping_timeouts` ping retries will be asked to shutdown.\n",
  447.       DEFAULT_MAX_AGENT_PING_TIMEOUTS,
  448.       [](size_t value) -> Option<Error> {
  449.         if (value < 1) {
  450.           return Error("Expected `--max_agent_ping_timeouts` to be at least 1");
  451.         }
  452.         return None();
  453.       });
  454.  
  455.   add(&Flags::authorizers,
  456.       "authorizers",
  457.       "Authorizer implementation to use when authorizing actions that\n"
  458.       "require it.\n"
  459.       "Use the default `" + string(DEFAULT_AUTHORIZER) + "`, or\n"
  460.       "load an alternate authorizer module using `--modules`.\n"
  461.       "\n"
  462.       "Note that if the flag `--authorizers` is provided with a value\n"
  463.       "different than the default `" + string(DEFAULT_AUTHORIZER) + "`, the\n"
  464.       "ACLs passed through the `--acls` flag will be ignored.\n"
  465.       "\n"
  466.       "Currently there's no support for multiple authorizers.",
  467.       DEFAULT_AUTHORIZER);
  468.  
  469.   add(&Flags::http_authenticators,
  470.       "http_authenticators",
  471.       "HTTP authenticator implementation to use when handling requests to\n"
  472.       "authenticated endpoints. Use the default\n"
  473.       "`" + string(DEFAULT_HTTP_AUTHENTICATOR) + "`, or load an alternate\n"
  474.       "HTTP authenticator module using `--modules`.\n"
  475.       "\n"
  476.       "Currently there is no support for multiple HTTP authenticators.",
  477.       DEFAULT_HTTP_AUTHENTICATOR);
  478.  
  479.   add(&Flags::http_framework_authenticators,
  480.       "http_framework_authenticators",
  481.       "HTTP authenticator implementation to use when authenticating HTTP\n"
  482.       "frameworks. Use the \n"
  483.       "`" + string(DEFAULT_HTTP_AUTHENTICATOR) + "` authenticator or load an\n"
  484.       "alternate authenticator module using `--modules`.\n"
  485.       "Must be used in conjunction with `--http_authenticate_frameworks`.\n"
  486.       "\n"
  487.       "Currently there is no support for multiple HTTP framework\n"
  488.       "authenticators.");
  489.  
  490.   add(&Flags::max_completed_frameworks,
  491.       "max_completed_frameworks",
  492.       "Maximum number of completed frameworks to store in memory.",
  493.       DEFAULT_MAX_COMPLETED_FRAMEWORKS);
  494.  
  495.   add(&Flags::max_completed_tasks_per_framework,
  496.       "max_completed_tasks_per_framework",
  497.       "Maximum number of completed tasks per framework to store in memory.",
  498.       DEFAULT_MAX_COMPLETED_TASKS_PER_FRAMEWORK);
  499.  
  500.   add(&Flags::master_contender,
  501.       "master_contender",
  502.       "The symbol name of the master contender to use.\n"
  503.       "This symbol should exist in a module specified through\n"
  504.       "the --modules flag. Cannot be used in conjunction with --zk.\n"
  505.       "Must be used in conjunction with --master_detector.");
  506.  
  507.   add(&Flags::master_detector,
  508.       "master_detector",
  509.       "The symbol name of the master detector to use. This symbol\n"
  510.       "should exist in a module specified through the --modules flag.\n"
  511.       "Cannot be used in conjunction with --zk.\n"
  512.       "Must be used in conjunction with --master_contender.");
  513. }

 

里面的参数和http://mesos.apache.org/documentation/latest/configuration/中的参数列表一模一样。

 

posted @ 2016-07-24 09:37  popsuper1982  阅读(2402)  评论(0编辑  收藏  举报