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 解析命令行参数和环境变量

?


master::Flags flags;

?

// The following flags are executable specific (e.g., since we only

// have one instance of libprocess per execution, we only want to

// advertise the IP and port option once, here).

Option<string> ip;

flags.add(&ip,

"ip",

"IP address to listen on. This cannot be used in conjunction\n"

"with `--ip_discovery_command`.");

?

uint16_t port;

flags.add(&port,

"port",

"Port to listen on.",

MasterInfo().port());

?

Option<string> advertise_ip;

flags.add(&advertise_ip,

"advertise_ip",

"IP address advertised to reach this Mesos master.\n"

"The master does not bind using this IP address.\n"

"However, this IP address may be used to access this master.");

?

Option<string> advertise_port;

flags.add(&advertise_port,

"advertise_port",

"Port advertised to reach Mesos master (along with\n"

"`advertise_ip`). The master does not bind to this port.\n"

"However, this port (along with `advertise_ip`) may be used to\n"

"access this master.");

?

Option<string> zk;

flags.add(&zk,

"zk",

"ZooKeeper URL (used for leader election amongst masters)\n"

"May be one of:\n"

" `zk://host1:port1,host2:port2,.../path`\n"

" `zk://username:[email protected]:port1,host2:port2,.../path`\n"

" `file:///path/to/file` (where file contains one of the above)\n"

"NOTE: Not required if master is run in standalone mode (non-HA).");

?

// Optional IP discover script that will set the Master IP.

// If set, its output is expected to be a valid parseable IP string.

Option<string> ip_discovery_command;

flags.add(&ip_discovery_command,

"ip_discovery_command",

"Optional IP discovery binary: if set, it is expected to emit\n"

"the IP address which the master will try to bind to.\n"

"Cannot be used in conjunction with `--ip`.");

?

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

?

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


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里面下面的代码:


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 agent binds to; unless the user explicitly prevents\n"

"that, using `--no-hostname_lookup`, in which case the IP itself\n"

"is used.");

?

add(&Flags::hostname_lookup,

"hostname_lookup",

"Whether we should execute a lookup to find out the server‘s hostname,\n"

"if not explicitly set (via, e.g., `--hostname`).\n"

"True by default; if set to `false` it will cause Mesos\n"

"to use the IP address, unless the hostname is explicitly set.",

true);

?

add(&Flags::root_submissions,

"root_submissions",

"Can root submit frameworks?",

true);

?

add(&Flags::work_dir,

"work_dir",

"Path of the master work directory. This is where the persistent\n"

"information of the cluster will be stored. Note that locations like\n"

"`/tmp` which are cleaned automatically are not suitable for the work\n"

"directory when running in production, since long-running masters could\n"

"lose data when cleanup occurs. (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`.\n"

"NOTE: Not required if master is run in standalone mode (non-HA).");

?

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 an agent. 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(20));

?

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::agent_reregister_timeout,

"agent_reregister_timeout",

flags::DeprecatedName("slave_reregister_timeout"),

"The timeout within which all agents are expected to re-register\n"

"when a new master is elected as the leader. Agents 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 at least " +

stringify(MIN_AGENT_REREGISTER_TIMEOUT) + ".",

MIN_AGENT_REREGISTER_TIMEOUT);

?

// TODO(bmahler): Add a `Percentage` abstraction for flags.

// TODO(bmahler): Add a `--production` flag for production defaults.

add(&Flags::recovery_agent_removal_limit,

"recovery_agent_removal_limit",

flags::DeprecatedName("recovery_slave_removal_limit"),

"For failovers, limit on the percentage of agents 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 agents.\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 agents 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 agents occur\n"

"in the cluster.\n"

"Values: [0%-100%]",

stringify(RECOVERY_AGENT_REMOVAL_PERCENT_LIMIT * 100.0) + "%");

?

// TODO(vinod): Add a `Rate` abstraction in stout and the

