OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interface_stats_io_context.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
7 #include <ksync/ksync_types.h>
9 #include <uve/vm_uve_table.h>
10 
12  uint32_t seqno,
15  : IoContext(msg, msg_len, seqno, ctx, type) {
16 }
17 
19 }
20 
24 
25  int id = ctx->marker_id();
27  StatsManager::InterfaceStats *stats = ctx->IdToStats(id);
28  if (!stats) {
29  /* Stats Entry for interface does not exist. Interface could have
30  * been deleted */
31  if (!ctx->MoreData()) {
32  /* No more queries to vrouter */
34  }
35  /* The marker will remain unchanged if there are more queries to be
36  * done */
37  return;
38  }
39  if (stats->drop_stats_received) {
40  if (!ctx->MoreData()) {
41  /* No more queries to vrouter */
43  }
44  /* The marker will remain unchanged if there are more queries to be
45  * done */
46  } else {
47  /* Drop stats not received for last interface. Start fetching the
48  * stats from last interface */
49  ctx->set_marker_id((id-1));
50  }
51  }
52 }
53 
57  AgentStatsCollector *collector = ctx->agent()->stats_collector();
58  /* (1) Reset the marker for query during next timer interval, if there is
59  * no additional records for the current query
60  * (2) If there are additional interfaces to be queried, send DUMP request
61  * for those as well
62  * (3) Send UVE for stats info only when we have queried and obtained
63  * results for all interfaces. */
64  UpdateMarker();
67  (ctx->agent()->uve()->interface_uve_table());
68  it->SendInterfaceStats();
69  VmUveTable *vmt = static_cast<VmUveTable *>
70  (ctx->agent()->uve()->vm_uve_table());
71  vmt->SendVmStats();
72  } else {
73  collector->SendInterfaceBulkGet();
74  }
75 }
76 
78  KSYNC_ERROR(VRouterError, "VRouter Interface query failed. Error <", err,
80  ">. Object <", "N/A", ">. State <", "N/A",
81  ">. Message number :", GetSeqno());
82  LOG(ERROR, "Error reading Interface Stats. Error <" << err << ": "
84  << ": Sequence No : " << GetSeqno());
85 }
86 
StatsManager::InterfaceStats * IdToStats(int id) const
uint32_t GetSeqno() const
Definition: ksync_sock.h:138
AgentUveBase * uve() const
Definition: agent.cc:909
#define KSYNC_ERROR(obj,...)
Definition: ksync_entry.h:16
VmUveTableBase * vm_uve_table() const
uint8_t type
Definition: load_balance.h:109
virtual void ErrorHandler(int err)
AgentSandeshContext * sandesh_context_
Definition: ksync_sock.h:150
AgentStatsCollector * stats_collector() const
Definition: agent.cc:917
static std::string VrouterErrorToString(uint32_t error)
InterfaceUveTable * interface_uve_table() const
InterfaceStatsIoContext(int msg_len, char *msg, uint32_t seqno, AgentStatsSandeshContext *ctx, IoContext::Type type)
#define LOG(_Level, _Msg)
Definition: logging.h:33
void SendVmStats(void)
Definition: vm_uve_table.cc:96