Apache Mesos
container_daemon_process.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_CONTAINER_DAEMON_PROCESS_HPP__
18 #define __SLAVE_CONTAINER_DAEMON_PROCESS_HPP__
19 
20 #include <functional>
21 #include <string>
22 
23 #include <mesos/mesos.hpp>
24 #include <mesos/agent/agent.hpp>
25 
26 #include <process/future.hpp>
27 #include <process/http.hpp>
28 #include <process/process.hpp>
29 
30 #include <stout/option.hpp>
31 
32 #include "common/http.hpp"
33 
34 namespace mesos {
35 namespace internal {
36 namespace slave {
37 
38 class ContainerDaemonProcess : public process::Process<ContainerDaemonProcess>
39 {
40 public:
41  explicit ContainerDaemonProcess(
42  const process::http::URL& _agentUrl,
43  const Option<std::string>& _authToken,
44  const ContainerID& containerId,
45  const Option<CommandInfo>& commandInfo,
46  const Option<Resources>& resources,
47  const Option<ContainerInfo>& containerInfo,
48  const Option<std::function<process::Future<Nothing>()>>& _postStartHook,
49  const Option<std::function<process::Future<Nothing>()>>& _postStopHook);
50 
51  ContainerDaemonProcess(const ContainerDaemonProcess& other) = delete;
52 
54  const ContainerDaemonProcess& other) = delete;
55 
57 
58  // Made public for testing purpose.
59  void launchContainer();
60  void waitContainer();
61 
62 protected:
63  void initialize() override;
64 
65 private:
66  const process::http::URL agentUrl;
67  const Option<std::string> authToken;
68  const ContentType contentType;
69  const Option<std::function<process::Future<Nothing>()>> postStartHook;
70  const Option<std::function<process::Future<Nothing>()>> postStopHook;
71 
72  agent::Call launchCall;
73  agent::Call waitCall;
74 
75  process::Promise<Nothing> terminated;
76 };
77 
78 } // namespace slave {
79 } // namespace internal {
80 } // namespace mesos {
81 
82 #endif // __SLAVE_CONTAINER_DAEMON_PROCESS_HPP__
ContainerDaemonProcess(const process::http::URL &_agentUrl, const Option< std::string > &_authToken, const ContainerID &containerId, const Option< CommandInfo > &commandInfo, const Option< Resources > &resources, const Option< ContainerInfo > &containerInfo, const Option< std::function< process::Future< Nothing >()>> &_postStartHook, const Option< std::function< process::Future< Nothing >()>> &_postStopHook)
ContentType
Definition: http.hpp:43
ContainerDaemonProcess & operator=(const ContainerDaemonProcess &other)=delete
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2851
Definition: http.hpp:130
Definition: agent.hpp:25
Definition: attributes.hpp:24
Definition: container_daemon_process.hpp:38
Definition: process.hpp:505
void initialize() override
Invoked when a process gets spawned.