// corresponding parser for flags.

add(&Flags::agent_removal_rate_limit,

"agent_removal_rate_limit",

flags::DeprecatedName("slave_removal_rate_limit"),

"The maximum rate (e.g., `1/10mins`, `2/3hrs`, etc) at which agents\n"

"will be removed from the master when they fail health checks.\n"

"By default, agents will be removed as soon as they fail the health\n"

"checks. The value is of the form `(Number of agents)/(Duration)`.");

?

add(&Flags::webui_dir,

"webui_dir",

"Directory path of the webui files/assets",

PKGDATADIR "/webui");

?

add(&Flags::whitelist,

"whitelist",

"Path to a file which contains a list of agents (one per line) to\n"

"advertise offers for. The file is watched, and periodically re-read to\n"

"refresh the agent whitelist. By default there is no whitelist / all\n"

"machines are accepted. Path could be of the form\n"

"`file:///path/to/file` or `/path/to/file`.\n");

?

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).",

DEFAULT_ALLOCATION_INTERVAL);

?

add(&Flags::cluster,

"cluster",

"Human readable name for the cluster, displayed in the webui.");

?

add(&Flags::roles,

"roles",

"A comma-separated list of the allocation roles that frameworks\n"

"in this cluster may belong to. This flag is deprecated;\n"

"if it is not specified, any role name can be used.");

?

add(&Flags::weights,

"weights",

"A comma-separated list of role/weight pairs of the form\n"

"`role=weight,role=weight`. Weights can be used to control the\n"

"relative share of cluster resources that is offered to different\n"

"roles. This flag is deprecated. Instead, operators should configure\n"

"weights dynamically using the `/weights` HTTP endpoint.");

?

// TODO(adam-mesos): Deprecate --authenticate for --authenticate_frameworks.

// See MESOS-4386 for details.

add(&Flags::authenticate_frameworks,

"authenticate_frameworks",

flags::DeprecatedName("authenticate"),

"If `true`, only authenticated frameworks are allowed to register. If\n"

"`false`, unauthenticated frameworks are also allowed to register. For\n"

"HTTP based frameworks use the `--authenticate_http_frameworks` flag.",

false);

?

add(&Flags::authenticate_agents,

"authenticate_agents",

flags::DeprecatedName("authenticate_slaves"),

"If `true`, only authenticated agents are allowed to register.\n"

"If `false`, unauthenticated agents are also allowed to register.",

false);

?

add(&Flags::authenticate_http,

"authenticate_http",

"If `true`, only authenticated requests for HTTP endpoints supporting\n"

"authentication are allowed. If `false`, unauthenticated requests to\n"

"HTTP endpoints are also allowed.\n",

false);

?

add(&Flags::authenticate_http_frameworks,

"authenticate_http_frameworks",

"If `true`, only authenticated HTTP frameworks are allowed to register.\n"

"If `false`, HTTP frameworks are not authenticated.",

false);

?

add(&Flags::credentials,

"credentials",

"Path to a JSON-formatted file containing credentials.\n"

"Path could be of the form `file:///path/to/file` or `/path/to/file`."

"\n"

"Example:\n"

"{\n"

" \"credentials\": [\n"

" {\n"

" \"principal\": \"sherman\",\n"

" \"secret\": \"kitesurf\"\n"

" }\n"

" ]\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"

"Note that if the flag `--authorizers` is provided with a value\n"

"different than `" + string(DEFAULT_AUTHORIZER) + "`, the ACLs contents\n"

"will be ignored.\n"

"\n"

"See the ACLs protobuf in acls.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"

" \"teardown_frameworks\": [\n"

" {\n"

" \"principals\": { \"values\": [\"a\", \"b\"] },\n"

" \"framework_principals\": { \"values\": [\"c\"] }\n"

" }\n"

" ],\n"

" \"set_quotas\": [\n"

" {\n"

" \"principals\": { \"values\": [\"a\"] },\n"

" \"roles\": { \"values\": [\"a\", \"b\"] }\n"

" }\n"

" ],\n"

" \"remove_quotas\": [\n"

" {\n"

" \"principals\": { \"values\": [\"a\"] },\n"

" \"quota_principals\": { \"values\": [\"a\"] }\n"

" }\n"

" ]\n"

"}");

