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::DomainInfo evolve(const DomainInfo& domainInfo);
66 v1::ExecutorID evolve(const ExecutorID& executorId);
67 v1::ExecutorInfo evolve(const ExecutorInfo& executorInfo);
68 v1::FileInfo evolve(const FileInfo& fileInfo);
69 v1::FrameworkID evolve(const FrameworkID& frameworkId);
70 v1::FrameworkInfo evolve(const FrameworkInfo& frameworkInfo);
71 v1::InverseOffer evolve(const InverseOffer& inverseOffer);
72 v1::KillPolicy evolve(const KillPolicy& killPolicy);
73 v1::MachineID evolve(const MachineID& machineId);
74 v1::MasterInfo evolve(const MasterInfo& masterInfo);
75 v1::Offer evolve(const Offer& offer);
76 v1::OfferID evolve(const OfferID& offerId);
77 v1::OperationStatus evolve(const OperationStatus& status);
78 v1::Resource evolve(const Resource& resource);
79 v1::ResourceProviderID evolve(const ResourceProviderID& resourceProviderId);
80 v1::Resources evolve(const Resources& resources);
81 v1::Task evolve(const Task& task);
82 v1::TaskID evolve(const TaskID& taskId);
83 v1::TaskInfo evolve(const TaskInfo& taskInfo);
84 v1::TaskStatus evolve(const TaskStatus& status);
85 v1::UUID evolve(const UUID& uuid);
86 
87 
89 v1::agent::ProcessIO evolve(const agent::ProcessIO& processIO);
91 
92 
93 v1::maintenance::ClusterStatus evolve(
94  const maintenance::ClusterStatus& cluster);
95 v1::maintenance::Schedule evolve(const maintenance::Schedule& schedule);
96 
97 
100 
101 
102 // Helper for repeated field evolving to 'T1' from 'T2'.
103 template <typename T1, typename T2>
104 google::protobuf::RepeatedPtrField<T1> evolve(
105  google::protobuf::RepeatedPtrField<T2> t2s)
106 {
107  google::protobuf::RepeatedPtrField<T1> t1s;
108 
109  foreach (const T2& t2, t2s) {
110  t1s.Add()->CopyFrom(evolve(t2));
111  }
112 
113  return t1s;
114 }
115 
116 
120 
121 
122 // Helper functions that evolve old style internal messages to a
123 // v1::scheduler::Event.
124 v1::scheduler::Event evolve(const ExitedExecutorMessage& message);
125 v1::scheduler::Event evolve(const ExecutorToFrameworkMessage& message);
126 v1::scheduler::Event evolve(const FrameworkErrorMessage& message);
127 v1::scheduler::Event evolve(const FrameworkRegisteredMessage& message);
128 v1::scheduler::Event evolve(const FrameworkReregisteredMessage& message);
129 v1::scheduler::Event evolve(const InverseOffersMessage& message);
130 v1::scheduler::Event evolve(const LostSlaveMessage& message);
131 v1::scheduler::Event evolve(const ResourceOffersMessage& message);
132 v1::scheduler::Event evolve(const RescindInverseOfferMessage& message);
133 v1::scheduler::Event evolve(const RescindResourceOfferMessage& message);
134 v1::scheduler::Event evolve(const StatusUpdateMessage& message);
135 v1::scheduler::Event evolve(const UpdateOperationStatusMessage& message);
136 
137 
140 
141 
142 // Helper functions that evolve old style internal messages to a
143 // v1::Executor::Event.
144 v1::executor::Event evolve(const ExecutorRegisteredMessage& message);
145 v1::executor::Event evolve(const FrameworkToExecutorMessage& message);
146 v1::executor::Event evolve(const KillTaskMessage& message);
147 v1::executor::Event evolve(const RunTaskMessage& message);
148 v1::executor::Event evolve(const ShutdownExecutorMessage& message);
149 v1::executor::Event evolve(const StatusUpdateAcknowledgementMessage& message);
150 
151 
154 
155 
156 // Before the v1 API we had REST endpoints that returned JSON. The JSON was not
157 // specified in any formal way, i.e., there were no protobufs which captured the
158 // structure. As part of the v1 API we introduced the Call/Response protobufs
159 // (see v1/master.proto and v1/agent.proto). This evolve variant transforms a
160 // JSON object that would have been returned from a particular REST endpoint to
161 // a `Response` protobuf suitable for returning from the new v1 API endpoints.
162 
163 // Declaration of helper functions for evolving JSON objects used in master's
164 // REST endpoints pre v1 API.
165 template <v1::master::Response::Type T>
167 
168 
169 // Declaration of helper functions for evolving JSON objects used in agent's
170 // REST endpoints pre v1 API.
171 template <v1::agent::Response::Type T>
173 
174 
175 template <v1::agent::Response::Type T>
177 
178 } // namespace internal {
179 } // namespace mesos {
180 
181 #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:2660
Definition: json.hpp:194
Definition: json.hpp:154
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2661
Definition: spec.hpp:30
Definition: attributes.hpp:24
mesos::v1::scheduler::Response Response
Definition: mesos.hpp:2663
Try< Nothing > schedule(const mesos::maintenance::Schedule &schedule, const hashmap< MachineID, Machine > &machines)
Performs the following checks on the new maintenance schedule: