17 #ifndef __MESOS_TYPE_UTILS_H__ 18 #define __MESOS_TYPE_UTILS_H__ 24 #include <boost/functional/hash.hpp> 26 #include <google/protobuf/map.h> 27 #include <google/protobuf/repeated_field.h> 29 #include <google/protobuf/util/message_differencer.h> 51 bool operator==(
const CheckStatusInfo& left,
const CheckStatusInfo& right);
52 bool operator==(
const CommandInfo& left,
const CommandInfo& right);
53 bool operator==(
const CommandInfo::URI& left,
const CommandInfo::URI& right);
54 bool operator==(
const ContainerID& left,
const ContainerID& right);
55 bool operator==(
const ContainerInfo& left,
const ContainerInfo& right);
56 bool operator==(
const Credential& left,
const Credential& right);
57 bool operator==(
const CSIPluginInfo& left,
const CSIPluginInfo& right);
60 const CSIPluginContainerInfo& left,
61 const CSIPluginContainerInfo& right);
63 bool operator==(
const DiscoveryInfo& left,
const DiscoveryInfo& right);
64 bool operator==(
const Environment& left,
const Environment& right);
65 bool operator==(
const ExecutorInfo& left,
const ExecutorInfo& right);
66 bool operator==(
const HealthCheck& left,
const HealthCheck& right);
67 bool operator==(
const KillPolicy& left,
const KillPolicy& right);
68 bool operator==(
const Label& left,
const Label& right);
69 bool operator==(
const Labels& left,
const Labels& right);
70 bool operator==(
const MasterInfo& left,
const MasterInfo& right);
73 bool operator==(
const OperationStatus& left,
const OperationStatus& right);
76 const ResourceProviderInfo& left,
77 const ResourceProviderInfo& right);
80 const ResourceStatistics& left,
81 const ResourceStatistics& right);
83 bool operator==(
const SlaveInfo& left,
const SlaveInfo& right);
84 bool operator==(
const Task& left,
const Task& right);
85 bool operator==(
const TaskGroupInfo& left,
const TaskGroupInfo& right);
86 bool operator==(
const TaskInfo& left,
const TaskInfo& right);
87 bool operator==(
const TaskStatus& left,
const TaskStatus& right);
88 bool operator==(
const URL& left,
const URL& right);
89 bool operator==(
const UUID& left,
const UUID& right);
90 bool operator==(
const Volume& left,
const Volume& right);
92 const Volume::Source::CSIVolume::VolumeCapability& left,
93 const Volume::Source::CSIVolume::VolumeCapability& right);
95 bool operator!=(
const CheckStatusInfo& left,
const CheckStatusInfo& right);
96 bool operator!=(
const ExecutorInfo& left,
const ExecutorInfo& right);
97 bool operator!=(
const Labels& left,
const Labels& right);
100 bool operator!=(
const OperationStatus& left,
const OperationStatus& right);
102 bool operator!=(
const TaskStatus& left,
const TaskStatus& right);
104 const Volume::Source::CSIVolume::VolumeCapability& left,
105 const Volume::Source::CSIVolume::VolumeCapability& right);
107 inline bool operator==(
const ExecutorID& left,
const ExecutorID& right)
109 return left.value() == right.value();
113 inline bool operator==(
const FrameworkID& left,
const FrameworkID& right)
115 return left.value() == right.value();
122 bool operator==(
const FrameworkInfo& left,
const FrameworkInfo& right) =
delete;
125 namespace typeutils {
130 bool equivalent(
const FrameworkInfo& left,
const FrameworkInfo& right);
139 inline bool operator==(
const OfferID& left,
const OfferID& right)
141 return left.value() == right.value();
145 inline bool operator==(
const OperationID& left,
const OperationID& right)
147 return left.value() == right.value();
152 const ResourceProviderID& left,
153 const ResourceProviderID& right)
155 return left.value() == right.value();
159 inline bool operator==(
const SlaveID& left,
const SlaveID& right)
161 return left.value() == right.value();
165 inline bool operator==(
const TaskID& left,
const TaskID& right)
167 return left.value() == right.value();
171 inline bool operator==(
const TimeInfo& left,
const TimeInfo& right)
173 return left.nanoseconds() == right.nanoseconds();
177 inline bool operator==(
const DurationInfo& left,
const DurationInfo& right)
179 return left.nanoseconds() == right.nanoseconds();
183 inline bool operator==(
const ContainerID& left,
const std::string& right)
185 return left.value() == right;
189 inline bool operator==(
const ExecutorID& left,
const std::string& right)
191 return left.value() == right;
195 inline bool operator==(
const FrameworkID& left,
const std::string& right)
197 return left.value() == right;
201 inline bool operator==(
const OfferID& left,
const std::string& right)
203 return left.value() == right;
207 inline bool operator==(
const SlaveID& left,
const std::string& right)
209 return left.value() == right;
213 inline bool operator==(
const TaskID& left,
const std::string& right)
215 return left.value() == right;
220 const DomainInfo::FaultDomain::RegionInfo& left,
221 const DomainInfo::FaultDomain::RegionInfo& right)
223 return left.name() == right.name();
228 const DomainInfo::FaultDomain::ZoneInfo& left,
229 const DomainInfo::FaultDomain::ZoneInfo& right)
231 return left.name() == right.name();
236 const DomainInfo::FaultDomain& left,
237 const DomainInfo::FaultDomain& right)
239 return left.region() == right.region() && left.zone() == right.zone();
243 inline bool operator==(
const DomainInfo& left,
const DomainInfo& right)
245 return left.fault_domain() == right.fault_domain();
249 inline bool operator==(
const DrainInfo& left,
const DrainInfo& right)
251 return google::protobuf::util::MessageDifferencer::Equals(left, right);
255 inline bool operator==(
const DrainConfig& left,
const DrainConfig& right)
257 return google::protobuf::util::MessageDifferencer::Equals(left, right);
265 inline bool operator==(
const MachineID& left,
const MachineID& right)
269 return left.has_hostname() == right.has_hostname() &&
271 left.has_ip() == right.has_ip() &&
272 left.ip() == right.ip();
276 inline bool operator!=(
const ContainerID& left,
const ContainerID& right)
278 return !(left == right);
283 const CSIPluginContainerInfo& left,
284 const CSIPluginContainerInfo& right)
286 return !(left == right);
290 inline bool operator!=(
const ExecutorID& left,
const ExecutorID& right)
292 return left.value() != right.value();
296 inline bool operator!=(
const FrameworkID& left,
const FrameworkID& right)
298 return left.value() != right.value();
302 inline bool operator!=(
const OperationID& left,
const OperationID& right)
304 return left.value() != right.value();
309 const ResourceProviderID& left,
310 const ResourceProviderID& right)
312 return left.value() != right.value();
316 inline bool operator!=(
const SlaveID& left,
const SlaveID& right)
318 return left.value() != right.value();
323 const ResourceProviderInfo& left,
324 const ResourceProviderInfo& right)
326 return !(left == right);
330 inline bool operator!=(
const TimeInfo& left,
const TimeInfo& right)
332 return !(left == right);
338 return !(left == right);
342 inline bool operator!=(
const DurationInfo& left,
const DurationInfo& right)
344 return !(left == right);
349 const DomainInfo::FaultDomain::RegionInfo& left,
350 const DomainInfo::FaultDomain::RegionInfo& right)
352 return left.name() != right.name();
356 inline bool operator<(
const ContainerID& left,
const ContainerID& right)
358 return left.value() < right.value();
362 inline bool operator<(
const DurationInfo& left,
const DurationInfo& right)
364 return left.nanoseconds() < right.nanoseconds();
368 inline bool operator<(
const ExecutorID& left,
const ExecutorID& right)
370 return left.value() < right.value();
374 inline bool operator<(
const FrameworkID& left,
const FrameworkID& right)
376 return left.value() < right.value();
380 inline bool operator<(
const OfferID& left,
const OfferID& right)
382 return left.value() < right.value();
386 inline bool operator<(
const SlaveID& left,
const SlaveID& right)
388 return left.value() < right.value();
392 inline bool operator<(
const TaskID& left,
const TaskID& right)
394 return left.value() < right.value();
399 std::ostream& stream,
400 const CapabilityInfo& capabilityInfo);
404 std::ostream& stream,
405 const DeviceWhitelist& deviceWhitelist);
409 std::ostream& stream,
410 const CheckStatusInfo& checkStatusInfo);
413 std::ostream&
operator<<(std::ostream& stream,
const CommandInfo& commandInfo);
416 std::ostream&
operator<<(std::ostream& stream,
const ContainerID& containerId);
420 std::ostream& stream,
421 const ContainerInfo& containerInfo);
424 std::ostream&
operator<<(std::ostream& stream,
const DomainInfo& domainInfo);
427 std::ostream&
operator<<(std::ostream& stream,
const DrainConfig& drainConfig);
430 std::ostream&
operator<<(std::ostream& stream,
const DrainState& state);
436 std::ostream&
operator<<(std::ostream& stream,
const ExecutorID& executorId);
439 std::ostream&
operator<<(std::ostream& stream,
const ExecutorInfo& executor);
442 std::ostream&
operator<<(std::ostream& stream,
const FrameworkID& frameworkId);
448 std::ostream&
operator<<(std::ostream& stream,
const OfferID& offerId);
451 std::ostream&
operator<<(std::ostream& stream,
const OperationID& operationId);
454 std::ostream&
operator<<(std::ostream& stream,
const OperationState& state);
460 std::ostream&
operator<<(std::ostream& stream,
const RateLimits& limits);
464 std::ostream& stream,
465 const ResourceProviderID& resourceProviderId);
469 std::ostream& stream,
470 const ResourceProviderInfo& resourceProviderInfo);
473 std::ostream&
operator<<(std::ostream& stream,
const RLimitInfo& rlimitInfo);
476 std::ostream&
operator<<(std::ostream& stream,
const SlaveID& slaveId);
479 std::ostream&
operator<<(std::ostream& stream,
const SlaveInfo& slave);
482 std::ostream&
operator<<(std::ostream& stream,
const TaskID& taskId);
485 std::ostream&
operator<<(std::ostream& stream,
const MachineID& machineId);
488 std::ostream&
operator<<(std::ostream& stream,
const TaskInfo& task);
491 std::ostream&
operator<<(std::ostream& stream,
const TaskState& state);
495 std::ostream& stream,
503 std::ostream& stream,
508 std::ostream& stream,
519 std::ostream& stream,
524 std::ostream& stream,
528 template <
typename T>
530 std::ostream& stream,
531 const std::vector<T>& messages)
534 for (
auto it = messages.begin(); it != messages.end(); ++it) {
535 if (it != messages.begin()) {
555 template <
typename Key,
typename Value>
557 const Map<Key, Value>& left,
const Map<Key, Value>& right)
559 if (left.size() != right.size()) {
563 for (
auto it = left.begin(); it != left.end(); ++it) {
564 auto found = right.find(it->first);
565 if (found == right.end() || found->second != it->second) {
574 template <
typename Key,
typename Value>
576 const Map<Key, Value>& left,
const Map<Key, Value>& right)
578 return !(left == right);
582 template <
typename Key,
typename Value>
584 std::ostream& stream,
const Map<Key, Value>&
map)
587 for (
auto it = map.cbegin(); it != map.end(); ++it) {
588 if (it != map.cbegin()) {
591 stream << it->first <<
": " << it->second;
599 template <
typename T>
601 std::ostream& stream,
602 const RepeatedPtrField<T>& messages)
605 for (
auto it = messages.begin(); it != messages.end(); ++it) {
606 if (it != messages.begin()) {
622 struct hash<
mesos::CommandInfo::URI>
636 if (uri.executable()) {
640 boost::hash_combine(seed, uri.value());
641 boost::hash_combine(seed, uri.output_file());
654 result_type
operator()(
const argument_type& containerId)
const 657 boost::hash_combine(seed, containerId.value());
659 if (containerId.has_parent()) {
677 result_type
operator()(
const argument_type& executorId)
const 680 boost::hash_combine(seed, executorId.value());
693 result_type
operator()(
const argument_type& frameworkId)
const 696 boost::hash_combine(seed, frameworkId.value());
712 return static_cast<size_t>(imageType);
728 boost::hash_combine(seed, machineId.ip());
744 boost::hash_combine(seed, offerId.value());
757 result_type
operator()(
const argument_type& operationId)
const 760 boost::hash_combine(seed, operationId.value());
767 struct hash<
mesos::ResourceProviderID>
773 result_type
operator()(
const argument_type& resourceProviderId)
const 776 boost::hash_combine(seed, resourceProviderId.value());
792 boost::hash_combine(seed, slaveId.value());
808 boost::hash_combine(seed, taskId.value());
824 return static_cast<size_t>(taskState);
830 struct hash<
mesos::TaskStatus_Source>
839 return static_cast<size_t>(source);
845 struct hash<
mesos::TaskStatus_Reason>
854 return static_cast<size_t>(reason);
869 boost::hash_combine(seed, uuid.value());
876 struct hash<
std::pair<mesos::FrameworkID, mesos::ExecutorID>>
894 struct hash<
std::pair<mesos::FrameworkID, mesos::OperationID>>
912 #endif // __MESOS_TYPE_UTILS_H__ std::ostream & operator<<(std::ostream &stream, const Attribute &attribute)
size_t result_type
Definition: type_utils.hpp:896
size_t result_type
Definition: type_utils.hpp:862
Definition: type_utils.hpp:687
mesos::MachineID argument_type
Definition: type_utils.hpp:722
result_type operator()(const argument_type &executorId) const
Definition: type_utils.hpp:677
size_t result_type
Definition: type_utils.hpp:673
Definition: master.hpp:27
result_type operator()(const argument_type &containerId) const
Definition: type_utils.hpp:654
mesos::Image::Type argument_type
Definition: type_utils.hpp:707
result_type operator()(const argument_type &slaveId) const
Definition: type_utils.hpp:789
result_type operator()(const argument_type &uri) const
Definition: type_utils.hpp:628
size_t result_type
Definition: type_utils.hpp:801
result_type operator()(const argument_type &resourceProviderId) const
Definition: type_utils.hpp:773
result_type operator()(const argument_type &pair) const
Definition: type_utils.hpp:901
mesos::TaskStatus_Source argument_type
Definition: type_utils.hpp:834
bool operator==(const Resource::ReservationInfo &left, const Resource::ReservationInfo &right)
Definition: type_utils.hpp:619
result_type operator()(const argument_type &offerId) const
Definition: type_utils.hpp:741
mesos::TaskState argument_type
Definition: type_utils.hpp:819
mesos::ContainerID argument_type
Definition: type_utils.hpp:652
Capability
Definition: capabilities.hpp:35
result_type operator()(const argument_type &reason) const
Definition: type_utils.hpp:851
Operation
Definition: cgroups.hpp:444
result_type operator()(const argument_type &machineId) const
Definition: type_utils.hpp:724
size_t result_type
Definition: type_utils.hpp:720
bool operator<(const ContainerID &left, const ContainerID &right)
Definition: type_utils.hpp:356
mesos::TaskID argument_type
Definition: type_utils.hpp:803
size_t result_type
Definition: type_utils.hpp:847
size_t result_type
Definition: type_utils.hpp:832
mesos::ResourceProviderID argument_type
Definition: type_utils.hpp:771
mesos::FrameworkID argument_type
Definition: type_utils.hpp:691
size_t result_type
Definition: type_utils.hpp:705
result_type operator()(const argument_type &source) const
Definition: type_utils.hpp:836
bool operator!=(const Resource::ReservationInfo &left, const Resource::ReservationInfo &right)
Environment * environment
mesos::UUID argument_type
Definition: type_utils.hpp:864
Option< std::string > diff(const FrameworkInfo &left, const FrameworkInfo &right)
result_type operator()(const argument_type &uuid) const
Definition: type_utils.hpp:866
size_t result_type
Definition: type_utils.hpp:737
size_t result_type
Definition: type_utils.hpp:817
size_t result_type
Definition: type_utils.hpp:624
Definition: protobuf.hpp:61
size_t result_type
Definition: type_utils.hpp:753
result_type operator()(const argument_type &taskId) const
Definition: type_utils.hpp:805
std::pair< mesos::FrameworkID, mesos::ExecutorID > argument_type
Definition: type_utils.hpp:881
result_type operator()(const argument_type &frameworkId) const
Definition: type_utils.hpp:693
Iterable< V > map(F &&f, const Iterable< U, Us... > &input)
Definition: lambda.hpp:46
bool equivalent(const FrameworkInfo &left, const FrameworkInfo &right)
result_type operator()(const argument_type &pair) const
Definition: type_utils.hpp:883
Type
Definition: capabilities.hpp:82
CSIPluginContainerInfo::Service Service
Definition: service_manager.hpp:38
std::pair< mesos::FrameworkID, mesos::OperationID > argument_type
Definition: type_utils.hpp:899
mesos::CommandInfo::URI argument_type
Definition: type_utils.hpp:626
Try< uint32_t > type(const std::string &path)
Definition: type_utils.hpp:648
size_t result_type
Definition: type_utils.hpp:650
Type utilities for the protobuf library that are not specific to particular protobuf classes...
Definition: type_utils.hpp:552
mesos::ExecutorID argument_type
Definition: type_utils.hpp:675
result_type operator()(const argument_type &imageType) const
Definition: type_utils.hpp:709
size_t result_type
Definition: type_utils.hpp:785
mesos::SlaveID argument_type
Definition: type_utils.hpp:787
mesos::TaskStatus_Reason argument_type
Definition: type_utils.hpp:849
size_t result_type
Definition: type_utils.hpp:878
std::string lower(const std::string &s)
Definition: strings.hpp:429
Definition: type_utils.hpp:751
mesos::OperationID argument_type
Definition: type_utils.hpp:755
mesos::OfferID argument_type
Definition: type_utils.hpp:739
size_t result_type
Definition: type_utils.hpp:769
result_type operator()(const argument_type &operationId) const
Definition: type_utils.hpp:757
Definition: type_utils.hpp:671
size_t result_type
Definition: type_utils.hpp:689
result_type operator()(const argument_type &taskState) const
Definition: type_utils.hpp:821