Skip to content

Commit

Permalink
Merge pull request #303 from noironetworks/remove-simstats
Browse files Browse the repository at this point in the history
Remove unused SimStats functionality
  • Loading branch information
gautvenk committed Dec 7, 2020
2 parents 9971086 + c7145a7 commit 7f1e191
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 614 deletions.
3 changes: 0 additions & 3 deletions agent-ovs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ libopflex_agent_la_include_HEADERS = \
lib/include/opflexagent/Network.h \
lib/include/opflexagent/cmd.h \
lib/include/opflexagent/logging.h \
lib/include/opflexagent/SimStats.h \
lib/include/opflexagent/SpanSessionState.h \
lib/include/opflexagent/SpanListener.h \
lib/include/opflexagent/SpanManager.h \
Expand Down Expand Up @@ -222,7 +221,6 @@ libopflex_agent_la_SOURCES = \
lib/MulticastListener.cpp \
lib/TaskQueue.cpp \
lib/Network.cpp \
lib/SimStats.cpp \
lib/SpanManager.cpp \
lib/NetFlowManager.cpp \
lib/FSSnatSource.cpp \
Expand Down Expand Up @@ -478,7 +476,6 @@ agent_test_SOURCES = \
lib/test/SpanManager_test.cpp \
lib/test/NetflowManager_test.cpp \
lib/test/ServiceManager_test.cpp \
lib/test/SimStats_test.cpp \
lib/test/ExtraConfigManager_test.cpp \
lib/test/SnatManager_test.cpp \
lib/test/QosManager_test.cpp \
Expand Down
68 changes: 1 addition & 67 deletions agent-ovs/lib/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "config.h"
#endif

#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
Expand All @@ -33,12 +32,10 @@
#include <opflexagent/logging.h>

#include <opflexagent/Renderer.h>
#include <opflexagent/SimStats.h>

#include <opflexagent/FSFaultSource.h>
#include <opflexagent/FaultSource.h>

#include <cstdlib>
#include <mutex>
#include <condition_variable>
#include <chrono>
Expand Down Expand Up @@ -70,7 +67,6 @@ Agent::Agent(OFFramework& framework_, const LogParams& _logParams)
notifServer(agent_io),rendererFwdMode(opflex_elem_t::INVALID_MODE),
faultManager(*this, framework),
started(false), presetFwdMode(opflex_elem_t::INVALID_MODE),
contractInterval(0), securityGroupInterval(0), interfaceInterval(0),
spanManager(framework, agent_io),
netflowManager(framework,agent_io),
qosManager(*this,framework, agent_io),
Expand All @@ -89,7 +85,6 @@ Agent::Agent(OFFramework& framework_, const LogParams& _logParams)
notifServer(agent_io),rendererFwdMode(opflex_elem_t::INVALID_MODE),
faultManager(*this, framework),
started(false), presetFwdMode(opflex_elem_t::INVALID_MODE),
contractInterval(0), securityGroupInterval(0), interfaceInterval(0),
spanManager(framework, agent_io),
netflowManager(framework,agent_io),
qosManager(*this,framework,agent_io),
Expand Down Expand Up @@ -459,30 +454,6 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) {
}
}

if (statMode == StatMode::SIM) {
LOG(INFO) << "Simulation of stats enabled";
Agent::StatProps statProps{};
statProps.interval = 30;
setSimStatProperties(OPFLEX_STATS_INTERFACE_SETTING, OPFLEX_STATS_INTERFACE_INTERVAL,
properties, statProps);
if (statProps.enabled)
setInterfaceInterval(statProps.interval*1000);
statProps.interval = 10;
setSimStatProperties(OPFLEX_STATS_CONTRACT_SETTING, OPFLEX_STATS_CONTRACT_INTERVAL,
properties, statProps);
if (statProps.enabled)
setContractInterval(statProps.interval*1000);
statProps.interval = 10;
setSimStatProperties(OPFLEX_STATS_SECGRP_SETTING, OPFLEX_STATS_SECGRP_INTERVAL,
properties, statProps);
if (statProps.enabled)
setSecurityGroupInterval(statProps.interval*1000);

LOG(INFO) << "contract interval set to " << contractInterval << " millisecs";
LOG(INFO) << "security group interval set to " << securityGroupInterval << " millisecs";
LOG(INFO) << "interface interval set to " << interfaceInterval << " millisecs";
}

boost::optional<boost::uint_t<64>::fast> prr_timer_present =
properties.get_optional<boost::uint_t<64>::fast>(OPFLEX_PRR_INTERVAL);
if (prr_timer_present) {
Expand Down Expand Up @@ -660,13 +631,6 @@ void Agent::start() {
for (const host_t& h : opflexPeers)
framework.addPeer(h.first, h.second);


if (statMode == StatMode::SIM) {
pSimStats = std::unique_ptr<SimStats>(new SimStats(*this));
pSimStats->start();
policyManager.registerListener(&(*pSimStats));
}

if (statMode == StatMode::OFF) {
LOG(INFO) << "Disable stats reporting completely";
framework.disableObservableReporting();
Expand All @@ -686,11 +650,6 @@ void Agent::stop() {
if (!started) return;
LOG(INFO) << "Stopping OpFlex Agent";

// if stats simulation is enbaled, stop it.
if (statMode == StatMode::SIM) {
pSimStats->stop();
}

// Just in case the io_service gets blocked by some stray
// events that don't get cleared, abort the process after a
// timeout
Expand Down Expand Up @@ -789,37 +748,12 @@ void Agent::createUniverse (std::shared_ptr<modelgbp::dmtree::Root> root)
}

inline StatMode Agent::getStatModeFromString(const std::string& mode) {
if (mode == "simulate")
return StatMode::SIM;
else if (mode == "off")
if (mode == "off")
return StatMode::OFF;
else
return StatMode::REAL;
}

inline void Agent::setSimStatProperties(const std::string& enabled_prop,
const std::string& interval_prop,
const ptree& properties, Agent::StatProps& props) {
boost::optional<bool> enabled = properties.get_optional<bool>(enabled_prop);
if (enabled) {
if (enabled.get() == true) {
boost::optional<long> interval =
properties.get_optional<long>(interval_prop);
props.enabled = true;
if (interval) {
if (interval.get() < 10)
props.interval = 10*1000;
else
props.interval = interval.get();
}
} else {
props.enabled = false;
}
} else {
props.enabled = false;
}
}

void Agent::setUplinkMac(const std::string &mac) {
LOG(DEBUG) << "Got TunnelEp MAC " << mac;
opflex::modb::MAC _mac = opflex::modb::MAC(mac);
Expand Down
5 changes: 2 additions & 3 deletions agent-ovs/lib/PolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2167,9 +2167,8 @@ void PolicyManager::updateExternalNode(const URI& uri,
using namespace modelgbp::epr;
using namespace modelgbp::epdr;

optional<shared_ptr<RoutingDomain>> rd
= boost::make_optional<shared_ptr<RoutingDomain> >(false, nullptr);
optional<shared_ptr<InstContext>> rdInst;
auto rd = boost::make_optional<shared_ptr<RoutingDomain> >(false, nullptr);
auto rdInst = boost::make_optional<shared_ptr<InstContext> >(false, nullptr);
ExternalNodeState &ens = ext_node_map[uri];
vector<shared_ptr<StaticRoute>> staticRoutes;
optional<shared_ptr<ExternalNode>> extNode =
Expand Down
Loading

0 comments on commit 7f1e191

Please sign in to comment.