17 #ifndef __MASTER_HPP__
18 #define __MASTER_HPP__
28 #include <boost/circular_buffer.hpp>
112 struct BoundedRateLimiter;
122 const MachineID& _machineId,
123 const std::string& _version,
124 std::vector<SlaveInfo::Capability> _capabilites,
126 std::vector<Resource> _checkpointedResources,
128 std::vector<ExecutorInfo> executorInfos = std::vector<ExecutorInfo>(),
129 std::vector<Task>
tasks = std::vector<Task>());
134 const FrameworkID& frameworkId,
135 const TaskID& taskId)
const;
166 const FrameworkID& frameworkId,
167 const ExecutorID& executorId)
const;
170 const FrameworkID& frameworkId,
171 const ExecutorInfo& executorInfo);
174 const FrameworkID& frameworkId,
175 const ExecutorID& executorId);
177 void apply(
const std::vector<ResourceConversion>& conversions);
180 const SlaveInfo&
info,
181 const std::string& _version,
182 const std::vector<SlaveInfo::Capability>& _capabilites,
292 return stream << slave.
id <<
" at " << slave.
pid
293 <<
" (" << slave.
info.hostname() <<
")";
310 template <
typename Message,
typename Event = v1::scheduler::Event>
311 bool send(
const Message& message)
341 template <
typename Message,
typename Event>
346 const Message& _heartbeatMessage,
351 logMessage(_logMessage),
352 heartbeatMessage(_heartbeatMessage),
375 VLOG(2) <<
"Sending heartbeat to " << logMessage;
377 Message
message(heartbeatMessage);
381 process::delay(interval,
this, &Heartbeater<Message, Event>::heartbeat);
384 const std::string logMessage;
385 const Message heartbeatMessage;
401 const Option<std::shared_ptr<process::RateLimiter>>&
409 const std::string&
name);
413 const FrameworkInfo& frameworkInfo);
417 const FrameworkInfo& frameworkInfo,
422 const FrameworkID& frameworkId);
426 const FrameworkID& frameworkId);
431 const FrameworkID& frameworkId,
432 const std::vector<Request>& requests);
436 const FrameworkID& frameworkId,
437 const std::vector<TaskInfo>& tasks,
439 const std::vector<OfferID>& offerIds);
443 const FrameworkID& frameworkId,
444 const std::vector<std::string>& role);
448 const FrameworkID& frameworkId,
449 const TaskID& taskId);
453 const SlaveID& slaveId,
454 const FrameworkID& frameworkId,
455 const TaskID& taskId,
456 const std::string& uuid);
460 const SlaveID& slaveId,
461 const FrameworkID& frameworkId,
462 const ExecutorID& executorId,
463 const std::string& data);
467 const SlaveID& slaveId,
468 const FrameworkID& frameworkId,
469 const ExecutorID& executorId,
470 const std::string& data);
474 RegisterSlaveMessage&& registerSlaveMessage);
478 ReregisterSlaveMessage&& incomingMessage);
482 const SlaveID& slaveId);
490 const FrameworkID& frameworkId,
491 const std::vector<TaskStatus>&
statuses);
494 const UpdateOperationStatusMessage& update);
498 const SlaveID& slaveId,
499 const FrameworkID& frameworkId,
500 const ExecutorID& executorId,
506 const MachineID& machineId,
522 const SlaveInfo& slave,
523 bool duringMasterFailover,
524 const std::string& message);
536 const FrameworkID& frameworkId,
540 const FrameworkID& frameworkId,
544 const FrameworkID& frameworkId,
606 RegisterSlaveMessage&& registerSlaveMessage,
612 RegisterSlaveMessage&& registerSlaveMessage,
617 ReregisterSlaveMessage&& incomingMessage,
623 ReregisterSlaveMessage&& incomingMessage,
628 ReregisterSlaveMessage&& incomingMessage,
633 const std::vector<FrameworkInfo>& frameworks);
643 const std::string& path);
652 const std::vector<TaskStatus>& statuses);
660 const std::vector<ExecutorInfo>& executors,
661 const std::vector<Task>& tasks);
666 const std::set<std::string>& suppressedRoles);
674 const FrameworkInfo&
info,
675 const std::set<std::string>& suppressedRoles);
683 const FrameworkInfo& frameworkInfo,
686 const std::set<std::string>& suppressedRoles);
708 const FrameworkInfo& frameworkInfo,
709 const std::set<std::string>& suppressedRoles);
720 std::vector<Archive::Framework>&& completedFrameworks);
723 const SlaveInfo& slave,
724 const TimeInfo& unreachableTime,
725 bool duringMasterFailover,
726 const std::string& message,
727 bool registrarResult);
736 const std::string& message,
742 const std::string& removalCause,
747 const std::string& message,
752 const FrameworkInfo& frameworkInfo,
758 const FrameworkInfo& frameworkInfo);
763 const SlaveInfo& slaveInfo,
769 const TaskInfo& task,
790 const Offer::Operation::Reserve& reserve,
817 const Offer::Operation::Unreserve& unreserve,
838 const Offer::Operation::Create&
create,
859 const Offer::Operation::Destroy&
destroy,
870 void updateTask(Task* task,
const StatusUpdate& update);
876 void removeTask(Task* task,
bool unreachable =
false);
881 const FrameworkID& frameworkId,
882 const ExecutorID& executorId);
896 const UpdateOperationStatusMessage& update,
897 bool convertResources =
true);
913 const StatusUpdate& update,
921 void removeOffer(Offer* offer,
bool rescind =
false);
932 Offer*
getOffer(
const OfferID& offerId)
const;
953 const std::string& message);
958 const std::string& message);
963 const std::string& message);
967 const scheduler::Call::Suppress& suppress,
968 const std::string& message);
972 const scheduler::Call::Revive& revive,
973 const std::string& message);
982 const scheduler::Call::Subscribe& subscribe);
986 const FrameworkInfo& frameworkInfo,
988 const std::set<std::string>& suppressedRoles,
993 const scheduler::Call::Subscribe& subscribe);
997 const FrameworkInfo& frameworkInfo,
999 const std::set<std::string>& suppressedRoles,
1011 scheduler::Call::Accept accept);
1014 const FrameworkID& frameworkId,
1015 const SlaveID& slaveId,
1017 const scheduler::Call::Accept& accept,
1020 void acceptInverseOffers(
1022 const scheduler::Call::AcceptInverseOffers& accept);
1026 const scheduler::Call::Decline& decline);
1028 void declineInverseOffers(
1030 const scheduler::Call::DeclineInverseOffers& decline);
1034 const scheduler::Call::Revive& revive);
1038 const scheduler::Call::Kill& kill);
1042 const scheduler::Call::Shutdown& shutdown);
1046 const scheduler::Call::Acknowledge& acknowledge);
1048 void acknowledgeOperationStatus(
1050 const scheduler::Call::AcknowledgeOperationStatus& acknowledge);
1054 const scheduler::Call::Reconcile& reconcile);
1056 void reconcileOperations(
1058 const scheduler::Call::ReconcileOperations& reconcile);
1062 const scheduler::Call::Message& message);
1066 const scheduler::Call::Request& request);
1070 const scheduler::Call::Suppress& suppress);
1072 bool elected()
const
1074 return leader.
isSome() && leader.
get() == info_;
1077 void scheduleRegistryGc();
1079 void doRegistryGc();
1096 bool isWhitelistedRole(
const std::string& name)
const;
1108 explicit QuotaHandler(
Master* _master) : master(_master)
1110 CHECK_NOTNULL(master);
1165 const mesos::quota::QuotaInfo& request)
const;
1187 void rescindOffers(
const mesos::quota::QuotaInfo& request)
const;
1191 const mesos::quota::QuotaInfo&
quotaInfo)
const;
1195 const mesos::quota::QuotaInfo&
quotaInfo)
const;
1202 const mesos::quota::QuotaRequest& quotaRequest,
1207 const mesos::quota::QuotaInfo&
quotaInfo,
1211 const std::string& role,
1216 const std::string& role)
const;
1231 class WeightsHandler
1234 explicit WeightsHandler(
Master* _master) : master(_master)
1236 CHECK_NOTNULL(master);
1262 const WeightInfo& weight)
const;
1266 const std::vector<std::string>& roles)
const;
1269 const std::vector<WeightInfo>& weightInfos,
1270 const std::list<bool>& roleAuthorizations)
const;
1278 const google::protobuf::RepeatedPtrField<WeightInfo>& weightInfos)
1282 const std::vector<WeightInfo>& weightInfos)
const;
1286 void rescindOffers(
const std::vector<WeightInfo>& weightInfos)
const;
1296 explicit Http(
Master* _master) : master(_master),
1297 quotaHandler(_master),
1298 weightsHandler(_master) {}
1428 static std::string API_HELP();
1429 static std::string SCHEDULER_HELP();
1430 static std::string FLAGS_HELP();
1431 static std::string FRAMEWORKS_HELP();
1432 static std::string HEALTH_HELP();
1433 static std::string REDIRECT_HELP();
1434 static std::string ROLES_HELP();
1435 static std::string TEARDOWN_HELP();
1436 static std::string SLAVES_HELP();
1437 static std::string STATE_HELP();
1438 static std::string STATESUMMARY_HELP();
1439 static std::string TASKS_HELP();
1440 static std::string MAINTENANCE_SCHEDULE_HELP();
1441 static std::string MAINTENANCE_STATUS_HELP();
1442 static std::string MACHINE_DOWN_HELP();
1443 static std::string MACHINE_UP_HELP();
1444 static std::string CREATE_VOLUMES_HELP();
1445 static std::string DESTROY_VOLUMES_HELP();
1446 static std::string RESERVE_HELP();
1447 static std::string UNRESERVE_HELP();
1448 static std::string QUOTA_HELP();
1449 static std::string WEIGHTS_HELP();
1462 const size_t offset,
1463 const std::string& order,
1468 const FrameworkID&
id,
1473 const FrameworkID&
id)
const;
1476 const mesos::maintenance::Schedule&
schedule,
1481 const mesos::maintenance::Schedule&
schedule,
1485 const mesos::maintenance::Schedule&
schedule,
1486 bool applied)
const;
1488 mesos::maintenance::Schedule _getMaintenanceSchedule(
1495 const google::protobuf::RepeatedPtrField<MachineID>& machineIds,
1499 const google::protobuf::RepeatedPtrField<MachineID>& machineIds,
1503 const SlaveID& slaveId,
1504 const google::protobuf::RepeatedPtrField<Resource>& resources,
1509 const SlaveID& slaveId,
1510 const google::protobuf::RepeatedPtrField<Resource>& resources,
1515 const SlaveID& slaveId,
1516 const google::protobuf::RepeatedPtrField<Resource>& volumes,
1521 const SlaveID& slaveId,
1522 const google::protobuf::RepeatedPtrField<Resource>& volumes,
1546 const SlaveID& slaveId,
1561 mesos::master::Response::GetAgents _getAgents(
1639 mesos::master::Response::GetTasks _getTasks(
1668 mesos::master::Response::GetFrameworks _getFrameworks(
1676 mesos::master::Response::GetExecutors _getExecutors(
1685 mesos::master::Response::GetState _getState(
1712 const SlaveID& slaveId)
const;
1718 QuotaHandler quotaHandler;
1722 WeightsHandler weightsHandler;
1737 Master* master,
const OfferID& offerId);
1740 Master* master,
const OfferID& offerId);
1743 Master* master,
const SlaveID& slaveId);
1771 std::list<mesos::maintenance::Schedule> schedules;
1815 bool contains(
const SlaveID& slaveId)
const
1817 return ids.contains(slaveId);
1822 return pids.contains(pid);
1825 Slave*
get(
const SlaveID& slaveId)
const
1827 return ids.get(slaveId).getOrElse(
nullptr);
1832 return pids.get(pid).getOrElse(
nullptr);
1835 void put(
Slave* slave)
1837 CHECK_NOTNULL(slave);
1838 ids[slave->id] = slave;
1839 pids[slave->pid] = slave;
1842 void remove(
Slave* slave)
1844 CHECK_NOTNULL(slave);
1845 ids.erase(slave->
id);
1855 size_t size()
const {
return ids.size(); }
1860 iterator begin() {
return ids.begin(); }
1861 iterator end() {
return ids.end(); }
1863 const_iterator begin()
const {
return ids.begin(); }
1864 const_iterator end()
const {
return ids.end(); }
1918 Frameworks(
const Flags& masterFlags)
1919 : completed(masterFlags.max_completed_frameworks) {}
1948 Subscribers(
Master* _master) : master(_master) {};
1963 event.set_type(mesos::master::Event::HEARTBEAT);
2024 Subscribers subscribers;
2051 std::vector<std::string> authenticatorNames;
2064 int64_t nextFrameworkId;
2065 int64_t nextOfferId;
2066 int64_t nextSlaveId;
2072 std::shared_ptr<Metrics> metrics;
2075 double _uptime_secs()
2082 return elected() ? 1 : 0;
2085 double _slaves_connected();
2086 double _slaves_disconnected();
2087 double _slaves_active();
2088 double _slaves_inactive();
2089 double _slaves_unreachable();
2091 double _frameworks_connected();
2092 double _frameworks_disconnected();
2093 double _frameworks_active();
2094 double _frameworks_inactive();
2096 double _outstanding_offers()
2098 return static_cast<double>(offers.size());
2101 double _event_queue_messages()
2103 return static_cast<double>(eventCount<process::MessageEvent>());
2106 double _event_queue_dispatches()
2108 return static_cast<double>(eventCount<process::DispatchEvent>());
2111 double _event_queue_http_requests()
2113 return static_cast<double>(eventCount<process::HttpEvent>());
2116 double _tasks_staging();
2117 double _tasks_starting();
2118 double _tasks_running();
2119 double _tasks_unreachable();
2120 double _tasks_killing();
2122 double _resources_total(
const std::string& name);
2123 double _resources_used(
const std::string& name);
2124 double _resources_percent(
const std::string& name);
2126 double _resources_revocable_total(
const std::string& name);
2127 double _resources_revocable_used(
const std::string& name);
2128 double _resources_revocable_percent(
const std::string& name);
2139 const FrameworkInfo& frameworkInfo,
2145 std::ostream& stream,
2146 const Framework& framework);
2174 const Flags& masterFlags,
2175 const FrameworkInfo&
info,
2184 const Flags& masterFlags,
2185 const FrameworkInfo& info,
2194 const Flags& masterFlags,
2195 const FrameworkInfo& info)
2200 if (
http.isSome()) {
2207 if (tasks.count(taskId) > 0) {
2208 return tasks[taskId];
2216 CHECK(!tasks.contains(task->task_id()))
2217 <<
"Duplicate task " << task->task_id()
2218 <<
" of framework " << task->framework_id();
2222 foreach (
const Resource& resource, task->resources()) {
2223 CHECK(resource.has_allocation_info());
2226 tasks[task->task_id()] = task;
2229 CHECK(task->state() != TASK_UNREACHABLE)
2230 <<
"Task '" << task->task_id() <<
"' of framework " <<
id()
2231 <<
" added in TASK_UNREACHABLE state";
2247 const Resources resources = task->resources();
2255 CHECK(!task->resources().empty());
2256 const std::string& role =
2257 task->resources().begin()->allocation_info().role();
2273 CHECK(tasks.contains(task->task_id()))
2274 <<
"Unknown task " << task->task_id()
2275 <<
" of framework " << task->framework_id();
2286 CHECK(!task->resources().empty());
2287 const std::string& role =
2288 task->resources().begin()->allocation_info().role();
2290 auto allocatedToRole = [&role](
const Resource& resource) {
2291 return resource.allocation_info().role() == role;
2294 if (
roles.count(role) == 0 &&
2302 template <
typename Message>
2306 LOG(WARNING) <<
"Master attempted to send message to disconnected"
2307 <<
" framework " << *
this;
2310 if (
http.isSome()) {
2311 if (!
http.get().send(message)) {
2312 LOG(WARNING) <<
"Unable to send event to framework " << *
this <<
":"
2313 <<
" connection closed";
2317 master->
send(pid.get(), message);
2343 CHECK(tasks.contains(task->task_id()))
2344 <<
"Unknown task " << task->task_id()
2345 <<
" of framework " << task->framework_id();
2350 task->state() != TASK_UNREACHABLE) {
2357 CHECK(task->state() != TASK_UNREACHABLE);
2364 tasks.erase(task->task_id());
2369 CHECK(!
offers.
contains(offer)) <<
"Duplicate offer " << offer->id();
2378 <<
"Unknown offer " << offer->id();
2392 <<
"Duplicate inverse offer " << inverseOffer->id();
2399 <<
"Unknown inverse offer " << inverseOffer->id();
2405 const ExecutorID& executorId)
2412 const ExecutorInfo& executorInfo)
2414 CHECK(!
hasExecutor(slaveId, executorInfo.executor_id()))
2415 <<
"Duplicate executor '" << executorInfo.executor_id()
2416 <<
"' on agent " << slaveId;
2420 foreach (
const Resource& resource, executorInfo.resources()) {
2421 CHECK(resource.has_allocation_info());
2424 executors[slaveId][executorInfo.executor_id()] = executorInfo;
2432 if (!executorInfo.resources().empty()) {
2433 const std::string& role =
2434 executorInfo.resources().begin()->allocation_info().role();
2443 const ExecutorID& executorId)
2446 <<
"Unknown executor '" << executorId
2447 <<
"' of framework " <<
id()
2448 <<
" of agent " << slaveId;
2450 const ExecutorInfo& executorInfo =
executors[slaveId][executorId];
2461 if (!executorInfo.resources().empty()) {
2462 const std::string& role =
2463 executorInfo.resources().begin()->allocation_info().role();
2465 auto allocatedToRole = [&role](
const Resource& resource) {
2466 return resource.allocation_info().role() == role;
2469 if (
roles.count(role) == 0 &&
2484 CHECK(operation->has_framework_id());
2486 const FrameworkID& frameworkId = operation->framework_id();
2492 <<
"Duplicate operation '" << operation->info().id()
2493 <<
"' (uuid: " << uuid->
toString() <<
") "
2494 <<
"of framework " << frameworkId;
2498 if (operation->info().has_id()) {
2508 CHECK(operation->has_slave_id())
2509 <<
"External resource provider is not supported yet";
2511 const SlaveID& slaveId = operation->slave_id();
2520 foreachkey (
const std::string& role, consumed->allocations()) {
2530 CHECK(operation->has_slave_id())
2531 <<
"External resource provider is not supported yet";
2533 const SlaveID& slaveId = operation->slave_id();
2543 <<
"Tried to recover resources " << consumed.
get()
2544 <<
" which do not seem used";
2547 <<
"Tried to recover resources " << consumed.
get() <<
" of agent "
2548 << slaveId <<
" which do not seem used";
2560 foreachkey (
const std::string& role, consumed->allocations()) {
2561 auto allocatedToRole = [&role](
const Resource& resource) {
2562 return resource.allocation_info().role() == role;
2565 if (
roles.count(role) == 0 &&
2579 <<
"Unknown operation '" << operation->info().id()
2580 <<
"' (uuid: " << uuid->
toString() <<
") "
2581 <<
"of framework " << operation->framework_id();
2591 const FrameworkID
id()
const {
return info.id(); }
2599 CHECK_EQ(info.id(), newInfo.id());
2602 std::set<std::string> oldRoles =
roles;
2610 if (newInfo.has_role()) {
2611 info.set_role(newInfo.role());
2614 if (newInfo.roles_size() > 0) {
2615 info.mutable_roles()->CopyFrom(newInfo.roles());
2620 if (newInfo.user() != info.user()) {
2621 LOG(WARNING) <<
"Cannot update FrameworkInfo.user to '" << newInfo.user()
2622 <<
"' for framework " <<
id() <<
". Check MESOS-703";
2625 info.set_name(newInfo.name());
2627 if (newInfo.has_failover_timeout()) {
2628 info.set_failover_timeout(newInfo.failover_timeout());
2630 info.clear_failover_timeout();
2633 if (newInfo.checkpoint() != info.checkpoint()) {
2634 LOG(WARNING) <<
"Cannot update FrameworkInfo.checkpoint to '"
2635 <<
stringify(newInfo.checkpoint()) <<
"' for framework "
2636 <<
id() <<
". Check MESOS-703";
2639 if (newInfo.has_hostname()) {
2640 info.set_hostname(newInfo.hostname());
2642 info.clear_hostname();
2645 if (newInfo.principal() != info.principal()) {
2646 LOG(WARNING) <<
"Cannot update FrameworkInfo.principal to '"
2647 << newInfo.principal() <<
"' for framework " <<
id()
2648 <<
". Check MESOS-703";
2651 if (newInfo.has_webui_url()) {
2652 info.set_webui_url(newInfo.webui_url());
2654 info.clear_webui_url();
2657 if (newInfo.capabilities_size() > 0) {
2658 info.mutable_capabilities()->CopyFrom(newInfo.capabilities());
2660 info.clear_capabilities();
2664 if (newInfo.has_labels()) {
2665 info.mutable_labels()->CopyFrom(newInfo.labels());
2667 info.clear_labels();
2670 const std::set<std::string>& newRoles =
roles;
2672 const std::set<std::string> removedRoles = [&]() {
2673 std::set<std::string> result = oldRoles;
2674 foreach (
const std::string& role, newRoles) {
2680 foreach (
const std::string& role, removedRoles) {
2681 auto allocatedToRole = [&role](
const Resource& resource) {
2682 return resource.allocation_info().role() == role;
2693 const std::set<std::string> addedRoles = [&]() {
2694 std::set<std::string> result = newRoles;
2695 foreach (
const std::string& role, oldRoles) {
2701 foreach (
const std::string& role, addedRoles) {
2715 if (
http.isSome()) {
2729 }
else if (
http.isSome()) {
2751 LOG(WARNING) <<
"Failed to close HTTP pipe for " << *
this;
2772 event.set_type(scheduler::Event::HEARTBEAT);
2890 const Flags& masterFlags,
2891 const FrameworkInfo& _info,
2900 reregisteredTime(time),
2904 foreach (
const std::string& role,
roles) {
2920 std::ostream& stream,
2925 stream << framework.
id() <<
" (" << framework.
info.name() <<
")";
2928 stream <<
" at " << framework.
pid.
get();
2940 Role(
const std::string& _role) : role(_role) {}
2956 auto allocatedTo = [](
const std::string&
role) {
2957 return [
role](
const Resource& resource) {
2958 CHECK(resource.has_allocation_info());
2959 return resource.allocation_info().role() ==
role;
2987 #endif // __MASTER_HPP__
void _consume(process::MessageEvent &&event)
void recoverFramework(const FrameworkInfo &info, const std::set< std::string > &suppressedRoles)
std::string generate(const std::string &prefix="")
Returns 'prefix(N)' where N represents the number of instances where the same prefix (wrt...
Try< Resources > getConsumedResources(const Offer::Operation &operation)
bool send(const Message &message)
Definition: master.hpp:311
Framework(Master *const master, const Flags &masterFlags, const FrameworkInfo &info, const process::UPID &_pid, const process::Time &time=process::Clock::now())
Definition: master.hpp:2173
void recoverResources(Operation *operation)
Definition: master.hpp:2528
Definition: nothing.hpp:16
hashmap< TaskID, Task * > tasks
Definition: master.hpp:2819
Definition: master.hpp:2936
Master *const master
Definition: master.hpp:2792
void removeOperation(Operation *operation)
ContentType
Definition: http.hpp:43
void removeExecutor(const FrameworkID &frameworkId, const ExecutorID &executorId)
Try< bool > update(const std::string &link, const Handle &parent, uint16_t protocol, const action::Mirror &mirror)
void _removeSlave(Slave *slave, const process::Future< bool > ®istrarResult, const std::string &removalCause, Option< process::metrics::Counter > reason=None())
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:100
FrameworkID newFrameworkId()
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
Subscriber(const HttpConnection &_http, const Option< process::http::authentication::Principal > _principal)
Definition: master.hpp:1956
ProcessBase(const std::string &id="")
void finalize() override
Invoked when a process is terminated.
void launchTasks(const process::UPID &from, const FrameworkID &frameworkId, const std::vector< TaskInfo > &tasks, const Filters &filters, const std::vector< OfferID > &offerIds)
SlaveInfo info
Definition: master.hpp:188
bool connected() const
Definition: master.hpp:2785
void removeSlave(Slave *slave, const std::string &message, Option< process::metrics::Counter > reason=None())
~Framework()
Definition: master.hpp:2198
Role(const std::string &_role)
Definition: master.hpp:2940
Slave(Master *const _master, SlaveInfo _info, const process::UPID &_pid, const MachineID &_machineId, const std::string &_version, std::vector< SlaveInfo::Capability > _capabilites, const process::Time &_registeredTime, std::vector< Resource > _checkpointedResources, const Option< id::UUID > &resourceVersion, std::vector< ExecutorInfo > executorInfos=std::vector< ExecutorInfo >(), std::vector< Task > tasks=std::vector< Task >())
const SlaveID id
Definition: master.hpp:187
void exceededCapacity(const process::MessageEvent &event, const Option< std::string > &principal, uint64_t capacity)
hashset< Offer * > offers
Definition: master.hpp:251
process::Future< Nothing > recover()
friend struct Subscriber
Definition: master.hpp:1732
Option< process::Timer > reregistrationTimer
Definition: master.hpp:217
bool connected
Definition: master.hpp:204
#define CHECK_NONE(expression)
Definition: check.hpp:48
void updateSlave(UpdateSlaveMessage &&message)
Task * getTask(const TaskID &taskId)
Definition: master.hpp:2205
Resources totalResources
Definition: master.hpp:277
void addFramework(Framework *framework, const std::set< std::string > &suppressedRoles)
constexpr Duration DEFAULT_HEARTBEAT_INTERVAL
Definition: constants.hpp:52
Definition: protobuf_utils.hpp:251
hashmap< SlaveID, Resources > offeredResources
Definition: master.hpp:2882
Definition: master.hpp:2170
protobuf::framework::Capabilities capabilities
Definition: master.hpp:2798
bool hasExecutor(const SlaveID &slaveId, const ExecutorID &executorId)
Definition: master.hpp:2404
std::set< std::string > getRoles(const FrameworkInfo &frameworkInfo)
void deactivateFramework(const process::UPID &from, const FrameworkID &frameworkId)
Try< Nothing > activateRecoveredFramework(Framework *framework, const FrameworkInfo &frameworkInfo, const Option< process::UPID > &pid, const Option< HttpConnection > &http, const std::set< std::string > &suppressedRoles)
Resources filter(const lambda::function< bool(const Resource &)> &predicate) const
v1::AgentID evolve(const SlaveID &slaveId)
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
InverseOffer * getInverseOffer(Master *master, const OfferID &offerId)
Try< Nothing > machines(const google::protobuf::RepeatedPtrField< MachineID > &ids)
Performs the following checks on a list of machines:
void addUnreachableTask(const Task &task)
Definition: master.hpp:2331
process::Future< bool > authorizeTask(const TaskInfo &task, Framework *framework)
void offer(const FrameworkID &frameworkId, const hashmap< std::string, hashmap< SlaveID, Resources >> &resources)
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2583
Definition: resources.hpp:79
Resources totalUsedResources
Definition: master.hpp:2874
void exited(const process::UPID &pid) override
Invoked when a linked process has exited.
Slave * getSlave(Master *master, const SlaveID &slaveId)
void _registerSlave(const process::UPID &pid, RegisterSlaveMessage &®isterSlaveMessage, const Option< process::http::authentication::Principal > &principal, const process::Future< bool > &authorized)
void removeExecutor(const SlaveID &slaveId, const ExecutorID &executorId)
Definition: master.hpp:2442
Option< HttpConnection > http
Definition: master.hpp:2804
bool contains(const Elem &elem) const
Definition: hashset.hpp:102
~Subscriber()
Definition: master.hpp:1996
void unregisterFramework(const process::UPID &from, const FrameworkID &frameworkId)
void update(const FrameworkInfo &newInfo)
Definition: master.hpp:2596
Definition: registrar.hpp:91
void addFramework(Framework *framework)
Definition: master.hpp:2942
void executorMessage(const process::UPID &from, const SlaveID &slaveId, const FrameworkID &frameworkId, const ExecutorID &executorId, const std::string &data)
void unregisterSlave(const process::UPID &from, const SlaveID &slaveId)
void addCompletedTask(Task &&task)
Definition: master.hpp:2321
void addOperation(Operation *operation)
Operation
Definition: cgroups.hpp:441
Future< Nothing > redirect(int_fd from, Option< int_fd > to, size_t chunk=4096, const std::vector< lambda::function< void(const std::string &)>> &hooks={})
Redirect output from the 'from' file descriptor to the 'to' file descriptor (or /dev/null if 'to' is ...
void updateConnection(const HttpConnection &newHttp)
Definition: master.hpp:2723
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
void __reregisterSlave(const process::UPID &pid, ReregisterSlaveMessage &&incomingMessage, const process::Future< bool > &readmit)
Framework(Master *const master, const Flags &masterFlags, const FrameworkInfo &info)
Definition: master.hpp:2193
Definition: duration.hpp:32
void removeOperation(Operation *operation)
Definition: master.hpp:2573
void killTask(const process::UPID &from, const FrameworkID &frameworkId, const TaskID &taskId)
void resourceRequest(const process::UPID &from, const FrameworkID &frameworkId, const std::vector< Request > &requests)
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
bool isPending() const
Definition: future.hpp:1224
Try< Nothing > update(const SlaveInfo &info, const std::string &_version, const std::vector< SlaveInfo::Capability > &_capabilites, const Resources &_checkpointedResources, const Option< id::UUID > &resourceVersion)
void lostCandidacy(const process::Future< Nothing > &lost)
void heartbeat()
Definition: master.hpp:2764
std::ostream & operator<<(std::ostream &stream, const Slave &slave)
Definition: master.hpp:290
void send(const process::UPID &to, const google::protobuf::Message &message)
Definition: protobuf.hpp:118
void removeInverseOffer(InverseOffer *inverseOffer, bool rescind=false)
void _exited(Framework *framework)
bool isSome() const
Definition: option.hpp:115
Definition: event.hpp:214
process::Future< Nothing > closed() const
Definition: master.hpp:324
Try< bool > set(const std::string &_link, unsigned int flags)
Definition: internal.hpp:125
void trackUnderRole(const std::string &role)
hashmap< FrameworkID, hashmap< TaskID, Task * > > tasks
Definition: master.hpp:240
void updateConnection(const process::UPID &newPid)
Definition: master.hpp:2711
void removeOffer(Offer *offer)
Definition: master.hpp:2375
void detected(const process::Future< Option< MasterInfo >> &_leader)
multihashmap< FrameworkID, TaskID > killedTasks
Definition: master.hpp:244
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2584
void __registerSlave(const process::UPID &pid, RegisterSlaveMessage &®isterSlaveMessage, const process::Future< bool > &admit)
Definition: master.hpp:2159
void registerSlave(const process::UPID &from, RegisterSlaveMessage &®isterSlaveMessage)
void updateUnavailability(const MachineID &machineId, const Option< Unavailability > &unavailability)
Task * getTask(const FrameworkID &frameworkId, const TaskID &taskId) const
Definition: hashmap.hpp:38
void failoverFramework(Framework *framework, const process::UPID &newPid)
process::Future< Nothing > _recover(const Registry ®istry)
hashmap< ResourceProviderID, ResourceProviderInfo > resourceProviders
Definition: master.hpp:282
void removeTask(Task *task, bool unreachable=false)
bool contains(const std::string &s, const std::string &substr)
Definition: strings.hpp:406
#define CHECK_SOME(expression)
Definition: check.hpp:44
hashmap< std::string, MessageHandler > message
Definition: process.hpp:443
Definition: master.hpp:299
bool active() const
Definition: master.hpp:2784
void exitedExecutor(const process::UPID &from, const SlaveID &slaveId, const FrameworkID &frameworkId, const ExecutorID &executorId, int32_t status)
Resources checkpointedResources
Definition: master.hpp:270
SlaveObserver * observer
Definition: master.hpp:279
bool isTerminalState(const TaskState &state)
void removeTask(Task *task)
Try< Nothing > unavailability(const Unavailability &unavailability)
An "untyped" PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
void addOffer(Offer *offer)
BoundedHashMap< TaskID, process::Owned< Task > > unreachableTasks
Definition: master.hpp:2832
Option< Error > validateFrameworkAuthentication(const FrameworkInfo &frameworkInfo, const process::UPID &from)
Definition: master.hpp:1954
process::Future< Nothing > removed(const std::string &link)
void markGone(Slave *slave, const TimeInfo &goneTime)
bool recovered() const
Definition: master.hpp:2786
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:776
process::Time registeredTime
Definition: master.hpp:200
bool active
Definition: master.hpp:209
hashmap< id::UUID, Operation * > operations
Definition: master.hpp:2845
An abstraction for contending to be a leading master.
Definition: contender.hpp:40
std::set< std::string > roles
Definition: master.hpp:2796
void reregisterSlave(const process::UPID &from, ReregisterSlaveMessage &&incomingMessage)
process::UPID pid
Definition: master.hpp:192
process::Future< Nothing > apply(Slave *slave, const Offer::Operation &operation)
Definition: protobuf_utils.hpp:439
void addSlave(Slave *slave, std::vector< Archive::Framework > &&completedFrameworks)
process::http::Pipe::Writer writer
Definition: master.hpp:329
bool write(std::string s)
Option< process::Time > reregisteredTime
Definition: master.hpp:201
Future< Nothing > readerClosed() const
void apply(const std::vector< ResourceConversion > &conversions)
void consume(process::MessageEvent &&event) override
process::Time reregisteredTime
Definition: master.hpp:2810
Master *const master
Definition: master.hpp:186
friend struct SlavesWriter
Definition: master.hpp:1731
void addOffer(Offer *offer)
Definition: master.hpp:2367
Timer delay(const Duration &duration, const PID< T > &pid, void(T::*method)())
Definition: delay.hpp:31
void put(const Key &key, const Value &value)
Definition: hashmap.hpp:104
void disconnect(Framework *framework)
Option< Error > quotaInfo(const mesos::quota::QuotaInfo "aInfo)
const T & get() const &
Definition: option.hpp:118
void removeExecutor(Slave *slave, const FrameworkID &frameworkId, const ExecutorID &executorId)
const std::string role
Definition: master.hpp:2971
Framework(Master *const master, const Flags &masterFlags, const FrameworkInfo &info, const HttpConnection &_http, const process::Time &time=process::Clock::now())
Definition: master.hpp:2183
void removeOffer(Offer *offer, bool rescind=false)
process::Future< bool > authorizeDestroyVolume(const Offer::Operation::Destroy &destroy, const Option< process::http::authentication::Principal > &principal)
Authorizes a DESTROY operation.
void updateSlaveFrameworks(Slave *slave, const std::vector< FrameworkInfo > &frameworks)
Definition: protobuf.hpp:100
process::Time registeredTime
Definition: master.hpp:2809
process::Future< Nothing > destroy(const std::string &hierarchy, const std::string &cgroup="/")
#define foreachvalue(VALUE, ELEMS)
Definition: foreach.hpp:77
bool isTrackedUnderRole(const std::string &role) const
void removeInverseOffer(InverseOffer *inverseOffer)
Definition: master.hpp:2396
void addExecutor(const FrameworkID &frameworkId, const ExecutorInfo &executorInfo)
Operation * getOperation(const id::UUID &uuid) const
Definition: whitelist_watcher.hpp:37
void removeFramework(Framework *framework)
Definition: master.hpp:2947
MasterInfo info() const
Definition: master.hpp:559
void inverseOfferTimeout(const OfferID &inverseOfferId)
bool isCompletedFramework(const FrameworkID &frameworkId)
hashmap< Option< ResourceProviderID >, id::UUID > resourceVersions
Definition: master.hpp:281
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
void offerTimeout(const OfferID &offerId)
void schedulerMessage(const process::UPID &from, const SlaveID &slaveId, const FrameworkID &frameworkId, const ExecutorID &executorId, const std::string &data)
virtual void initialize() override
Invoked when a process gets spawned.
Definition: master.hpp:358
FrameworkInfo info
Definition: master.hpp:2794
ContentType contentType
Definition: master.hpp:330
void statusUpdateAcknowledgement(const process::UPID &from, const SlaveID &slaveId, const FrameworkID &frameworkId, const TaskID &taskId, const std::string &uuid)
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
void initialize() override
Invoked when a process gets spawned.
id::UUID streamId
Definition: master.hpp:331
HttpConnection http
Definition: master.hpp:2008
void send(const Message &message)
Definition: master.hpp:2303
Definition: boundedhashmap.hpp:27
Basic model of an allocator: resources are allocated to a framework in the form of offers...
Definition: allocator.hpp:55
void _markUnreachable(const SlaveInfo &slave, const TimeInfo &unreachableTime, bool duringMasterFailover, const std::string &message, bool registrarResult)
void removeInverseOffer(InverseOffer *inverseOffer)
void agentReregisterTimeout(const SlaveID &slaveId)
void registerFramework(const process::UPID &from, const FrameworkInfo &frameworkInfo)
Offer * getOffer(const OfferID &offerId) const
void send(const process::Shared< mesos::master::Event > &event, const process::Owned< AuthorizationAcceptor > &authorizeRole, const process::Owned< AuthorizationAcceptor > &authorizeFramework, const process::Owned< AuthorizationAcceptor > &authorizeTask, const process::Owned< AuthorizationAcceptor > &authorizeExecutor, const Option< process::Shared< FrameworkInfo >> &frameworkInfo, const Option< process::Shared< Task >> &task)
void recoverResources(Task *task)
Definition: master.hpp:2271
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
#define flags
Definition: decoder.hpp:18
process::Future< bool > markUnreachable(const SlaveInfo &slave, bool duringMasterFailover, const std::string &message)
bool empty() const
Definition: resources.hpp:388
Resources addTask(const TaskInfo &task, Framework *framework, Slave *slave)
void contended(const process::Future< process::Future< Nothing >> &candidacy)
InverseOffer * getInverseOffer(const OfferID &inverseOfferId) const
friend void * schedule(void *)
Definition: master.hpp:2166
static Try< UUID > fromBytes(const std::string &s)
Definition: uuid.hpp:49
void updateOperation(Operation *operation, const UpdateOperationStatusMessage &update, bool convertResources=true)
hashset< InverseOffer * > inverseOffers
Definition: master.hpp:2836
void updateTask(Task *task, const StatusUpdate &update)
void removeTask(Task *task, bool unreachable)
Definition: master.hpp:2341
Definition: master.hpp:2163
friend struct Slave
Definition: master.hpp:1730
void updateFramework(Framework *framework, const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles)
Object protobuf(const google::protobuf::Message &message)
Definition: protobuf.hpp:836
void addInverseOffer(InverseOffer *inverseOffer)
void _failoverFramework(Framework *framework)
const MachineID machineId
Definition: master.hpp:190
void set(const Key &key, const Value &value)
Definition: boundedhashmap.hpp:39
void frameworkFailoverTimeout(const FrameworkID &frameworkId, const process::Time &reregisteredTime)
void ___reregisterSlave(const process::UPID &pid, ReregisterSlaveMessage &&incomingMessage, const process::Future< bool > &updated)
hashmap< OperationID, id::UUID > operationUUIDs
Definition: master.hpp:2849
void reregisterFramework(const process::UPID &from, const FrameworkInfo &frameworkInfo, bool failover)
boost::circular_buffer< process::Owned< Task > > completedTasks
Definition: master.hpp:2826
Definition: master.hpp:117
hashmap< uint16_t, std::string > * statuses
Resources allocatedResources() const
Definition: master.hpp:2952
#define foreachkey(KEY, ELEMS)
Definition: foreach.hpp:74
HttpConnection(const process::http::Pipe::Writer &_writer, ContentType _contentType, id::UUID _streamId)
Definition: master.hpp:301
void recoverResources(Task *task)
constexpr size_t MAX_REMOVED_SLAVES
Definition: constants.hpp:84
hashset< InverseOffer * > inverseOffers
Definition: master.hpp:254
bool close()
Definition: master.hpp:319
void authenticate(const process::UPID &from, const process::UPID &pid)
An abstraction of a Master detector which can be used to detect the leading master from a group...
Definition: detector.hpp:38
static Time now()
The current clock time for either the current process that makes this call or the global clock time i...
void addExecutor(const SlaveID &slaveId, const ExecutorInfo &executorInfo)
Definition: master.hpp:2411
process::Future< bool > authorizeUnreserveResources(const Offer::Operation::Unreserve &unreserve, const Option< process::http::authentication::Principal > &principal)
Authorizes an UNRESERVE operation.
void _reconcileTasks(Framework *framework, const std::vector< TaskStatus > &statuses)
Definition: event.hpp:103
void statusUpdate(StatusUpdate update, const process::UPID &pid)
process::Future< bool > authorizeSlave(const SlaveInfo &slaveInfo, const Option< process::http::authentication::Principal > &principal)
void inverseOffer(const FrameworkID &frameworkId, const hashmap< SlaveID, UnavailableResources > &resources)
hashmap< TaskID, TaskInfo > pendingTasks
Definition: master.hpp:2815
process::Future< bool > authorizeFramework(const FrameworkInfo &frameworkInfo)
Heartbeater(const std::string &_logMessage, const Message &_heartbeatMessage, const HttpConnection &_http, const Duration &_interval, const Option< Duration > &_delay=None())
Definition: master.hpp:345
void recoveredSlavesTimeout(const Registry ®istry)
virtual void lost(const UPID &)
Invoked when a linked process can no longer be monitored.
Definition: process.hpp:133
Definition: master.hpp:342
bool hasExecutor(const FrameworkID &frameworkId, const ExecutorID &executorId) const
Given an encoding function for individual records, this provides encoding from typed records into "Re...
Definition: recordio.hpp:57
Option< process::Owned< Heartbeater< scheduler::Event, v1::scheduler::Event > > > heartbeater
Definition: master.hpp:2886
Option< process::UPID > pid
Definition: master.hpp:2805
Master(mesos::allocator::Allocator *allocator, Registrar *registrar, Files *files, mesos::master::contender::MasterContender *contender, mesos::master::detector::MasterDetector *detector, const Option< Authorizer * > &authorizer, const Option< std::shared_ptr< process::RateLimiter >> &slaveRemovalLimiter, const Flags &flags=Flags())
void _reregisterSlave(const process::UPID &pid, ReregisterSlaveMessage &&incomingMessage, const Option< process::http::authentication::Principal > &principal, const process::Future< bool > &authorized)
void authenticationTimeout(process::Future< Option< std::string >> future)
Definition: metrics.hpp:38
std::string toString() const
Definition: uuid.hpp:87
bool isSpeculativeOperation(const Offer::Operation &operation)
State
Definition: master.hpp:2153
Offer * getOffer(Master *master, const OfferID &offerId)
Try< Nothing > create(const std::string &hierarchy, const std::string &cgroup, bool recursive=false)
hashmap< FrameworkID, Framework * > frameworks
Definition: master.hpp:2980
Subscriber & operator=(const Subscriber &)=delete
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
process::Time unregisteredTime
Definition: master.hpp:2811
std::string serialize(ContentType contentType, const google::protobuf::Message &message)
void addOperation(Operation *operation)
Definition: master.hpp:2482
std::string version
Definition: master.hpp:195
URI http(const std::string &host, const std::string &path="/", const Option< int > &port=None(), const Option< std::string > &query=None(), const Option< std::string > &fragment=None(), const Option< std::string > &user=None(), const Option< std::string > &password=None())
Creates an http URI with the given parameters.
Definition: http.hpp:35
hashmap< FrameworkID, hashmap< ExecutorID, ExecutorInfo > > executors
Definition: master.hpp:224
void reviveOffers(const process::UPID &from, const FrameworkID &frameworkId, const std::vector< std::string > &role)
hashset< Offer * > offers
Definition: master.hpp:2834
std::string stringify(int flags)
void fileAttached(const process::Future< Nothing > &result, const std::string &path)
void addTask(Task *task)
Definition: master.hpp:2214
void reconcileTasks(const process::UPID &from, const FrameworkID &frameworkId, const std::vector< TaskStatus > &statuses)
void closeHttpConnection()
Definition: master.hpp:2746
Definition: master.hpp:2151
void untrackUnderRole(const std::string &role)
bool contains(const Resources &that) const
protobuf::slave::Capabilities capabilities
Definition: master.hpp:198
hashmap< SlaveID, hashmap< ExecutorID, ExecutorInfo > > executors
Definition: master.hpp:2841
Definition: process.hpp:493
void sendSlaveLost(const SlaveInfo &slaveInfo)
process::Owned< Heartbeater< mesos::master::Event, v1::master::Event > > heartbeater
Definition: master.hpp:2010
hashmap< id::UUID, Operation * > operations
Definition: master.hpp:248
void reconcileKnownSlave(Slave *slave, const std::vector< ExecutorInfo > &executors, const std::vector< Task > &tasks)
bool contains(const Key &key) const
Definition: hashmap.hpp:86
void forward(const StatusUpdate &update, const process::UPID &acknowledgee, Framework *framework)
Nothing _agentReregisterTimeout(const SlaveID &slaveId)
void removeFramework(Framework *framework)
Try< std::set< pid_t > > pids()
Definition: freebsd.hpp:62
const Option< process::http::authentication::Principal > principal
Definition: master.hpp:2011
hashmap< SlaveID, Resources > usedResources
Definition: master.hpp:2878
Resources totalOfferedResources
Definition: master.hpp:2881
Definition: master.hpp:392
Resources offeredResources
Definition: master.hpp:261
hashmap< FrameworkID, hashmap< TaskID, TaskInfo > > pendingTasks
Definition: master.hpp:230
const FrameworkID id() const
Definition: master.hpp:2591
process::Future< bool > authorizeReserveResources(const Offer::Operation::Reserve &reserve, const Option< process::http::authentication::Principal > &principal)
Authorizes a RESERVE operation.
void submitScheduler(const std::string &name)
void removeOperation(Operation *operation)
void deactivate(Framework *framework, bool rescind)
const T & get() const
Definition: try.hpp:73
constexpr const char * name
Definition: shell.hpp:41
hashmap< FrameworkID, Resources > usedResources
Definition: master.hpp:259
void throttled(process::MessageEvent &&event, const Option< std::string > &principal)
void addOperation(Framework *framework, Slave *slave, Operation *operation)
void __removeSlave(Slave *slave, const std::string &message, const Option< TimeInfo > &unreachableTime)
process::Future< bool > authorizeCreateVolume(const Offer::Operation::Create &create, const Option< process::http::authentication::Principal > &principal)
Authorizes a CREATE operation.
void removeOffer(Offer *offer)
void updateOperationStatus(const UpdateOperationStatusMessage &update)
Try< std::vector< Value > > time(const std::string &hierarchy, const std::string &cgroup)
Framework * getFramework(const FrameworkID &frameworkId) const
void addInverseOffer(InverseOffer *inverseOffer)
Definition: master.hpp:2389
State state
Definition: master.hpp:2807
void _authenticate(const process::UPID &pid, const process::Future< Option< std::string >> &future)