Apache Mesos
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mesos::internal::slave::Subsystem Class Referenceabstract

An abstraction for cgroups subsystem. More...

#include <subsystem.hpp>

Inheritance diagram for mesos::internal::slave::Subsystem:
process::Process< Subsystem > process::ProcessBase process::EventConsumer mesos::internal::slave::BlkioSubsystem mesos::internal::slave::CpuacctSubsystem mesos::internal::slave::CpusetSubsystem mesos::internal::slave::CpuSubsystem mesos::internal::slave::DevicesSubsystem mesos::internal::slave::HugetlbSubsystem mesos::internal::slave::MemorySubsystem mesos::internal::slave::NetClsSubsystem mesos::internal::slave::NetPrioSubsystem mesos::internal::slave::PerfEventSubsystem mesos::internal::slave::PidsSubsystem

Public Member Functions

virtual ~Subsystem ()
 
virtual std::string name () const =0
 The cgroups subsystem name of this Subsystem object. More...
 
virtual process::Future< Nothingrecover (const ContainerID &containerId, const std::string &cgroup)
 Recover the cgroups subsystem for the associated container. More...
 
virtual process::Future< Nothingprepare (const ContainerID &containerId, const std::string &cgroup)
 Prepare the cgroups subsystem for the associated container. More...
 
virtual process::Future< Nothingisolate (const ContainerID &containerId, const std::string &cgroup, pid_t pid)
 Isolate the associated container to cgroups subsystem. More...
 
virtual process::Future< mesos::slave::ContainerLimitation > watch (const ContainerID &containerId, const std::string &cgroup)
 Watch the container and report if any resource constraint impacts it. More...
 
virtual process::Future< Nothingupdate (const ContainerID &containerId, const std::string &cgroup, const Resources &resources)
 Update resources allocated to the associated container in this cgroups subsystem. More...
 
virtual process::Future< ResourceStatistics > usage (const ContainerID &containerId, const std::string &cgroup)
 Gather resource usage statistics of the cgroups subsystem for the associated container. More...
 
virtual process::Future< ContainerStatus > status (const ContainerID &containerId, const std::string &cgroup)
 Get the run-time status of cgroups subsystem specific properties associated with the container. More...
 
virtual process::Future< Nothingcleanup (const ContainerID &containerId, const std::string &cgroup)
 Clean up the cgroups subsystem for the associated container. More...
 
- Public Member Functions inherited from process::Process< Subsystem >
virtual ~Process ()
 
PID< Subsystem > self () const
 Returns the PID of the process. More...
 
- Public Member Functions inherited from process::ProcessBase
 ProcessBase (const std::string &id="")
 
virtual ~ProcessBase ()
 
const UPIDself () const
 
- Public Member Functions inherited from process::EventConsumer
virtual ~EventConsumer ()
 

Static Public Member Functions

static Try< process::Owned< Subsystem > > create (const Flags &flags, const std::string &name, const std::string &hierarchy)
 Attempts to create a specific Subsystem object that will contain specific information associated with container. More...
 

Protected Member Functions

 Subsystem (const Flags &_flags, const std::string &_hierarchy)
 
- Protected Member Functions inherited from process::ProcessBase
virtual void serve (Event &&event)
 Invoked when an event is serviced. More...
 
void consume (MessageEvent &&event) override
 
void consume (DispatchEvent &&event) override
 
void consume (HttpEvent &&event) override
 
void consume (ExitedEvent &&event) override
 
void consume (TerminateEvent &&event) override
 
virtual void initialize ()
 Invoked when a process gets spawned. More...
 
virtual void finalize ()
 Invoked when a process is terminated. More...
 
virtual void exited (const UPID &)
 Invoked when a linked process has exited. More...
 
virtual void lost (const UPID &)
 Invoked when a linked process can no longer be monitored. More...
 
void send (const UPID &to, const std::string &name, const char *data=nullptr, size_t length=0)
 Sends the message to the specified UPID. More...
 
void send (const UPID &to, std::string &&name)
 
void send (const UPID &to, std::string &&name, std::string &&data)
 
UPID link (const UPID &pid, const RemoteConnection remote=RemoteConnection::REUSE)
 Links with the specified UPID. More...
 
void install (const std::string &name, const MessageHandler &handler)
 Sets up a handler for messages with the specified name. More...
 
template<typename T >
void install (const std::string &name, void(T::*method)(const UPID &, const std::string &))
 Sets up a handler for messages with the specified name. More...
 
void delegate (const std::string &name, const UPID &pid)
 Delegates incoming messages, with the specified name, to the UPID. More...
 
void route (const std::string &name, const Option< std::string > &help, const HttpRequestHandler &handler, const RouteOptions &options=RouteOptions())
 Sets up a handler for HTTP requests with the specified name. More...
 
template<typename T >
void route (const std::string &name, const Option< std::string > &help, Future< http::Response >(T::*method)(const http::Request &), const RouteOptions &options=RouteOptions())
 Sets up a handler for HTTP requests with the specified name. More...
 
void route (const std::string &name, const std::string &realm, const Option< std::string > &help, const AuthenticatedHttpRequestHandler &handler, const RouteOptions &options=RouteOptions())
 
template<typename T >
void route (const std::string &name, const Option< std::string > &realm, const Option< std::string > &help, Future< http::Response >(T::*method)(const http::Request &, const Option< http::authentication::Principal > &), const RouteOptions &options=RouteOptions())
 Forwards to the correct overload of process::ProcessBase::route(), depending on whether the authentication realm realm is present. More...
 
void provide (const std::string &name, const std::string &path, const std::map< std::string, std::string > &types=mime::types)
 Sets up the default HTTP request handler to provide the static asset(s) at the specified absolute path for the specified name. More...
 