?

add(&Flags::firewall_rules,

"firewall_rules",

"The value could be a JSON-formatted string of rules or a\n"

"file path containing the JSON-formatted rules used in the endpoints\n"

"firewall. Path must be of the form `file:///path/to/file`\n"

"or `/path/to/file`.\n"

"\n"

"See the `Firewall` message in `flags.proto` for the expected format.\n"

"\n"

"Example:\n"

"{\n"

" \"disabled_endpoints\" : {\n"

" \"paths\" : [\n"

" \"/files/browse\",\n"

" \"/metrics/snapshot\"\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_agent,

"max_executors_per_agent",

flags::DeprecatedName("max_executors_per_slave"),

"Maximum number of executors allowed per agent. 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 agent.");

#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.\n"

"If not set, offers do not timeout.");

?

// This help message for --modules flag is the same for

// {master,slave,sched,tests}/flags.[ch]pp 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"

"}\n\n"

"Cannot be used in conjunction with --modules_dir.\n");

?

// This help message for --modules_dir flag is the same for

// {master,slave,sched,tests}/flags.[ch]pp and should always be kept in

// sync.

add(&Flags::modulesDir,

"modules_dir",

"Directory path of the module manifest files.\n"

"The manifest files are processed in alphabetical order.\n"

"(See --modules for more information on module manifest files)\n"

"Cannot be used in conjunction with --modules.\n");

?

add(&Flags::authenticators,

"authenticators",

"Authenticator implementation to use when authenticating frameworks\n"

"and/or agents. Use the default `" + string(DEFAULT_AUTHENTICATOR) + "`\n"

"or load an alternate authenticator module using `--modules`.",

DEFAULT_AUTHENTICATOR);

?

add(&Flags::allocator,

"allocator",

"Allocator to use for resource allocation to frameworks.\n"

"Use the default `" + string(DEFAULT_ALLOCATOR) + "` allocator, or\n"

"load an alternate allocator module using `--modules`.",

DEFAULT_ALLOCATOR);

?

add(&Flags::fair_sharing_excluded_resource_names,

"fair_sharing_excluded_resource_names",

"A comma-separated list of the resource names (e.g. ‘gpus‘)\n"

"that will be excluded from fair sharing constraints.\n"

"This may be useful in cases where the fair sharing\n"

"implementation currently has limitations. E.g. See the\n"

"problem of \"scarce\" resources:\n"

" http://www.mail-archive.com/[email protected]/msg35631.html\n"

" https://issues.apache.org/jira/browse/MESOS-5377");

?

add(&Flags::hooks,

"hooks",

"A comma-separated list of hook modules to be\n"

"installed inside master.");

?

add(&Flags::agent_ping_timeout,

"agent_ping_timeout",

flags::DeprecatedName("slave_ping_timeout"),

"The timeout within which each agent is expected to respond to a\n"

"ping from the master. Agents that do not respond within\n"

"max_agent_ping_timeouts ping retries will be asked to shutdown.\n"

"NOTE: The total ping timeout (`agent_ping_timeout` multiplied by\n"

"`max_agent_ping_timeouts`) should be greater than the ZooKeeper\n"

"session timeout to prevent useless re-registration attempts.\n",

DEFAULT_AGENT_PING_TIMEOUT,

[](const Duration& value) -> Option<Error> {

if (value < Seconds(1) || value > Minutes(15)) {

return Error("Expected `--agent_ping_timeout` to be between " +

stringify(Seconds(1)) + " and " +

stringify(Minutes(15)));

}

return None();

});

