OpenSDN source code
sandesh_client.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 //
7 // sandesh_client.cc
8 //
9 // Sandesh Client
10 //
11 
12 #include <boost/bind/bind.hpp>
13 #include <boost/assign.hpp>
14 #include <boost/foreach.hpp>
15 
16 #include <base/task_annotations.h>
17 #include <base/time_util.h>
18 #include <io/event_manager.h>
19 #include <io/tcp_session.h>
20 #include <io/tcp_server.h>
21 
22 #include <sandesh/sandesh_constants.h>
23 #include <sandesh/sandesh_types.h>
24 #include <sandesh/sandesh.h>
25 #include <sandesh/sandesh_trace.h>
26 #include <sandesh/sandesh_session.h>
27 #include <sandesh/sandesh_http.h>
28 
29 #include "sandesh_state_machine.h"
30 
31 #include <sandesh/protocol/TXMLProtocol.h>
32 #include <sandesh/sandesh_ctrl_types.h>
33 #include <sandesh/sandesh_uve_types.h>
34 #include <sandesh/derived_stats_results_types.h>
35 #include <sandesh/common/vns_constants.h>
36 #include "sandesh_client.h"
37 #include "sandesh_uve.h"
38 #include "sandesh_util.h"
39 
40 using boost::asio::ip::address;
41 using namespace boost::asio;
42 using boost::system::error_code;
43 using std::string;
44 using std::map;
45 using std::make_pair;
46 using std::vector;
47 using namespace boost::placeholders;
48 
49 const std::string SandeshClient::kSMTask = "sandesh::SandeshClientSM";
50 const std::string SandeshClient::kSessionWriterTask = "sandesh::SandeshClientSession";
51 const std::string SandeshClient::kSessionReaderTask = "sandesh::SandeshClientReader";
53 const std::vector<Sandesh::QueueWaterMarkInfo>
54  SandeshClient::kSessionWaterMarkInfo = boost::assign::tuple_list_of
55  (50*1024*1024, SandeshLevel::SYS_UVE, true, false)
56  (30*1024*1024, SandeshLevel::SYS_EMERG, true, false)
57  (20*1024*1024, SandeshLevel::SYS_ERR, true, false)
58  (1*1024*1024, SandeshLevel::SYS_DEBUG, true, false)
59  (35*1024*1024, SandeshLevel::SYS_EMERG, false, false)
60  (25*1024*1024, SandeshLevel::SYS_ERR, false, false)
61  (15*1024*1024, SandeshLevel::SYS_DEBUG, false, false)
62  (2*1024, SandeshLevel::INVALID, false, false);
63 
65  const std::vector<Endpoint> &collectors,
66  const SandeshConfig &config,
67  bool periodicuve)
68  : SslServer(evm, boost::asio::ssl::context::tlsv12_client,
69  config.sandesh_ssl_enable),
70  sm_task_instance_(kSMTaskInstance),
71  sm_task_id_(TaskScheduler::GetInstance()->GetTaskId(kSMTask)),
72  session_task_instance_(kSessionTaskInstance),
73  session_writer_task_id_(TaskScheduler::GetInstance()->GetTaskId(kSessionWriterTask)),
74  session_reader_task_id_(TaskScheduler::GetInstance()->GetTaskId(kSessionReaderTask)),
75  dscp_value_(0),
76  collectors_(collectors),
77  stats_collector_(config.stats_collector),
78  sm_(SandeshClientSM::CreateClientSM(evm, this, sm_task_instance_, sm_task_id_,
79  periodicuve)),
80  session_wm_info_(kSessionWaterMarkInfo),
81  session_close_interval_msec_(0),
82  session_close_time_usec_(0) {
83  // Set task policy for exclusion between state machine and session tasks since
84  // session delete happens in state machine task
85  if (!task_policy_set_) {
86  TaskPolicy sm_task_policy = boost::assign::list_of
90  task_policy_set_ = true;
91  }
92  if (config.sandesh_ssl_enable) {
93  boost::asio::ssl::context *ctx = context();
94  boost::system::error_code ec;
95  ctx->set_options(boost::asio::ssl::context::default_workarounds |
96  boost::asio::ssl::context::no_tlsv1 |
97  boost::asio::ssl::context::no_sslv3 |
98  boost::asio::ssl::context::no_sslv2 |
99  boost::asio::ssl::context::no_tlsv1_1, ec);
100  if (ec.value() != 0) {
101  SANDESH_LOG(ERROR, "Error setting ssl options: " << ec.message());
102  exit(EINVAL);
103  }
104  // CA certificate
105  if (!config.ca_cert.empty()) {
106  // Verify that the peer certificate is signed by a trusted CA
107  ctx->set_verify_mode(boost::asio::ssl::verify_peer |
108  boost::asio::ssl::verify_fail_if_no_peer_cert,
109  ec);
110  if (ec.value() != 0) {
111  SANDESH_LOG(ERROR, "Error setting verification mode: " <<
112  ec.message());
113  exit(EINVAL);
114  }
115  ctx->load_verify_file(config.ca_cert, ec);
116  if (ec.value() != 0) {
117  SANDESH_LOG(ERROR, "Error loading CA certificate: " <<
118  ec.message());
119  exit(EINVAL);
120  }
121  }
122  // Server certificate
123  ctx->use_certificate_chain_file(config.certfile, ec);
124  if (ec.value() != 0) {
125  SANDESH_LOG(ERROR, "Error using server certificate: " <<
126  ec.message());
127  exit(EINVAL);
128  }
129  // Server private key
130  ctx->use_private_key_file(config.keyfile,
131  boost::asio::ssl::context::pem, ec);
132  if (ec.value() != 0) {
133  SANDESH_LOG(ERROR, "Error using server private key file: " <<
134  ec.message());
135  exit(EINVAL);
136  }
137  }
138  if (stats_collector_ != "") {
139  UdpServer::Endpoint stats_server;
140  size_t found = stats_collector_.find(":");
141  if (found != std::string::npos) {
143  } else {
144 #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
145  stats_client_.reset(new StatsClientLocal(*evm->io_service(), stats_collector_));
146 #else
147  SANDESH_LOG(ERROR, "Unix Domain Sockets are not supported on this platform");
148 #endif
149  }
150  }
151 }
152 
154 
156  const std::vector<std::string>& collector_list) {
157  std::vector<Endpoint> collector_endpoints;
158 
159  BOOST_FOREACH(const std::string& collector, collector_list) {
160  Endpoint ep;
161  if (!MakeEndpoint(&ep, collector)) {
162  SANDESH_LOG(ERROR, __func__ << ": Invalid collector address: " <<
163  collector);
164  return;
165  }
166  collector_endpoints.push_back(ep);
167  }
168  sm_->SetCollectors(collector_endpoints);
169 }
170 
172  sm_->SetAdminState(false);
173  if (collectors_.size())
174  sm_->SetCollectors(collectors_);
175  if (stats_collector_ != "") {
176  stats_client_->Initialize();
177  }
178 }
179 
181  sm_->SetAdminState(true);
182 }
183 
185  return sm_->SendSandesh(snh);
186 }
187 
189  return sm_->SendSandeshUVE(snh);
190 }
191 
192 bool SandeshClient::ReceiveCtrlMsg(const std::string &msg,
193  const SandeshHeader &header, const std::string &sandesh_name,
194  const uint32_t header_offset) {
195 
196  Sandesh * sandesh = SandeshSession::DecodeCtrlSandesh(msg, header, sandesh_name, header_offset);
197 
198  const SandeshCtrlServerToClient * snh = dynamic_cast<const SandeshCtrlServerToClient *>(sandesh);
199  if (!snh) {
200  SANDESH_LOG(ERROR, "Received Ctrl Message with wrong type " << sandesh->Name());
201  sandesh->Release();
202  return false;
203  }
204  if (!snh->get_success()) {
205  SANDESH_LOG(ERROR, "Received Ctrl Message : Connection with server has failed");
206  sandesh->Release();
207  return false;
208  }
209  SANDESH_LOG(DEBUG, "Received Ctrl Message with size " << snh->get_type_info().size());
210 
211  map<string,uint32_t> sMap;
212  const vector<UVETypeInfo> & vu = snh->get_type_info();
213  for(uint32_t i = 0; i < vu.size(); i++) {
214  sMap.insert(std::make_pair(vu[i].get_type_name(), vu[i].get_seq_num()));
215  }
217 
218  sandesh->Release();
219  return true;
220 }
221 
222 
223 bool SandeshClient::ReceiveMsg(const std::string& msg,
224  const SandeshHeader &header, const std::string &sandesh_name,
225  const uint32_t header_offset) {
226 
227  namespace sandesh_prot = contrail::sandesh::protocol;
228  namespace sandesh_trans = contrail::sandesh::transport;
229 
230  if (header.get_Hints() & g_sandesh_constants.SANDESH_CONTROL_HINT) {
231  bool success = ReceiveCtrlMsg(msg, header, sandesh_name, header_offset);
232  if (success) {
233  Sandesh::UpdateRxMsgStats(sandesh_name, msg.size());
234  } else {
235  Sandesh::UpdateRxMsgFailStats(sandesh_name, msg.size(),
236  SandeshRxDropReason::ControlMsgFailed);
237  }
238  return success;
239  }
240 
241  // Create and process the sandesh
243  if (sandesh == NULL) {
244  SANDESH_LOG(ERROR, __func__ << ": Unknown sandesh: " << sandesh_name);
245  Sandesh::UpdateRxMsgFailStats(sandesh_name, msg.size(),
246  SandeshRxDropReason::CreateFailed);
247  return true;
248  }
249  boost::shared_ptr<sandesh_trans::TMemoryBuffer> btrans =
250  boost::shared_ptr<sandesh_trans::TMemoryBuffer>(
251  new sandesh_trans::TMemoryBuffer((uint8_t *)msg.c_str() + header_offset,
252  msg.size() - header_offset));
253  boost::shared_ptr<sandesh_prot::TXMLProtocol> prot =
254  boost::shared_ptr<sandesh_prot::TXMLProtocol>(new sandesh_prot::TXMLProtocol(btrans));
255  int32_t xfer = sandesh->Read(prot);
256  if (xfer < 0) {
257  SANDESH_LOG(ERROR, __func__ << ": Decoding " << sandesh_name << " FAILED");
258  Sandesh::UpdateRxMsgFailStats(sandesh_name, msg.size(),
259  SandeshRxDropReason::DecodingFailed);
260  return false;
261  }
262 
263  Sandesh::UpdateRxMsgStats(sandesh_name, msg.size());
264  SandeshRequest *sr = dynamic_cast<SandeshRequest *>(sandesh);
265  assert(sr);
267  return true;
268 }
269 
270 void
271 SandeshCtrlServerToClient::HandleRequest() const { }
272 
273 void
274 SandeshCtrlClientToServer::HandleRequest() const { }
275 
276 
279  SandeshReceiveMsgCb rmcb,
280  TcpServer::Endpoint ep) {
282  Socket *socket = session->socket();
283 
284  error_code ec;
285  socket->open(ip::tcp::v4(), ec);
286  if (ec) {
287  SANDESH_LOG(ERROR, __func__ << " Open FAILED: " << ec.message());
289  return NULL;
290  }
291  ec = session->SetSocketOptions();
292  if (ec) {
293  SANDESH_LOG(ERROR, __func__ << " Unable to set socket options: " << ec.message());
295  return NULL;
296  }
297  if (dscp_value_) {
299  }
300  SandeshSession *sandesh_session =
301  static_cast<SandeshSession *>(session);
302  sandesh_session->SetReceiveMsgCb(rmcb);
303  sandesh_session->SetConnection(NULL);
304  sandesh_session->set_observer(eocb);
305  // Set watermarks
306  for (size_t i = 0; i < session_wm_info_.size(); i++) {
307  sandesh_session->SetSendQueueWaterMark(session_wm_info_[i]);
308  }
309  TcpServer::Connect(sandesh_session, ep);
310 
311  return sandesh_session;
312 }
313 
315  std::vector<string> stv;
316 
317  SandeshUVETypeMaps::uve_global_map::const_iterator it =
319  for(; it!= SandeshUVETypeMaps::End(); it++) {
320  stv.push_back(it->first);
321  }
322  SANDESH_LOG(DEBUG, "Sending Ctrl Message for " << Sandesh::source() << ":" <<
323  Sandesh::module() << ":" << Sandesh::instance_id() << ":" <<
324  Sandesh::node_type() << " count " << count);
325 
326  SandeshCtrlClientToServer::Request(Sandesh::source(), Sandesh::module(),
327  count, stv, getpid(), Sandesh::http_port(),
329 
330 }
331 
333  SandeshSession *session(sm_->session());
334  if (session) {
336  return true;
337  }
338  return false;
339 }
340 
341 bool DoCloseSMSession(uint64_t now_usec, uint64_t last_close_usec,
342  uint64_t last_close_interval_usec, int *close_interval_msec) {
343  // If this is the first time, we will accept the next close
344  // only after the initial close interval time
345  if (last_close_interval_usec == 0 || last_close_usec == 0) {
346  *close_interval_msec =
348  return true;
349  }
350  assert(now_usec >= last_close_usec);
351  uint64_t time_since_close_usec(now_usec - last_close_usec);
352  // We will ignore close events receive before the last close
353  // interval is finished
354  if (time_since_close_usec <= last_close_interval_usec) {
355  *close_interval_msec = 0;
356  return false;
357  }
358  // We will double the close interval time if we get a close
359  // event between last close interval and 2 * last close interval.
360  // If the close event is between 2 * last close interval and
361  // 4 * last close interval, then the close interval will be
362  // same as the current close interval. If the close event is
363  // after 4 * last close interval, then we will reset the close
364  // interval to the initial close interval
365  if (time_since_close_usec > last_close_interval_usec &&
366  time_since_close_usec <= 2 * last_close_interval_usec) {
367  uint64_t nclose_interval_msec((2 * last_close_interval_usec)/1000);
368  *close_interval_msec = std::min(nclose_interval_msec,
369  static_cast<uint64_t>(
371  return true;
372  } else if ((2 * last_close_interval_usec <= time_since_close_usec) &&
373  (time_since_close_usec <= 4 * last_close_interval_usec)) {
374  *close_interval_msec = last_close_interval_usec/1000;
375  return true;
376  } else {
377  *close_interval_msec =
379  return true;
380  }
381 }
382 
384  uint64_t now_usec(UTCTimestampUsec());
385  int close_interval_msec(0);
386  bool close(DoCloseSMSession(now_usec, session_close_time_usec_,
387  session_close_interval_msec_ * 1000, &close_interval_msec));
388  if (close) {
389  session_close_time_usec_ = now_usec;
390  session_close_interval_msec_ = close_interval_msec;
391  return CloseSMSessionInternal();
392  }
393  return false;
394 }
395 
396 static bool client_start = false;
397 static uint64_t client_start_time;
398 
399 void SandeshClient::SendUVE(int count,
400  const string & stateName, const string & server,
401  const Endpoint & server_ip,
402  const std::vector<TcpServer::Endpoint> & collector_eps) {
403  ModuleClientState mcs;
404  mcs.set_name(Sandesh::source() + ":" + Sandesh::node_type() +
405  ":" + Sandesh::module() + ":" + Sandesh::instance_id());
406  SandeshClientInfo sci;
407  if (!client_start) {
409  client_start = true;
410  }
411  sci.set_start_time(client_start_time);
412  sci.set_successful_connections(count);
413  sci.set_pid(getpid());
414  sci.set_http_port(Sandesh::http_port());
415  sci.set_status(stateName);
416  sci.set_collector_name(server);
417  std::ostringstream collector_ip;
418  collector_ip << server_ip;
419  sci.set_collector_ip(collector_ip.str());
420  std::vector<std::string> collectors;
421  BOOST_FOREACH(const TcpServer::Endpoint& ep, collector_eps) {
422  std::ostringstream collector_ip;
423  collector_ip << ep;
424  collectors.push_back(collector_ip.str());
425  }
426  sci.set_collector_list(collectors);
427  // Sandesh client socket statistics
428  SocketIOStats rx_stats;
429  GetRxSocketStats(rx_stats);
430  sci.set_rx_socket_stats(rx_stats);
431  SocketIOStats tx_stats;
432  GetTxSocketStats(tx_stats);
433  sci.set_tx_socket_stats(tx_stats);
434 
435  mcs.set_client_info(sci);
436 
437  std::vector<SandeshMessageTypeStats> mtype_stats;
438  SandeshMessageStats magg_stats;
439  Sandesh::GetMsgStats(&mtype_stats, &magg_stats);
440 
441  map<string,uint64_t> csev;
442  csev.insert(make_pair("sent", magg_stats.get_messages_sent()));
443  csev.insert(make_pair("dropped_no_queue",
444  magg_stats.get_messages_sent_dropped_no_queue()));
445  csev.insert(make_pair("dropped_no_client",
446  magg_stats.get_messages_sent_dropped_no_client()));
447  csev.insert(make_pair("dropped_no_session",
448  magg_stats.get_messages_sent_dropped_no_session()));
449  csev.insert(make_pair("dropped_queue_level",
450  magg_stats.get_messages_sent_dropped_queue_level()));
451  csev.insert(make_pair("dropped_client_send_failed",
452  magg_stats.get_messages_sent_dropped_client_send_failed()));
453  csev.insert(make_pair("dropped_session_not_connected",
454  magg_stats.get_messages_sent_dropped_session_not_connected()));
455  csev.insert(make_pair("dropped_header_write_failed",
456  magg_stats.get_messages_sent_dropped_header_write_failed()));
457  csev.insert(make_pair("dropped_write_failed",
458  magg_stats.get_messages_sent_dropped_write_failed()));
459  csev.insert(make_pair("dropped_wrong_client_sm_state",
460  magg_stats.get_messages_sent_dropped_wrong_client_sm_state()));
461  csev.insert(make_pair("dropped_validation_failed",
462  magg_stats.get_messages_sent_dropped_validation_failed()));
463  csev.insert(make_pair("dropped_rate_limited",
464  magg_stats.get_messages_sent_dropped_rate_limited()));
465  csev.insert(make_pair("dropped_sending_disabled",
466  magg_stats.get_messages_sent_dropped_sending_disabled()));
467  csev.insert(make_pair("dropped_sending_to_syslog",
468  magg_stats.get_messages_sent_dropped_sending_to_syslog()));
469  mcs.set_tx_msg_agg(csev);
470 
471  map <string,SandeshMessageStats> csevm;
472  for (vector<SandeshMessageTypeStats>::const_iterator smit = mtype_stats.begin();
473  smit != mtype_stats.end(); smit++) {
474  SandeshMessageStats res_sms;
475  const SandeshMessageStats& src_sms = smit->get_stats();
476  res_sms.set_messages_sent(src_sms.get_messages_sent());
477  res_sms.set_messages_sent_dropped_no_queue(
478  src_sms.get_messages_sent_dropped_no_queue());
479  res_sms.set_messages_sent_dropped_no_client(
480  src_sms.get_messages_sent_dropped_no_client());
481  res_sms.set_messages_sent_dropped_no_session(
482  src_sms.get_messages_sent_dropped_no_session());
483  res_sms.set_messages_sent_dropped_queue_level(
484  src_sms.get_messages_sent_dropped_queue_level());
485  res_sms.set_messages_sent_dropped_client_send_failed(
486  src_sms.get_messages_sent_dropped_client_send_failed());
487  res_sms.set_messages_sent_dropped_session_not_connected(
488  src_sms.get_messages_sent_dropped_session_not_connected());
489  res_sms.set_messages_sent_dropped_header_write_failed(
490  src_sms.get_messages_sent_dropped_header_write_failed());
491  res_sms.set_messages_sent_dropped_write_failed(
492  src_sms.get_messages_sent_dropped_write_failed());
493  res_sms.set_messages_sent_dropped_wrong_client_sm_state(
494  src_sms.get_messages_sent_dropped_wrong_client_sm_state());
495  res_sms.set_messages_sent_dropped_validation_failed(
496  src_sms.get_messages_sent_dropped_validation_failed());
497  res_sms.set_messages_sent_dropped_rate_limited(
498  src_sms.get_messages_sent_dropped_rate_limited());
499  res_sms.set_messages_sent_dropped_sending_disabled(
500  src_sms.get_messages_sent_dropped_sending_disabled());
501  res_sms.set_messages_sent_dropped_sending_to_syslog(
502  src_sms.get_messages_sent_dropped_sending_to_syslog());
503  csevm.insert(make_pair(smit->get_message_type(), res_sms));
504  }
505  mcs.set_msg_type_agg(csevm);
506 
507  SandeshModuleClientTrace::Send(mcs);
508 }
509 
512  SandeshSession *session = sm_->session();
513  if (session) {
515  }
516  session_wm_info_.push_back(scwm);
517 }
518 
520  SandeshSession *session = sm_->session();
521  if (session) {
523  }
524  session_wm_info_.clear();
525 }
526 
528  std::vector<Sandesh::QueueWaterMarkInfo> &scwm_info) const {
529  scwm_info = session_wm_info_;
530 }
531 
533  return new SandeshSession(this, socket, session_task_instance_,
536 }
537 
538 void SandeshClient::SetDscpValue(uint8_t value) {
539  if (value == dscp_value_)
540  return;
541 
542  dscp_value_ = value;
543  SandeshSession *sess = session();
544  if (sess) {
545  sess->SetDscpSocketOption(value);
546  }
548 }
boost::asio::io_context * io_service()
Definition: event_manager.h:43
static Sandesh * CreateInstance(std::string const &s)
Definition: cpp/sandesh.h:626
void InitializeSMSession(int connects)
virtual SandeshSession * CreateSMSession(SslSession::EventObserver eocb, SandeshReceiveMsgCb rmcb, TcpServer::Endpoint ep)
SandeshSession * session() const
std::vector< Sandesh::QueueWaterMarkInfo > session_wm_info_
void ReConfigCollectors(const std::vector< std::string > &)
std::vector< Endpoint > collectors_
static const std::string kSessionReaderTask
uint64_t session_close_time_usec_
void GetSessionWaterMarkInfo(std::vector< Sandesh::QueueWaterMarkInfo > &scwm_info) const
bool ReceiveMsg(const std::string &msg, const SandeshHeader &header, const std::string &sandesh_name, const uint32_t header_offset)
boost::scoped_ptr< StatsClient > stats_client_
int session_task_instance_
virtual ~SandeshClient()
static bool task_policy_set_
void ResetSessionWaterMarkInfo()
static const int kInitialSMSessionCloseIntervalMSec
void SetDscpValue(uint8_t value)
bool CloseSMSessionInternal()
bool SendSandeshUVE(Sandesh *snh_uve)
void SendUVE(int count, const std::string &stateName, const std::string &server, const Endpoint &server_ip, const std::vector< Endpoint > &collector_eps)
std::string stats_collector_
uint8_t dscp_value_
static const int kMaxSMSessionCloseIntervalMSec
int session_writer_task_id_
bool SendSandesh(Sandesh *snh)
int session_close_interval_msec_
bool ReceiveCtrlMsg(const std::string &msg, const SandeshHeader &header, const std::string &sandesh_name, const uint32_t header_offset)
static const std::vector< Sandesh::QueueWaterMarkInfo > kSessionWaterMarkInfo
static const std::string kSessionWriterTask
int session_reader_task_id_
static const std::string kSMTask
boost::scoped_ptr< SandeshClientSM > sm_
SandeshClient(EventManager *evm, const std::vector< Endpoint > &collectors, const SandeshConfig &config, bool periodicuve=false)
void SetSessionWaterMarkInfo(Sandesh::QueueWaterMarkInfo &scwm)
virtual SslSession * AllocSession(SslSocket *socket)
static void UpdateDscp(uint8_t dscp)
bool Enqueue(SandeshRxQueue *queue)
Definition: sandesh.cc:804
virtual void EnqueueClose()
virtual boost::system::error_code SetSocketOptions()
static Sandesh * DecodeCtrlSandesh(const std::string &msg, const SandeshHeader &header, const std::string &sandesh_name, const uint32_t &header_offset)
void SetConnection(SandeshConnection *connection)
void SetSendQueueWaterMark(Sandesh::QueueWaterMarkInfo &wm_info)
void SetReceiveMsgCb(SandeshReceiveMsgCb cb)
void ResetSendQueueWaterMark()
static uve_global_map::const_iterator Begin()
Definition: sandesh_uve.h:60
static uve_global_map::const_iterator End()
Definition: sandesh_uve.h:61
static void SyncAllMaps(const std::map< std::string, uint32_t > &, bool periodic=false)
Definition: sandesh_uve.cc:61
static int http_port()
Definition: cpp/sandesh.h:300
boost::tuple< size_t, SandeshLevel::type, bool, bool > QueueWaterMarkInfo
Definition: cpp/sandesh.h:150
static void UpdateRxMsgFailStats(const std::string &msg_name, uint64_t bytes, SandeshRxDropReason::type dreason)
Definition: sandesh.cc:880
static void GetMsgStats(std::vector< SandeshMessageTypeStats > *mtype_stats, SandeshMessageStats *magg_stats)
Definition: sandesh.cc:898
static void UpdateRxMsgStats(const std::string &msg_name, uint64_t bytes)
Definition: sandesh.cc:874
static std::string source()
Definition: cpp/sandesh.h:292
static std::string module()
Definition: cpp/sandesh.h:294
static SandeshRxQueue * recv_queue()
Definition: cpp/sandesh.h:301
static std::string instance_id()
Definition: cpp/sandesh.h:296
static std::string node_type()
Definition: cpp/sandesh.h:298
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > SslSocket
Definition: ssl_server.h:17
boost::asio::ssl::context * context()
Definition: ssl_server.cc:44
virtual Socket * socket() const
Definition: ssl_session.cc:99
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
Definition: task.h:307
void SetPolicy(int task_id, TaskPolicy &policy)
Sets the task exclusion policy. Adds policy entries for the task Examples:
Definition: task.cc:637
static TaskScheduler * GetInstance()
Definition: task.cc:574
boost::asio::ip::tcp::endpoint Endpoint
Definition: tcp_server.h:31
virtual void Connect(TcpSession *session, Endpoint remote)
Definition: tcp_server.cc:477
void GetRxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:642
virtual TcpSession * CreateSession()
Definition: tcp_server.cc:191
virtual void DeleteSession(TcpSession *session)
Definition: tcp_server.cc:200
boost::asio::ip::tcp::socket Socket
Definition: tcp_server.h:32
void GetTxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:646
void set_observer(EventObserver observer)
Definition: tcp_session.cc:220
boost::function< void(TcpSession *, Event)> EventObserver
Definition: tcp_session.h:60
int SetDscpSocketOption(uint8_t value)
Definition: tcp_session.cc:571
boost::asio::ip::udp::endpoint Endpoint
Definition: udp_server.h:24
static EventManager evm
#define SANDESH_LOG(_Level, _Msg)
Definition: cpp/sandesh.h:477
@ INVALID
Definition: globals.h:150
static uint64_t client_start_time
bool DoCloseSMSession(uint64_t now_usec, uint64_t last_close_usec, uint64_t last_close_interval_usec, int *close_interval_msec)
static bool client_start
boost::function< bool(const std::string &, SandeshSession *)> SandeshReceiveMsgCb
bool MakeEndpoint(TcpServer::Endpoint *ep, const std::string &epstr)
Definition: sandesh_util.cc:19
std::string keyfile
std::string ca_cert
std::string certfile
The class is used to specify a Task label for formulating a task exclusion list (an execution policy)...
Definition: task.h:249
std::vector< TaskExclusion > TaskPolicy
Defines a type to store an execution policy (a list of task exclusions).
Definition: task.h:273
static uint64_t UTCTimestampUsec()
Definition: time_util.h:14