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