Skip to content

Commit

Permalink
Merge "Disable flow and UVE stats from TSN" into R2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 15, 2015
2 parents 3676f73 + 54baab9 commit e8c8d51
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 115 deletions.
15 changes: 11 additions & 4 deletions src/vnsw/agent/contrail/contrail_agent_init.cc
Expand Up @@ -11,6 +11,7 @@
#include <controller/controller_init.h>
#include <vrouter/ksync/ksync_init.h>
#include <uve/agent_uve.h>
#include <uve/agent_uve_stats.h>
#include <vrouter/stats_collector/agent_stats_collector.h>
#include <vrouter/flow_stats/flow_stats_collector.h>
#include <openstack/instance_service_server.h>
Expand Down Expand Up @@ -38,7 +39,13 @@ void ContrailAgentInit::ProcessOptions
* Initialization routines
****************************************************************************/
void ContrailAgentInit::FactoryInit() {
AgentObjectFactory::Register<AgentUveBase>(boost::factory<AgentUve *>());
if (agent()->tsn_enabled() == false) {
AgentObjectFactory::Register<AgentUveBase>
(boost::factory<AgentUveStats *>());
} else {
AgentObjectFactory::Register<AgentUveBase>
(boost::factory<AgentUve *>());
}
if (agent_param()->vrouter_on_nic_mode() || agent_param()->vrouter_on_host_dpdk()) {
AgentObjectFactory::Register<KSync>(boost::factory<KSyncTcp *>());
} else {
Expand Down Expand Up @@ -73,14 +80,14 @@ void ContrailAgentInit::CreateModules() {
*(agent()->event_manager()->io_service()),
agent()));
agent()->set_stats_collector(stats_collector_.get());
}

flow_stats_collector_.reset(new FlowStatsCollector(
flow_stats_collector_.reset(new FlowStatsCollector(
*(agent()->event_manager()->io_service()),
agent()->params()->flow_stats_interval(),
agent()->params()->flow_cache_timeout(),
uve_.get()));
agent()->set_flow_stats_collector(flow_stats_collector_.get());
agent()->set_flow_stats_collector(flow_stats_collector_.get());
}

ksync_.reset(AgentObjectFactory::Create<KSync>(agent()));
agent()->set_ksync(ksync_.get());
Expand Down
8 changes: 4 additions & 4 deletions src/vnsw/agent/ovs_tor_agent/tor_agent_init.cc
Expand Up @@ -22,7 +22,7 @@
#include <oper/mpls.h>
#include <oper/route_common.h>
#include <oper/bridge_route.h>
#include <uve/agent_uve_base.h>
#include <uve/agent_uve.h>

#include <cfg/cfg_init.h>
#include <controller/controller_init.h>
Expand Down Expand Up @@ -77,9 +77,9 @@ void TorAgentInit::CreateModules() {
static_cast<TorAgentParam *>(agent_param()),
ovs_peer_manager()));
agent()->set_ovsdb_client(ovsdb_client_.get());
uve_.reset(new AgentUveBase(agent(), AgentUveBase::kBandwidthInterval, true,
AgentUveBase::kDefaultInterval,
AgentUveBase::kIncrementalInterval));
uve_.reset(new AgentUve(agent(), AgentUveBase::kBandwidthInterval,
AgentUveBase::kDefaultInterval,
AgentUveBase::kIncrementalInterval));
agent()->set_uve(uve_.get());
}

