mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [mesos] branch master updated: Removed dead code from v1 API serialization changes.
Date Tue, 25 Feb 2020 16:57:01 GMT
This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 1dd099f  Removed dead code from v1 API serialization changes.
1dd099f is described below

commit 1dd099f7677f897eda7fe12f959ae3763aba3b40
Author: Benjamin Mahler <bmahler@apache.org>
AuthorDate: Thu Jan 30 17:19:43 2020 -0500

    Removed dead code from v1 API serialization changes.
    
    Per MESOS-10026, we replaced the old protobuf object construction
    code with a direct serialization approach to improve performance.
    This patch removes the old object construction code (I originally
    kept it in case we needed it to debug, but at this point I'm more
    confident that we don't need it).
    
    Review: https://reviews.apache.org/r/72068
---
 src/master/http.cpp   | 201 ----------------------------------------------
 src/master/master.hpp |  10 ---
 src/slave/http.cpp    | 216 --------------------------------------------------
 src/slave/http.hpp    |   8 --
 4 files changed, 435 deletions(-)

diff --git a/src/master/http.cpp b/src/master/http.cpp
index bf04395..c7d674c 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -1331,34 +1331,6 @@ Future<Response> Master::Http::getFrameworks(
 }
 
 
-mesos::master::Response::GetFrameworks Master::Http::_getFrameworks(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  mesos::master::Response::GetFrameworks getFrameworks;
-  foreachvalue (const Framework* framework,
-                master->frameworks.registered) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    *getFrameworks.add_frameworks() = model(*framework);
-  }
-
-  foreachvalue (const Owned<Framework>& framework,
-                master->frameworks.completed) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    *getFrameworks.add_completed_frameworks() = model(*framework);
-  }
-
-  return getFrameworks;
-}
-
-
 Future<Response> Master::Http::getExecutors(
     const mesos::master::Call& call,
     const Option<Principal>& principal,
@@ -1384,56 +1356,6 @@ Future<Response> Master::Http::getExecutors(
 }
 
 
-mesos::master::Response::GetExecutors Master::Http::_getExecutors(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  // Construct framework list with both active and completed frameworks.
-  vector<const Framework*> frameworks;
-  foreachvalue (Framework* framework, master->frameworks.registered) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework);
-  }
-
-  foreachvalue (const Owned<Framework>& framework,
-                master->frameworks.completed) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework.get());
-  }
-
-  mesos::master::Response::GetExecutors getExecutors;
-
-  foreach (const Framework* framework, frameworks) {
-    foreachpair (const SlaveID& slaveId,
-                 const auto& executorsMap,
-                 framework->executors) {
-      foreachvalue (const ExecutorInfo& executorInfo, executorsMap) {
-        // Skip unauthorized executors.
-        if (!approvers->approved<VIEW_EXECUTOR>(
-                executorInfo, framework->info)) {
-          continue;
-        }
-
-        mesos::master::Response::GetExecutors::Executor* executor =
-          getExecutors.add_executors();
-
-        executor->mutable_executor_info()->CopyFrom(executorInfo);
-        executor->mutable_slave_id()->CopyFrom(slaveId);
-      }
-    }
-  }
-
-  return getExecutors;
-}
-
-
 Future<Response> Master::Http::getState(
     const mesos::master::Call& call,
     const Option<Principal>& principal,
@@ -1459,25 +1381,6 @@ Future<Response> Master::Http::getState(
 }
 
 
-mesos::master::Response::GetState Master::Http::_getState(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  // NOTE: This function must be blocking instead of returning a
-  // `Future`. This is because `subscribe()` needs to atomically
-  // add subscriber to `subscribers` map and send the captured state
-  // in `SUBSCRIBED` without being interleaved by any other events.
-
-  mesos::master::Response::GetState getState;
-
-  *getState.mutable_get_tasks() = _getTasks(approvers);
-  *getState.mutable_get_executors() = _getExecutors(approvers);
-  *getState.mutable_get_frameworks() = _getFrameworks(approvers);
-  *getState.mutable_get_agents() = _getAgents(approvers);
-
-  return getState;
-}
-
-
 class Master::Http::FlagsError : public Error
 {
 public:
@@ -2153,35 +2056,6 @@ Future<Response> Master::Http::getAgents(
 }
 
 
-mesos::master::Response::GetAgents Master::Http::_getAgents(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  mesos::master::Response::GetAgents getAgents;
-  foreachvalue (const Slave* slave, master->slaves.registered) {
-    mesos::master::Response::GetAgents::Agent* agent = getAgents.add_agents();
-    *agent =
-        protobuf::master::event::createAgentResponse(
-            *slave,
-            master->slaves.draining.get(slave->id),
-            master->slaves.deactivated.contains(slave->id),
-            approvers);
-  }
-
-  foreachvalue (const SlaveInfo& slaveInfo, master->slaves.recovered) {
-    SlaveInfo* agent = getAgents.add_recovered_agents();
-    agent->CopyFrom(slaveInfo);
-    agent->clear_resources();
-    foreach (const Resource& resource, slaveInfo.resources()) {
-      if (approvers->approved<VIEW_ROLE>(resource)) {
-        agent->add_resources()->CopyFrom(resource);
-      }
-    }
-  }
-
-  return getAgents;
-}
-
-
 string Master::Http::QUOTA_HELP()
 {
   return HELP(
@@ -3087,81 +2961,6 @@ Future<Response> Master::Http::getTasks(
 }
 
 
-mesos::master::Response::GetTasks Master::Http::_getTasks(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  // Construct framework list with both active and completed frameworks.
-  vector<const Framework*> frameworks;
-  foreachvalue (Framework* framework, master->frameworks.registered) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework);
-  }
-
-  foreachvalue (const Owned<Framework>& framework,
-                master->frameworks.completed) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework.get());
-  }
-
-  mesos::master::Response::GetTasks getTasks;
-
-  vector<const Task*> tasks;
-  foreach (const Framework* framework, frameworks) {
-    // Pending tasks.
-    foreachvalue (const TaskInfo& taskInfo, framework->pendingTasks) {
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(taskInfo, framework->info)) {
-        continue;
-      }
-
-      *getTasks.add_pending_tasks() =
-        protobuf::createTask(taskInfo, TASK_STAGING, framework->id());
-    }
-
-    // Active tasks.
-    foreachvalue (Task* task, framework->tasks) {
-      CHECK_NOTNULL(task);
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task, framework->info)) {
-        continue;
-      }
-
-      getTasks.add_tasks()->CopyFrom(*task);
-    }
-
-    // Unreachable tasks.
-    foreachvalue (const Owned<Task>& task, framework->unreachableTasks) {
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task, framework->info)) {
-        continue;
-      }
-
-      getTasks.add_unreachable_tasks()->CopyFrom(*task);
-    }
-
-    // Completed tasks.
-    foreach (const Owned<Task>& task, framework->completedTasks) {
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task, framework->info)) {
-        continue;
-      }
-
-      getTasks.add_completed_tasks()->CopyFrom(*task);
-    }
-  }
-
-  return getTasks;
-}
-
-
 // /master/maintenance/schedule endpoint help.
 string Master::Http::MAINTENANCE_SCHEDULE_HELP()
 {
diff --git a/src/master/master.hpp b/src/master/master.hpp
index f1aa40f..d774d77 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1742,8 +1742,6 @@ private:
         const mesos::master::Call& call,
         const Option<process::http::authentication::Principal>& principal,
         ContentType contentType) const;
-    mesos::master::Response::GetAgents _getAgents(
-        const process::Owned<ObjectApprovers>& approvers) const;
 
     process::Future<process::http::Response> getFlags(
         const mesos::master::Call& call,
@@ -1839,8 +1837,6 @@ private:
         const mesos::master::Call& call,
         const Option<process::http::authentication::Principal>& principal,
         ContentType contentType) const;
-    mesos::master::Response::GetTasks _getTasks(
-        const process::Owned<ObjectApprovers>& approvers) const;
 
     process::Future<process::http::Response> createVolumes(
         const mesos::master::Call& call,
@@ -1876,22 +1872,16 @@ private:
         const mesos::master::Call& call,
         const Option<process::http::authentication::Principal>& principal,
         ContentType contentType) const;
-    mesos::master::Response::GetFrameworks _getFrameworks(
-        const process::Owned<ObjectApprovers>& approvers) const;
 
     process::Future<process::http::Response> getExecutors(
         const mesos::master::Call& call,
         const Option<process::http::authentication::Principal>& principal,
         ContentType contentType) const;
-    mesos::master::Response::GetExecutors _getExecutors(
-        const process::Owned<ObjectApprovers>& approvers) const;
 
     process::Future<process::http::Response> getState(
         const mesos::master::Call& call,
         const Option<process::http::authentication::Principal>& principal,
         ContentType contentType) const;
-    mesos::master::Response::GetState _getState(
-        const process::Owned<ObjectApprovers>& approvers) const;
 
     static std::function<void(JSON::ObjectWriter*)> jsonifySubscribe(
         const Master* master,
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index d598440..4493abf 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -1765,34 +1765,6 @@ string Http::serializeGetFrameworks(
 }
 
 
-mesos::agent::Response::GetFrameworks Http::_getFrameworks(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  mesos::agent::Response::GetFrameworks getFrameworks;
-  foreachvalue (const Framework* framework, slave->frameworks) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    getFrameworks.add_frameworks()->mutable_framework_info()
-      ->CopyFrom(framework->info);
-  }
-
-  foreachvalue (const Owned<Framework>& framework, slave->completedFrameworks)
{
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    getFrameworks.add_completed_frameworks()->mutable_framework_info()
-      ->CopyFrom(framework->info);
-  }
-
-  return getFrameworks;
-}
-
-
 Future<Response> Http::getExecutors(
     const mesos::agent::Call& call,
     ContentType contentType,
@@ -2031,61 +2003,6 @@ string Http::serializeGetExecutors(
 }
 
 
-mesos::agent::Response::GetExecutors Http::_getExecutors(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  // Construct framework list with both active and completed frameworks.
-  vector<const Framework*> frameworks;
-  foreachvalue (Framework* framework, slave->frameworks) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework);
-  }
-
-  foreachvalue (const Owned<Framework>& framework, slave->completedFrameworks)
{
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework.get());
-  }
-
-  mesos::agent::Response::GetExecutors getExecutors;
-
-  foreach (const Framework* framework, frameworks) {
-    foreachvalue (Executor* executor, framework->executors) {
-      // Skip unauthorized executors.
-      if (!approvers->approved<VIEW_EXECUTOR>(
-              executor->info,
-              framework->info)) {
-        continue;
-      }
-
-      getExecutors.add_executors()->mutable_executor_info()->CopyFrom(
-          executor->info);
-    }
-
-    foreach (const Owned<Executor>& executor, framework->completedExecutors)
{
-      // Skip unauthorized executors.
-      if (!approvers->approved<VIEW_EXECUTOR>(
-              executor->info,
-              framework->info)) {
-        continue;
-      }
-
-      getExecutors.add_completed_executors()->mutable_executor_info()->CopyFrom(
-          executor->info);
-    }
-  }
-
-  return getExecutors;
-}
-
-
 Future<Response> Http::getOperations(
     const mesos::agent::Call& call,
     ContentType acceptType,
@@ -2496,126 +2413,6 @@ string Http::serializeGetTasks(
 }
 
 
-mesos::agent::Response::GetTasks Http::_getTasks(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  // Construct framework list with both active and completed frameworks.
-  vector<const Framework*> frameworks;
-  foreachvalue (Framework* framework, slave->frameworks) {
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework);
-  }
-
-  foreachvalue (const Owned<Framework>& framework, slave->completedFrameworks)
{
-    // Skip unauthorized frameworks.
-    if (!approvers->approved<VIEW_FRAMEWORK>(framework->info)) {
-      continue;
-    }
-
-    frameworks.push_back(framework.get());
-  }
-
-  // Construct executor list with both active and completed executors.
-  hashmap<const Executor*, const Framework*> executors;
-  foreach (const Framework* framework, frameworks) {
-    foreachvalue (Executor* executor, framework->executors) {
-      // Skip unauthorized executors.
-      if (!approvers->approved<VIEW_EXECUTOR>(
-              executor->info, framework->info)) {
-        continue;
-      }
-
-      executors.put(executor, framework);
-    }
-
-    foreach (const Owned<Executor>& executor, framework->completedExecutors)
{
-      // Skip unauthorized executors.
-      if (!approvers->approved<VIEW_EXECUTOR>(
-              executor->info, framework->info)) {
-        continue;
-      }
-
-      executors.put(executor.get(), framework);
-    }
-  }
-
-  mesos::agent::Response::GetTasks getTasks;
-
-  foreach (const Framework* framework, frameworks) {
-    // Pending tasks.
-    typedef hashmap<TaskID, TaskInfo> TaskMap;
-    foreachvalue (const TaskMap& taskInfos, framework->pendingTasks) {
-      foreachvalue (const TaskInfo& taskInfo, taskInfos) {
-        // Skip unauthorized tasks.
-        if (!approvers->approved<VIEW_TASK>(taskInfo, framework->info)) {
-          continue;
-        }
-
-        const Task& task =
-          protobuf::createTask(taskInfo, TASK_STAGING, framework->id());
-
-        getTasks.add_pending_tasks()->CopyFrom(task);
-      }
-    }
-  }
-
-  foreachpair (const Executor* executor,
-               const Framework* framework,
-               executors) {
-    // Queued tasks.
-    foreachvalue (const TaskInfo& taskInfo, executor->queuedTasks) {
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(taskInfo, framework->info)) {
-        continue;
-      }
-
-      const Task& task =
-        protobuf::createTask(taskInfo, TASK_STAGING, framework->id());
-
-      getTasks.add_queued_tasks()->CopyFrom(task);
-    }
-
-    // Launched tasks.
-    foreachvalue (Task* task, executor->launchedTasks) {
-      CHECK_NOTNULL(task);
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task, framework->info)) {
-        continue;
-      }
-
-      getTasks.add_launched_tasks()->CopyFrom(*task);
-    }
-
-    // Terminated tasks.
-    foreachvalue (Task* task, executor->terminatedTasks) {
-      CHECK_NOTNULL(task);
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task, framework->info)) {
-        continue;
-      }
-
-      getTasks.add_terminated_tasks()->CopyFrom(*task);
-    }
-
-    // Completed tasks.
-    foreach (const std::shared_ptr<Task>& task, executor->completedTasks) {
-      // Skip unauthorized tasks.
-      if (!approvers->approved<VIEW_TASK>(*task.get(), framework->info)) {
-        continue;
-      }
-
-      getTasks.add_completed_tasks()->CopyFrom(*task);
-    }
-  }
-
-  return getTasks;
-}
-
-
 Future<Response> Http::getAgent(
     const mesos::agent::Call& call,
     ContentType acceptType,
@@ -2839,19 +2636,6 @@ string Http::serializeGetState(
 }
 
 
-mesos::agent::Response::GetState Http::_getState(
-    const Owned<ObjectApprovers>& approvers) const
-{
-  mesos::agent::Response::GetState getState;
-
-  *getState.mutable_get_tasks() = _getTasks(approvers);
-  *getState.mutable_get_executors() = _getExecutors(approvers);
-  *getState.mutable_get_frameworks() = _getFrameworks(approvers);
-
-  return getState;
-}
-
-
 string Http::STATISTICS_HELP()
 {
   return HELP(
diff --git a/src/slave/http.hpp b/src/slave/http.hpp
index bc1b62e..71fc6f7 100644
--- a/src/slave/http.hpp
+++ b/src/slave/http.hpp
@@ -187,8 +187,6 @@ private:
       const process::Owned<ObjectApprovers>& approvers) const;
   std::string serializeGetFrameworks(
       const process::Owned<ObjectApprovers>& approvers) const;
-  mesos::agent::Response::GetFrameworks _getFrameworks(
-      const process::Owned<ObjectApprovers>& approvers ) const;
 
   process::Future<process::http::Response> getExecutors(
       const mesos::agent::Call& call,
@@ -199,8 +197,6 @@ private:
       const process::Owned<ObjectApprovers>& approvers) const;
   std::string serializeGetExecutors(
       const process::Owned<ObjectApprovers>& approvers) const;
-  mesos::agent::Response::GetExecutors _getExecutors(
-      const process::Owned<ObjectApprovers>& approvers) const;
 
   process::Future<process::http::Response> getOperations(
       const mesos::agent::Call& call,
@@ -216,8 +212,6 @@ private:
       const process::Owned<ObjectApprovers>& approvers) const;
   std::string serializeGetTasks(
       const process::Owned<ObjectApprovers>& approvers) const;
-  mesos::agent::Response::GetTasks _getTasks(
-      const process::Owned<ObjectApprovers>& approvers) const;
 
   process::Future<process::http::Response> getAgent(
       const mesos::agent::Call& call,
@@ -238,8 +232,6 @@ private:
       const process::Owned<ObjectApprovers>& approvers) const;
   std::string serializeGetState(
       const process::Owned<ObjectApprovers>& approvers) const;
-  mesos::agent::Response::GetState _getState(
-      const process::Owned<ObjectApprovers>& approvers) const;
 
   process::Future<process::http::Response> launchNestedContainer(
       const mesos::agent::Call& call,


Mime
View raw message