?

add(&Flags::max_agent_ping_timeouts,

"max_agent_ping_timeouts",

flags::DeprecatedName("max_slave_ping_timeouts"),

"The number of times an agent can fail to respond to a\n"

"ping from the master. Agents that do not respond within\n"

"`max_agent_ping_timeouts` ping retries will be asked to shutdown.\n",

DEFAULT_MAX_AGENT_PING_TIMEOUTS,

[](size_t value) -> Option<Error> {

if (value < 1) {

return Error("Expected `--max_agent_ping_timeouts` to be at least 1");

}

return None();

});

?

add(&Flags::authorizers,

"authorizers",

"Authorizer implementation to use when authorizing actions that\n"

"require it.\n"

"Use the default `" + string(DEFAULT_AUTHORIZER) + "`, or\n"

"load an alternate authorizer module using `--modules`.\n"

"\n"

"Note that if the flag `--authorizers` is provided with a value\n"

"different than the default `" + string(DEFAULT_AUTHORIZER) + "`, the\n"

"ACLs passed through the `--acls` flag will be ignored.\n"

"\n"

"Currently there‘s no support for multiple authorizers.",

DEFAULT_AUTHORIZER);

?

add(&Flags::http_authenticators,

"http_authenticators",

"HTTP authenticator implementation to use when handling requests to\n"

"authenticated endpoints. Use the default\n"

"`" + string(DEFAULT_HTTP_AUTHENTICATOR) + "`, or load an alternate\n"

"HTTP authenticator module using `--modules`.\n"

"\n"

"Currently there is no support for multiple HTTP authenticators.",

DEFAULT_HTTP_AUTHENTICATOR);

?

add(&Flags::http_framework_authenticators,

"http_framework_authenticators",

"HTTP authenticator implementation to use when authenticating HTTP\n"

"frameworks. Use the \n"

"`" + string(DEFAULT_HTTP_AUTHENTICATOR) + "` authenticator or load an\n"

"alternate authenticator module using `--modules`.\n"

"Must be used in conjunction with `--http_authenticate_frameworks`.\n"

"\n"

"Currently there is no support for multiple HTTP framework\n"

"authenticators.");

?

add(&Flags::max_completed_frameworks,

"max_completed_frameworks",

"Maximum number of completed frameworks to store in memory.",

DEFAULT_MAX_COMPLETED_FRAMEWORKS);

?

add(&Flags::max_completed_tasks_per_framework,

"max_completed_tasks_per_framework",

"Maximum number of completed tasks per framework to store in memory.",

DEFAULT_MAX_COMPLETED_TASKS_PER_FRAMEWORK);

?

add(&Flags::master_contender,

"master_contender",

"The symbol name of the master contender to use.\n"

"This symbol should exist in a module specified through\n"

"the --modules flag. Cannot be used in conjunction with --zk.\n"

"Must be used in conjunction with --master_detector.");

?

add(&Flags::master_detector,

"master_detector",

"The symbol name of the master detector to use. This symbol\n"

"should exist in a module specified through the --modules flag.\n"

"Cannot be used in conjunction with --zk.\n"

"Must be used in conjunction with --master_contender.");

}

?

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

?

时间: 2024-08-05 06:39:56

Mesos原理与代码分析(2): Mesos Master的启动之一的相关文章

Mesos原理与代码分析(4) Mesos Master的启动之三

3. ModuleManager::load(flags.modules.get())如果有参数--modules或者--modules_dir=dirpath,则会将路径中的so文件load进来 ? 代码中加载模块的代码如下 ? 对应的命令行参数如下: ? ? 都可以写什么Module呢? ? 首先是Allocator ? 默认是内置的Hierarchical Dominant Resource Fairness allocator ? 要写一个自己的Allocator: 通过--module

Mesos原理与代码分析(5): Mesos Master的启动之四