Expand Down
6 changes: 5 additions & 1 deletion src/vnsw/agent/pkt/pkt_sandesh_flow.cc
Expand Up @@ -396,19 +396,23 @@ void FetchFlowRecord::HandleRequest() const {
// Intended for use in testing only
void FlowAgeTimeReq::HandleRequest() const {
Agent *agent = Agent::GetInstance();
uint32_t age_time = get_new_age_time();

FlowStatsCollector *collector = agent->flow_stats_collector();

FlowAgeTimeResp *resp = new FlowAgeTimeResp();
if (collector == NULL) {
goto done;
}
resp->set_old_age_time(collector->flow_age_time_intvl_in_secs());

uint32_t age_time = get_new_age_time();
if (age_time && age_time != resp->get_old_age_time()) {
collector->UpdateFlowAgeTimeInSecs(age_time);
resp->set_new_age_time(age_time);
} else {
resp->set_new_age_time(resp->get_old_age_time());
}
done:
resp->set_context(context());
resp->set_more(false);
resp->Response();
Expand Down
11 changes: 6 additions & 5 deletions src/vnsw/agent/test/test_util.cc
Expand Up @@ -7,6 +7,7 @@
#include "test/test_init.h"
#include "oper/mirror_table.h"
#include "uve/test/vn_uve_table_test.h"
#include "uve/agent_uve_stats.h"

#define MAX_TESTNAME_LEN 80

Expand Down Expand Up @@ -696,7 +697,7 @@ bool VmPortGetStats(PortInfo *input, int id, uint32_t & bytes, uint32_t & pkts)
if (intf == NULL)
return false;

AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
const StatsManager::InterfaceStats *st = sm->GetInterfaceStats(intf);
if (st == NULL)
Expand All @@ -714,7 +715,7 @@ bool VrfStatsMatch(int vrf_id, std::string vrf_name, bool stats_match,
uint64_t fabric_composites, uint64_t l2_mcast_composites,
uint64_t l3_mcast_composites, uint64_t multi_proto_composites,
uint64_t encaps, uint64_t l2_encaps) {
AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
const StatsManager::VrfStats *st = sm->GetVrfStats(vrf_id);
if (st == NULL) {
Expand Down Expand Up @@ -761,7 +762,7 @@ bool VrfStatsMatchPrev(int vrf_id, uint64_t discards, uint64_t resolves,
uint64_t l2_mcast_composites, uint64_t l3_mcast_composites,
uint64_t multi_proto_composites, uint64_t encaps,
uint64_t l2_encaps) {
AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
const StatsManager::VrfStats *st = sm->GetVrfStats(vrf_id);
if (st == NULL) {
Expand Down Expand Up @@ -801,7 +802,7 @@ bool VmPortStats(PortInfo *input, int id, uint32_t bytes, uint32_t pkts) {
if (intf == NULL)
return false;

AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
const StatsManager::InterfaceStats *st = sm->GetInterfaceStats(intf);
if (st == NULL)
Expand All @@ -814,7 +815,7 @@ bool VmPortStats(PortInfo *input, int id, uint32_t bytes, uint32_t pkts) {

bool VmPortStatsMatch(Interface *intf, uint32_t ibytes, uint32_t ipkts,
uint32_t obytes, uint32_t opkts) {
AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
const StatsManager::InterfaceStats *st = sm->GetInterfaceStats(intf);
EXPECT_TRUE(st != NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/vnsw/agent/uve/SConscript
Expand Up @@ -94,6 +94,7 @@ libuve = env.Library('uve',
SandeshGenObjs +
[
'agent_uve_base.cc',
'agent_uve.cc',
'interface_uve_table.cc',
'l4_port_bitmap.cc',
'prouter_uve_table.cc',
Expand All @@ -108,7 +109,7 @@ libuve = env.Library('uve',
libstatsuve = env.Library('statsuve',
StatsSandeshGenObjs +
[
'agent_uve.cc',
'agent_uve_stats.cc',
'interface_uve_stats_table.cc',
'stats_manager.cc',
'vm_stat.cc',
Expand Down
38 changes: 6 additions & 32 deletions src/vnsw/agent/uve/agent_uve.cc
Expand Up @@ -21,39 +21,13 @@

AgentUve::AgentUve(Agent *agent, uint64_t intvl, uint32_t default_intvl,
uint32_t incremental_intvl)
: AgentUveBase(agent, intvl, false, default_intvl, incremental_intvl),
stats_manager_(new StatsManager(agent)) {
//Override vm_uve_table_ to point to derived class object
vn_uve_table_.reset(new VnUveTable(agent, default_intvl));
vm_uve_table_.reset(new VmUveTable(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntry(agent));
interface_uve_table_.reset(new InterfaceUveStatsTable(agent,
default_intvl));
}
: AgentUveBase(agent, intvl, default_intvl, incremental_intvl) {

AgentUve::~AgentUve() {
vn_uve_table_.reset(new VnUveTableBase(agent, default_intvl));
vm_uve_table_.reset(new VmUveTableBase(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntryBase(agent));
interface_uve_table_.reset(new InterfaceUveTable(agent, default_intvl));
}

StatsManager *AgentUve::stats_manager() const {
return stats_manager_.get();
}

void AgentUve::Shutdown() {
AgentUveBase::Shutdown();
stats_manager_->Shutdown();
}

void AgentUve::RegisterDBClients() {
AgentUveBase::RegisterDBClients();
stats_manager_->RegisterDBClients();
}

// The following is deprecated and is present only for backward compatibility
void GetStatsInterval::HandleRequest() const {
StatsIntervalResp_InSeconds *resp = new StatsIntervalResp_InSeconds();
resp->set_agent_stats_interval(0);
resp->set_flow_stats_interval(0);
resp->set_context(context());
resp->Response();
return;
AgentUve::~AgentUve() {
}
8 changes: 0 additions & 8 deletions src/vnsw/agent/uve/agent_uve.h
Expand Up @@ -6,7 +6,6 @@
#define vnsw_agent_uve_h

#include <uve/agent_uve_base.h>
#include <uve/stats_manager.h>

//The class to drive UVE module initialization for agent
//Defines objects required for statistics collection from vrouter and
Expand All @@ -17,13 +16,6 @@ class AgentUve : public AgentUveBase {
uint32_t incremental_intvl);
virtual ~AgentUve();

virtual void Shutdown();
virtual void RegisterDBClients();
StatsManager *stats_manager() const;

protected:
boost::scoped_ptr<StatsManager> stats_manager_;

private:
DISALLOW_COPY_AND_ASSIGN(AgentUve);
};
Expand Down
8 changes: 1 addition & 7 deletions src/vnsw/agent/uve/agent_uve_base.cc
Expand Up @@ -28,7 +28,7 @@ using process::g_process_info_constants;

AgentUveBase *AgentUveBase::singleton_;

AgentUveBase::AgentUveBase(Agent *agent, uint64_t intvl, bool create_objects,
AgentUveBase::AgentUveBase(Agent *agent, uint64_t intvl,
uint32_t default_intvl, uint32_t incremental_intvl)
: vn_uve_table_(NULL), vm_uve_table_(NULL), vrouter_uve_entry_(NULL),
prouter_uve_table_(new ProuterUveTable(agent, default_intvl)),
Expand All @@ -39,12 +39,6 @@ AgentUveBase::AgentUveBase(Agent *agent, uint64_t intvl, bool create_objects,
vrouter_stats_collector_(new VrouterStatsCollector(
*(agent->event_manager()->io_service()),
this)) {
if (create_objects) {
vn_uve_table_.reset(new VnUveTableBase(agent, default_intvl));
vm_uve_table_.reset(new VmUveTableBase(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntryBase(agent));
interface_uve_table_.reset(new InterfaceUveTable(agent, default_intvl));
}
singleton_ = this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/uve/agent_uve_base.h
Expand Up @@ -30,7 +30,7 @@ class AgentUveBase {
static const uint32_t kIncrementalInterval = (1000); // time in millisecs

static const uint64_t kBandwidthInterval = (1000000); // time in microseconds
AgentUveBase(Agent *agent, uint64_t intvl, bool create_object,
AgentUveBase(Agent *agent, uint64_t intvl,
uint32_t default_intvl, uint32_t incremental_intvl);
virtual ~AgentUveBase();

Expand Down
58 changes: 58 additions & 0 deletions src/vnsw/agent/uve/agent_uve_stats.cc
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

#include <base/cpuinfo.h>
#include <db/db.h>
#include <cmn/agent_cmn.h>
#include <oper/interface_common.h>
#include <oper/interface.h>

#include <uve/stats_collector.h>
#include <uve/agent_uve_stats.h>
#include <uve/stats_interval_types.h>
#include <init/agent_param.h>
#include <oper/mirror_table.h>
#include <uve/vrouter_stats_collector.h>
#include <uve/vm_uve_table.h>
#include <uve/vn_uve_table.h>
#include <uve/vrouter_uve_entry.h>
#include <uve/interface_uve_stats_table.h>

AgentUveStats::AgentUveStats(Agent *agent, uint64_t intvl,
uint32_t default_intvl, uint32_t incremental_intvl)
: AgentUveBase(agent, intvl, default_intvl, incremental_intvl),
stats_manager_(new StatsManager(agent)) {
vn_uve_table_.reset(new VnUveTable(agent, default_intvl));
vm_uve_table_.reset(new VmUveTable(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntry(agent));
interface_uve_table_.reset(new InterfaceUveStatsTable(agent,
default_intvl));
}

AgentUveStats::~AgentUveStats() {
}

StatsManager *AgentUveStats::stats_manager() const {
return stats_manager_.get();
}

void AgentUveStats::Shutdown() {
AgentUveBase::Shutdown();
stats_manager_->Shutdown();
}

void AgentUveStats::RegisterDBClients() {
AgentUveBase::RegisterDBClients();
stats_manager_->RegisterDBClients();
}

// The following is deprecated and is present only for backward compatibility
void GetStatsInterval::HandleRequest() const {
StatsIntervalResp_InSeconds *resp = new StatsIntervalResp_InSeconds();
resp->set_agent_stats_interval(0);
resp->set_flow_stats_interval(0);
resp->set_context(context());
resp->Response();
return;
}
31 changes: 31 additions & 0 deletions src/vnsw/agent/uve/agent_uve_stats.h
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

#ifndef vnsw_agent_uve_stats_h
#define vnsw_agent_uve_stats_h

#include <uve/agent_uve_base.h>
#include <uve/stats_manager.h>

//The class to drive UVE module initialization for agent
//Defines objects required for statistics collection from vrouter and
//objects required for sending UVE information to collector.
class AgentUveStats : public AgentUveBase {
public:
AgentUveStats(Agent *agent, uint64_t intvl, uint32_t default_intvl,
uint32_t incremental_intvl);
virtual ~AgentUveStats();

virtual void Shutdown();
virtual void RegisterDBClients();
StatsManager *stats_manager() const;

protected:
boost::scoped_ptr<StatsManager> stats_manager_;

private:
DISALLOW_COPY_AND_ASSIGN(AgentUveStats);
};

#endif //vnsw_agent_uve_stats_h
4 changes: 2 additions & 2 deletions src/vnsw/agent/uve/interface_uve_stats_table.cc
Expand Up @@ -4,7 +4,7 @@

#include <oper/interface_common.h>
#include <uve/interface_uve_stats_table.h>
#include <uve/agent_uve.h>
#include <uve/agent_uve_stats.h>

InterfaceUveStatsTable::InterfaceUveStatsTable(Agent *agent,
uint32_t default_intvl)
Expand All @@ -30,7 +30,7 @@ bool InterfaceUveStatsTable::FrameInterfaceStatsMsg(UveInterfaceEntry* entry,
entry->SetVnVmInfo(uve);

const Interface *intf = static_cast<const Interface *>(vm_intf);
AgentUve *agent_uve = static_cast<AgentUve *>(agent_->uve());
AgentUveStats *agent_uve = static_cast<AgentUveStats *>(agent_->uve());
StatsManager::InterfaceStats *s =
agent_uve->stats_manager()->GetInterfaceStats(intf);
if (s == NULL) {
Expand Down
5 changes: 3 additions & 2 deletions src/vnsw/agent/uve/test/agent_stats_collector_test.cc
Expand Up @@ -19,7 +19,7 @@
#include <uve/vm_uve_table.h>
#include <init/agent_param.h>
#include <uve/test/agent_stats_collector_test.h>
#include <uve/agent_uve.h>
#include <uve/agent_uve_stats.h>

IoContext *AgentStatsCollectorTest::AllocateIoContext(char* buf, uint32_t buf_len,
StatsType type, uint32_t seq) {
Expand Down Expand Up @@ -99,7 +99,8 @@ void DropStatsIoContextTest::ErrorHandler(int err) {
}

void AgentStatsCollectorTest::Test_DeleteVrfStatsEntry(int vrf_id) {
AgentUve *uve = static_cast<AgentUve *>(Agent::GetInstance()->uve());
AgentUveStats *uve = static_cast<AgentUveStats *>
(Agent::GetInstance()->uve());
StatsManager *sm = uve->stats_manager();
StatsManager::VrfIdToVrfStatsTree::iterator it;
it = sm->vrf_stats_tree_.find(vrf_id);
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/uve/test/agent_uve_test.cc
Expand Up @@ -17,7 +17,7 @@
AgentUveBaseTest::AgentUveBaseTest(Agent *agent, uint64_t intvl,
uint32_t default_intvl,
uint32_t incremental_intvl)
: AgentUve(agent, intvl, default_intvl, incremental_intvl) {
: AgentUveStats(agent, intvl, default_intvl, incremental_intvl) {
if (vn_uve_table_) {
vn_uve_table_->Shutdown();
}
Expand Down

0 comments on commit e8c8d51

Please sign in to comment.