Removed an unnecessarily introduced Option. Review: https://reviews.apache.org/r/25304
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b71dc72d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b71dc72d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b71dc72d Branch: refs/heads/master Commit: b71dc72dfac3f1106a1ad322da36a4d1e21eb5a3 Parents: 789d9b4 Author: Benjamin Mahler <[email protected]> Authored: Fri Aug 15 12:24:16 2014 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Wed Sep 3 14:01:16 2014 -0700 ---------------------------------------------------------------------- src/slave/http.cpp | 5 +---- src/slave/slave.cpp | 23 +++++++---------------- src/slave/slave.hpp | 7 ++----- 3 files changed, 10 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b71dc72d/src/slave/http.cpp ---------------------------------------------------------------------- diff --git a/src/slave/http.cpp b/src/slave/http.cpp index 39f8400..ec7c6b9 100644 --- a/src/slave/http.cpp +++ b/src/slave/http.cpp @@ -167,10 +167,7 @@ JSON::Object model(const Executor& executor) object.values["source"] = executor.info.source(); object.values["container"] = executor.containerId.value(); object.values["directory"] = executor.directory; - - if (executor.resources.isSome()) { - object.values["resources"] = model(executor.resources.get()); - } + object.values["resources"] = model(executor.resources); JSON::Array tasks; foreach (Task* task, executor.launchedTasks.values()) { http://git-wip-us.apache.org/repos/asf/mesos/blob/b71dc72d/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index a4027ec..ebde265 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -1248,8 +1248,7 @@ void Slave::_runTask( // TODO(Charles Reiss): The isolator is not guaranteed to update // the resources before the executor acts on its RunTaskMessage. // TODO(idownes): Wait until this completes. - CHECK_SOME(executor->resources); - containerizer->update(executor->containerId, executor->resources.get()); + containerizer->update(executor->containerId, executor->resources); LOG(INFO) << "Sending task '" << task.task_id() << "' to executor '" << executorId @@ -1843,8 +1842,7 @@ void Slave::registerExecutor( // that this will be delivered or (where necessary) acted on // before the executor gets its RunTaskMessages. // TODO(idownes): Wait until this completes. - CHECK_SOME(executor->resources); - containerizer->update(executor->containerId, executor->resources.get()); + containerizer->update(executor->containerId, executor->resources); // Tell executor it's registered and give it any queued tasks. ExecutorRegisteredMessage message; @@ -1977,8 +1975,7 @@ void Slave::reregisterExecutor( // Tell the containerizer to update the resources. // TODO(idownes): Wait until this completes. - CHECK_SOME(executor->resources); - containerizer->update(executor->containerId, executor->resources.get()); + containerizer->update(executor->containerId, executor->resources); // Monitor the executor. monitor.start( @@ -2179,8 +2176,7 @@ void Slave::statusUpdate(const StatusUpdate& update, const UPID& pid) // Wait until the container's resources have been updated before // sending the status update. - CHECK_SOME(executor->resources); - containerizer->update(executor->containerId, executor->resources.get()) + containerizer->update(executor->containerId, executor->resources) .onAny(defer(self(), &Slave::_statusUpdate, lambda::_1, @@ -3902,8 +3898,7 @@ Task* Executor::addTask(const TaskInfo& task) launchedTasks[task.task_id()] = t; - CHECK_SOME(resources); - resources = resources.get() + task.resources(); + resources += task.resources(); return t; } @@ -3924,10 +3919,7 @@ void Executor::terminateTask( } else if (launchedTasks.contains(taskId)) { // Update the resources if it's been launched. task = launchedTasks[taskId]; - CHECK_SOME(resources); - foreach (const Resource& resource, task->resources()) { - resources = resources.get() - resource; - } + resources -= task->resources(); launchedTasks.erase(taskId); } @@ -4000,8 +3992,7 @@ void Executor::recoverTask(const TaskState& state) // slave was down, the executor resources we capture here is an // upper-bound. The actual resources needed (for live tasks) by // the isolator will be calculated when the executor re-registers. - CHECK_SOME(resources); - resources = resources.get() + state.info.get().resources(); + resources += state.info.get().resources(); // Read updates to get the latest state of the task. foreach (const StatusUpdate& update, state.updates) { http://git-wip-us.apache.org/repos/asf/mesos/blob/b71dc72d/src/slave/slave.hpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp index 9d4607e..062e961 100644 --- a/src/slave/slave.hpp +++ b/src/slave/slave.hpp @@ -526,11 +526,8 @@ struct Executor process::UPID pid; - // Currently consumed resources. It is an option type as the - // executor info will not be known up-front and the executor - // resources therefore cannot be known until after the containerizer - // has launched the container. - Option<Resources> resources; + // Currently consumed resources. + Resources resources; // Tasks can be found in one of the following four data structures:
