Repository: mesos
Updated Branches:
  refs/heads/master 1bb89eaa5 -> 0cde970af


Moved code to group old/v1 operator API implementations together.

This change moves the create/destroy volumes, reserve/unreserve
for the v1 API to be closer to the corresponding implementations
for the old API.

Review: https://reviews.apache.org/r/49337/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0cde970a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0cde970a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0cde970a

Branch: refs/heads/master
Commit: 0cde970aff8da9c2bf0aa594a390cac4be90f715
Parents: bb4f294
Author: Anand Mazumdar <an...@apache.org>
Authored: Wed Jun 29 09:21:38 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Wed Jun 29 09:21:53 2016 -0700

----------------------------------------------------------------------
 src/master/http.cpp | 224 +++++++++++++++++++++++------------------------
 1 file changed, 112 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0cde970a/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 5d763d6..e5acdb8 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -879,42 +879,6 @@ string Master::Http::CREATE_VOLUMES_HELP()
 }
 
 
-Future<Response> Master::Http::_createVolumes(
-    const SlaveID& slaveId,
-    const RepeatedPtrField<Resource>& volumes,
-    const Option<string>& principal) const
-{
-  Slave* slave = master->slaves.registered.get(slaveId);
-  if (slave == nullptr) {
-    return BadRequest("No agent found with specified ID");
-  }
-
-  // Create an offer operation.
-  Offer::Operation operation;
-  operation.set_type(Offer::Operation::CREATE);
-  operation.mutable_create()->mutable_volumes()->CopyFrom(volumes);
-
-  Option<Error> validate = validation::operation::validate(
-      operation.create(), slave->checkpointedResources, principal);
-
-  if (validate.isSome()) {
-    return BadRequest("Invalid CREATE operation: " + validate.get().message);
-  }
-
-  return master->authorizeCreateVolume(operation.create(), principal)
-    .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
-      if (!authorized) {
-        return Forbidden();
-      }
-
-      // The resources required for this operation are equivalent to the
-      // volumes specified by the user minus any DiskInfo (DiskInfo will
-      // be created when this operation is applied).
-      return _operation(slaveId, removeDiskInfos(volumes), operation);
-    }));
-}
-
-
 Future<Response> Master::Http::createVolumes(
     const Request& request,
     const Option<string>& principal) const
@@ -983,6 +947,42 @@ Future<Response> Master::Http::createVolumes(
 }
 
 
+Future<Response> Master::Http::_createVolumes(
+    const SlaveID& slaveId,
+    const RepeatedPtrField<Resource>& volumes,
+    const Option<string>& principal) const
+{
+  Slave* slave = master->slaves.registered.get(slaveId);
+  if (slave == nullptr) {
+    return BadRequest("No agent found with specified ID");
+  }
+
+  // Create an offer operation.
+  Offer::Operation operation;
+  operation.set_type(Offer::Operation::CREATE);
+  operation.mutable_create()->mutable_volumes()->CopyFrom(volumes);
+
+  Option<Error> validate = validation::operation::validate(
+      operation.create(), slave->checkpointedResources, principal);
+
+  if (validate.isSome()) {
+    return BadRequest("Invalid CREATE operation: " + validate.get().message);
+  }
+
+  return master->authorizeCreateVolume(operation.create(), principal)
+    .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
+      if (!authorized) {
+        return Forbidden();
+      }
+
+      // The resources required for this operation are equivalent to the
+      // volumes specified by the user minus any DiskInfo (DiskInfo will
+      // be created when this operation is applied).
+      return _operation(slaveId, removeDiskInfos(volumes), operation);
+    }));
+}
+
+
 Future<Response> Master::Http::createVolumes(
     const mesos::master::Call& call,
     const Option<string>& principal,
@@ -1021,54 +1021,6 @@ string Master::Http::DESTROY_VOLUMES_HELP()
 }
 
 
-Future<Response> Master::Http::_destroyVolumes(
-    const SlaveID& slaveId,
-    const RepeatedPtrField<Resource>& volumes,
-    const Option<string>& principal) const
-{
-  Slave* slave = master->slaves.registered.get(slaveId);
-  if (slave == nullptr) {
-    return BadRequest("No agent found with specified ID");
-  }
-
-  // Create an offer operation.
-  Offer::Operation operation;
-  operation.set_type(Offer::Operation::DESTROY);
-  operation.mutable_destroy()->mutable_volumes()->CopyFrom(volumes);
-
-  Option<Error> validate = validation::operation::validate(
-      operation.destroy(), slave->checkpointedResources);
-
-  if (validate.isSome()) {
-    return BadRequest("Invalid DESTROY operation: " + validate.get().message);
-  }
-
-  return master->authorizeDestroyVolume(operation.destroy(), principal)
-    .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
-      if (!authorized) {
-        return Forbidden();
-      }
-
-      return _operation(slaveId, volumes, operation);
-    }));
-}
-
-
-Future<Response> Master::Http::destroyVolumes(
-    const mesos::master::Call& call,
-    const Option<string>& principal,
-    ContentType /*contentType*/) const
-{
-  CHECK_EQ(mesos::master::Call::DESTROY_VOLUMES, call.type());
-  CHECK(call.has_destroy_volumes());
-
-  const SlaveID& slaveId = call.destroy_volumes().slave_id();
-  const RepeatedPtrField<Resource>& volumes = call.destroy_volumes().volumes();
-
-  return _destroyVolumes(slaveId, volumes, principal);
-}
-
-
 Future<Response> Master::Http::destroyVolumes(
     const Request& request,
     const Option<string>& principal) const
