OpenSDN source code
interface_stats_io_context.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 
8 #include <ksync/ksync_types.h>
10 #include <uve/vm_uve_table.h>
11 
13  uint32_t seqno,
16  : IoContext(msg, msg_len, seqno, ctx, type) {
17 }
18 
20 }
21 
25 
26  int id = ctx->marker_id();
28  StatsManager::InterfaceStats *stats = ctx->IdToStats(id);
29  if (!stats) {
30  /* Stats Entry for interface does not exist. Interface could have
31  * been deleted */
32  if (!ctx->MoreData()) {
33  /* No more queries to vrouter */
35  }
36  /* The marker will remain unchanged if there are more queries to be
37  * done */
38  return;
39  }
40  if (stats->drop_stats_received) {
41  if (!ctx->MoreData()) {
42  /* No more queries to vrouter */
44  }
45  /* The marker will remain unchanged if there are more queries to be
46  * done */
47  } else {
48  /* Drop stats not received for last interface. Start fetching the
49  * stats from last interface */
50  ctx->set_marker_id((id-1));
51  }
52  }
53 }
54 
58  AgentStatsCollector *collector = ctx->agent()->stats_collector();
59  /* (1) Reset the marker for query during next timer interval, if there is
60  * no additional records for the current query
61  * (2) If there are additional interfaces to be queried, send DUMP request
62  * for those as well
63  * (3) Send UVE for stats info only when we have queried and obtained
64  * results for all interfaces. */
65  UpdateMarker();
68  (ctx->agent()->uve()->interface_uve_table());
69  it->SendInterfaceStats();
70  VmUveTable *vmt = static_cast<VmUveTable *>
71  (ctx->agent()->uve()->vm_uve_table());
72  vmt->SendVmStats();
73  } else {
74  collector->SendInterfaceBulkGet();
75  }
76 }
77 
79  KSYNC_ERROR(VRouterError, "VRouter Interface query failed. Error <", err,
81  ">. Object <", "N/A", ">. State <", "N/A",
82  ">. Message number :", GetSeqno());
83  LOG(ERROR, "Error reading Interface Stats. Error <" << err << ": "
85  << ": Sequence No : " << GetSeqno());
86 }
87 
StatsManager::InterfaceStats * IdToStats(int id) const
InterfaceUveTable * interface_uve_table() const
VmUveTableBase * vm_uve_table() const
AgentUveBase * uve() const
Definition: agent.cc:913
AgentStatsCollector * stats_collector() const
Definition: agent.cc:921
InterfaceStatsIoContext(int msg_len, char *msg, uint32_t seqno, AgentStatsSandeshContext *ctx, IoContext::Type type)
virtual void ErrorHandler(int err)
AgentSandeshContext * sandesh_context_
Definition: ksync_sock.h:151
uint32_t GetSeqno() const
Definition: ksync_sock.h:139
static std::string VrouterErrorToString(uint32_t error)
void SendVmStats(void)
Definition: vm_uve_table.cc:97
#define KSYNC_ERROR(obj,...)
Definition: ksync_entry.h:17
uint8_t type
Definition: load_balance.h:2
#define LOG(_Level, _Msg)
Definition: logging.h:35