Apache Mesos
executor.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 __MESOS_V1_EXECUTOR_HPP__
18 #define __MESOS_V1_EXECUTOR_HPP__
19 
20 #include <functional>
21 #include <queue>
22 #include <string>
23 
24 #include <mesos/http.hpp>
25 
26 #include <mesos/v1/mesos.hpp>
27 
29 
30 #include <process/owned.hpp>
31 
32 namespace mesos {
33 namespace v1 {
34 namespace executor {
35 
36 class MesosProcess; // Forward declaration.
37 
38 class MesosBase
39 {
40 public:
41  // Empty virtual destructor (necessary to instantiate subclasses).
42  virtual ~MesosBase() {}
43  virtual void send(const Call& call) = 0;
44 };
45 
46 
47 // Interface to Mesos for an executor.
48 //
49 // Expects three callbacks, 'connected', 'disconnected', and
50 // 'received' which will get invoked _serially_ when it's determined
51 // that we've connected (i.e. established TCP connection), disconnected
52 // (i.e, connection is broken), or received events from the agent.
53 // Note that we drop events while disconnected.
54 class Mesos : public MesosBase
55 {
56 public:
57  Mesos(ContentType contentType,
58  const std::function<void(void)>& connected,
59  const std::function<void(void)>& disconnected,
60  const std::function<void(const std::queue<Event>&)>& received);
61 
62  // Delete copy constructor.
63  Mesos(const Mesos& other) = delete;
64 
65  // Delete assignment operator.
66  Mesos& operator=(const Mesos& other) = delete;
67 
68  virtual ~Mesos();
69 
70  // Attempts to send a call to the agent.
71  //
72  // Some local validation of calls is performed which may result in dropped
73  // events without ever being sent to the agent.
74  virtual void send(const Call& call) override;
75 
76 private:
78 };
79 
80 } // namespace executor {
81 } // namespace v1 {
82 } // namespace mesos {
83 
84 #endif // __MESOS_V1_EXECUTOR_HPP__
ContentType
Definition: http.hpp:43
virtual void send(const Call &call)=0
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2583
virtual ~MesosBase()
Definition: executor.hpp:42
Mesos & operator=(const Mesos &other)=delete
Mesos(ContentType contentType, const std::function< void(void)> &connected, const std::function< void(void)> &disconnected, const std::function< void(const std::queue< Event > &)> &received)
Definition: executor.hpp:54
virtual void send(const Call &call) override
Definition: executor.hpp:38