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  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  // If adding another case here be sure to update the
365  // equality operator.
366  }
367  }
368  }
369 
370  // See mesos.proto for the meaning of agent capabilities.
371  bool multiRole = false;
372  bool hierarchicalRole = false;
373  bool reservationRefinement = false;
374  bool resourceProvider = false;
375  bool resizeVolume = false;
376  bool agentOperationFeedback = false;
377  bool agentDraining = false;
378 
379  google::protobuf::RepeatedPtrField<SlaveInfo::Capability>
381  {
382  google::protobuf::RepeatedPtrField<SlaveInfo::Capability> result;
383  if (multiRole) {
384  result.Add()->set_type(SlaveInfo::Capability::MULTI_ROLE);
385  }
386  if (hierarchicalRole) {
387  result.Add()->set_type(SlaveInfo::Capability::HIERARCHICAL_ROLE);
388  }
389  if (reservationRefinement) {
390  result.Add()->set_type(SlaveInfo::Capability::RESERVATION_REFINEMENT);
391  }
392  if (resourceProvider) {
393  result.Add()->set_type(SlaveInfo::Capability::RESOURCE_PROVIDER);
394  }
395  if (resizeVolume) {
396  result.Add()->set_type(SlaveInfo::Capability::RESIZE_VOLUME);
397  }
398  if (agentOperationFeedback) {
399  result.Add()->set_type(SlaveInfo::Capability::AGENT_OPERATION_FEEDBACK);
400  }
401  if (agentDraining) {
402  result.Add()->set_type(SlaveInfo::Capability::AGENT_DRAINING);
403  }
404 
405  return result;
406  }
407 };
408 
409 
410 bool operator==(const Capabilities& left, const Capabilities& right);
411 bool operator!=(const Capabilities& left, const Capabilities& right);
412 std::ostream& operator<<(std::ostream& stream, const Capabilities& c);
413 
414 
415 mesos::slave::ContainerLimitation createContainerLimitation(
416  const Resources& resources,
417  const std::string& message,
418  const TaskStatus::Reason& reason);
419 
420 
421 mesos::slave::ContainerState createContainerState(
422  const Option<ExecutorInfo>& executorInfo,
423  const Option<ContainerInfo>& containerInfo,
424  const ContainerID& id,
425  pid_t pid,
426  const std::string& directory);
427 
428 
429 mesos::slave::ContainerMountInfo createContainerMount(
430  const std::string& source,
431  const std::string& target,
432  unsigned long flags);
433 
434 
435 mesos::slave::ContainerMountInfo createContainerMount(
436  const std::string& source,
437  const std::string& target,
438  const std::string& type,
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  const std::string& options,
447  unsigned long flags);
448 
449 
450 mesos::slave::ContainerFileOperation containerSymlinkOperation(
451  const std::string& source,
452  const std::string& target);
453 
454 
455 mesos::slave::ContainerFileOperation containerRenameOperation(
456  const std::string& source,
457  const std::string& target);
458 
459 
460 mesos::slave::ContainerFileOperation containerMkdirOperation(
461  const std::string& target,
462  const bool recursive);
463 
464 
465 mesos::slave::ContainerFileOperation containerMountOperation(
466  const mesos::slave::ContainerMountInfo& mnt);
467 
468 } // namespace slave {
469 
470 namespace maintenance {
471 
475 Unavailability createUnavailability(
476  const process::Time& start,
477  const Option<Duration>& duration = None());
478 
479 
483 google::protobuf::RepeatedPtrField<MachineID> createMachineList(
484  std::initializer_list<MachineID> ids);
485 
486 
491 mesos::maintenance::Window createWindow(
492  std::initializer_list<MachineID> ids,
493  const Unavailability& unavailability);
494 
495 
500 mesos::maintenance::Schedule createSchedule(
501  std::initializer_list<mesos::maintenance::Window> windows);
502 
503 } // namespace maintenance {
504 
505 
506 namespace master {
507 
508 // TODO(mzhu): Consolidate these helpers into `struct Capabilities`.
509 // For example, to add a minimum capability for `QUOTA_V2`, we could do the
510 // following in the call site:
511 //
512 // Capabilities capabilities = registry->minimum_capabilities();
513 // capabilities.quotaV2 = needsV2;
514 // *registry->mutable_minimum_capabilities() = capabilities.toStrings();
515 //
516 // For this to work, we need to:
517 // - Add a constructor from repeated `MinimumCapability`
518 // - Add a toStrings() that goes back to repeated string
519 // - Note, unknown capabilities need to be carried in the struct.
520 //
521 // In addition, we should consolidate the helper
522 // `Master::misingMinimumCapabilities` into the struct as well.
523 
524 // Helper to add a minimum capability, it is a noop if already set.
526  google::protobuf::RepeatedPtrField<Registry::MinimumCapability>*
527  capabilities,
528  const MasterInfo::Capability::Type& capability);
529 
530 
531 // Helper to remove a minimum capability,
532 // it is a noop if already absent.
534  google::protobuf::RepeatedPtrField<Registry::MinimumCapability>*
535  capabilities,
536  const MasterInfo::Capability::Type& capability);
537 
538 
539 // TODO(bmahler): Store the repeated field within this so that we
540 // don't drop unknown capabilities.
542 {
543  Capabilities() = default;
544 
545  template <typename Iterable>
546  Capabilities(const Iterable& capabilities)
547  {
548  foreach (const MasterInfo::Capability& capability, capabilities) {
549  switch (capability.type()) {
551  break;
552  case MasterInfo::Capability::AGENT_UPDATE:
553  agentUpdate = true;
554  break;
555  case MasterInfo::Capability::AGENT_DRAINING:
556  agentDraining = true;
557  break;
558  case MasterInfo::Capability::QUOTA_V2:
559  quotaV2 = true;
560  break;
561  }
562  }
563  }
564 
565  bool agentUpdate = false;
566  bool agentDraining = false;
567  bool quotaV2 = false;
568 };
569 
570 namespace event {
571 
572 // Helper for creating a `TASK_UPDATED` event from a `Task`, its
573 // latest state according to the agent, and its status corresponding
574 // to the last status update acknowledged from the scheduler.
576  const Task& task,
577  const TaskState& state,
578  const TaskStatus& status);
579 
580 
581 // Helper for creating a `TASK_ADDED` event from a `Task`.
582 mesos::master::Event createTaskAdded(const Task& task);
583 
584 
585 // Helper for creating a 'FRAMEWORK_ADDED' event from a `Framework`.
587  const mesos::internal::master::Framework& framework);
588 
589 
590 // Helper for creating a 'FRAMEWORK_UPDATED' event from a `Framework`.
592  const mesos::internal::master::Framework& framework);
593 
594 
595 // Helper for creating a 'FRAMEWORK_REMOVED' event from a `FrameworkInfo`.
596 mesos::master::Event createFrameworkRemoved(const FrameworkInfo& frameworkInfo);
597 
598 
599 // Helper for creating an `Agent` response.
600 mesos::master::Response::GetAgents::Agent createAgentResponse(
601  const mesos::internal::master::Slave& slave,
602  const Option<DrainInfo>& drainInfo,
603  bool deactivated,
604  const Option<process::Owned<ObjectApprovers>>& approvers = None());
605 
606 
607 // Helper for creating an `AGENT_ADDED` event from a `Slave`.
609  const mesos::internal::master::Slave& slave,
610  const Option<DrainInfo>& drainInfo,
611  bool deactivated);
612 
613 
614 // Helper for creating an `AGENT_REMOVED` event from a `SlaveID`.
615 mesos::master::Event createAgentRemoved(const SlaveID& slaveId);
616 
617 } // namespace event {
618 } // namespace master {
619 
620 namespace framework {
621 
622 // TODO(bmahler): Store the repeated field within this so that we
623 // don't drop unknown capabilities.
625 {
626  Capabilities() = default;
627 
628  template <typename Iterable>
629  Capabilities(const Iterable& capabilities)
630  {
631  foreach (const FrameworkInfo::Capability& capability, capabilities) {
632  switch (capability.type()) {
634  break;
635  case FrameworkInfo::Capability::REVOCABLE_RESOURCES:
636  revocableResources = true;
637  break;
638  case FrameworkInfo::Capability::TASK_KILLING_STATE:
639  taskKillingState = true;
640  break;
641  case FrameworkInfo::Capability::GPU_RESOURCES:
642  gpuResources = true;
643  break;
644  case FrameworkInfo::Capability::SHARED_RESOURCES:
645  sharedResources = true;
646  break;
647  case FrameworkInfo::Capability::PARTITION_AWARE:
648  partitionAware = true;
649  break;
650  case FrameworkInfo::Capability::MULTI_ROLE:
651  multiRole = true;
652  break;
653  case FrameworkInfo::Capability::RESERVATION_REFINEMENT:
654  reservationRefinement = true;
655  break;
656  case FrameworkInfo::Capability::REGION_AWARE:
657  regionAware = true;
658  break;
659  }
660  }
661  }
662 
663  // See mesos.proto for the meaning of these capabilities.
664  bool revocableResources = false;
665  bool taskKillingState = false;
666  bool gpuResources = false;
667  bool sharedResources = false;
668  bool partitionAware = false;
669  bool multiRole = false;
670  bool reservationRefinement = false;
671  bool regionAware = false;
672 };
673 
674 
675 // Helper to get roles from FrameworkInfo based on the
676 // presence of the MULTI_ROLE capability.
677 std::set<std::string> getRoles(const FrameworkInfo& frameworkInfo);
678 
679 } // namespace framework {
680 
681 } // namespace protobuf {
682 } // namespace internal {
683 } // namespace mesos {
684 
685 #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:546
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:458
Try< Nothing > start(const std::string &name)
Starts the slice with the given name (via &#39;systemctl start <name>&#39;).
Definition: protobuf_utils.hpp:541
Capabilities(const Iterable &capabilities)
Definition: protobuf_utils.hpp:629
Definition: protobuf_utils.hpp:71
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2783
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:624
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:380
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:79
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:2401
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)