You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2017/12/08 08:04:24 UTC

[3/3] mesos git commit: Changed the resource provider OPERATION event to APPLY_OFFER_OPERATION.

Changed the resource provider OPERATION event to APPLY_OFFER_OPERATION.

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


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

Branch: refs/heads/master
Commit: c78496fd5c2f48f2989449e3edc032af18524802
Parents: fb47d1c
Author: Greg Mann <gr...@gmail.com>
Authored: Thu Dec 7 22:45:24 2017 -0800
Committer: Greg Mann <gr...@gmail.com>
Committed: Thu Dec 7 23:18:12 2017 -0800

----------------------------------------------------------------------
 .../resource_provider/resource_provider.proto   |  6 ++---
 .../resource_provider/resource_provider.proto   |  6 ++---
 src/messages/messages.proto                     |  2 +-
 src/resource_provider/manager.cpp               | 12 +++++----
 src/resource_provider/state.proto               |  2 +-
 src/resource_provider/storage/provider.cpp      | 28 +++++++++++---------
 src/tests/mesos.hpp                             | 14 +++++-----
 src/tests/slave_tests.cpp                       |  4 +--
 8 files changed, 41 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/include/mesos/resource_provider/resource_provider.proto
----------------------------------------------------------------------
diff --git a/include/mesos/resource_provider/resource_provider.proto b/include/mesos/resource_provider/resource_provider.proto
index 2619cd0..360d862 100644
--- a/include/mesos/resource_provider/resource_provider.proto
+++ b/include/mesos/resource_provider/resource_provider.proto
@@ -33,7 +33,7 @@ message Event {
     UNKNOWN = 0;
 
     SUBSCRIBED = 1;                  // See 'Subscribed' below.
-    OPERATION = 2;                   // See 'Operation' below.
+    APPLY_OFFER_OPERATION = 2;       // See 'ApplyOfferOperation' below.
     PUBLISH_RESOURCES = 3;           // See 'PublishResources' below.
     ACKNOWLEDGE_OFFER_OPERATION = 4; // See 'AcknowledgeOfferOperation' below.
     RECONCILE_OFFER_OPERATIONS = 5;  // See 'ReconcileOfferOperations' below.
@@ -47,7 +47,7 @@ message Event {
 
   // Received when the master wants to send an operation to the
   // resource provider.
-  message Operation {
+  message ApplyOfferOperation {
     required FrameworkID framework_id = 1;
     required Offer.Operation info = 2;
 
@@ -98,7 +98,7 @@ message Event {
 
   optional Type type = 1;
   optional Subscribed subscribed = 2;
-  optional Operation operation = 3;
+  optional ApplyOfferOperation apply_offer_operation = 3;
   optional PublishResources publish_resources = 4;
   optional AcknowledgeOfferOperation acknowledge_offer_operation = 5;
   optional ReconcileOfferOperations reconcile_offer_operations = 6;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/include/mesos/v1/resource_provider/resource_provider.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/resource_provider/resource_provider.proto b/include/mesos/v1/resource_provider/resource_provider.proto
index 135729b..3e799f3 100644
--- a/include/mesos/v1/resource_provider/resource_provider.proto
+++ b/include/mesos/v1/resource_provider/resource_provider.proto
@@ -33,7 +33,7 @@ message Event {
     UNKNOWN = 0;
 
     SUBSCRIBED = 1;                  // See 'Subscribed' below.
-    OPERATION = 2;                   // See 'Operation' below.
+    APPLY_OFFER_OPERATION = 2;       // See 'ApplyOfferOperation' below.
     PUBLISH_RESOURCES = 3;           // See 'PublishResources' below.
     ACKNOWLEDGE_OFFER_OPERATION = 4; // See 'AcknowledgeOfferOperation' below.
     RECONCILE_OFFER_OPERATIONS = 5;  // See 'ReconcileOfferOperations' below.
@@ -47,7 +47,7 @@ message Event {
 
   // Received when the master wants to send an operation to the
   // resource provider.
-  message Operation {
+  message ApplyOfferOperation {
     required FrameworkID framework_id = 1;
     required Offer.Operation info = 2;
 
@@ -98,7 +98,7 @@ message Event {
 
   optional Type type = 1;
   optional Subscribed subscribed = 2;
-  optional Operation operation = 3;
+  optional ApplyOfferOperation apply_offer_operation = 3;
   optional PublishResources publish_resources = 4;
   optional AcknowledgeOfferOperation acknowledge_offer_operation = 5;
   optional ReconcileOfferOperations reconcile_offer_operations = 6;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 1a70967..44b45d5 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -779,7 +779,7 @@ message OfferOperationStatusUpdateRecord {
  * the master for external resource providers) to apply an offer
  * operation.
  *
- * See resource_provider::Event::OPERATION.
+ * See resource_provider::Event::APPLY_OFFER_OPERATION.
  */
 message ApplyOfferOperationMessage {
   optional FrameworkID framework_id = 1;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/resource_provider/manager.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/manager.cpp b/src/resource_provider/manager.cpp
index 9c0d19c..879caba 100644
--- a/src/resource_provider/manager.cpp
+++ b/src/resource_provider/manager.cpp
@@ -389,11 +389,13 @@ void ResourceProviderManagerProcess::applyOfferOperation(
     << resourceProviderId.get();
 
   Event event;
-  event.set_type(Event::OPERATION);
-  event.mutable_operation()->mutable_framework_id()->CopyFrom(frameworkId);
-  event.mutable_operation()->mutable_info()->CopyFrom(operation);
-  event.mutable_operation()->set_operation_uuid(message.operation_uuid());
-  event.mutable_operation()->set_resource_version_uuid(
+  event.set_type(Event::APPLY_OFFER_OPERATION);
+  event.mutable_apply_offer_operation()
+    ->mutable_framework_id()->CopyFrom(frameworkId);
+  event.mutable_apply_offer_operation()->mutable_info()->CopyFrom(operation);
+  event.mutable_apply_offer_operation()
+    ->set_operation_uuid(message.operation_uuid());
+  event.mutable_apply_offer_operation()->set_resource_version_uuid(
       message.resource_version_uuid().uuid());
 
   if (!resourceProvider->http.send(event)) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/resource_provider/state.proto
----------------------------------------------------------------------
diff --git a/src/resource_provider/state.proto b/src/resource_provider/state.proto
index ae30d16..321201e 100644
--- a/src/resource_provider/state.proto
+++ b/src/resource_provider/state.proto
@@ -30,7 +30,7 @@ message ResourceProviderState {
   // This includes only pending operations. Operations that have
   // unacknowledged statuses should be recovered through the status
   // update manager.
-  repeated Event.Operation operations = 1;
+  repeated Event.ApplyOfferOperation operations = 1;
 
   // The total resources provided by this resource provider.
   repeated Resource resources = 2;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index b6db618..2193866 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -329,7 +329,7 @@ private:
 
   // Functions for received events.
   void subscribed(const Event::Subscribed& subscribed);
-  void operation(const Event::Operation& operation);
+  void applyOfferOperation(const Event::ApplyOfferOperation& operation);
   void publishResources(const Event::PublishResources& publish);
   void acknowledgeOfferOperation(
       const Event::AcknowledgeOfferOperation& acknowledge);
@@ -411,7 +411,7 @@ private:
   // NOTE: We store the list of pending operations in a `LinkedHashMap`
   // to preserve the order we receive the operations. This is useful
   // when we replay depending operations during recovery.
-  LinkedHashMap<UUID, Event::Operation> pendingOperations;
+  LinkedHashMap<UUID, Event::ApplyOfferOperation> pendingOperations;
   Resources totalResources;
   Option<UUID> resourceVersion;
   hashmap<string, VolumeData> volumes;
@@ -448,9 +448,9 @@ void StorageLocalResourceProviderProcess::received(const Event& event)
       subscribed(event.subscribed());
       break;
     }
-    case Event::OPERATION: {
-      CHECK(event.has_operation());
-      operation(event.operation());
+    case Event::APPLY_OFFER_OPERATION: {
+      CHECK(event.has_apply_offer_operation());
+      applyOfferOperation(event.apply_offer_operation());
       break;
     }
     case Event::PUBLISH_RESOURCES: {
@@ -587,7 +587,7 @@ Future<Nothing> StorageLocalResourceProviderProcess::recover()
         }
 
         if (resourceProviderState.isSome()) {
-          foreach (const Event::Operation& operation,
+          foreach (const Event::ApplyOfferOperation& operation,
                    resourceProviderState->operations()) {
             Try<UUID> uuid = UUID::fromBytes(operation.operation_uuid());
             CHECK_SOME(uuid);
@@ -965,8 +965,8 @@ void StorageLocalResourceProviderProcess::subscribed(
 }
 
 
-void StorageLocalResourceProviderProcess::operation(
-    const Event::Operation& operation)
+void StorageLocalResourceProviderProcess::applyOfferOperation(
+    const Event::ApplyOfferOperation& operation)
 {
   Future<Resources> converted;
 
@@ -2026,7 +2026,8 @@ Future<Nothing> StorageLocalResourceProviderProcess::applyOfferOperation(
   Option<Error> error;
 
   CHECK(pendingOperations.contains(operationUuid));
-  const Event::Operation& operation = pendingOperations.at(operationUuid);
+  const Event::ApplyOfferOperation& operation =
+    pendingOperations.at(operationUuid);
 
   Try<UUID> operationVersion =
     UUID::fromBytes(operation.resource_version_uuid());
@@ -2295,7 +2296,8 @@ Try<Nothing> StorageLocalResourceProviderProcess::applyResourceConversions(
   Option<Error> error;
 
   CHECK(pendingOperations.contains(operationUuid));
-  const Event::Operation& operation = pendingOperations.at(operationUuid);
+  const Event::ApplyOfferOperation& operation =
+    pendingOperations.at(operationUuid);
 
   if (conversions.isSome()) {
     // Strip away the allocation info when applying the convertion to
@@ -2388,7 +2390,9 @@ void StorageLocalResourceProviderProcess::checkpointResourceProviderState()
 {
   ResourceProviderState state;
 
-  foreachvalue (const Event::Operation& operation, pendingOperations) {
+  foreachvalue (
+      const Event::ApplyOfferOperation& operation,
+      pendingOperations) {
     state.add_operations()->CopyFrom(operation);
   }
 
@@ -2414,7 +2418,7 @@ void StorageLocalResourceProviderProcess::sendResourceProviderStateUpdate()
   Call::UpdateState* update = call.mutable_update_state();
 
   foreachpair (const UUID& uuid,
-               const Event::Operation& operation,
+               const Event::ApplyOfferOperation& operation,
                pendingOperations) {
     // TODO(chhsiao): Maintain a list of terminated but unacknowledged
     // offer operations in memory and reconstruc that during recovery

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index be976c4..9506889 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -2834,7 +2834,7 @@ public:
               Source>::subscribedDefault));
     EXPECT_CALL(*this, subscribed(_)).WillRepeatedly(DoDefault());
 
-    ON_CALL(*this, operation(_))
+    ON_CALL(*this, applyOfferOperation(_))
       .WillByDefault(Invoke(
           this,
           &MockResourceProvider<
@@ -2848,7 +2848,7 @@ public:
               OfferOperationState,
               Operation,
               Source>::operationDefault));
-    EXPECT_CALL(*this, operation(_)).WillRepeatedly(DoDefault());
+    EXPECT_CALL(*this, applyOfferOperation(_)).WillRepeatedly(DoDefault());
 
     ON_CALL(*this, publishResources(_))
       .WillByDefault(Invoke(
@@ -2870,7 +2870,9 @@ public:
   MOCK_METHOD0_T(connected, void());
   MOCK_METHOD0_T(disconnected, void());
   MOCK_METHOD1_T(subscribed, void(const typename Event::Subscribed&));
-  MOCK_METHOD1_T(operation, void(const typename Event::Operation&));
+  MOCK_METHOD1_T(
+      applyOfferOperation,
+      void(const typename Event::ApplyOfferOperation&));
   MOCK_METHOD1_T(
       publishResources,
       void(const typename Event::PublishResources&));
@@ -2891,8 +2893,8 @@ public:
         case Event::SUBSCRIBED:
           subscribed(event.subscribed());
           break;
-        case Event::OPERATION:
-          operation(event.operation());
+        case Event::APPLY_OFFER_OPERATION:
+          applyOfferOperation(event.apply_offer_operation());
           break;
         case Event::PUBLISH_RESOURCES:
           publishResources(event.publish_resources());
@@ -3000,7 +3002,7 @@ public:
     }
   }
 
-  void operationDefault(const typename Event::Operation& operation)
+  void operationDefault(const typename Event::ApplyOfferOperation& operation)
   {
     CHECK(info.has_id());
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c78496fd/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 8739f0b..ee490a0 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -9214,8 +9214,8 @@ TEST_F(SlaveTest, ResourceProviderReconciliation)
 
   // We now perform a `RESERVE` operation on the offered resources,
   // but let the operation fail in the resource provider.
-  Future<v1::resource_provider::Event::Operation> operation;
-  EXPECT_CALL(resourceProvider, operation(_))
+  Future<v1::resource_provider::Event::ApplyOfferOperation> operation;
+  EXPECT_CALL(resourceProvider, applyOfferOperation(_))
     .WillOnce(FutureArg<0>(&operation));
 
   {