template<typename T >
size_t eventCount ()
 Returns the number of events of the given type currently on the event queue. More...
 

Protected Attributes

const Flags flags
 Flags used to launch the agent. More...
 
const std::string hierarchy
 The hierarchy path of cgroups subsystem. More...
 

Additional Inherited Members

- Protected Types inherited from process::Process< Subsystem >
typedef Subsystem Self
 
typedef Subsystem This
 
- Protected Types inherited from process::ProcessBase
enum  RemoteConnection { RemoteConnection::REUSE, RemoteConnection::RECONNECT }
 Describes the behavior of the link call when the target pid points to a remote process. More...
 
typedef lambda::function< void(const UPID &, const std::string &)> MessageHandler
 Any function which takes a "from" UPID and a message body as arguments. More...
 
typedef lambda::function< Future< http::Response >const http::Request &)> HttpRequestHandler
 Any function which takes a process::http::Request and returns a process::http::Response. More...
 
typedef lambda::function< Future< http::Response > const http::Request &, const Option< http::authentication::Principal > &)> AuthenticatedHttpRequestHandler
 Any function which takes a process::http::Request and an Option<Principal> and returns a process::http::Response. More...
 

Detailed Description

An abstraction for cgroups subsystem.

Constructor & Destructor Documentation

virtual mesos::internal::slave::Subsystem::~Subsystem ( )
inlinevirtual
mesos::internal::slave::Subsystem::Subsystem ( const Flags _flags,
const std::string &  _hierarchy 
)
protected

Member Function Documentation

virtual process::Future<Nothing> mesos::internal::slave::Subsystem::cleanup ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Clean up the cgroups subsystem for the associated container.

It will be called when destruction to ensure everything be cleanup. Similar to the isolator cleanup, it's likely that the cleanup for the subsystem is called for unknown containers (see MESOS-6059). We should ignore the cleanup request if the container is unknown to the subsystem.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
Nothing or an error if cleanup fails.

Reimplemented in mesos::internal::slave::NetClsSubsystem, mesos::internal::slave::MemorySubsystem, mesos::internal::slave::PerfEventSubsystem, and mesos::internal::slave::DevicesSubsystem.

static Try<process::Owned<Subsystem> > mesos::internal::slave::Subsystem::create ( const Flags flags,
const std::string &  name,
const std::string &  hierarchy 
)
static

Attempts to create a specific Subsystem object that will contain specific information associated with container.

Parameters
flagsFlags used to launch the agent.
nameThe name of cgroups subsystem.
hierarchyThe hierarchy path of cgroups subsystem.
Returns
A specific Subsystem object or an error if create fails.
virtual process::Future<Nothing> mesos::internal::slave::Subsystem::isolate ( const ContainerID &  containerId,
const std::string &  cgroup,
pid_t  pid 
)
virtual

Isolate the associated container to cgroups subsystem.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
pidThe process id of container.
Returns
Nothing or an error if isolate fails.

Reimplemented in mesos::internal::slave::NetClsSubsystem.

virtual std::string mesos::internal::slave::Subsystem::name ( ) const
pure virtual
virtual process::Future<Nothing> mesos::internal::slave::Subsystem::prepare ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Prepare the cgroups subsystem for the associated container.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
Nothing or an error if prepare fails.

Reimplemented in mesos::internal::slave::NetClsSubsystem, mesos::internal::slave::MemorySubsystem, mesos::internal::slave::PerfEventSubsystem, and mesos::internal::slave::DevicesSubsystem.

virtual process::Future<Nothing> mesos::internal::slave::Subsystem::recover ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Recover the cgroups subsystem for the associated container.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
Nothing or an error if recover fails.

Reimplemented in mesos::internal::slave::NetClsSubsystem, mesos::internal::slave::MemorySubsystem, mesos::internal::slave::PerfEventSubsystem, and mesos::internal::slave::DevicesSubsystem.

virtual process::Future<ContainerStatus> mesos::internal::slave::Subsystem::status ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Get the run-time status of cgroups subsystem specific properties associated with the container.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
The container status or an error if get fails.

Reimplemented in mesos::internal::slave::NetClsSubsystem.

virtual process::Future<Nothing> mesos::internal::slave::Subsystem::update ( const ContainerID &  containerId,
const std::string &  cgroup,
const Resources resources 
)
virtual

Update resources allocated to the associated container in this cgroups subsystem.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
resourcesThe resources need to update.
Returns
Nothing or an error if update fails.

Reimplemented in mesos::internal::slave::MemorySubsystem, and mesos::internal::slave::CpuSubsystem.

virtual process::Future<ResourceStatistics> mesos::internal::slave::Subsystem::usage ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Gather resource usage statistics of the cgroups subsystem for the associated container.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
The resource usage statistics or an error if gather statistics fails.

Reimplemented in mesos::internal::slave::MemorySubsystem, mesos::internal::slave::PerfEventSubsystem, mesos::internal::slave::CpuSubsystem, mesos::internal::slave::BlkioSubsystem, and mesos::internal::slave::CpuacctSubsystem.

virtual process::Future<mesos::slave::ContainerLimitation> mesos::internal::slave::Subsystem::watch ( const ContainerID &  containerId,
const std::string &  cgroup 
)
virtual

Watch the container and report if any resource constraint impacts it.

Parameters
containerIdThe target containerId.
cgroupThe target cgroup.
Returns
The resource limitation that impacts the container or an error if watch fails.

Reimplemented in mesos::internal::slave::MemorySubsystem.

Member Data Documentation

const Flags mesos::internal::slave::Subsystem::flags
protected

Flags used to launch the agent.

const std::string mesos::internal::slave::Subsystem::hierarchy
protected

The hierarchy path of cgroups subsystem.


The documentation for this class was generated from the following file: