Apache Mesos
slave.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 __SLAVE_HPP__
18 #define __SLAVE_HPP__
19 
20 #include <stdint.h>
21 
22 #include <list>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 #include <boost/circular_buffer.hpp>
28 
29 #include <mesos/attributes.hpp>
30 #include <mesos/resources.hpp>
31 #include <mesos/type_utils.hpp>
32 
33 #include <mesos/agent/agent.hpp>
34 
36 
38 
40 
42 
46 
48 
49 #include <process/http.hpp>
50 #include <process/future.hpp>
51 #include <process/owned.hpp>
52 #include <process/limiter.hpp>
53 #include <process/process.hpp>
54 #include <process/protobuf.hpp>
55 #include <process/shared.hpp>
56 
57 #include <stout/boundedhashmap.hpp>
58 #include <stout/bytes.hpp>
59 #include <stout/linkedhashmap.hpp>
60 #include <stout/hashmap.hpp>
61 #include <stout/hashset.hpp>
62 #include <stout/option.hpp>
63 #include <stout/os.hpp>
64 #include <stout/path.hpp>
65 #include <stout/recordio.hpp>
66 #include <stout/uuid.hpp>
67 
68 #include "common/http.hpp"
70 #include "common/recordio.hpp"
71 
72 #include "files/files.hpp"
73 
74 #include "internal/evolve.hpp"
75 
76 #include "messages/messages.hpp"
77 
80 
81 #include "slave/constants.hpp"
83 #include "slave/flags.hpp"
84 #include "slave/gc.hpp"
85 #include "slave/http.hpp"
86 #include "slave/metrics.hpp"
87 #include "slave/paths.hpp"
88 #include "slave/state.hpp"
89 
90 // `REGISTERING` is used as an enum value, but it's actually defined as a
91 // constant in the Windows SDK.
92 #ifdef __WINDOWS__
93 #undef REGISTERING
94 #undef REGISTERED
95 #endif // __WINDOWS__
96 
97 namespace mesos {
98 
99 // Forward declarations.
100 class Authorizer;
101 class DiskProfileAdaptor;
102 
103 namespace internal {
104 namespace slave {
105 
106 // Some forward declarations.
107 class TaskStatusUpdateManager;
108 class Executor;
109 class Framework;
110 
111 struct HttpConnection;
112 struct ResourceProvider;
113 
114 
115 class Slave : public ProtobufProcess<Slave>
116 {
117 public:
118  Slave(const std::string& id,
119  const Flags& flags,
121  Containerizer* containerizer,
122  Files* files,
123  GarbageCollector* gc,
124  TaskStatusUpdateManager* taskStatusUpdateManager,
125  mesos::slave::ResourceEstimator* resourceEstimator,
126  mesos::slave::QoSController* qosController,
127  mesos::SecretGenerator* secretGenerator,
128  const Option<Authorizer*>& authorizer);
129 
130  virtual ~Slave();
131 
132  void shutdown(const process::UPID& from, const std::string& message);
133 
134  void registered(
135  const process::UPID& from,
136  const SlaveID& slaveId,
137  const MasterSlaveConnection& connection);
138 
139  void reregistered(
140  const process::UPID& from,
141  const SlaveID& slaveId,
142  const std::vector<ReconcileTasksMessage>& reconciliations,
143  const MasterSlaveConnection& connection);
144 
145  void doReliableRegistration(Duration maxBackoff);
146 
147  // Made 'virtual' for Slave mocking.
148  virtual void runTask(
149  const process::UPID& from,
150  const FrameworkInfo& frameworkInfo,
151  const FrameworkID& frameworkId,
152  const process::UPID& pid,
153  const TaskInfo& task,
154  const std::vector<ResourceVersionUUID>& resourceVersionUuids);
155 
156  void run(
157  const FrameworkInfo& frameworkInfo,
158  ExecutorInfo executorInfo,
159  Option<TaskInfo> task,
160  Option<TaskGroupInfo> taskGroup,
161  const std::vector<ResourceVersionUUID>& resourceVersionUuids,
162  const process::UPID& pid);
163 
164  // Made 'virtual' for Slave mocking.
165  virtual void _run(
166  const process::Future<std::list<bool>>& unschedules,
167  const FrameworkInfo& frameworkInfo,
168  const ExecutorInfo& executorInfo,
169  const Option<TaskInfo>& task,
170  const Option<TaskGroupInfo>& taskGroup,
171  const std::vector<ResourceVersionUUID>& resourceVersionUuids);
172 
173  // Made 'virtual' for Slave mocking.
174  virtual void runTaskGroup(
175  const process::UPID& from,
176  const FrameworkInfo& frameworkInfo,
177  const ExecutorInfo& executorInfo,
178  const TaskGroupInfo& taskGroupInfo,
179  const std::vector<ResourceVersionUUID>& resourceVersionUuids);
180 
181  // Made 'virtual' for Slave mocking.
182  virtual void killTask(
183  const process::UPID& from,
184  const KillTaskMessage& killTaskMessage);
185 
186  // Made 'virtual' for Slave mocking.
187  virtual void shutdownExecutor(
188  const process::UPID& from,
189  const FrameworkID& frameworkId,
190  const ExecutorID& executorId);
191 
192  void shutdownFramework(
193  const process::UPID& from,
194  const FrameworkID& frameworkId);
195 
196  void schedulerMessage(
197  const SlaveID& slaveId,
198  const FrameworkID& frameworkId,
199  const ExecutorID& executorId,
200  const std::string& data);
201 
202  void updateFramework(
203  const UpdateFrameworkMessage& message);
204 
205  void checkpointResources(
206  std::vector<Resource> checkpointedResources,
207  bool changeTotal);
208 
210  const std::vector<Resource>& checkpointedResources);
211 
212  void applyOperation(const ApplyOperationMessage& message);
213 
214  // Reconciles pending operations with the master. This is necessary to handle
215  // cases in which operations were dropped in transit, or in which an agent's
216  // `UpdateSlaveMessage` was sent at the same time as an operation was en route
217  // from the master to the agent.
218  void reconcileOperations(const ReconcileOperationsMessage& message);
219 
220  void subscribe(
221  HttpConnection http,
222  const executor::Call::Subscribe& subscribe,
223  Framework* framework,
224  Executor* executor);
225 
226  void registerExecutor(
227  const process::UPID& from,
228  const FrameworkID& frameworkId,
229  const ExecutorID& executorId);
230 
231  // Called when an executor re-registers with a recovering slave.
232  // 'tasks' : Unacknowledged tasks (i.e., tasks that the executor
233  // driver never received an ACK for.)
234  // 'updates' : Unacknowledged updates.
235  void reregisterExecutor(
236  const process::UPID& from,
237  const FrameworkID& frameworkId,
238  const ExecutorID& executorId,
239  const std::vector<TaskInfo>& tasks,
240  const std::vector<StatusUpdate>& updates);
241 
242  void _reregisterExecutor(
243  const process::Future<Nothing>& future,
244  const FrameworkID& frameworkId,
245  const ExecutorID& executorId,
246  const ContainerID& containerId);
247 
248  void executorMessage(
249  const SlaveID& slaveId,
250  const FrameworkID& frameworkId,
251  const ExecutorID& executorId,
252  const std::string& data);
253 
254  void ping(const process::UPID& from, bool connected);
255 
256  // Handles the task status update.
257  // NOTE: If 'pid' is a valid UPID an ACK is sent to this pid
258  // after the update is successfully handled. If pid == UPID()
259  // no ACK is sent. The latter is used by the slave to send
260  // status updates it generated (e.g., TASK_LOST). If pid == None()
261  // an ACK is sent to the corresponding HTTP based executor.
262  // NOTE: StatusUpdate is passed by value because it is modified
263  // to ensure source field is set.
264  void statusUpdate(StatusUpdate update, const Option<process::UPID>& pid);
265 
266  // Called when the slave receives a `StatusUpdate` from an executor
267  // and the slave needs to retrieve the container status for the
268  // container associated with the executor.
269  void _statusUpdate(
270  StatusUpdate update,
271  const Option<process::UPID>& pid,
272  const ExecutorID& executorId,
273  const Option<process::Future<ContainerStatus>>& containerStatus);
274 
275  // Continue handling the status update after optionally updating the
276  // container's resources.
277  void __statusUpdate(
278  const Option<process::Future<Nothing>>& future,
279  const StatusUpdate& update,
280  const Option<process::UPID>& pid,
281  const ExecutorID& executorId,
282  const ContainerID& containerId,
283  bool checkpoint);
284 
285  // This is called when the task status update manager finishes
286  // handling the update. If the handling is successful, an
287  // acknowledgment is sent to the executor.
288  void ___statusUpdate(
289  const process::Future<Nothing>& future,
290  const StatusUpdate& update,
291  const Option<process::UPID>& pid);
292 
293  // This is called by task status update manager to forward a status
294  // update to the master. Note that the latest state of the task is
295  // added to the update before forwarding.
296  void forward(StatusUpdate update);
297 
299  const process::UPID& from,
300  const SlaveID& slaveId,
301  const FrameworkID& frameworkId,
302  const TaskID& taskId,
303  const std::string& uuid);
304 
306  const process::Future<bool>& future,
307  const TaskID& taskId,
308  const FrameworkID& frameworkId,
309  const id::UUID& uuid);
310 
312  const process::UPID& from,
313  const AcknowledgeOperationStatusMessage& acknowledgement);
314 
315  void executorLaunched(
316  const FrameworkID& frameworkId,
317  const ExecutorID& executorId,
318  const ContainerID& containerId,
320 
321  // Made 'virtual' for Slave mocking.
322  virtual void executorTerminated(
323  const FrameworkID& frameworkId,
324  const ExecutorID& executorId,
325  const process::Future<Option<
326  mesos::slave::ContainerTermination>>& termination);
327 
328  // NOTE: Pulled these to public to make it visible for testing.
329  // TODO(vinod): Make tests friends to this class instead.
330 
331  // Garbage collects the directories based on the current disk usage.
332  // TODO(vinod): Instead of making this function public, we need to
333  // mock both GarbageCollector (and pass it through slave's constructor)
334  // and os calls.
336 
337  // Garbage collect image layers based on the disk usage of image
338  // store.
340 
341  // Invoked whenever the detector detects a change in masters.
342  // Made public for testing purposes.
343  void detected(const process::Future<Option<MasterInfo>>& _master);
344 
345  enum State
346  {
347  RECOVERING, // Slave is doing recovery.
348  DISCONNECTED, // Slave is not connected to the master.
349  RUNNING, // Slave has (re-)registered.
350  TERMINATING, // Slave is shutting down.
351  } state;
352 
353  // Describes information about agent recovery.
355  {
356  // Flag to indicate if recovery, including reconciling
357  // (i.e., reconnect/kill) with executors is finished.
359 
360  // Flag to indicate that HTTP based executors can
361  // subscribe with the agent. We allow them to subscribe
362  // after the agent recovers the containerizer.
363  bool reconnect = false;
364  } recoveryInfo;
365 
366  // TODO(benh): Clang requires members to be public in order to take
367  // their address which we do in tests (for things like
368  // FUTURE_DISPATCH).
369 // protected:
370  virtual void initialize();
371  virtual void finalize();
372  virtual void exited(const process::UPID& pid);
373 
374  void __run(
375  const process::Future<std::list<bool>>& future,
376  const FrameworkInfo& frameworkInfo,
377  const ExecutorInfo& executorInfo,
378  const Option<TaskInfo>& task,
379  const Option<TaskGroupInfo>& taskGroup,
380  const std::vector<ResourceVersionUUID>& resourceVersionUuids);
381 
382  // This is called when the resource limits of the container have
383  // been updated for the given tasks and task groups. If the update is
384  // successful, we flush the given tasks to the executor by sending
385  // RunTaskMessages or `LAUNCH_GROUP` events.
386  void ___run(
387  const process::Future<Nothing>& future,
388  const FrameworkID& frameworkId,
389  const ExecutorID& executorId,
390  const ContainerID& containerId,
391  const std::list<TaskInfo>& tasks,
392  const std::list<TaskGroupInfo>& taskGroups);
393 
395  const FrameworkID& frameworkId,
396  const ExecutorID& executorId,
397  const ContainerID& containerId);
398 
399  // If an executor is launched for a task group, `taskInfo` would not be set.
400  void launchExecutor(
401  const Option<process::Future<Secret>>& future,
402  const FrameworkID& frameworkId,
403  const ExecutorID& executorId,
404  const Option<TaskInfo>& taskInfo);
405 
406  void fileAttached(const process::Future<Nothing>& result,
407  const std::string& path,
408  const std::string& virtualPath);
409 
410  Nothing detachFile(const std::string& path);
411 
412  // TODO(qianzhang): This is a workaround to make the default executor
413  // task's volume directory visible in MESOS UI. In MESOS-7225, we made
414  // sure a task can access any volumes specified in its disk resources
415  // from its sandbox by introducing a workaround to the default executor,
416  // i.e., adding a `SANDBOX_PATH` volume with type `PARENT` to the
417  // corresponding nested container. This volume gets translated into a
418  // bind mount in the nested container's mount namespace, which is is not
419  // visible in Mesos UI because it operates in the host namespace. See
420  // Mesos-8279 for details.
421  //
422  // To make the task's volume directory visible in Mesos UI, here we
423  // attach the executor's volume directory to it, so when users browse
424  // task's volume directory in Mesos UI, what they actually browse is the
425  // executor's volume directory. Note when calling `Files::attach()`, the
426  // third argument `authorized` is not specified because it is already
427  // specified when we do the attach for the executor's sandbox and it also
428  // applies to the executor's tasks.
430  const ExecutorInfo& executorInfo,
431  const ContainerID& executorContainerId,
432  const Task& task);
433 
434  // TODO(qianzhang): Remove the task's volume directory from the /files
435  // endpoint. This is a workaround for MESOS-8279.
437  const ExecutorInfo& executorInfo,
438  const ContainerID& executorContainerId,
439  const std::vector<Task>& tasks);
440 
441  // Triggers a re-detection of the master when the slave does
442  // not receive a ping.
444 
445  void authenticate();
446 
447  // Helper routines to lookup a framework/executor.
448  Framework* getFramework(const FrameworkID& frameworkId) const;
449 
451  const FrameworkID& frameworkId,
452  const ExecutorID& executorId) const;
453 
454  Executor* getExecutor(const ContainerID& containerId) const;
455 
456  // Returns the ExecutorInfo associated with a TaskInfo. If the task has no
457  // ExecutorInfo, then we generate an ExecutorInfo corresponding to the
458  // command executor.
459  ExecutorInfo getExecutorInfo(
460  const FrameworkInfo& frameworkInfo,
461  const TaskInfo& task) const;
462 
463  // Shuts down the executor if it did not register yet.
465  const FrameworkID& frameworkId,
466  const ExecutorID& executorId,
467  const ContainerID& containerId);
468 
469  // Cleans up all un-reregistered executors during recovery.
471 
472  // This function returns the max age of executor/slave directories allowed,
473  // given a disk usage. This value could be used to tune gc.
474  Duration age(double usage);
475 
476  // Checks the current disk usage and schedules for gc as necessary.
477  void checkDiskUsage();
478 
479  // Checks the current container image disk usage and trigger image
480  // gc if necessary.
481  void checkImageDiskUsage();
482 
483  // Recovers the slave, task status update manager and isolator.
485 
486  // This is called after 'recover()'. If 'flags.reconnect' is
487  // 'reconnect', the slave attempts to reconnect to any old live
488  // executors. Otherwise, the slave attempts to shutdown/kill them.
490 
491  // This is a helper to call recover() on the containerizer at the end of
492  // recover() and before __recover().
493  // TODO(idownes): Remove this when we support defers to objects.
496 
497  // This is called when recovery finishes.
498  // Made 'virtual' for Slave mocking.
499  virtual void __recover(const process::Future<Nothing>& future);
500 
501  // Helper to recover a framework from the specified state.
502  void recoverFramework(
504  const hashset<ExecutorID>& executorsToRecheckpoint,
505  const hashmap<ExecutorID, hashset<TaskID>>& tasksToRecheckpoint);
506 
507  // Removes and garbage collects the executor.
508  void removeExecutor(Framework* framework, Executor* executor);
509 
510  // Removes and garbage collects the framework.
511  // Made 'virtual' for Slave mocking.
512  virtual void removeFramework(Framework* framework);
513 
514  // Schedules a 'path' for gc based on its modification time.
515  process::Future<Nothing> garbageCollect(const std::string& path);
516 
517  // Called when the slave was signaled from the specified user.
518  void signaled(int signal, int uid);
519 
520  // Made 'virtual' for Slave mocking.
521  virtual void qosCorrections();
522 
523  // Made 'virtual' for Slave mocking.
524  virtual void _qosCorrections(
526  mesos::slave::QoSCorrection>>& correction);
527 
528  // Returns the resource usage information for all executors.
530 
531  // Handle the second phase of shutting down an executor for those
532  // executors that have not properly shutdown within a timeout.
534  const FrameworkID& frameworkId,
535  const ExecutorID& executorId,
536  const ContainerID& containerId);
537 
538 private:
539  friend class Executor;
540  friend class Framework;
541  friend class Http;
542 
543  friend struct Metrics;
544 
545  Slave(const Slave&) = delete;
546  Slave& operator=(const Slave&) = delete;
547 
548  void _authenticate();
549  void authenticationTimeout(process::Future<bool> future);
550 
551  // Shut down an executor. This is a two phase process. First, an
552  // executor receives a shut down message (shut down phase), then
553  // after a configurable timeout the slave actually forces a kill
554  // (kill phase, via the isolator) if the executor has not
555  // exited.
556  void _shutdownExecutor(Framework* framework, Executor* executor);
557 
558  // Process creation of persistent volumes (for CREATE) and/or deletion
559  // of persistent volumes (for DESTROY) as a part of handling
560  // checkpointed resources, and commit the checkpointed resources on
561  // successful completion of all the operations.
562  Try<Nothing> syncCheckpointedResources(
563  const Resources& newCheckpointedResources);
564 
565  process::Future<bool> authorizeTask(
566  const TaskInfo& task,
567  const FrameworkInfo& frameworkInfo);
568 
569  process::Future<bool> authorizeLogAccess(
571 
572  process::Future<bool> authorizeSandboxAccess(
574  const FrameworkID& frameworkId,
575  const ExecutorID& executorId);
576 
577  void sendExecutorTerminatedStatusUpdate(
578  const TaskID& taskId,
579  const process::Future<Option<
580  mesos::slave::ContainerTermination>>& termination,
581  const FrameworkID& frameworkId,
582  const Executor* executor);
583 
584  // Forwards the current total of oversubscribed resources.
585  void forwardOversubscribed();
586  void _forwardOversubscribed(
587  const process::Future<Resources>& oversubscribable);
588 
589  // Helper functions to generate `UpdateSlaveMessage` for either
590  // just updates to resource provider-related information, or both
591  // resource provider-related information and oversubscribed
592  // resources.
593  UpdateSlaveMessage generateResourceProviderUpdate() const;
594  UpdateSlaveMessage generateUpdateSlaveMessage() const;
595 
596  void handleResourceProviderMessage(
598 
599  void addOperation(Operation* operation);
600 
601  // Transitions the operation, and recovers resource if the operation becomes
602  // terminal.
603  void updateOperation(
604  Operation* operation,
605  const UpdateOperationStatusMessage& update);
606 
607  void removeOperation(Operation* operation);
608 
609  Operation* getOperation(const id::UUID& uuid) const;
610 
611  void addResourceProvider(ResourceProvider* resourceProvider);
612  ResourceProvider* getResourceProvider(const ResourceProviderID& id) const;
613 
614  void apply(Operation* operation);
615 
616  // Publish all resources that are needed to run the current set of
617  // tasks and executors on the agent.
618  // NOTE: The `additionalResources` parameter is for publishing
619  // additional task resources when launching executors. Consider
620  // removing this parameter once we revisited MESOS-600.
621  process::Future<Nothing> publishResources(
622  const Option<Resources>& additionalResources = None());
623 
624  // Gauge methods.
625  double _frameworks_active()
626  {
627  return static_cast<double>(frameworks.size());
628  }
629 
630  double _uptime_secs()
631  {
632  return (process::Clock::now() - startTime).secs();
633  }
634 
635  double _registered()
636  {
637  return master.isSome() ? 1 : 0;
638  }
639 
640  double _tasks_staging();
641  double _tasks_starting();
642  double _tasks_running();
643  double _tasks_killing();
644 
645  double _executors_registering();
646  double _executors_running();
647  double _executors_terminating();
648 
649  double _executor_directory_max_allowed_age_secs();
650 
651  double _resources_total(const std::string& name);
652  double _resources_used(const std::string& name);
653  double _resources_percent(const std::string& name);
654 
655  double _resources_revocable_total(const std::string& name);
656  double _resources_revocable_used(const std::string& name);
657  double _resources_revocable_percent(const std::string& name);
658 
659  // Checks whether the two `SlaveInfo` objects are considered
660  // compatible based on the value of the `--configuration_policy`
661  // flag.
662  Try<Nothing> compatible(
663  const SlaveInfo& previous,
664  const SlaveInfo& current) const;
665 
666  protobuf::master::Capabilities requiredMasterCapabilities;
667 
668  const Flags flags;
669 
670  const Http http;
671 
672  SlaveInfo info;
673 
674  protobuf::slave::Capabilities capabilities;
675 
676  // Resources that are checkpointed by the slave.
677  Resources checkpointedResources;
678 
679  // The current total resources of the agent, i.e., `info.resources()` with
680  // checkpointed resources applied and resource provider resources.
681  Resources totalResources;
682 
683  Option<process::UPID> master;
684 
686 
687  // Note that these frameworks are "completed" only in that
688  // they no longer have any active tasks or executors on this
689  // particular agent.
690  //
691  // TODO(bmahler): Implement a more accurate framework lifecycle
692  // in the agent code, ideally the master can inform the agent
693  // when a framework is actually completed, and the agent can
694  // perhaps store a cache of "idle" frameworks. See MESOS-7890.
696 
698 
699  Containerizer* containerizer;
700 
701  Files* files;
702 
704 
705  process::Time startTime;
706 
707  GarbageCollector* gc;
708 
709  TaskStatusUpdateManager* taskStatusUpdateManager;
710 
711  // Master detection future.
713 
714  // Master's ping timeout value, updated on reregistration.
715  Duration masterPingTimeout;
716 
717  // Timer for triggering re-detection when no ping is received from
718  // the master.
719  process::Timer pingTimer;
720 
721  // Timer for triggering agent (re)registration after detecting a new master.
722  process::Timer agentRegistrationTimer;
723 
724  // Root meta directory containing checkpointed data.
725  const std::string metaDir;
726 
727  // Indicates the number of errors ignored in "--no-strict" recovery mode.
728  unsigned int recoveryErrors;
729 
730  Option<Credential> credential;
731 
732  // Authenticatee name as supplied via flags.
733  std::string authenticateeName;
734 
735  Authenticatee* authenticatee;
736 
737  // Indicates if an authentication attempt is in progress.
738  Option<process::Future<bool>> authenticating;
739 
740  // Indicates if the authentication is successful.
741  bool authenticated;
742 
743  // Indicates if a new authentication attempt should be enforced.
744  bool reauthenticate;
745 
746  // Indicates the number of failed authentication attempts.
747  uint64_t failedAuthentications;
748 
749  // Maximum age of executor directories. Will be recomputed
750  // periodically every flags.disk_watch_interval.
751  Duration executorDirectoryMaxAllowedAge;
752 
753  mesos::slave::ResourceEstimator* resourceEstimator;
754 
755  mesos::slave::QoSController* qosController;
756 
757  std::shared_ptr<DiskProfileAdaptor> diskProfileAdaptor;
758 
759  mesos::SecretGenerator* secretGenerator;
760 
761  const Option<Authorizer*> authorizer;
762 
763  // The most recent estimate of the total amount of oversubscribed
764  // (allocated and oversubscribable) resources.
765  Option<Resources> oversubscribedResources;
766 
767  ResourceProviderManager resourceProviderManager;
768  process::Owned<LocalResourceProviderDaemon> localResourceProviderDaemon;
769 
770  // Local resource providers known by the agent.
772 
773  // Used to establish the relationship between the operation and the
774  // resources that the operation is operating on. Each resource
775  // provider will keep a resource version UUID, and change it when it
776  // believes that the resources from this resource provider are out
777  // of sync from the master's view. The master will keep track of
778  // the last known resource version UUID for each resource provider,
779  // and attach the resource version UUID in each operation it sends
780  // out. The resource provider should reject operations that have a
781  // different resource version UUID than that it maintains, because
782  // this means the operation is operating on resources that might
783  // have already been invalidated.
784  id::UUID resourceVersion;
785 
786  // Keeps track of the following:
787  // (1) Pending operations for resources from the agent.
788  // (2) Pending operations or terminal operations that have
789  // unacknowledged status updates for resource provider
790  // provided resources.
792 };
793 
794 
795 // Represents the streaming HTTP connection to an executor.
797 {
799  ContentType _contentType)
800  : writer(_writer),
801  contentType(_contentType),
802  encoder(lambda::bind(serialize, contentType, lambda::_1)) {}
803 
804  // Converts the message to an Event before sending.
805  template <typename Message>
806  bool send(const Message& message)
807  {
808  // We need to evolve the internal 'message' into a
809  // 'v1::executor::Event'.
810  return writer.write(encoder.encode(evolve(message)));
811  }
812 
813  bool close()
814  {
815  return writer.close();
816  }
817 
819  {
820  return writer.readerClosed();
821  }
822 
826 };
827 
828 
829 std::ostream& operator<<(std::ostream& stream, const Executor& executor);
830 
831 
832 // Information describing an executor.
833 class Executor
834 {
835 public:
836  Executor(
837  Slave* slave,
838  const FrameworkID& frameworkId,
839  const ExecutorInfo& info,
840  const ContainerID& containerId,
841  const std::string& directory,
842  const Option<std::string>& user,
843  bool checkpoint);
844 
845  ~Executor();
846 
847  // Note that these tasks will also be tracked within `queuedTasks`.
848  void enqueueTaskGroup(const TaskGroupInfo& taskGroup);
849 
850  void enqueueTask(const TaskInfo& task);
851  Option<TaskInfo> dequeueTask(const TaskID& taskId);
852  Task* addLaunchedTask(const TaskInfo& task);
853  void completeTask(const TaskID& taskId);
854  void checkpointExecutor();
855  void checkpointTask(const TaskInfo& task);
856  void checkpointTask(const Task& task);
857 
858  void recoverTask(const state::TaskState& state, bool recheckpointTask);
859 
860  Try<Nothing> updateTaskState(const TaskStatus& status);
861 
862  // Returns true if there are any queued/launched/terminated tasks.
863  bool incompleteTasks();
864 
865  // Sends a message to the connected executor.
866  template <typename Message>
867  void send(const Message& message)
868  {
869  if (state == REGISTERING || state == TERMINATED) {
870  LOG(WARNING) << "Attempting to send message to disconnected"
871  << " executor " << *this << " in state " << state;
872  }
873 
874  if (http.isSome()) {
875  if (!http->send(message)) {
876  LOG(WARNING) << "Unable to send event to executor " << *this
877  << ": connection closed";
878  }
879  } else if (pid.isSome()) {
880  slave->send(pid.get(), message);
881  } else {
882  LOG(WARNING) << "Unable to send event to executor " << *this
883  << ": unknown connection type";
884  }
885  }
886 
887  // Returns true if this executor is generated by Mesos for a command
888  // task (either command executor for MesosContainerizer or docker
889  // executor for DockerContainerizer).
890  bool isGeneratedForCommandTask() const;
891 
892  // Closes the HTTP connection.
893  void closeHttpConnection();
894 
895  // Returns the task group associated with the task.
896  Option<TaskGroupInfo> getQueuedTaskGroup(const TaskID& taskId);
897 
899 
900  enum State
901  {
902  REGISTERING, // Executor is launched but not (re-)registered yet.
903  RUNNING, // Executor has (re-)registered.
904  TERMINATING, // Executor is being shutdown/killed.
905  TERMINATED, // Executor has terminated but there might be pending updates.
906  } state;
907 
908  // We store the pointer to 'Slave' to get access to its methods
909  // variables. One could imagine 'Executor' as being an inner class
910  // of the 'Slave' class.
912 
913  const ExecutorID id;
914  const ExecutorInfo info;
915 
916  const FrameworkID frameworkId;
917 
918  const ContainerID containerId;
919 
920  const std::string directory;
921 
922  // The sandbox will be owned by this user and the executor will
923  // run as this user. This can be set to None when --switch_user
924  // is false or when compiled for Windows.
926 
927  const bool checkpoint;
928 
929  // An Executor can either be connected via HTTP or by libprocess
930  // message passing. The following are the possible states:
931  //
932  // Agent State Executor State http pid Executor Type
933  // ----------- -------------- ---- ---- -------------
934  // RECOVERING REGISTERING None UPID() Unknown
935  // REGISTERING None Some Libprocess
936  // REGISTERING None None HTTP
937  //
938  // * REGISTERING None None Not known yet
939  // * * None Some Libprocess
940  // * * Some None HTTP
943 
944  // Tasks can be found in one of the following four data structures:
945  //
946  // TODO(bmahler): Make these private to enforce that the task
947  // lifecycle helper functions are not being bypassed, and provide
948  // public views into them.
949 
950  // Not yet launched tasks. This also includes tasks from `queuedTaskGroups`.
952 
953  // Not yet launched task groups. This is needed for correctly sending
954  // TASK_KILLED status updates for all tasks in the group if any of the
955  // tasks were killed before the executor could register with the agent.
956  std::list<TaskGroupInfo> queuedTaskGroups;
957 
958  // Running.
960 
961  // Terminated but pending updates.
963 
964  // Terminated and updates acked.
965  // NOTE: We use a shared pointer for Task because clang doesn't like
966  // Boost's implementation of circular_buffer with Task (Boost
967  // attempts to do some memset's which are unsafe).
968  boost::circular_buffer<std::shared_ptr<Task>> completedTasks;
969 
970  // When the slave initiates a destroy of the container, we expect a
971  // termination to occur. The 'pendingTermation' indicates why the
972  // slave initiated the destruction and will influence the
973  // information sent in the status updates for any remaining
974  // non-terminal tasks.
976 
977 private:
978  Executor(const Executor&) = delete;
979  Executor& operator=(const Executor&) = delete;
980 
981  bool isGeneratedForCommandTask_;
982 };
983 
984 
985 // Information about a framework.
987 {
988 public:
989  Framework(
990  Slave* slave,
991  const Flags& slaveFlags,
992  const FrameworkInfo& info,
993  const Option<process::UPID>& pid);
994 
995  ~Framework();
996 
997  // Returns whether the framework is idle, where idle is
998  // defined as having no activity:
999  // (1) The framework has no non-terminal tasks and executors.
1000  // (2) All status updates have been acknowledged.
1001  //
1002  // TODO(bmahler): The framework should also not be considered
1003  // idle if there are unacknowledged updates for "pending" tasks.
1004  bool idle() const;
1005 
1006  void checkpointFramework() const;
1007 
1008  const FrameworkID id() const { return info.id(); }
1009 
1010  Executor* addExecutor(const ExecutorInfo& executorInfo);
1011  Executor* getExecutor(const ExecutorID& executorId) const;
1012  Executor* getExecutor(const TaskID& taskId) const;
1013 
1014  void destroyExecutor(const ExecutorID& executorId);
1015 
1016  void recoverExecutor(
1017  const state::ExecutorState& state,
1018  bool recheckpointExecutor,
1019  const hashset<TaskID>& tasksToRecheckpoint);
1020 
1021  void addPendingTask(
1022  const ExecutorID& executorId,
1023  const TaskInfo& task);
1024 
1025  // Note that these tasks will also be tracked within `pendingTasks`.
1026  void addPendingTaskGroup(
1027  const ExecutorID& executorId,
1028  const TaskGroupInfo& taskGroup);
1029 
1030  bool hasTask(const TaskID& taskId) const;
1031  bool isPending(const TaskID& taskId) const;
1032 
1033  // Returns the task group associated with a pending task.
1034  Option<TaskGroupInfo> getTaskGroupForPendingTask(const TaskID& taskId);
1035 
1036  // Returns whether the pending task was removed.
1037  bool removePendingTask(const TaskID& taskId);
1038 
1039  Option<ExecutorID> getExecutorIdForPendingTask(const TaskID& taskId) const;
1040 
1041  Resources allocatedResources() const;
1042 
1043  enum State
1044  {
1045  RUNNING, // First state of a newly created framework.
1046  TERMINATING, // Framework is shutting down in the cluster.
1047  } state;
1048 
1049  // We store the pointer to 'Slave' to get access to its methods and
1050  // variables. One could imagine 'Framework' being an inner class of
1051  // the 'Slave' class.
1053 
1054  FrameworkInfo info;
1055 
1057 
1058  // Frameworks using the scheduler driver will have a 'pid',
1059  // which allows us to send executor messages directly to the
1060  // driver. Frameworks using the HTTP API (in 0.24.0) will
1061  // not have a 'pid', in which case executor messages are
1062  // sent through the master.
1064 
1065  // Executors can be found in one of the following
1066  // data structures:
1067  //
1068  // TODO(bmahler): Make these private to enforce that
1069  // the executors lifecycle helper functions are not
1070  // being bypassed, and provide public views into them.
1071 
1072  // Executors with pending tasks.
1074 
1075  // Pending task groups. This is needed for correctly sending
1076  // TASK_KILLED status updates for all tasks in the group if
1077  // any of the tasks are killed while pending.
1078  std::list<TaskGroupInfo> pendingTaskGroups;
1079 
1080  // Current running executors.
1082 
1083  boost::circular_buffer<process::Owned<Executor>> completedExecutors;
1084 
1085 private:
1086  Framework(const Framework&) = delete;
1087  Framework& operator=(const Framework&) = delete;
1088 };
1089 
1090 
1092 {
1094  const ResourceProviderInfo& _info,
1095  const Resources& _totalResources,
1096  const id::UUID& _resourceVersion)
1097  : info(_info),
1098  totalResources(_totalResources),
1099  resourceVersion(_resourceVersion) {}
1100 
1101  void addOperation(Operation* operation);
1102  void removeOperation(Operation* operation);
1103 
1104  ResourceProviderInfo info;
1106 
1107  // Used to establish the relationship between the operation and the
1108  // resources that the operation is operating on. Each resource
1109  // provider will keep a resource version UUID, and change it when it
1110  // believes that the resources from this resource provider are out
1111  // of sync from the master's view. The master will keep track of
1112  // the last known resource version UUID for each resource provider,
1113  // and attach the resource version UUID in each operation it sends
1114  // out. The resource provider should reject operations that have a
1115  // different resource version UUID than that it maintains, because
1116  // this means the operation is operating on resources that might
1117  // have already been invalidated.
1119 
1120  // Pending operations or terminal operations that have
1121  // unacknowledged status updates.
1123 };
1124 
1125 
1139 std::map<std::string, std::string> executorEnvironment(
1140  const Flags& flags,
1141  const ExecutorInfo& executorInfo,
1142  const std::string& directory,
1143  const SlaveID& slaveId,
1144  const process::PID<Slave>& slavePid,
1145  const Option<Secret>& authenticationToken,
1146  bool checkpoint);
1147 
1148 
1149 std::ostream& operator<<(std::ostream& stream, Executor::State state);
1150 std::ostream& operator<<(std::ostream& stream, Framework::State state);
1151 std::ostream& operator<<(std::ostream& stream, Slave::State state);
1152 
1153 } // namespace slave {
1154 } // namespace internal {
1155 } // namespace mesos {
1156 
1157 #endif // __SLAVE_HPP__
void schedulerMessage(const SlaveID &slaveId, const FrameworkID &frameworkId, const ExecutorID &executorId, const std::string &data)
Option< TaskInfo > dequeueTask(const TaskID &taskId)
bool isPending(const TaskID &taskId) const
struct mesos::internal::slave::Slave::RecoveryInfo recoveryInfo
virtual process::Future< ResourceUsage > usage()
enum mesos::internal::slave::Framework::State state
void checkpointTask(const TaskInfo &task)
void executorMessage(const SlaveID &slaveId, const FrameworkID &frameworkId, const ExecutorID &executorId, const std::string &data)
void enqueueTaskGroup(const TaskGroupInfo &taskGroup)
Try< uid_t > uid(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:182
Definition: nothing.hpp:16
ContentType
Definition: http.hpp:43
Definition: http.hpp:42
Definition: option.hpp:28
Try< bool > update(const std::string &link, const Handle &parent, uint16_t protocol, const action::Mirror &mirror)
State
Definition: slave.hpp:900
virtual void exited(const process::UPID &pid)
Invoked when a linked process has exited.
hashmap< id::UUID, Operation * > operations
Definition: slave.hpp:1122
void _reregisterExecutor(const process::Future< Nothing > &future, const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId)
Duration age(double usage)
const Option< std::string > user
Definition: slave.hpp:925
std::ostream & operator<<(std::ostream &stream, const MesosContainerizerProcess::State &state)
virtual void finalize()
Invoked when a process is terminated.
const ExecutorInfo info
Definition: slave.hpp:914
virtual void removeFramework(Framework *framework)
Definition: try.hpp:34
void ___run(const process::Future< Nothing > &future, const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId, const std::list< TaskInfo > &tasks, const std::list< TaskGroupInfo > &taskGroups)
void send(const Message &message)
Definition: slave.hpp:867
virtual void shutdownExecutor(const process::UPID &from, const FrameworkID &frameworkId, const ExecutorID &executorId)
void detachTaskVolumeDirectories(const ExecutorInfo &executorInfo, const ContainerID &executorContainerId, const std::vector< Task > &tasks)
void _checkDiskUsage(const process::Future< double > &usage)
Framework * getFramework(const FrameworkID &frameworkId) const
Definition: hashset.hpp:53
void removeExecutor(Framework *framework, Executor *executor)
process::Future< Nothing > _recoverContainerizer(const Option< state::SlaveState > &state)
process::Future< Nothing > closed() const
Definition: slave.hpp:818
std::list< TaskGroupInfo > pendingTaskGroups
Definition: slave.hpp:1078
v1::AgentID evolve(const SlaveID &slaveId)
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
void addOperation(Operation *operation)
void recoverTask(const state::TaskState &state, bool recheckpointTask)
Definition: resources.hpp:79
virtual void runTask(const process::UPID &from, const FrameworkInfo &frameworkInfo, const FrameworkID &frameworkId, const process::UPID &pid, const TaskInfo &task, const std::vector< ResourceVersionUUID > &resourceVersionUuids)
enum mesos::internal::slave::Executor::State state
virtual void runTaskGroup(const process::UPID &from, const FrameworkInfo &frameworkInfo, const ExecutorInfo &executorInfo, const TaskGroupInfo &taskGroupInfo, const std::vector< ResourceVersionUUID > &resourceVersionUuids)
virtual void _run(const process::Future< std::list< bool >> &unschedules, const FrameworkInfo &frameworkInfo, const ExecutorInfo &executorInfo, const Option< TaskInfo > &task, const Option< TaskGroupInfo > &taskGroup, const std::vector< ResourceVersionUUID > &resourceVersionUuids)
bool reconnect
Definition: slave.hpp:363
virtual void executorTerminated(const FrameworkID &frameworkId, const ExecutorID &executorId, const process::Future< Option< mesos::slave::ContainerTermination >> &termination)
Option< process::UPID > pid
Definition: slave.hpp:1063
Definition: files.hpp:73
void subscribe(HttpConnection http, const executor::Call::Subscribe &subscribe, Framework *framework, Executor *executor)
hashmap< ExecutorID, hashmap< TaskID, TaskInfo > > pendingTasks
Definition: slave.hpp:1073
enum mesos::internal::slave::Slave::State state
Operation
Definition: cgroups.hpp:441
void _checkImageDiskUsage(const process::Future< double > &usage)
void reregisterExecutor(const process::UPID &from, const FrameworkID &frameworkId, const ExecutorID &executorId, const std::vector< TaskInfo > &tasks, const std::vector< StatusUpdate > &updates)
Definition: flags.hpp:39
Slave * slave
Definition: slave.hpp:1052
Definition: duration.hpp:32
Option< mesos::slave::ContainerTermination > pendingTermination
Definition: slave.hpp:975
std::map< std::string, std::string > executorEnvironment(const Flags &flags, const ExecutorInfo &executorInfo, const std::string &directory, const SlaveID &slaveId, const process::PID< Slave > &slavePid, const Option< Secret > &authenticationToken, bool checkpoint)
Returns a map of environment variables necessary in order to launch an executor.
void recoverFramework(const state::FrameworkState &state, const hashset< ExecutorID > &executorsToRecheckpoint, const hashmap< ExecutorID, hashset< TaskID >> &tasksToRecheckpoint)
Option< ExecutorID > getExecutorIdForPendingTask(const TaskID &taskId) const
void send(const process::UPID &to, const google::protobuf::Message &message)
Definition: protobuf.hpp:118
bool isSome() const
Definition: option.hpp:115
Definition: task_status_update_manager.hpp:58
LinkedHashMap< TaskID, TaskInfo > queuedTasks
Definition: slave.hpp:951
void statusUpdateAcknowledgement(const process::UPID &from, const SlaveID &slaveId, const FrameworkID &frameworkId, const TaskID &taskId, const std::string &uuid)
const bool checkpoint
Definition: slave.hpp:927
void signaled(int signal, int uid)
bool close()
Definition: slave.hpp:813
ContentType contentType
Definition: slave.hpp:824
void checkpointResourcesMessage(const std::vector< Resource > &checkpointedResources)
Definition: hashmap.hpp:38
process::Future< Nothing > garbageCollect(const std::string &path)
void operationStatusAcknowledgement(const process::UPID &from, const AcknowledgeOperationStatusMessage &acknowledgement)
Definition: resource_estimator.hpp:37
boost::circular_buffer< std::shared_ptr< Task > > completedTasks
Definition: slave.hpp:968
void recoverExecutor(const state::ExecutorState &state, bool recheckpointExecutor, const hashset< TaskID > &tasksToRecheckpoint)
process::Future< Secret > generateSecret(const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId)
hashmap< std::string, MessageHandler > message
Definition: process.hpp:443
Definition: containerizer.hpp:57
void shutdownExecutorTimeout(const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId)
void attachTaskVolumeDirectory(const ExecutorInfo &executorInfo, const ContainerID &executorContainerId, const Task &task)
bool hasTask(const TaskID &taskId) const
void _statusUpdateAcknowledgement(const process::Future< bool > &future, const TaskID &taskId, const FrameworkID &frameworkId, const id::UUID &uuid)
Definition: slave.hpp:115
void registered(const process::UPID &from, const SlaveID &slaveId, const MasterSlaveConnection &connection)
An &quot;untyped&quot; PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
Option< HttpConnection > http
Definition: slave.hpp:941
Resources allocatedResources() const
void pingTimeout(process::Future< Option< MasterInfo >> future)
virtual void initialize()
Invoked when a process gets spawned.
Definition: http.hpp:340
const ContainerID containerId
Definition: slave.hpp:918
Option< process::UPID > pid
Definition: slave.hpp:942
ExecutorInfo getExecutorInfo(const FrameworkInfo &frameworkInfo, const TaskInfo &task) const
void __run(const process::Future< std::list< bool >> &future, const FrameworkInfo &frameworkInfo, const ExecutorInfo &executorInfo, const Option< TaskInfo > &task, const Option< TaskGroupInfo > &taskGroup, const std::vector< ResourceVersionUUID > &resourceVersionUuids)
Definition: uuid.hpp:35
void forward(StatusUpdate update)
Definition: protobuf_utils.hpp:434
void reconcileOperations(const ReconcileOperationsMessage &message)
bool write(std::string s)
const FrameworkID id() const
Definition: slave.hpp:1008
Future< Nothing > readerClosed() const
void launchExecutor(const Option< process::Future< Secret >> &future, const FrameworkID &frameworkId, const ExecutorID &executorId, const Option< TaskInfo > &taskInfo)
friend struct Metrics
Definition: slave.hpp:543
const T & get() const &
Definition: option.hpp:118
protobuf::framework::Capabilities capabilities
Definition: slave.hpp:1056
process::Future< Nothing > _recover()
ResourceProviderInfo info
Definition: slave.hpp:1104
The SecretGenerator interface represents a mechanism to create a secret from a principal.
Definition: secret_generator.hpp:34
Definition: protobuf.hpp:100
Executor * getExecutor(const ExecutorID &executorId) const
const ExecutorID id
Definition: slave.hpp:913
ResourceProvider(const ResourceProviderInfo &_info, const Resources &_totalResources, const id::UUID &_resourceVersion)
Definition: slave.hpp:1093
Executor(Slave *slave, const FrameworkID &frameworkId, const ExecutorInfo &info, const ContainerID &containerId, const std::string &directory, const Option< std::string > &user, bool checkpoint)
HttpConnection(const process::http::Pipe::Writer &_writer, ContentType _contentType)
Definition: slave.hpp:798
State
Definition: slave.hpp:1043
::recordio::Encoder< v1::executor::Event > encoder
Definition: slave.hpp:825
void executorLaunched(const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId, const process::Future< Containerizer::LaunchResult > &future)
Task * addLaunchedTask(const TaskInfo &task)
Definition: time.hpp:23
void reregistered(const process::UPID &from, const SlaveID &slaveId, const std::vector< ReconcileTasksMessage > &reconciliations, const MasterSlaveConnection &connection)
void fileAttached(const process::Future< Nothing > &result, const std::string &path, const std::string &virtualPath)
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
void _statusUpdate(StatusUpdate update, const Option< process::UPID > &pid, const ExecutorID &executorId, const Option< process::Future< ContainerStatus >> &containerStatus)
Definition: boundedhashmap.hpp:27
void run(const FrameworkInfo &frameworkInfo, ExecutorInfo executorInfo, Option< TaskInfo > task, Option< TaskGroupInfo > taskGroup, const std::vector< ResourceVersionUUID > &resourceVersionUuids, const process::UPID &pid)
const FrameworkID frameworkId
Definition: slave.hpp:916
void detected(const process::Future< Option< MasterInfo >> &_master)
Try< Nothing > checkpoint(const std::string &path, const std::string &message)
Definition: state.hpp:115
#define flags
Definition: decoder.hpp:18
A &quot;process identifier&quot; used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:279
hashmap< ExecutorID, Executor * > executors
Definition: slave.hpp:1081
void completeTask(const TaskID &taskId)
Definition: none.hpp:27
Executor * addExecutor(const ExecutorInfo &executorInfo)
boost::circular_buffer< process::Owned< Executor > > completedExecutors
Definition: slave.hpp:1083
Slave * slave
Definition: slave.hpp:911
LinkedHashMap< TaskID, Task * > launchedTasks
Definition: slave.hpp:959
Try< Nothing > updateTaskState(const TaskStatus &status)
process::Future< Nothing > recover(const Try< state::State > &state)
void ___statusUpdate(const process::Future< Nothing > &future, const StatusUpdate &update, const Option< process::UPID > &pid)
Definition: timer.hpp:30
void shutdownFramework(const process::UPID &from, const FrameworkID &frameworkId)
void applyOperation(const ApplyOperationMessage &message)
Nothing detachFile(const std::string &path)
void destroyExecutor(const ExecutorID &executorId)
virtual void killTask(const process::UPID &from, const KillTaskMessage &killTaskMessage)
bool send(const Message &message)
Definition: slave.hpp:806
virtual void __recover(const process::Future< Nothing > &future)
void addPendingTask(const ExecutorID &executorId, const TaskInfo &task)
Slave(const std::string &id, const Flags &flags, mesos::master::detector::MasterDetector *detector, Containerizer *containerizer, Files *files, GarbageCollector *gc, TaskStatusUpdateManager *taskStatusUpdateManager, mesos::slave::ResourceEstimator *resourceEstimator, mesos::slave::QoSController *qosController, mesos::SecretGenerator *secretGenerator, const Option< Authorizer * > &authorizer)
Resources totalResources
Definition: slave.hpp:1105
std::list< TaskGroupInfo > queuedTaskGroups
Definition: slave.hpp:956
An abstraction of a Master detector which can be used to detect the leading master from a group...
Definition: detector.hpp:38
id::UUID resourceVersion
Definition: slave.hpp:1118
static Time now()
The current clock time for either the current process that makes this call or the global clock time i...
Option< TaskGroupInfo > getQueuedTaskGroup(const TaskID &taskId)
void ping(const process::UPID &from, bool connected)
Definition: metrics.hpp:32
void checkpointResources(std::vector< Resource > checkpointedResources, bool changeTotal)
void __statusUpdate(const Option< process::Future< Nothing >> &future, const StatusUpdate &update, const Option< process::UPID > &pid, const ExecutorID &executorId, const ContainerID &containerId, bool checkpoint)
void doReliableRegistration(Duration maxBackoff)
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
Option< TaskGroupInfo > getTaskGroupForPendingTask(const TaskID &taskId)
process::Promise< Nothing > recovered
Definition: slave.hpp:358
Definition: qos_controller.hpp:44
std::string serialize(ContentType contentType, const google::protobuf::Message &message)
void removeOperation(Operation *operation)
const std::string directory
Definition: slave.hpp:920
void statusUpdate(StatusUpdate update, const Option< process::UPID > &pid)
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
State
Definition: slave.hpp:345
FrameworkInfo info
Definition: slave.hpp:1054
Definition: owned.hpp:35
process::http::Pipe::Writer writer
Definition: slave.hpp:823
void shutdown(const process::UPID &from, const std::string &message)
Definition: slave.hpp:833
friend class Http
Definition: slave.hpp:541
bool removePendingTask(const TaskID &taskId)
virtual void _qosCorrections(const process::Future< std::list< mesos::slave::QoSCorrection >> &correction)
Executor * getExecutor(const FrameworkID &frameworkId, const ExecutorID &executorId) const
void registerExecutor(const process::UPID &from, const FrameworkID &frameworkId, const ExecutorID &executorId)
PID< MetricsProcess > metrics
void updateFramework(const UpdateFrameworkMessage &message)
LinkedHashMap< TaskID, Task * > terminatedTasks
Definition: slave.hpp:962
constexpr const char * name
Definition: shell.hpp:41
Resources allocatedResources() const
void addPendingTaskGroup(const ExecutorID &executorId, const TaskGroupInfo &taskGroup)
void registerExecutorTimeout(const FrameworkID &frameworkId, const ExecutorID &executorId, const ContainerID &containerId)
Definition: slave.hpp:986
Definition: authenticatee.hpp:29
void enqueueTask(const TaskInfo &task)
Definition: future.hpp:57
Framework(Slave *slave, const Flags &slaveFlags, const FrameworkInfo &info, const Option< process::UPID > &pid)