bool operator == (const ExecutorInfo& left, const ExecutorInfo& right) { return left.executor_id() == right.executor_id() && left.data() == right.data() && Resources(left.resources()) == Resources(right.resources()) && left.command() == right.command() && left.framework_id() == right.framework_id() && left.name() == right.name() && left.source() == right.source() && left.container() == right.container() && left.discovery() == right.discovery(); }
inline bool operator == (const ExecutorInfo& left, const ExecutorInfo& right) { return left.executor_id() == right.executor_id() && left.has_framework_id() == right.has_framework_id() && (!left.has_framework_id() || (left.framework_id() == right.framework_id())) && left.command() == right.command() && Resources(left.resources()) == Resources(right.resources()) && left.has_name() == right.has_name() && (!left.has_name() || (left.name() == right.name())) && left.has_source() == right.has_source() && (!left.has_source() || (left.source() == right.source())) && left.has_data() == right.has_data() && (!left.has_data() || (left.data() == right.data())); }
inline WorkID createExecutorWorkID(const ExecutorInfo info) { WorkID workID; workID.mutable_framework_id()->CopyFrom(info.framework_id()); workID.mutable_executor_id()->CopyFrom(info.executor_id()); return workID; }
inline slave::QoSCorrection_Kill createKill(const ExecutorInfo info) { slave::QoSCorrection_Kill kill; kill.mutable_framework_id()->CopyFrom(info.framework_id()); kill.mutable_executor_id()->CopyFrom(info.executor_id()); return kill; }
Try<double_t> ExecutorAgeFilter::age(const ExecutorInfo& executorInfo) { auto startedTime = started->find(executorInfo); if (startedTime == started->end()) { return Error( "Could not find started time for executor '" + executorInfo.framework_id().value() + "' of framework '" + executorInfo.executor_id().value() + "': framework not present"); } else { return difftime(time(NULL), startedTime->second); } }
Future<bool> TestContainerizer::_launch( const ContainerID& containerId, const ExecutorInfo& executorInfo, const string& directory, const Option<string>& user, const SlaveID& slaveId, const PID<slave::Slave>& slavePid, bool checkpoint) { CHECK(!drivers.contains(containerId)) << "Failed to launch executor " << executorInfo.executor_id() << " of framework " << executorInfo.framework_id() << " because it is already launched"; CHECK(executors.contains(executorInfo.executor_id())) << "Failed to launch executor " << executorInfo.executor_id() << " of framework " << executorInfo.framework_id() << " because it is unknown to the containerizer"; // Store mapping from (frameworkId, executorId) -> containerId to facilitate // easy destroy from tests. std::pair<FrameworkID, ExecutorID> key(executorInfo.framework_id(), executorInfo.executor_id()); containers_[key] = containerId; Executor* executor = executors[executorInfo.executor_id()]; Owned<MesosExecutorDriver> driver(new MesosExecutorDriver(executor)); drivers[containerId] = driver; // Prepare additional environment variables for the executor. const map<string, string>& env = executorEnvironment( executorInfo, directory, slaveId, slavePid, checkpoint, Duration::zero()); foreachpair (const string& name, const string variable, env) { os::setenv(name, variable); }
Future<bool> launch( const ContainerID& containerId, const Option<TaskInfo>& taskInfo, const ExecutorInfo& executorInfo, const string& directory, const Option<string>& user, const SlaveID& slaveId, const map<string, string>& environment, bool checkpoint) { CHECK(!terminatedContainers.contains(containerId)) << "Failed to launch nested container " << containerId << " for executor '" << executorInfo.executor_id() << "'" << " of framework " << executorInfo.framework_id() << " because this ContainerID is being re-used with" << " a previously terminated container"; CHECK(!containers_.contains(containerId)) << "Failed to launch container " << containerId << " for executor '" << executorInfo.executor_id() << "'" << " of framework " << executorInfo.framework_id() << " because it is already launched"; CHECK(executors.contains(executorInfo.executor_id())) << "Failed to launch executor '" << executorInfo.executor_id() << "'" << " of framework " << executorInfo.framework_id() << " because it is unknown to the containerizer"; containers_[containerId] = Owned<ContainerData>(new ContainerData()); containers_.at(containerId)->executorId = executorInfo.executor_id(); containers_.at(containerId)->frameworkId = executorInfo.framework_id(); // We need to synchronize all reads and writes to the environment // as this is global state. // // TODO(jmlvanre): Even this is not sufficient, as other aspects // of the code may read an environment variable while we are // manipulating it. The better solution is to pass the environment // variables into the fork, or to set them on the command line. // See MESOS-3475. static std::mutex mutex; synchronized(mutex) { // Since the constructor for `MesosExecutorDriver` reads // environment variables to load flags, even it needs to // be within this synchronization section. // // Prepare additional environment variables for the executor. // TODO(benh): Need to get flags passed into the TestContainerizer // in order to properly use here. slave::Flags flags; flags.recovery_timeout = Duration::zero(); // We need to save the original set of environment variables so we // can reset the environment after calling 'driver->start()' below. hashmap<string, string> original = os::environment(); foreachpair (const string& name, const string variable, environment) { os::setenv(name, variable); } // TODO(benh): Can this be removed and done exclusively in the // 'executorEnvironment()' function? There are other places in the // code where we do this as well and it's likely we can do this once // in 'executorEnvironment()'. foreach (const Environment::Variable& variable, executorInfo.command().environment().variables()) { os::setenv(variable.name(), variable.value()); } os::setenv("MESOS_LOCAL", "1"); const Owned<ExecutorData>& executorData = executors.at(executorInfo.executor_id()); if (executorData->executor != nullptr) { executorData->driver = Owned<MesosExecutorDriver>( new MesosExecutorDriver(executorData->executor)); executorData->driver->start(); } else { shared_ptr<v1::MockHTTPExecutor> executor = executorData->v1ExecutorMock; executorData->v1Library = Owned<v1::executor::TestMesos>( new v1::executor::TestMesos(ContentType::PROTOBUF, executor)); } os::unsetenv("MESOS_LOCAL"); // Unset the environment variables we set by resetting them to their // original values and also removing any that were not part of the // original environment. foreachpair (const string& name, const string& value, original) { os::setenv(name, value); }
Future<bool> TestContainerizer::_launch( const ContainerID& containerId, const ExecutorInfo& executorInfo, const string& directory, const Option<string>& user, const SlaveID& slaveId, const PID<slave::Slave>& slavePid, bool checkpoint) { CHECK(!drivers.contains(containerId)) << "Failed to launch executor " << executorInfo.executor_id() << " of framework " << executorInfo.framework_id() << " because it is already launched"; CHECK(executors.contains(executorInfo.executor_id())) << "Failed to launch executor " << executorInfo.executor_id() << " of framework " << executorInfo.framework_id() << " because it is unknown to the containerizer"; // Store mapping from (frameworkId, executorId) -> containerId to facilitate // easy destroy from tests. std::pair<FrameworkID, ExecutorID> key(executorInfo.framework_id(), executorInfo.executor_id()); containers_[key] = containerId; Executor* executor = executors[executorInfo.executor_id()]; // We need to synchronize all reads and writes to the environment as this is // global state. // TODO(jmlvanre): Even this is not sufficient, as other aspects of the code // may read an environment variable while we are manipulating it. The better // solution is to pass the environment variables into the fork, or to set them // on the command line. See MESOS-3475. static std::mutex mutex; synchronized(mutex) { // Since the constructor for `MesosExecutorDriver` reads environment // variables to load flags, even it needs to be within this synchronization // section. Owned<MesosExecutorDriver> driver(new MesosExecutorDriver(executor)); drivers[containerId] = driver; // Prepare additional environment variables for the executor. // TODO(benh): Need to get flags passed into the TestContainerizer // in order to properly use here. slave::Flags flags; flags.recovery_timeout = Duration::zero(); // We need to save the original set of environment variables so we // can reset the environment after calling 'driver->start()' below. hashmap<string, string> original = os::environment(); const map<string, string> environment = executorEnvironment( executorInfo, directory, slaveId, slavePid, checkpoint, flags); foreachpair (const string& name, const string variable, environment) { os::setenv(name, variable); } // TODO(benh): Can this be removed and done exlusively in the // 'executorEnvironment()' function? There are other places in the // code where we do this as well and it's likely we can do this once // in 'executorEnvironment()'. foreach (const Environment::Variable& variable, executorInfo.command().environment().variables()) { os::setenv(variable.name(), variable.value()); } os::setenv("MESOS_LOCAL", "1"); driver->start(); os::unsetenv("MESOS_LOCAL"); // Unset the environment variables we set by resetting them to their // original values and also removing any that were not part of the // original environment. foreachpair (const string& name, const string& value, original) { os::setenv(name, value); }