Replaced `.get().` with `->` in the agent. Review: https://reviews.apache.org/r/59559/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4a5ec22a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4a5ec22a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4a5ec22a Branch: refs/heads/master Commit: 4a5ec22a7a32ea1761afbd4b5abc0005df772006 Parents: b048934 Author: Neil Conway <neil.con...@gmail.com> Authored: Thu May 25 10:01:56 2017 -0700 Committer: Neil Conway <neil.con...@gmail.com> Committed: Thu May 25 10:02:55 2017 -0700 ---------------------------------------------------------------------- src/slave/flags.cpp | 2 +- src/slave/http.cpp | 7 ++-- src/slave/main.cpp | 4 +-- src/slave/slave.cpp | 62 ++++++++++++++++---------------- src/slave/state.cpp | 20 +++++------ src/slave/status_update_manager.cpp | 10 +++--- 6 files changed, 52 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/flags.cpp ---------------------------------------------------------------------- diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp index 0c8276e..d0dc9c8 100644 --- a/src/slave/flags.cpp +++ b/src/slave/flags.cpp @@ -315,7 +315,7 @@ mesos::internal::slave::Flags::Flags() "}", [](const Option<JSON::Object>& object) -> Option<Error> { if (object.isSome()) { - foreachvalue (const JSON::Value& value, object.get().values) { + foreachvalue (const JSON::Value& value, object->values) { if (!value.is<JSON::String>()) { return Error("`executor_environment_variables` must " "only contain string values"); http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/http.cpp ---------------------------------------------------------------------- diff --git a/src/slave/http.cpp b/src/slave/http.cpp index 5beaf91..4444a38 100644 --- a/src/slave/http.cpp +++ b/src/slave/http.cpp @@ -412,7 +412,7 @@ Future<Response> Slave::Http::api( Option<Error> error = validation::agent::call::validate(call); if (error.isSome()) { - return Error("Failed to validate agent::Call: " + error.get().message); + return Error("Failed to validate agent::Call: " + error->message); } return call; @@ -705,8 +705,7 @@ Future<Response> Slave::Http::executor( Option<Error> error = validation::executor::call::validate(call); if (error.isSome()) { - return BadRequest("Failed to validate Executor::Call: " + - error.get().message); + return BadRequest("Failed to validate Executor::Call: " + error->message); } ContentType acceptType; @@ -1312,7 +1311,7 @@ Future<Response> Slave::Http::state( if (slave->master.isSome()) { Try<string> hostname = - net::getHostname(slave->master.get().address.ip); + net::getHostname(slave->master->address.ip); if (hostname.isSome()) { writer->field("master_hostname", hostname.get()); http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/main.cpp ---------------------------------------------------------------------- diff --git a/src/slave/main.cpp b/src/slave/main.cpp index 947f1f2..a363ae6 100644 --- a/src/slave/main.cpp +++ b/src/slave/main.cpp @@ -184,7 +184,7 @@ static Try<Nothing> assignCgroups(const slave::Flags& flags) // isolators/cgroups/perf.cpp. Consider moving ancillary // processes to a different cgroup, e.g., moving 'docker log' to // the container's cgroup. - if (!processes.get().empty()) { + if (!processes->empty()) { // For each process, we print its pid as well as its command // to help triaging. vector<string> infos; @@ -193,7 +193,7 @@ static Try<Nothing> assignCgroups(const slave::Flags& flags) // Only print the command if available. if (proc.isSome()) { - infos.push_back(stringify(pid) + " '" + proc.get().command + "'"); + infos.push_back(stringify(pid) + " '" + proc->command + "'"); } else { infos.push_back(stringify(pid)); } http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 15e4d68..dbc1c4b 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -256,7 +256,7 @@ void Slave::initialize() } else { credential = _credential.get(); LOG(INFO) << "Agent using credential for: " - << credential.get().principal(); + << credential->principal(); } } @@ -458,7 +458,7 @@ void Slave::initialize() } bool foundEntry = false; - foreach (const fs::MountTable::Entry& entry, mountTable.get().entries) { + foreach (const fs::MountTable::Entry& entry, mountTable->entries) { if (entry.dir == realpath.get()) { foundEntry = true; break; @@ -911,13 +911,13 @@ void Slave::detected(const Future<Option<MasterInfo>>& _master) LOG(INFO) << "Re-detecting master"; latest = None(); master = None(); - } else if (_master.get().isNone()) { + } else if (_master->isNone()) { LOG(INFO) << "Lost leading master"; latest = None(); master = None(); } else { latest = _master.get(); - master = UPID(_master.get().get().pid()); + master = UPID(latest->pid()); LOG(INFO) << "New master detected at " << master.get(); @@ -5767,17 +5767,17 @@ Future<Nothing> Slave::recover(const Try<state::State>& state) // NOTE: 'resourcesState' is None if the slave rootDir does not // exist or the resources checkpoint file cannot be found. if (resourcesState.isSome()) { - if (resourcesState.get().errors > 0) { + if (resourcesState->errors > 0) { LOG(WARNING) << "Errors encountered during resources recovery: " - << resourcesState.get().errors; + << resourcesState->errors; - metrics.recovery_errors += resourcesState.get().errors; + metrics.recovery_errors += resourcesState->errors; } - checkpointedResources = resourcesState.get().resources; + checkpointedResources = resourcesState->resources; - if (resourcesState.get().target.isSome()) { - Resources targetResources = resourcesState.get().target.get(); + if (resourcesState->target.isSome()) { + Resources targetResources = resourcesState->target.get(); // Sync the checkpointed resources from the target (which was // only created when there are pending changes in the @@ -5835,44 +5835,44 @@ Future<Nothing> Slave::recover(const Try<state::State>& state) totalResources = _totalResources.get(); } - if (slaveState.isSome() && slaveState.get().info.isSome()) { + if (slaveState.isSome() && slaveState->info.isSome()) { // Check for SlaveInfo compatibility. // TODO(vinod): Also check for version compatibility. // NOTE: We set the 'id' field in 'info' from the recovered slave, // as a hack to compare the info created from options/flags with // the recovered info. - info.mutable_id()->CopyFrom(slaveState.get().id); + info.mutable_id()->CopyFrom(slaveState->id); if (flags.recover == "reconnect" && - !(info == slaveState.get().info.get())) { + !(info == slaveState->info.get())) { return Failure(strings::join( "\n", "Incompatible agent info detected.", "------------------------------------------------------------", - "Old agent info:\n" + stringify(slaveState.get().info.get()), + "Old agent info:\n" + stringify(slaveState->info.get()), "------------------------------------------------------------", "New agent info:\n" + stringify(info), "------------------------------------------------------------")); } - info = slaveState.get().info.get(); // Recover the slave info. + info = slaveState->info.get(); // Recover the slave info. - if (slaveState.get().errors > 0) { + if (slaveState->errors > 0) { LOG(WARNING) << "Errors encountered during agent recovery: " - << slaveState.get().errors; + << slaveState->errors; - metrics.recovery_errors += slaveState.get().errors; + metrics.recovery_errors += slaveState->errors; } // TODO(bernd-mesos): Make this an instance method call, see comment // in "fetcher.hpp"". - Try<Nothing> recovered = Fetcher::recover(slaveState.get().id, flags); + Try<Nothing> recovered = Fetcher::recover(slaveState->id, flags); if (recovered.isError()) { return Failure(recovered.error()); } // Recover the frameworks. foreachvalue (const FrameworkState& frameworkState, - slaveState.get().frameworks) { + slaveState->frameworks) { recoverFramework(frameworkState, injectedExecutors, injectedTasks); } } @@ -7109,18 +7109,18 @@ void Framework::recoverExecutor( info.checkpoint()); // Recover the libprocess PID if possible for PID based executors. - if (run.get().http.isSome()) { - if (!run.get().http.get()) { + if (run->http.isSome()) { + if (!run->http.get()) { // When recovering in non-strict mode, the assumption is that the // slave can die after checkpointing the forked pid but before the // libprocess pid. So, it is not possible for the libprocess pid // to exist but not the forked pid. If so, it is a really bad // situation (e.g., disk corruption). - CHECK_SOME(run.get().forkedPid) + CHECK_SOME(run->forkedPid) << "Failed to get forked pid for executor " << state.id << " of framework " << id(); - executor->pid = run.get().libprocessPid.get(); + executor->pid = run->libprocessPid.get(); } else { // We set the PID to None() to signify that this is a HTTP based // executor. @@ -7133,7 +7133,7 @@ void Framework::recoverExecutor( } // And finally recover all the executor's tasks. - foreachvalue (const TaskState& taskState, run.get().tasks) { + foreachvalue (const TaskState& taskState, run->tasks) { executor->recoverTask( taskState, tasksToRecheckpoint.contains(taskState.id)); @@ -7167,13 +7167,13 @@ void Framework::recoverExecutor( // If the latest run of the executor was completed (i.e., terminated // and all updates are acknowledged) in the previous run, we // transition its state to 'TERMINATED' and gc the directories. - if (run.get().completed) { + if (run->completed) { ++slave->metrics.executors_terminated; executor->state = Executor::TERMINATED; - CHECK_SOME(run.get().id); - const ContainerID& runId = run.get().id.get(); + CHECK_SOME(run->id); + const ContainerID& runId = run->id.get(); // GC the executor run's work directory. const string path = paths::getExecutorRunPath( @@ -7353,7 +7353,7 @@ void Executor::recoverTask(const TaskState& state, bool recheckpointTask) // 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. - resources += state.info.get().resources(); + resources += state.info->resources(); // Read updates to get the latest state of the task. foreach (const StatusUpdate& update, state.updates) { @@ -7503,7 +7503,7 @@ void Executor::closeHttpConnection() { CHECK_SOME(http); - if (!http.get().close()) { + if (!http->close()) { LOG(WARNING) << "Failed to close HTTP pipe for " << *this; } @@ -7550,7 +7550,7 @@ map<string, string> executorEnvironment( if (flags.executor_environment_variables.isSome()) { foreachpair (const string& key, const JSON::Value& value, - flags.executor_environment_variables.get().values) { + flags.executor_environment_variables->values) { // See slave/flags.cpp where we validate each value is a string. CHECK(value.is<JSON::String>()); environment[key] = value.as<JSON::String>().value; http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/state.cpp ---------------------------------------------------------------------- diff --git a/src/slave/state.cpp b/src/slave/state.cpp index 33dcc7a..18b790d 100644 --- a/src/slave/state.cpp +++ b/src/slave/state.cpp @@ -193,7 +193,7 @@ Try<SlaveState> SlaveState::recover( } state.frameworks[frameworkId] = framework.get(); - state.errors += framework.get().errors; + state.errors += framework->errors; } return state; @@ -269,7 +269,7 @@ Try<FrameworkState> FrameworkState::recover( } } - if (pid.get().empty()) { + if (pid->empty()) { // This could happen if the slave died after opening the file for // writing but before it checkpointed anything. LOG(WARNING) << "Found empty framework pid file '" << path << "'"; @@ -302,7 +302,7 @@ Try<FrameworkState> FrameworkState::recover( } state.executors[executorId] = executor.get(); - state.errors += executor.get().errors; + state.errors += executor->errors; } return state; @@ -364,7 +364,7 @@ Try<ExecutorState> ExecutorState::recover( } state.runs[containerId] = run.get(); - state.errors += run.get().errors; + state.errors += run->errors; } } @@ -465,7 +465,7 @@ Try<RunState> RunState::recover( } state.tasks[taskId] = task.get(); - state.errors += task.get().errors; + state.errors += task->errors; } // Read the forked pid. @@ -493,7 +493,7 @@ Try<RunState> RunState::recover( } } - if (pid.get().empty()) { + if (pid->empty()) { // This could happen if the slave died after opening the file for // writing but before it checkpointed anything. LOG(WARNING) << "Found empty executor forked pid file '" << path << "'"; @@ -529,7 +529,7 @@ Try<RunState> RunState::recover( } } - if (pid.get().empty()) { + if (pid->empty()) { // This could happen if the slave died after opening the file for // writing but before it checkpointed anything. LOG(WARNING) << "Found empty executor libprocess pid file '" << path @@ -645,10 +645,10 @@ Try<TaskState> TaskState::recover( break; } - if (record.get().type() == StatusUpdateRecord::UPDATE) { - state.updates.push_back(record.get().update()); + if (record->type() == StatusUpdateRecord::UPDATE) { + state.updates.push_back(record->update()); } else { - state.acks.insert(UUID::fromBytes(record.get().uuid()).get()); + state.acks.insert(UUID::fromBytes(record->uuid()).get()); } } http://git-wip-us.apache.org/repos/asf/mesos/blob/4a5ec22a/src/slave/status_update_manager.cpp ---------------------------------------------------------------------- diff --git a/src/slave/status_update_manager.cpp b/src/slave/status_update_manager.cpp index 0cd88ac..e0d029b 100644 --- a/src/slave/status_update_manager.cpp +++ b/src/slave/status_update_manager.cpp @@ -206,7 +206,7 @@ Future<Nothing> StatusUpdateManagerProcess::recover( return Nothing(); } - foreachvalue (const FrameworkState& framework, state.get().frameworks) { + foreachvalue (const FrameworkState& framework, state->frameworks) { foreachvalue (const ExecutorState& executor, framework.executors) { LOG(INFO) << "Recovering executor '" << executor.id << "' of framework " << framework.id; @@ -232,7 +232,7 @@ Future<Nothing> StatusUpdateManagerProcess::recover( Option<RunState> run = executor.runs.get(latest); CHECK_SOME(run); - if (run.get().completed) { + if (run->completed) { VLOG(1) << "Skipping recovering updates of" << " executor '" << executor.id << "' of framework " << framework.id @@ -241,7 +241,7 @@ Future<Nothing> StatusUpdateManagerProcess::recover( continue; } - foreachvalue (const TaskState& task, run.get().tasks) { + foreachvalue (const TaskState& task, run->tasks) { // No updates were ever received for this task! // This means either: // 1) the executor never received this task or @@ -254,7 +254,7 @@ Future<Nothing> StatusUpdateManagerProcess::recover( // Create a new status update stream. StatusUpdateStream* stream = createStatusUpdateStream( - task.id, framework.id, state.get().id, true, executor.id, latest); + task.id, framework.id, state->id, true, executor.id, latest); // Replay the stream. Try<Nothing> replay = stream->replay(task.updates, task.acks); @@ -473,7 +473,7 @@ void StatusUpdateManagerProcess::timeout(const Duration& duration) CHECK_NOTNULL(stream); if (!stream->pending.empty()) { CHECK_SOME(stream->timeout); - if (stream->timeout.get().expired()) { + if (stream->timeout->expired()) { const StatusUpdate& update = stream->pending.front(); LOG(WARNING) << "Resending status update " << update;