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