Skip to content

Commit d6e1ca6

Browse files
committed
mesos osx build fixes
1 parent 32f16ad commit d6e1ca6

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

userspace/libsinsp/mesos.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ mesos::mesos(const std::string& state_uri,
2727
const uri_list_t& marathon_uris,
2828
const std::string& groups_api,
2929
const std::string& apps_api,
30-
const std::string& watch_api): m_state_http(*this, state_uri + state_api),
30+
const std::string& watch_api)
31+
#ifdef HAS_CAPTURE
32+
: m_state_http(*this, state_uri + state_api),
3133
m_collector(false), m_creation_logged(false)
34+
#endif // HAS_CAPTURE
3235
{
36+
#ifdef HAS_CAPTURE
3337
for(const auto& uri : marathon_uris)
3438
{
3539
int port = (uri.substr(0, 5) == "https") ? 443 : 80;
@@ -51,6 +55,7 @@ mesos::mesos(const std::string& state_uri,
5155
}
5256

5357
refresh(marathon_uris.size());
58+
#endif // HAS_CAPTURE
5459
}
5560

5661
mesos::~mesos()
@@ -59,6 +64,7 @@ mesos::~mesos()
5964

6065
void mesos::refresh(bool marathon)
6166
{
67+
#ifdef HAS_CAPTURE
6268
clear(marathon);
6369

6470
m_state_http.get_all_data(&mesos::parse_state);
@@ -80,12 +86,13 @@ void mesos::refresh(bool marathon)
8086
m_collector.add(watch_http.second);
8187
}
8288
}
89+
#endif // HAS_CAPTURE
8390
}
8491

8592
bool mesos::is_alive() const
8693
{
8794
bool connected = true;
88-
95+
#ifdef HAS_CAPTURE
8996
connected &= m_state_http.is_connected();
9097
for(const auto& group : m_marathon_groups_http)
9198
{
@@ -98,12 +105,14 @@ bool mesos::is_alive() const
98105
}
99106

100107
connected &= (m_collector.subscription_count() > 0);
108+
#endif // HAS_CAPTURE
101109

102110
return connected;
103111
}
104112

105113
void mesos::watch()
106114
{
115+
#ifdef HAS_CAPTURE
107116
if(m_marathon_watch_http.size())
108117
{
109118
if(!m_collector.subscription_count())
@@ -115,6 +124,7 @@ void mesos::watch()
115124
}
116125
m_collector.get_data();
117126
}
127+
#endif // HAS_CAPTURE
118128
}
119129

120130
void mesos::determine_node_type(const Json::Value& root)
@@ -143,6 +153,7 @@ void mesos::determine_node_type(const Json::Value& root)
143153

144154
void mesos::add_task_labels(std::string& json)
145155
{
156+
#ifdef HAS_CAPTURE
146157
Json::Value root;
147158
Json::Reader reader;
148159
try
@@ -174,8 +185,10 @@ void mesos::add_task_labels(std::string& json)
174185
{
175186
g_logger.log(std::string("Error while looking for taks labels:") + ex.what(), sinsp_logger::SEV_ERROR);
176187
}
188+
#endif // HAS_CAPTURE
177189
}
178190

191+
#ifdef HAS_CAPTURE
179192
void mesos::get_groups(marathon_http::ptr_t http, std::string& json)
180193
{
181194
std::string group_ev_type = mesos_event_data::m_events[mesos_event_data::MESOS_GROUP_CHANGE_SUCCESS_EVENT];
@@ -242,6 +255,7 @@ void mesos::on_watch_data(const std::string& framework_id, mesos_event_data&& ms
242255
}
243256
}
244257
}
258+
#endif // HAS_CAPTURE
245259

246260
void mesos::parse_state(const std::string& json)
247261
{

userspace/libsinsp/mesos.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class mesos
5555
void watch();
5656
private:
5757

58-
void on_watch_data(const std::string& framework_id, mesos_event_data&& msg);
5958
void parse_state(const std::string& json);
6059
void determine_node_type(const Json::Value& root);
6160
bool is_master() const;
@@ -70,19 +69,24 @@ class mesos
7069
void parse_apps(const std::string& json);
7170

7271
void add_task_labels(std::string& json);
72+
73+
#ifdef HAS_CAPTURE
74+
void on_watch_data(const std::string& framework_id, mesos_event_data&& msg);
7375
void get_groups(marathon_http::ptr_t http, std::string& json);
7476

7577
typedef std::unordered_map<int, marathon_http::ptr_t> marathon_http_map;
7678
typedef std::unordered_map<int, marathon_dispatcher::ptr_t> marathon_disp_map;
7779

78-
node_t m_node_type;
7980
mesos_http m_state_http;
8081
marathon_http_map m_marathon_groups_http;
8182
marathon_http_map m_marathon_apps_http;
8283
marathon_http_map m_marathon_watch_http;
83-
mesos_state_t m_state;
84-
marathon_disp_map m_dispatch;
8584
mesos_collector m_collector;
85+
marathon_disp_map m_dispatch;
86+
#endif // HAS_CAPTURE
87+
88+
node_t m_node_type;
89+
mesos_state_t m_state;
8690
bool m_creation_logged;
8791

8892
static const mesos_component::component_map m_components;
@@ -106,10 +110,12 @@ inline bool mesos::is_master() const
106110
return m_node_type == NODE_MASTER;
107111
}
108112

113+
#ifdef HAS_CAPTURE
109114
inline bool mesos::has_marathon() const
110115
{
111116
return m_marathon_watch_http.size() > 0;
112117
}
118+
#endif // HAS_CAPTURE
113119

114120
inline void mesos::clear(bool marathon)
115121
{

userspace/libsinsp/utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ std::string get_json_string(const Json::Value& root, const std::string& name)
12501250
return ret;
12511251
}
12521252

1253-
#ifndef _WIN32
1253+
#if defined(__linux__)
12541254
///////////////////////////////////////////////////////////////////////////////
12551255
// Curl helpers
12561256
///////////////////////////////////////////////////////////////////////////////
@@ -1359,4 +1359,4 @@ void sinsp_curl::check_error(unsigned ret)
13591359
throw sinsp_exception(os.str());
13601360
}
13611361
}
1362-
#endif // _WIN32
1362+
#endif // __linux__

userspace/libsinsp/utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ std::string get_json_string(const Json::Value& root, const std::string& name);
189189
// Curl helpers
190190
///////////////////////////////////////////////////////////////////////////////
191191

192+
#if defined(__linux__)
193+
192194
class uri;
193195

194196
class sinsp_curl
@@ -215,3 +217,5 @@ class sinsp_curl
215217
string m_cert;
216218
long m_timeout;
217219
};
220+
221+
#endif // __linux__

0 commit comments

Comments
 (0)