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  friend std::ostream& operator<<(std::ostream& stream, const Type& type) {
49  switch (type) {
50  case Type::UPDATE_STATE:
51  return stream << "UPDATE_STATE";
53  return stream << "UPDATE_OPERATION_STATUS";
54  case Type::DISCONNECT:
55  return stream << "DISCONNECT";
56  }
57 
58  UNREACHABLE();
59  }
60 
61  struct UpdateState
62  {
63  ResourceProviderInfo info;
67  };
68 
70  {
71  UpdateOperationStatusMessage update;
72  };
73 
74  struct Disconnect
75  {
76  ResourceProviderID resourceProviderId;
77  };
78 
80 
84 };
85 
86 
87 inline std::ostream& operator<<(
88  std::ostream& stream,
89  const ResourceProviderMessage& resourceProviderMessage)
90 {
91  stream << stringify(resourceProviderMessage.type) << ": ";
92 
93  switch (resourceProviderMessage.type) {
96  updateState = resourceProviderMessage.updateState;
97 
98  CHECK_SOME(updateState);
99 
100  return stream
101  << updateState->info.id() << " "
102  << updateState->totalResources;
103  }
104 
108  resourceProviderMessage.updateOperationStatus;
109 
110  CHECK_SOME(updateOperationStatus);
111 
112  return stream
113  << "(uuid: "
114  << updateOperationStatus->update.operation_uuid()
115  << ") for framework "
116  << updateOperationStatus->update.framework_id()
117  << " (latest state: "
118  << updateOperationStatus->update.latest_status().state()
119  << ", status update state: "
120  << updateOperationStatus->update.status().state() << ")";
121  }
122 
125  resourceProviderMessage.disconnect;
126 
127  CHECK_SOME(disconnect);
128 
129  return stream
130  << "resource provider "
131  << disconnect->resourceProviderId;
132  }
133  }
134 
135  UNREACHABLE();
136 }
137 
138 } // namespace internal {
139 } // namespace mesos {
140 
141 #endif // __RESOURCE_PROVIDER_MESSAGE_HPP__
Option< UpdateState > updateState
Definition: message.hpp:81
Definition: option.hpp:28
ResourceProviderInfo info
Definition: message.hpp:63
Definition: resources.hpp:79
friend std::ostream & operator<<(std::ostream &stream, const Type &type)
Definition: message.hpp:48
ResourceProviderID resourceProviderId
Definition: message.hpp:76
hashmap< UUID, Operation > operations
Definition: message.hpp:66
#define CHECK_SOME(expression)
Definition: check.hpp:50
Type type
Definition: message.hpp:79
Option< Disconnect > disconnect
Definition: message.hpp:83
Definition: spec.hpp:30
Option< UpdateOperationStatus > updateOperationStatus
Definition: message.hpp:82
#define UNREACHABLE()
Definition: unreachable.hpp:22
Definition: attributes.hpp:24
UpdateOperationStatusMessage update
Definition: message.hpp:71
std::string stringify(int flags)
Resources totalResources
Definition: message.hpp:65