Apache Mesos
protobuf_utils.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 __PROTOBUF_UTILS_HPP__
18 #define __PROTOBUF_UTILS_HPP__
19 
20 #include <initializer_list>
21 #include <ostream>
22 #include <set>
23 #include <string>
24 
25 #include <sys/stat.h>
26 
27 #include <google/protobuf/map.h>
28 
29 #include <mesos/mesos.hpp>
30 
32 
33 #include <mesos/master/master.hpp>
34 
35 #include <mesos/slave/isolator.hpp>
36 
37 #include <process/time.hpp>
38 
39 #include <stout/duration.hpp>
40 #include <stout/ip.hpp>
41 #include <stout/none.hpp>
42 #include <stout/option.hpp>
43 #include <stout/try.hpp>
44 #include <stout/uuid.hpp>
45 
46 #include "master/registry.hpp"
47 
48 #include "messages/messages.hpp"
49 
50 // Forward declaration (in lieu of an include).
51 namespace process {
52 struct UPID;
53 }
54 
55 namespace mesos {
56 
57 class ObjectApprovers;
58 
59 namespace internal {
60 
61 namespace master {
62 // Forward declaration (in lieu of an include).
63 struct Framework;
64 struct Slave;
65 } // namespace master {
66 
67 namespace protobuf {
68 
69 // Modeled after WireFormatLite from protobuf, but to provide
70 // missing helpers.
72 {
73 public:
74  // This is a wrapper to compute cached sizes before calling into
75  // `WireFormatLite::WriteMessage`, which assumes that sizes are
76  // already cached.
78  int field_number,
79  const google::protobuf::MessageLite& value,
80  google::protobuf::io::CodedOutputStream* output)
81  {
82  // Cache the sizes first.
83  value.ByteSizeLong();
84 
85  google::protobuf::internal::WireFormatLite::WriteMessage(
86  field_number, value, output);
87  }
88 };
89 
90 
91 // Internal helper class for protobuf union validation.
93 {
94 public:
95  UnionValidator(const google::protobuf::Descriptor*);
97  const int messageTypeNumber, const google::protobuf::Message&) const;
98 
99 private:
100  std::vector<std::pair<int, const google::protobuf::FieldDescriptor*>>
101  unionFieldDescriptors_;
102  const google::protobuf::EnumDescriptor* typeDescriptor_;
103 };
104 
105 //
106 // A message is a "protobuf union" if, and only if,
107 // the following requirements are satisfied:
108 // 1. It has a required field named `type` of an enum type.
109 // 2. A member of this enum with a number (not index!) of 0
110 // either is named "UNKNOWN" or does not exist.
111 // 3. For each other member of this enum there is an optional field
112 // in the message with an exactly matching name in lowercase.
113 // (Being or not being a protobuf uinion depends on a message declaration only.)
114 //
115 // A "protobuf union" is valid if, and only if, all the message fields
116 // which correspond to members of this enum that do not matching the value
117 // of the `type` field, are not set.
118 // (Validity of the protobuf union depends on the message contents.
119 // Note that it does not depend on whether the matching field is set or not.)
120 //
121 // NOTE: If possible, oneof should be used in the new messages instead
122 // of the "protobuf union".
123 //
124 // This function returns None if the protobuf union is valid
125 // and Error otherwise.
126 // In case the ProtobufUnion is not a protobuf union,
127 // this function will abort the process on the first use.
128 template <class ProtobufUnion>
129 Option<Error> validateProtobufUnion(const ProtobufUnion& message)
130 {
131  static const UnionValidator validator(ProtobufUnion::descriptor());
132  return validator.validate(message.type(), message);
133 }
134 
135 
137  const FrameworkInfo& framework,
139 
140 
141 // Returns whether the task state is terminal. Terminal states
142 // mean that the resources are released and the task cannot
143 // transition back to a non-terminal state. Note that
144 // `TASK_UNREACHABLE` is not a terminal state, but still
145 // releases the resources.
146 bool isTerminalState(const TaskState& state);
147 
148 
149 // See TaskStatus for more information about these fields. Note
150 // that the 'uuid' must be provided for updates that need
151 // acknowledgement. Currently, all slave and executor generated
152 // updates require acknowledgement, whereas master generated
153 // and scheduler driver generated updates do not.
154 StatusUpdate createStatusUpdate(
155  const FrameworkID& frameworkId,
156  const Option<SlaveID>& slaveId,
157  const TaskID& taskId,
158  const TaskState& state,
159  const TaskStatus::Source& source,
160  const Option<id::UUID>& uuid,
161  const std::string& message = "",
162  const Option<TaskStatus::Reason>& reason = None(),
163  const Option<ExecutorID>& executorId = None(),
164  const Option<bool>& healthy = None(),
165  const Option<CheckStatusInfo>& checkStatus = None(),
166  const Option<Labels>& labels = None(),
167  const Option<ContainerStatus>& containerStatus = None(),
168  const Option<TimeInfo>& unreachableTime = None(),
169  const Option<Resources>& limitedResources = None());
170 
171 
172 StatusUpdate createStatusUpdate(
173  const FrameworkID& frameworkId,
174  const TaskStatus& status,
175  const Option<SlaveID>& slaveId);
176 
177 
178 // Helper function that creates a new task status from scratch with
179 // obligatory fields set.
180 TaskStatus createTaskStatus(
181  const TaskID& taskId,
182  const TaskState& state,
183  const id::UUID& uuid,
184  double timestamp);
185 
186 
187 // Helper function that creates a new task status from the given task
188 // status. Specific fields in `status` can be overridden in the new
189 // status by specifying the appropriate argument. Fields `task_id`,
190 // `slave_id`, `executor_id`, cannot be changed; while `timestamp`
191 // and `uuid` cannot be preserved.
192 //
193 // NOTE: A task status update may be used for guaranteed delivery of
194 // some task-related information, e.g., task's health update. In this
195 // case, it is often desirable to preserve specific fields from the
196 // previous status update to avoid shadowing information that was
197 // delivered previously.
198 TaskStatus createTaskStatus(
199  TaskStatus status,
200  const id::UUID& uuid,
201  double timestamp,
202  const Option<TaskState>& state = None(),
203  const Option<std::string>& message = None(),
204  const Option<TaskStatus::Source>& source = None(),
205  const Option<TaskStatus::Reason>& reason = None(),
206  const Option<std::string>& data = None(),
207  const Option<bool>& healthy = None(),
208  const Option<CheckStatusInfo>& checkStatus = None(),
209  const Option<Labels>& labels = None(),
210  const Option<ContainerStatus>& containerStatus = None(),
211  const Option<TimeInfo>& unreachableTime = None());
212 
213 
214 Task createTask(
215  const TaskInfo& task,
216  const TaskState& state,
217  const FrameworkID& frameworkId);
218 
219 
220 Option<bool> getTaskHealth(const Task& task);
221 
222 
224 
225 
227 
228 
229 bool isTerminalState(const OperationState& state);
230 
231 
232 OperationStatus createOperationStatus(
233  const OperationState& state,
234  const Option<OperationID>& operationId = None(),
235  const Option<std::string>& message = None(),
236  const Option<Resources>& convertedResources = None(),
237  const Option<id::UUID>& statusUUID = None(),
238  const Option<SlaveID>& slaveId = None(),
239  const Option<ResourceProviderID>& resourceProviderId = None());
240 
241 
243  const Offer::Operation& info,
244  const OperationStatus& latestStatus,
245  const Option<FrameworkID>& frameworkId,
246  const Option<SlaveID>& slaveId,
247  const Option<UUID>& operationUUID = None());
248 
249 
250 UpdateOperationStatusMessage createUpdateOperationStatusMessage(
251  const UUID& operationUUID,
252  const OperationStatus& status,
253  const Option<OperationStatus>& latestStatus = None(),
254  const Option<FrameworkID>& frameworkId = None(),
255  const Option<SlaveID>& slaveId = None());
256 
257 
258 // Create a `UUID`. If `uuid` is given it is used to initialize
259 // the created `UUID`; otherwise a random `UUID` is returned.
260 UUID createUUID(const Option<id::UUID>& uuid = None());
261 
262 
263 // Helper function that creates a MasterInfo from UPID.
264 MasterInfo createMasterInfo(const process::UPID& pid);
265 
266 
267 Label createLabel(
268  const std::string& key,
269  const Option<std::string>& value = None());
270 
271 
272 // Helper function to convert a protobuf string map to `Labels`.
274  const google::protobuf::Map<std::string, std::string>& map);
275 
276 
277 // Helper function to convert a `Labels` to a protobuf string map.
279  const Labels& labels);
280 
281 
282 // Previously, `Resource` did not contain `AllocationInfo`.
283 // So for backwards compatibility with old schedulers and
284 // tooling, we must allow operations to contain `Resource`s
285 // without an `AllocationInfo`. This allows the master to
286 // inject the offer's `AllocationInfo` into the operation's
287 // resources.
289  Offer::Operation* operation,
290  const Resource::AllocationInfo& allocationInfo);
291 
292 
293 // This strips the Resource::AllocationInfo from all
294 // Resource objects contained within the operation.
295 void stripAllocationInfo(Offer::Operation* operation);
296 
297 
298 bool isSpeculativeOperation(const Offer::Operation& operation);
299 
300 
301 // Helper function to pack a protobuf list of resource versions.
302 google::protobuf::RepeatedPtrField<ResourceVersionUUID> createResourceVersions(
303  const hashmap<Option<ResourceProviderID>, UUID>& resourceVersions);
304 
305 
306 // Helper function to unpack a protobuf list of resource versions.
308  const google::protobuf::RepeatedPtrField<ResourceVersionUUID>&
309  resourceVersionUUIDs);
310 
311 
312 // Helper function that fills in a TimeInfo from the current time.
313 TimeInfo getCurrentTime();
314 
315 
316 // Helper function that creates a `FileInfo` from data returned by `stat()`.
317 FileInfo createFileInfo(const std::string& path, const struct stat& s);
318 
319 
320 ContainerID getRootContainerId(const ContainerID& containerId);
321 
322 
323 ContainerID parseContainerId(const std::string& value);
324 
325 
327 
328 namespace slave {
329 
330 // TODO(bmahler): Store the repeated field within this so that we
331 // don't drop unknown capabilities.
333 {
334  Capabilities() = default;
335 
336  template <typename Iterable>
337  explicit Capabilities(const Iterable& capabilities)
338  {
339  foreach (const SlaveInfo::Capability& capability, capabilities) {
340  switch (capability.type()) {
342  break;
343  case SlaveInfo::Capability::MULTI_ROLE:
344  multiRole = true;
345  break;
346  case SlaveInfo::Capability::HIERARCHICAL_ROLE:
347  hierarchicalRole = true;
348  break;
349  case SlaveInfo::Capability::RESERVATION_REFINEMENT:
350  reservationRefinement = true;
351  break;
352  case SlaveInfo::Capability::RESOURCE_PROVIDER:
353  resourceProvider = true;
354  break;
355  case SlaveInfo::Capability::RESIZE_VOLUME:
356  resizeVolume = true;
357  break;
358  case SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK:
359  agentOperationFeedback = true;
360  break;
361  case SlaveInfo::Capability::AGENT_DRAINING:
362  agentDraining = true;
363  break;
364  case SlaveInfo::Capability::TASK_RESOURCE_LIMITS:
365  taskResourceLimits = true;
366  break;
367  // If adding another case here be sure to update the
368  // equality operator.
369  }
370  }
371  }
372 
373  // See mesos.proto for the meaning of agent capabilities.
374  bool multiRole = false;
375  bool hierarchicalRole = false;
376  bool reservationRefinement = false;
377  bool resourceProvider = false;
378  bool resizeVolume = false;
379  bool agentOperationFeedback = false;
380  bool agentDraining = false;
381  bool taskResourceLimits = false;
382 
383  google::protobuf::RepeatedPtrField<SlaveInfo::Capability>
385  {
386  google::protobuf::RepeatedPtrField<SlaveInfo::Capability> result;
387  if (multiRole) {
388  result.Add()->set_type(SlaveInfo::Capability::MULTI_ROLE);
389  }
390  if (hierarchicalRole) {
391  result.Add()->set_type(SlaveInfo::Capability::HIERARCHICAL_ROLE);
392  }
393  if (reservationRefinement) {
394  result.Add()->set_type(SlaveInfo::Capability::RESERVATION_REFINEMENT);
395  }
396  if (resourceProvider) {
397  result.Add()->set_type(SlaveInfo::Capability::RESOURCE_PROVIDER);
398  }
399  if (resizeVolume) {
400  result.Add()->set_type(SlaveInfo::Capability::RESIZE_VOLUME);
401  }
402  if (agentOperationFeedback) {
403  result.Add()->set_type(SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK);
404  }
405  if (agentDraining) {
406  result.Add()->set_type(SlaveInfo::Capability::AGENT_DRAINING);
407  }
408  if (taskResourceLimits) {
409  result.Add()->set_type(SlaveInfo::Capability::TASK_RESOURCE_LIMITS);
410  }
411 
412  return result;
413  }
414 };
415 
416 
417 bool operator==(const Capabilities& left, const Capabilities& right);
418 bool operator!=(const Capabilities& left, const Capabilities& right);
419 std::ostream& operator<<(std::ostream& stream, const Capabilities& c);
420 
421 
422 mesos::slave::ContainerLimitation createContainerLimitation(
423  const Resources& resources,
424  const std::string& message,
425  const TaskStatus::Reason& reason);
426 
427 
428 mesos::slave::ContainerState createContainerState(
429  const Option<ExecutorInfo>& executorInfo,
430  const Option<ContainerInfo>& containerInfo,
431  const ContainerID& id,
432  pid_t pid,
433  const std::string& directory);
434 
435 
436 mesos::slave::ContainerMountInfo createContainerMount(
437  const std::string& source,
438  const std::string& target,
439  unsigned long flags);
440 
441 
442 mesos::slave::ContainerMountInfo createContainerMount(
443  const std::string& source,
444  const std::string& target,
445  const std::string& type,
446  unsigned long flags);
447 
448 
449 mesos::slave::ContainerMountInfo createContainerMount(
450  const std::string& source,
451  const std::string& target,
452  const std::string& type,
453  const std::string& options,
454  unsigned long flags);
455 
456 
457 mesos::slave::ContainerFileOperation containerSymlinkOperation(
458  const std::string& source,
459  const std::string& target);
460 
461 
462 mesos::slave::ContainerFileOperation containerRenameOperation(
463  const std::string& source,
464  const std::string& target);
465 
466 
467 mesos::slave::ContainerFileOperation containerMkdirOperation(
468  const std::string& target,
469  const bool recursive);
470 
471 
472 mesos::slave::ContainerFileOperation containerMountOperation(
473  const mesos::slave::ContainerMountInfo& mnt);
474 
475 } // namespace slave {
476 
477 namespace maintenance {
478 
482 Unavailability createUnavailability(
483  const process::Time& start,
484  const Option<Duration>& duration = None());
485 
486 
490 google::protobuf::RepeatedPtrField<MachineID> createMachineList(
491  std::initializer_list<MachineID> ids);
492 
493 
498 mesos::maintenance::Window createWindow(
499  std::initializer_list<MachineID> ids,
500  const Unavailability& unavailability);
501 
502 
507 mesos::maintenance::Schedule createSchedule(
508  std::initializer_list<mesos::maintenance::Window> windows);
509 
510 } // namespace maintenance {
511 
512 
513 namespace master {
514 
515 // TODO(mzhu): Consolidate these helpers into `struct Capabilities`.
516 // For example, to add a minimum capability for `QUOTA_V2`, we could do the
517 // following in the call site:
518 //
519 // Capabilities capabilities = registry->minimum_capabilities();
520 // capabilities.quotaV2 = needsV2;
521 // *registry->mutable_minimum_capabilities() = capabilities.toStrings();
522 //
523 // For this to work, we need to:
524 // - Add a constructor from repeated `MinimumCapability`
525 // - Add a toStrings() that goes back to repeated string
526 // - Note, unknown capabilities need to be carried in the struct.
527 //
528 // In addition, we should consolidate the helper
529 // `Master::misingMinimumCapabilities` into the struct as well.
530 
531 // Helper to add a minimum capability, it is a noop if already set.
533  google::protobuf::RepeatedPtrField<Registry::MinimumCapability>*
534  capabilities,
535  const MasterInfo::Capability::Type& capability);
536 
537 
538 // Helper to remove a minimum capability,
539 // it is a noop if already absent.
541  google::protobuf::RepeatedPtrField<Registry::MinimumCapability>*
542  capabilities,
543  const MasterInfo::Capability::Type& capability);
544 
545 
546 // TODO(bmahler): Store the repeated field within this so that we
547 // don't drop unknown capabilities.
549 {
550  Capabilities() = default;
551 
552  template <typename Iterable>
553  explicit Capabilities(const Iterable& capabilities)
554  {
555  foreach (const MasterInfo::Capability& capability, capabilities) {
556  switch (capability.type()) {
558  break;
559  case MasterInfo::Capability::AGENT_UPDATE:
560  agentUpdate = true;
561  break;
562  case MasterInfo::Capability::AGENT_DRAINING:
563  agentDraining = true;
564  break;
565  case MasterInfo::Capability::QUOTA_V2:
566  quotaV2 = true;
567  break;
568  }
569  }
570  }
571 
572  bool agentUpdate = false;
573  bool agentDraining = false;
574  bool quotaV2 = false;
575 };
576 
577 namespace event {
578 
579 // Helper for creating a `TASK_UPDATED` event from a `Task`, its
580 // latest state according to the agent, and its status corresponding
581 // to the last status update acknowledged from the scheduler.
583  const Task& task,
584  const TaskState& state,
585  const TaskStatus& status);
586 
587 
588 // Helper for creating a `TASK_ADDED` event from a `Task`.
589 mesos::master::Event createTaskAdded(const Task& task);
590 
591 
592 // Helper for creating a 'FRAMEWORK_ADDED' event from a `Framework`.
594  const mesos::internal::master::Framework& framework);
595 
596 
597 // Helper for creating a 'FRAMEWORK_UPDATED' event from a `Framework`.
599  const mesos::internal::master::Framework& framework);
600 
601 
602 // Helper for creating a 'FRAMEWORK_REMOVED' event from a `FrameworkInfo`.
603 mesos::master::Event createFrameworkRemoved(const FrameworkInfo& frameworkInfo);
604 
605 
606 // Helper for creating an `Agent` response.
607 mesos::master::Response::GetAgents::Agent createAgentResponse(
608  const mesos::internal::master::Slave& slave,
609  const Option<DrainInfo>& drainInfo,
610  bool deactivated,
611  const Option<process::Owned<ObjectApprovers>>& approvers = None());
612 
613 
614 // Helper for creating an `AGENT_ADDED` event from a `Slave`.
616  const mesos::internal::master::Slave& slave,
617  const Option<DrainInfo>& drainInfo,
618  bool deactivated);
619 
620 
621 // Helper for creating an `AGENT_REMOVED` event from a `SlaveID`.
622 mesos::master::Event createAgentRemoved(const SlaveID& slaveId);
623 
624 } // namespace event {
625 } // namespace master {
626 
627 namespace framework {
628 
629 // TODO(bmahler): Store the repeated field within this so that we
630 // don't drop unknown capabilities.
632 {
633  Capabilities() = default;
634 
635  template <typename Iterable>
636  explicit Capabilities(const Iterable& capabilities)
637  {
638  foreach (const FrameworkInfo::Capability& capability, capabilities) {
639  switch (capability.type()) {
641  break;
642  case FrameworkInfo::Capability::REVOCABLE_RESOURCES:
643  revocableResources = true;
644  break;
645  case FrameworkInfo::Capability::TASK_KILLING_STATE:
646  taskKillingState = true;
647  break;
648  case FrameworkInfo::Capability::GPU_RESOURCES:
649  gpuResources = true;
650  break;
651  case FrameworkInfo::Capability::SHARED_RESOURCES:
652  sharedResources = true;
653  break;
654  case FrameworkInfo::Capability::PARTITION_AWARE:
655  partitionAware = true;
656  break;
657  case FrameworkInfo::Capability::MULTI_ROLE:
658  multiRole = true;
659  break;
660  case FrameworkInfo::Capability::RESERVATION_REFINEMENT:
661  reservationRefinement = true;
662  break;
663  case FrameworkInfo::Capability::REGION_AWARE:
664  regionAware = true;
665  break;
666  }
667  }
668  }
669 
670  // See mesos.proto for the meaning of these capabilities.
671  bool revocableResources = false;
672  bool taskKillingState = false;
673  bool gpuResources = false;
674  bool sharedResources = false;
675  bool partitionAware = false;
676  bool multiRole = false;
677  bool reservationRefinement = false;
678  bool regionAware = false;
679 };
680 
681 
682 // Helper to get roles from FrameworkInfo based on the
683 // presence of the MULTI_ROLE capability.
684 std::set<std::string> getRoles(const FrameworkInfo& frameworkInfo);
685 
686 } // namespace framework {
687 
688 } // namespace protobuf {
689 } // namespace internal {
690 } // namespace mesos {
691 
692 #endif // __PROTOBUF_UTILS_HPP__
hashmap< Option< ResourceProviderID >, UUID > parseResourceVersions(const google::protobuf::RepeatedPtrField< ResourceVersionUUID > &resourceVersionUUIDs)
Definition: path.hpp:29
UpdateOperationStatusMessage createUpdateOperationStatusMessage(const UUID &operationUUID, const OperationStatus &status, const Option< OperationStatus > &latestStatus=None(), const Option< FrameworkID > &frameworkId=None(), const Option< SlaveID > &slaveId=None())
Capabilities(const Iterable &capabilities)
Definition: protobuf_utils.hpp:553
Try< Resources > getConsumedResources(const Offer::Operation &operation)
Option< bool > getTaskHealth(const Task &task)
mesos::master::Event createFrameworkAdded(const mesos::internal::master::Framework &framework)
Option< Error > validate(const std::string &imageDir)
std::ostream & operator<<(std::ostream &stream, const Future< T > &future)
Definition: future.hpp:1826
void stripAllocationInfo(Offer::Operation *operation)
bool operator==(const std::string &s, const UPID::ID &id)
Definition: pid.hpp:226
Definition: master.hpp:27
Definition: check.hpp:33
Labels convertStringMapToLabels(const google::protobuf::Map< std::string, std::string > &map)
Option< Error > validateProtobufUnion(const ProtobufUnion &message)
Definition: protobuf_utils.hpp:129
google::protobuf::RepeatedPtrField< MachineID > createMachineList(std::initializer_list< MachineID > ids)
Helper for constructing a list of MachineID.
void injectAllocationInfo(Offer::Operation *operation, const Resource::AllocationInfo &allocationInfo)
Definition: protobuf_utils.hpp:332
Unavailability createUnavailability(const process::Time &start, const Option< Duration > &duration=None())
Helper for constructing an unavailability from a Time and Duration.
std::set< std::string > getRoles(const FrameworkInfo &frameworkInfo)
Capabilities(const Iterable &capabilities)
Definition: protobuf_utils.hpp:337
Definition: protobuf_utils.hpp:92
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
Definition: resources.hpp:83
mesos::master::Event createFrameworkUpdated(const mesos::internal::master::Framework &framework)
ContainerID getRootContainerId(const ContainerID &containerId)
mesos::maintenance::Schedule createSchedule(std::initializer_list< mesos::maintenance::Window > windows)
Helper for constructing a maintenance Schedule.
Capability
Definition: capabilities.hpp:35
Try< google::protobuf::Map< std::string, std::string > > convertLabelsToStringMap(const Labels &labels)
Operation
Definition: cgroups.hpp:444
Try< Nothing > start(const std::string &name)
Starts the slice with the given name (via &#39;systemctl start <name>&#39;).
Definition: protobuf_utils.hpp:548
Capabilities(const Iterable &capabilities)
Definition: protobuf_utils.hpp:636
Definition: protobuf_utils.hpp:71
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2852
Definition: hashmap.hpp:38
mesos::master::Event createTaskAdded(const Task &task)
DWORD pid_t
Definition: windows.hpp:181
mesos::slave::ContainerLimitation createContainerLimitation(const Resources &resources, const std::string &message, const TaskStatus::Reason &reason)
FileInfo createFileInfo(const std::string &path, const struct stat &s)
mesos::master::Event createTaskUpdated(const Task &task, const TaskState &state, const TaskStatus &status)
mesos::master::Event createAgentRemoved(const SlaveID &slaveId)
Try< Nothing > unavailability(const Unavailability &unavailability)
An "untyped" PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
StatusUpdate createStatusUpdate(const FrameworkID &frameworkId, const TaskStatus &status, const Option< SlaveID > &slaveId)
Option< ContainerStatus > getTaskContainerStatus(const Task &task)
mesos::slave::ContainerMountInfo createContainerMount(const std::string &source, const std::string &target, const std::string &type, const std::string &options, unsigned long flags)
Definition: uuid.hpp:35
Definition: protobuf_utils.hpp:631
Definition: agent.hpp:25
OperationStatus createOperationStatus(const OperationState &state, const Option< OperationID > &operationId=None(), const Option< std::string > &message=None(), const Option< Resources > &convertedResources=None(), const Option< id::UUID > &statusUUID=None(), const Option< SlaveID > &slaveId=None(), const Option< ResourceProviderID > &resourceProviderId=None())
Task createTask(const TaskInfo &task, const TaskState &state, const FrameworkID &frameworkId)
const int UNKNOWN
Definition: diagnosis.hpp:39
mesos::slave::ContainerFileOperation containerRenameOperation(const std::string &source, const std::string &target)
google::protobuf::RepeatedPtrField< SlaveInfo::Capability > toRepeatedPtrField() const
Definition: protobuf_utils.hpp:384
Definition: protobuf.hpp:61
mesos::master::Response::GetAgents::Agent createAgentResponse(const mesos::internal::master::Slave &slave, const Option< DrainInfo > &drainInfo, bool deactivated, const Option< process::Owned< ObjectApprovers >> &approvers=None())
Try< hashmap< std::string, uint64_t > > stat(const std::string &hierarchy, const std::string &cgroup, const std::string &file)
Definition: time.hpp:23
Operation createOperation(const Offer::Operation &info, const OperationStatus &latestStatus, const Option< FrameworkID > &frameworkId, const Option< SlaveID > &slaveId, const Option< UUID > &operationUUID=None())
Option< Error > validate(const int messageTypeNumber, const google::protobuf::Message &) const
void removeMinimumCapability(google::protobuf::RepeatedPtrField< Registry::MinimumCapability > *capabilities, const MasterInfo::Capability::Type &capability)
bool isTerminalState(const OperationState &state)
mesos::slave::ContainerFileOperation containerSymlinkOperation(const std::string &source, const std::string &target)
Iterable< V > map(F &&f, const Iterable< U, Us... > &input)
Definition: lambda.hpp:46
mesos::master::Event createAgentAdded(const mesos::internal::master::Slave &slave, const Option< DrainInfo > &drainInfo, bool deactivated)
Definition: none.hpp:27
Definition: attributes.hpp:24
bool operator!=(const std::string &s, const UPID::ID &id)
Definition: pid.hpp:232
mesos::master::Event createFrameworkRemoved(const FrameworkInfo &frameworkInfo)
Definition: executor.hpp:48
Type
Definition: capabilities.hpp:82
mesos::slave::ContainerFileOperation containerMountOperation(const mesos::slave::ContainerMountInfo &mnt)
Definition: master.hpp:122
static void WriteMessageWithoutCachedSizes(int field_number, const google::protobuf::MessageLite &value, google::protobuf::io::CodedOutputStream *output)
Definition: protobuf_utils.hpp:77
mesos::maintenance::Window createWindow(std::initializer_list< MachineID > ids, const Unavailability &unavailability)
Helper for constructing a maintenance Window.
Try< uint32_t > type(const std::string &path)
TaskStatus createTaskStatus(TaskStatus status, const id::UUID &uuid, double timestamp, const Option< TaskState > &state=None(), const Option< std::string > &message=None(), const Option< TaskStatus::Source > &source=None(), const Option< TaskStatus::Reason > &reason=None(), const Option< std::string > &data=None(), const Option< bool > &healthy=None(), const Option< CheckStatusInfo > &checkStatus=None(), const Option< Labels > &labels=None(), const Option< ContainerStatus > &containerStatus=None(), const Option< TimeInfo > &unreachableTime=None())
bool frameworkHasCapability(const FrameworkInfo &framework, FrameworkInfo::Capability::Type capability)
bool isSpeculativeOperation(const Offer::Operation &operation)
Label createLabel(const std::string &key, const Option< std::string > &value=None())
mesos::slave::ContainerState createContainerState(const Option< ExecutorInfo > &executorInfo, const Option< ContainerInfo > &containerInfo, const ContainerID &id, pid_t pid, const std::string &directory)
Definition: owned.hpp:36
Definition: master.hpp:2397
MasterInfo createMasterInfo(const process::UPID &pid)
Option< CheckStatusInfo > getTaskCheckStatus(const Task &task)
Definition: parse.hpp:33
void addMinimumCapability(google::protobuf::RepeatedPtrField< Registry::MinimumCapability > *capabilities, const MasterInfo::Capability::Type &capability)
ContainerID parseContainerId(const std::string &value)
UUID createUUID(const Option< id::UUID > &uuid=None())
google::protobuf::RepeatedPtrField< ResourceVersionUUID > createResourceVersions(const hashmap< Option< ResourceProviderID >, UUID > &resourceVersions)
mesos::slave::ContainerFileOperation containerMkdirOperation(const std::string &target, const bool recursive)