Apache Mesos
message.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __RESOURCE_PROVIDER_MESSAGE_HPP__
18 #define __RESOURCE_PROVIDER_MESSAGE_HPP__
19 
20 #include <ostream>
21 #include <vector>
22 
23 #include <mesos/mesos.hpp>
24 #include <mesos/resources.hpp>
25 
26 #include <stout/check.hpp>
27 #include <stout/hashmap.hpp>
28 #include <stout/jsonify.hpp>
29 #include <stout/option.hpp>
30 #include <stout/protobuf.hpp>
31 #include <stout/unreachable.hpp>
32 #include <stout/uuid.hpp>
33 
34 #include "messages/messages.hpp"
35 
36 namespace mesos {
37 namespace internal {
38 
40 {
41  enum class Type
42  {
46  };
47 
48  struct UpdateState
49  {
50  ResourceProviderInfo info;
54  };
55 
57  {
58  UpdateOperationStatusMessage update;
59  };
60 
61  struct Disconnect
62  {
63  ResourceProviderID resourceProviderId;
64  };
65 
67 
71 };
72 
73 
74 inline std::ostream& operator<<(
75  std::ostream& stream,
76  const ResourceProviderMessage& resourceProviderMessage)
77 {
78  switch (resourceProviderMessage.type) {
81  updateState = resourceProviderMessage.updateState;
82 
83  CHECK_SOME(updateState);
84 
85  return stream
86  << "UPDATE_STATE: "
87  << updateState->info.id() << " "
88  << updateState->totalResources;
89  }
90 
93  updateOperationStatus =
94  resourceProviderMessage.updateOperationStatus;
95 
96  CHECK_SOME(updateOperationStatus);
97 
98  return stream
99  << "UPDATE_OPERATION_STATUS: (uuid: "
100  << updateOperationStatus->update.operation_uuid()
101  << ") for framework "
102  << updateOperationStatus->update.framework_id()
103  << " (latest state: "
104  << updateOperationStatus->update.latest_status().state()
105  << ", status update state: "
106  << updateOperationStatus->update.status().state() << ")";
107  }
108 
111  resourceProviderMessage.disconnect;
112 
113  CHECK_SOME(disconnect);
114 
115  return stream
116  << "DISCONNECT: resource provider "
117  << disconnect->resourceProviderId;
118  }
119  }
120 
121  UNREACHABLE();
122 }
123 
124 } // namespace internal {
125 } // namespace mesos {
126 
127 #endif // __RESOURCE_PROVIDER_MESSAGE_HPP__
Option< UpdateState > updateState
Definition: message.hpp:68
Definition: option.hpp:28
ResourceProviderInfo info
Definition: message.hpp:50
id::UUID resourceVersion
Definition: message.hpp:51
std::ostream & operator<<(std::ostream &stream, const ImageGcConfig &imageGcConfig)
Definition: flags.hpp:92
Definition: resources.hpp:79
ResourceProviderID resourceProviderId
Definition: message.hpp:63
#define CHECK_SOME(expression)
Definition: check.hpp:44
Type type
Definition: message.hpp:66
Definition: uuid.hpp:35
Option< Disconnect > disconnect
Definition: message.hpp:70
Option< UpdateOperationStatus > updateOperationStatus
Definition: message.hpp:69
#define UNREACHABLE()
Definition: unreachable.hpp:22
hashmap< id::UUID, Operation > operations
Definition: message.hpp:53
UpdateOperationStatusMessage update
Definition: message.hpp:58
Resources totalResources
Definition: message.hpp:52