Apache Mesos
evolve.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 __INTERNAL_EVOLVE_HPP__
18 #define __INTERNAL_EVOLVE_HPP__
19 
20 #include <google/protobuf/message.h>
21 
22 #include <mesos/agent/agent.hpp>
23 
24 #include <mesos/mesos.hpp>
25 #include <mesos/resources.hpp>
26 
27 #include <mesos/master/master.hpp>
28 
30 
31 #include <mesos/master/master.hpp>
32 
34 
36 
38 
39 #include <mesos/v1/mesos.hpp>
40 #include <mesos/v1/resources.hpp>
41 
42 #include <mesos/v1/agent/agent.hpp>
43 
45 
47 
49 
51 
53 
54 #include <stout/foreach.hpp>
55 #include <stout/json.hpp>
56 
57 #include "messages/messages.hpp"
58 
59 namespace mesos {
60 namespace internal {
61 
62 // Helpers for evolving types between versions. Please add as necessary!
63 v1::AgentID evolve(const SlaveID& slaveId);
64 v1::AgentInfo evolve(const SlaveInfo& slaveInfo);
65 v1::ContainerInfo evolve(const ContainerInfo& containerInfo);
66 v1::DomainInfo evolve(const DomainInfo& domainInfo);
67 v1::DrainInfo evolve(const DrainInfo& drainInfo);
68 v1::ExecutorID evolve(const ExecutorID& executorId);
69 v1::ExecutorInfo evolve(const ExecutorInfo& executorInfo);
70 v1::FileInfo evolve(const FileInfo& fileInfo);
71 v1::FrameworkID evolve(const FrameworkID& frameworkId);
72 v1::FrameworkInfo evolve(const FrameworkInfo& frameworkInfo);
73 v1::InverseOffer evolve(const InverseOffer& inverseOffer);
74 v1::KillPolicy evolve(const KillPolicy& killPolicy);
75 v1::MachineID evolve(const MachineID& machineId);
76 v1::MasterInfo evolve(const MasterInfo& masterInfo);
77 v1::Offer evolve(const Offer& offer);
78 v1::OfferID evolve(const OfferID& offerId);
79 v1::OperationStatus evolve(const OperationStatus& status);
80 v1::Resource evolve(const Resource& resource);
81 v1::ResourceProviderID evolve(const ResourceProviderID& resourceProviderId);
82 v1::Resources evolve(const Resources& resources);
83 v1::Task evolve(const Task& task);
84 v1::TaskID evolve(const TaskID& taskId);
85 v1::TaskInfo evolve(const TaskInfo& taskInfo);
86 v1::TaskStatus evolve(const TaskStatus& status);
87 v1::UUID evolve(const UUID& uuid);
88 
89 
91 v1::agent::ProcessIO evolve(const agent::ProcessIO& processIO);
93 
94 
95 v1::maintenance::ClusterStatus evolve(
96  const maintenance::ClusterStatus& cluster);
97 v1::maintenance::Schedule evolve(const maintenance::Schedule& schedule);
98 
99 
102 
103 
104 // Helper for repeated field evolving to 'T1' from 'T2'.
105 template <typename T1, typename T2>
106 google::protobuf::RepeatedPtrField<T1> evolve(
107  const google::protobuf::RepeatedPtrField<T2>& t2s)
108 {
109  google::protobuf::RepeatedPtrField<T1> t1s;
110  t1s.Reserve(t2s.size());
111 
112  foreach (const T2& t2, t2s) {
113  *t1s.Add() = evolve(t2);
114  }
115 
116  return t1s;
117 }
118 
119 
123 
124 
125 // Helper functions that evolve old style internal messages to a
126 // v1::scheduler::Event.
127 v1::scheduler::Event evolve(const ExitedExecutorMessage& message);
128 v1::scheduler::Event evolve(const ExecutorToFrameworkMessage& message);
129 v1::scheduler::Event evolve(const FrameworkErrorMessage& message);
130 v1::scheduler::Event evolve(const FrameworkRegisteredMessage& message);
131 v1::scheduler::Event evolve(const FrameworkReregisteredMessage& message);
132 v1::scheduler::Event evolve(const InverseOffersMessage& message);
133 v1::scheduler::Event evolve(const LostSlaveMessage& message);
134 v1::scheduler::Event evolve(const ResourceOffersMessage& message);
135 v1::scheduler::Event evolve(const RescindInverseOfferMessage& message);
136 v1::scheduler::Event evolve(const RescindResourceOfferMessage& message);
137 v1::scheduler::Event evolve(const StatusUpdateMessage& message);
138 v1::scheduler::Event evolve(const UpdateOperationStatusMessage& message);
139 
140 
143 
144 
145 // Helper functions that evolve old style internal messages to a
146 // v1::Executor::Event.
147 v1::executor::Event evolve(const ExecutorRegisteredMessage& message);
148 v1::executor::Event evolve(const FrameworkToExecutorMessage& message);
149 v1::executor::Event evolve(const KillTaskMessage& message);
150 v1::executor::Event evolve(const RunTaskMessage& message);
151 v1::executor::Event evolve(const ShutdownExecutorMessage& message);
152 v1::executor::Event evolve(const StatusUpdateAcknowledgementMessage& message);
153 
154 
157 
158 
159 // Before the v1 API we had REST endpoints that returned JSON. The JSON was not
160 // specified in any formal way, i.e., there were no protobufs which captured the
161 // structure. As part of the v1 API we introduced the Call/Response protobufs
162 // (see v1/master.proto and v1/agent.proto). This evolve variant transforms a
163 // JSON object that would have been returned from a particular REST endpoint to
164 // a `Response` protobuf suitable for returning from the new v1 API endpoints.
165 
166 // Declaration of helper functions for evolving JSON objects used in master's
167 // REST endpoints pre v1 API.
168 template <v1::master::Response::Type T>
170 
171 
172 // Declaration of helper functions for evolving JSON objects used in agent's
173 // REST endpoints pre v1 API.
174 template <v1::agent::Response::Type T>
176 
177 
178 template <v1::agent::Response::Type T>
180 
181 } // namespace internal {
182 } // namespace mesos {
183 
184 #endif // __INTERNAL_EVOLVE_HPP__
v1::AgentID evolve(const SlaveID &slaveId)
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2797
Definition: json.hpp:198
Definition: json.hpp:158
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2798
Definition: agent.hpp:25
Definition: attributes.hpp:24
mesos::v1::scheduler::Response Response
Definition: mesos.hpp:2800
Try< Nothing > schedule(const mesos::maintenance::Schedule &schedule, const hashmap< MachineID, Machine > &machines)
Performs the following checks on the new maintenance schedule: