Skip to content

Commit

Permalink
Change table-stats from list to map so that infra can analyze the sta…
Browse files Browse the repository at this point in the history
…ts easily

map makes it easer to diff, merge etc. when compared with a vector

Change-Id: Iadf4bb1c7ebff96e57ebcd94bb49b92916eddf3d
Partial-Bug: #1576437
  • Loading branch information
ananth-at-camphor-networks committed Jul 15, 2016
1 parent 4334365 commit 0dbf792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/bgp/bgp_server.cc
Expand Up @@ -743,7 +743,7 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const {
rit != inst_mgr_->end(); ++rit) {
RoutingInstanceStatsData instance_info;
RoutingInstance::RouteTableList const rt_list = rit->GetTables();
std::vector<BgpTableStats> tables_stats;
std::map<string, BgpTableStats> tables_stats;

for (RoutingInstance::RouteTableList::const_iterator it =
rt_list.begin(); it != rt_list.end(); ++it) {
Expand All @@ -754,10 +754,6 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const {
string family = Address::FamilyToString(table->family());

bool changed = false;
if (first || table->stats()->get_address_family() != family) {
changed = true;
table->stats()->set_address_family(family);
}

if (first || table->stats()->get_prefixes() != table->Size()) {
changed = true;
Expand Down Expand Up @@ -786,7 +782,11 @@ uint32_t BgpServer::SendTableStatsUve(bool first) const {
}

if (changed) {
tables_stats.push_back(*table->stats());

// Set the address family to be able to find to which family,
// the associated updated stats are applicable.
table->stats()->set_address_family(family);
tables_stats.insert(make_pair(family, *table->stats()));

// Reset changed flags in the uve structure.
memset(&(table->stats()->__isset), 0,
Expand Down
2 changes: 1 addition & 1 deletion src/bgp/bgp_table.sandesh
Expand Up @@ -7,7 +7,7 @@ include "bgp/table_info.sandesh"
struct RoutingInstanceStatsData {
1: string name (key="ObjectRoutingInstance");
2: optional bool deleted
3: optional list<table_info.BgpTableStats> table_stats (tags=".address_family");
3: optional map<string, table_info.BgpTableStats> table_stats (tags=".address_family");
}

/**
Expand Down

0 comments on commit 0dbf792

Please sign in to comment.