? 5. Create an instance of allocator. ? 代码如下 ? Mesos源码中默认的Allocator,即HierarchicalDRFAllocator的位置在$MESOS_HOME/src/master/allocator/mesos/hierarchical.hpp,而DRF中对每个Framework排序的Sorter位于$MESOS_HOME/src/master/allocator/sorter/drf/sorter.cpp,可以查看其源码了解它的工作原

Mesos原理与代码分析(3): Mesos Master的启动之二

2. process::firewall::install(move(rules));如果有参数--firewall_rules则会添加规则 ? 对应的代码如下: // Initialize firewall rules. if (flags.firewall_rules.isSome()) { vector<Owned<FirewallRule>> rules; ? const Firewall firewall = flags.firewall_rules.get(); ? i

免费的Lucene 原理与代码分析完整版下载

Lucene是一个基于Java的高效的全文检索库.那么什么是全文检索,为什么需要全文检索?目前人们生活中出现的数据总的来说分为两类:结构化数据和非结构化数据.很容易理解,结构化数据是有固定格式和结构的或者有限长度的数据,比如数据库,元数据等.非结构化数据则是不定长或者没有固定格式的数据,如图片,邮件,文档等.还有一种较少的分类为半结构化数据,如XML,HTML等,在一定程度上我们可以将其按照结构化数据来处理,也可以抽取纯文本按照非结构化数据来处理.非结构化数据又称为全文数据.,对其搜索主要有两种

mesos支持gpu代码分析以及capos支持gpu实现

这篇文章涉及mesos如何在原生的mesoscontainerizer和docker containerizer上支持gpu的,以及如果自己实现一个mesos之上的framework capos支持gpu调度的实现原理,(capos是hulu内部的资源调度平台 refer to https://www.cnblogs.com/yanghuahui/p/9304302.html). mesos slave在启动的时候需要初始化containerizer的resource,包含cpu/mem/gpu

WordPress HOOK机制原理及代码分析

WordPress强大的插件机制让我们可以自由扩展功能.网上对插件的使用以及开发方法都有大量资料可以查询. 今天我们就分析一下四个主要函数的代码,包括: add_action.do_action.add_filter.apply_action. 一.add_action和add_filter 为什么把这两个函数放在一起讲呢?其实我们看看add_action函数的定义(图一)就可以知道,其实跟add_filter是同一个函数,执行的是相同的操作.只是把action和filter区分开,让开发者能更

Openvswitch原理与代码分析(6):用户态流表flow table的操作

当内核无法查找到流表项的时候,则会通过upcall来调用用户态ovs-vswtichd中的flow table. 会调用ofproto-dpif-upcall.c中的udpif_upcall_handler函数. static void * udpif_upcall_handler(void *arg) { ????struct handler *handler = arg; ????struct udpif *udpif = handler->udpif; ? ????while (!latc

Openvswitch原理与代码分析(1):总体架构

一.Opevswitch总体架构 Openvswitch的架构网上有如下的图表示: 每个模块都有不同的功能 ovs-vswitchd 为主要模块,实现交换机的守护进程daemon 在Openvswitch所在的服务器进行ps aux可以看到以下的进程 root 1008 0.1 0.8 242948 31712 ? S<Ll Aug06 32:17 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err

Lucene原理与代码分析解读笔记

Lucene是一个基于Java的高效的全文检索库. 那么什么是全文检索,为什么需要全文检索? 目前人们生活中出现的数据总的来说分为两类:结构化数据和非结构化数据.很容易理解,结构化数据是有固定格式和结构的或者有限长度的数据,比如数据库,元数据等.非结构化数据则是不定长或者没有固定格式的数据,如图片,邮件,文档等.还有一种较少的分类为半结构化数据,如XML,HTML等,在一定程度上我们可以将其按照结构化数据来处理,也可以抽取纯文本按照非结构化数据来处理. 非结构化数据又称为全文数据.,对其搜索主要