Apache Mesos
|
#include <process.hpp>
Classes | |
struct | RouteOptions |
Public Member Functions | |
ProcessBase (const std::string &id="") | |
~ProcessBase () override | |
const UPID & | self () const |
Public Member Functions inherited from process::EventConsumer | |
virtual | ~EventConsumer () |
Protected Types | |
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... | |
Protected Member Functions | |
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... | |
Friends | |
class | SocketManager |
class | ProcessManager |
void * | schedule (void *) |
|
protected |
Any function which takes a process::http::Request
and an Option<Principal>
and returns a process::http::Response
.
This type is meant to be used for the endpoint handlers of authenticated HTTP endpoints.
If the handler is called and the principal is set, this implies two things: 1) The realm that the handler's endpoint is installed into requires authentication. 2) The HTTP request has been successfully authenticated.
If the principal is not set, then the endpoint's realm does not require authentication.
The default consume implementation for HTTP events invokes installed HTTP handlers.
|
protected |
Any function which takes a process::http::Request
and returns a process::http::Response
.
The default consume implementation for HTTP events invokes installed HTTP handlers.
|
protected |
Any function which takes a "from" UPID
and a message body as arguments.
The default consume implementation for message events invokes installed message handlers, or delegates the message to another process. A message handler always takes precedence over delegating.
|
strongprotected |
Describes the behavior of the link
call when the target pid
points to a remote process.
This enum has no effect if the target pid
points to a local process.
|
explicit |
|
override |
|
overrideprotectedvirtual |
Reimplemented from process::EventConsumer.
Reimplemented in ProtobufProcess< T >, ProtobufProcess< Slave >, ProtobufProcess< NetworkProcess >, ProtobufProcess< Master >, ProtobufProcess< StatusUpdateManagerProcess< IDType, CheckpointType, UpdateType > >, ProtobufProcess< CheckerProcess >, and ProtobufProcess< ReqResProcess< Req, Res > >.
|
overrideprotectedvirtual |
Reimplemented from process::EventConsumer.
|
overrideprotectedvirtual |
Reimplemented from process::EventConsumer.
|
overrideprotectedvirtual |
Reimplemented from process::EventConsumer.
|
overrideprotectedvirtual |
Reimplemented from process::EventConsumer.
|
inlineprotected |
Delegates incoming messages, with the specified name, to the UPID
.
|
protected |
Returns the number of events of the given type currently on the event queue.
MUST be invoked from within the process itself in order to safely examine events.
|
inlineprotectedvirtual |
Invoked when a linked process has exited.
For local linked processes (i.e., when the linker and linkee are part of the same OS process), this can be used to reliably detect when the linked process has exited.
For remote linked processes, this indicates that the persistent TCP connection between the linker and the linkee has failed (e.g., linkee process died, a network error occurred). In this situation, the remote linkee process might still be running.
Reimplemented in mesos::internal::master::Master, and mesos::internal::slave::Slave.
|
inlineprotectedvirtual |
Invoked when a process is terminated.
NOTE: this does not get invoked automatically if process::ProcessBase::consume(TerminateEvent&&)
is overridden.
Reimplemented in mesos::internal::master::Master, mesos::internal::slave::Slave, NetworkProcess, mesos::internal::recordio::internal::ReaderProcess< T >, mesos::internal::log::LogWriterProcess, mesos::internal::HttpConnectionProcess< Call, Event >, process::SequenceProcess, mesos::internal::log::LogReaderProcess, process::RateLimiterProcess, mesos::internal::checks::CheckerProcess, process::System, mesos::internal::log::LogProcess, and process::HttpProxy.
|
inlineprotectedvirtual |
Invoked when a process gets spawned.
Reimplemented in mesos::internal::master::Master, mesos::internal::slave::Slave, process::internal::AwaitProcess< T >, mesos::internal::storage::UriDiskProfileAdaptorProcess, mesos::internal::recordio::internal::ReaderProcess< T >, zookeeper::GroupProcess, mesos::internal::log::LogWriterProcess, process::Help, process::internal::CollectProcess< T >, mesos::internal::log::LogReaderProcess, mesos::internal::slave::NetworkPortsIsolatorProcess, mesos::internal::slave::XfsDiskIsolatorProcess, mesos::internal::slave::PerfEventSubsystemProcess, mesos::internal::checks::CheckerProcess, mesos::internal::log::LogProcess, mesos::internal::slave::ContainerDaemonProcess, mesos::internal::VersionProcess, mesos::internal::ResponseHeartbeaterProcess< Message, Event >, mesos::internal::WhitelistWatcher, process::System, process::metrics::internal::MetricsProcess, process::Logging, process::MemoryProfiler, process::internal::ReaperProcess, and process::Profiler.
|
inlineprotected |
Sets up a handler for messages with the specified name.
|
inlineprotected |
Sets up a handler for messages with the specified name.
|
protected |
Links with the specified UPID
.
Linking with a process from within the same OS process is guaranteed to give you perfect monitoring of that process.
Linking to a remote process establishes a persistent TCP connection to the remote libprocess instance that hosts that process. If the TCP connection fails, the true state of the remote linked process cannot be determined; we handle this situation by generating an ExitedEvent.
|
inlineprotectedvirtual |
Invoked when a linked process can no longer be monitored.
TODO(neilc): This is not implemented.
|
inlineprotected |
Sets up the default HTTP request handler to provide the static asset(s) at the specified absolute path for the specified name.
For example, assuming the process named "server" invoked provide("name", "path")
, then an HTTP request for /server/name
would return the asset found at "path". If the specified path is a directory then an HTTP request for /server/name/file
would return the asset found at /path/file
.
The Content-Type
header of the HTTP response will be set to the specified type given the file extension, which can be changed via the optional types
parameter.
|
protected |
Sets up a handler for HTTP requests with the specified name.
name | The endpoint or URL to route. Must begin with a / and must not end with a '/'. |
|
inlineprotected |
Sets up a handler for HTTP requests with the specified name.
name | The endpoint or URL to route. Must begin with a / and must not end with a '/'. |
|
protected |
|
inlineprotected |
Forwards to the correct overload of process::ProcessBase::route()
, depending on whether the authentication realm realm
is present.
|
inline |
|
protected |
Sends the message to the specified UPID
.
Prefer the rvalue reference overloads if the data can be moved in.
|
protected |
|
protected |
|
inlineprotectedvirtual |
Invoked when an event is serviced.
Reimplemented in process::internal::ThunkProcess< R >.
|
friend |
|
friend |
|
friend |
hashmap<std::string, HttpEndpoint> process::ProcessBase::http |
hashmap<std::string, MessageHandler> process::ProcessBase::message |