@@ -1137,6 +1089,54 @@ Future<Response> Master::Http::destroyVolumes(
 }
 
 
+Future<Response> Master::Http::_destroyVolumes(
+    const SlaveID& slaveId,
+    const RepeatedPtrField<Resource>& volumes,
+    const Option<string>& principal) const
+{
+  Slave* slave = master->slaves.registered.get(slaveId);
+  if (slave == nullptr) {
+    return BadRequest("No agent found with specified ID");
+  }
+
+  // Create an offer operation.
+  Offer::Operation operation;
+  operation.set_type(Offer::Operation::DESTROY);
+  operation.mutable_destroy()->mutable_volumes()->CopyFrom(volumes);
+
+  Option<Error> validate = validation::operation::validate(
+      operation.destroy(), slave->checkpointedResources);
+
+  if (validate.isSome()) {
+    return BadRequest("Invalid DESTROY operation: " + validate.get().message);
+  }
+
+  return master->authorizeDestroyVolume(operation.destroy(), principal)
+    .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
+      if (!authorized) {
+        return Forbidden();
+      }
+
+      return _operation(slaveId, volumes, operation);
+    }));
+}
+
+
+Future<Response> Master::Http::destroyVolumes(
+    const mesos::master::Call& call,
+    const Option<string>& principal,
+    ContentType /*contentType*/) const
+{
+  CHECK_EQ(mesos::master::Call::DESTROY_VOLUMES, call.type());
+  CHECK(call.has_destroy_volumes());
+
+  const SlaveID& slaveId = call.destroy_volumes().slave_id();
+  const RepeatedPtrField<Resource>& volumes = call.destroy_volumes().volumes();
+
+  return _destroyVolumes(slaveId, volumes, principal);
+}
+
+
 string Master::Http::FRAMEWORKS_HELP()
 {
   return HELP(
@@ -1627,34 +1627,6 @@ Future<Response> Master::Http::getLeadingMaster(
 }
 
 
-Future<Response> Master::Http::reserveResources(
-    const mesos::master::Call& call,
-    const Option<string>& principal,
-    ContentType contentType) const
-{
-  CHECK_EQ(mesos::master::Call::RESERVE_RESOURCES, call.type());
-
-  const SlaveID& slaveId = call.reserve_resources().slave_id();
-  const Resources& resources = call.reserve_resources().resources();
-
-  return _reserve(slaveId, resources, principal);
-}
-
-
-Future<Response> Master::Http::unreserveResources(
-    const mesos::master::Call& call,
-    const Option<string>& principal,
-    ContentType contentType) const
-{
-  CHECK_EQ(mesos::master::Call::UNRESERVE_RESOURCES, call.type());
-
-  const SlaveID& slaveId = call.unreserve_resources().slave_id();
-  const Resources& resources = call.unreserve_resources().resources();
-
-  return _unreserve(slaveId, resources, principal);
-}
-
-
 string Master::Http::REDIRECT_HELP()
 {
   return HELP(
@@ -1847,6 +1819,20 @@ Future<Response> Master::Http::_reserve(
 }
 
 
+Future<Response> Master::Http::reserveResources(
+    const mesos::master::Call& call,
+    const Option<string>& principal,
+    ContentType contentType) const
+{
+  CHECK_EQ(mesos::master::Call::RESERVE_RESOURCES, call.type());
+
+  const SlaveID& slaveId = call.reserve_resources().slave_id();
+  const Resources& resources = call.reserve_resources().resources();
+
+  return _reserve(slaveId, resources, principal);
+}
+
+
 string Master::Http::SLAVES_HELP()
 {
   return HELP(
@@ -3948,6 +3934,20 @@ Future<Response> Master::Http::_operation(
     });
 }
 
+
+Future<Response> Master::Http::unreserveResources(
+    const mesos::master::Call& call,
+    const Option<string>& principal,
+    ContentType contentType) const
+{
+  CHECK_EQ(mesos::master::Call::UNRESERVE_RESOURCES, call.type());
+
+  const SlaveID& slaveId = call.unreserve_resources().slave_id();
+  const Resources& resources = call.unreserve_resources().resources();
+
+  return _unreserve(slaveId, resources, principal);
+}
+
 } // namespace master {
 } // namespace internal {
 } // namespace mesos {

Reply via email to