MCPcopy Create free account
hub / github.com/apache/mesos / executorEnvironment

Function executorEnvironment

src/slave/slave.cpp:11399–11526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11397
11398
11399map<string, string> executorEnvironment(
11400 const Flags& flags,
11401 const ExecutorInfo& executorInfo,
11402 const string& directory,
11403 const SlaveID& slaveId,
11404 const PID<Slave>& slavePid,
11405 const Option<Secret>& authenticationToken,
11406 bool checkpoint)
11407{
11408 map<string, string> environment;
11409
11410 // In cases where DNS is not available on the slave, the absence of
11411 // LIBPROCESS_IP in the executor's environment will cause an error when the
11412 // new executor process attempts a hostname lookup. Thus, we pass the slave's
11413 // LIBPROCESS_IP through here, even if the executor environment is specified
11414 // explicitly. Note that a LIBPROCESS_IP present in the provided flags will
11415 // override this value.
11416 Option<string> libprocessIP = os::getenv("LIBPROCESS_IP");
11417 if (libprocessIP.isSome()) {
11418 environment["LIBPROCESS_IP"] = libprocessIP.get();
11419 }
11420
11421 if (flags.executor_environment_variables.isSome()) {
11422 foreachpair (const string& key,
11423 const JSON::Value& value,
11424 flags.executor_environment_variables->values) {
11425 // See slave/flags.cpp where we validate each value is a string.
11426 CHECK(value.is<JSON::String>());
11427 environment[key] = value.as<JSON::String>().value;
11428 }
11429 }
11430
11431 // Set LIBPROCESS_PORT so that we bind to a random free port (since
11432 // this might have been set via --port option). We do this before
11433 // the environment variables below in case it is included.
11434 environment["LIBPROCESS_PORT"] = "0";
11435
11436 // Also add MESOS_NATIVE_JAVA_LIBRARY if it's not already present (and
11437 // like above, we do this before the environment variables below in
11438 // case the framework wants to override).
11439 // TODO(tillt): Adapt library towards JNI specific name once libmesos
11440 // has been split.
11441 if (environment.count("MESOS_NATIVE_JAVA_LIBRARY") == 0) {
11442 const string path =
11443 path::join(LIBDIR, os::libraries::expandName("mesos-" VERSION));
11444 if (os::exists(path)) {
11445 environment["MESOS_NATIVE_JAVA_LIBRARY"] = path;
11446 }
11447 }
11448
11449 // Also add MESOS_NATIVE_LIBRARY if it's not already present.
11450 // This environment variable is kept for offering non JVM-based
11451 // frameworks a more compact and JNI independent library.
11452 if (environment.count("MESOS_NATIVE_LIBRARY") == 0) {
11453 const string path =
11454 path::join(LIBDIR, os::libraries::expandName("mesos-" VERSION));
11455 if (os::exists(path)) {
11456 environment["MESOS_NATIVE_LIBRARY"] = path;

Callers 3

TEST_FFunction · 0.85
launchExecutorMethod · 0.85

Calls 11

expandNameFunction · 0.85
NanosecondsClass · 0.85
dataMethod · 0.80
getenvFunction · 0.50
joinFunction · 0.50
existsFunction · 0.50
stringifyFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
countMethod · 0.45
valueMethod · 0.45

Tested by 2

TEST_FFunction · 0.68