Skip to content

Commit

Permalink
changed uri to const ref and fixed indentations
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavanaashok33 committed May 29, 2020
1 parent 28b9dfe commit 499797a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion agent-ovs/lib/PrometheusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static string ofpeer_family_help[] =
"number of state reports sent to opflex peer",
"number of state reports responses received from opflex peer",
"number of state reports error repsonses from opflex peer",
"number of policies requested by the client which is not yet received"
"number of policies requested by the agent which is not yet resolved by opflex peer"
};

static string remote_ep_family_names[] =
Expand Down
11 changes: 8 additions & 3 deletions libopflex/engine/OpflexPEHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,14 @@ void OpflexPEHandler::handlePolicyResolveRes(uint64_t reqId,
for (it = policy.Begin(); it != policy.End(); ++it) {
const Value& mo = *it;
serializer.deserialize(mo, *client, true, &notifs);
const Value& uriv = mo["uri"];
OpflexPool& pool = getProcessor()->getPool();
pool.removePendingItem(conn, uriv.GetString());
if (!mo.HasMember("uri")) {
LOG(ERROR) << "uri member doesn't exist in the JSON value" ;
}
else {
const Value& uriv = mo["uri"];
OpflexPool& pool = getProcessor()->getPool();
pool.removePendingItem(conn, uriv.GetString());
}
}
}
client->deliverNotifications(notifs);
Expand Down
22 changes: 11 additions & 11 deletions libopflex/engine/OpflexPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ OpflexPool::~OpflexPool() {
uv_mutex_destroy(&conn_mutex);
}

void OpflexPool::addPendingItem(OpflexClientConnection* conn, std::string uri) {
void OpflexPool::addPendingItem(OpflexClientConnection* conn, const std::string& uri) {
std::string hostName = conn->getHostname();
std::unique_lock<std::mutex> lock(modify_uri_mutex);
if(pendingResolution[hostName].insert(uri).second == true) {
conn->getOpflexStats()->incrPolUnresolvedCount();
conn->getOpflexStats()->incrPolUnresolvedCount();
}
}

void OpflexPool::removePendingItem(OpflexClientConnection* conn, std::string uri) {
std::string hostName = conn->getHostname();
std::unique_lock<std::mutex> lock(modify_uri_mutex);
std::set<std::string>::iterator rem = pendingResolution[hostName].find(uri);
if (rem != pendingResolution[hostName].end()) {
pendingResolution[hostName].erase(rem);
conn->getOpflexStats()->decrPolUnresolvedCount();
}
void OpflexPool::removePendingItem(OpflexClientConnection* conn, const std::string& uri) {
std::string hostName = conn->getHostname();
std::unique_lock<std::mutex> lock(modify_uri_mutex);
std::set<std::string>::iterator rem = pendingResolution[hostName].find(uri);
if (rem != pendingResolution[hostName].end()) {
pendingResolution[hostName].erase(rem);
conn->getOpflexStats()->decrPolUnresolvedCount();
}
}

boost::optional<string> OpflexPool::getLocation() {
Expand Down Expand Up @@ -413,7 +413,7 @@ void incrementMsgCounter(OpflexClientConnection* conn, OpflexMessage* msg)

size_t OpflexPool::sendToRole(OpflexMessage* message,
OFConstants::OpflexRole role,
bool sync, std::string uri) {
bool sync, const std::string& uri) {
#ifdef HAVE_CXX11
std::unique_ptr<OpflexMessage> messagep(message);
#else
Expand Down
6 changes: 3 additions & 3 deletions libopflex/engine/include/opflex/engine/internal/OpflexPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ class OpflexPool : private boost::noncopyable {
/**
* Add the number of policies requested by the client
*/
void addPendingItem(OpflexClientConnection* conn, std::string uri);
void addPendingItem(OpflexClientConnection* conn, const std::string& uri);

/**
* Remove the policies recieved from the peer
*/
void removePendingItem(OpflexClientConnection* conn, std::string uri);
void removePendingItem(OpflexClientConnection* conn, const std::string& uri);

/**
* Register the given peer status listener to get updates on the
Expand Down Expand Up @@ -257,7 +257,7 @@ class OpflexPool : private boost::noncopyable {
*/
size_t sendToRole(OpflexMessage* message,
ofcore::OFConstants::OpflexRole role,
bool sync = false, std::string uri = "");
bool sync = false, const std::string& uri = "");

/**
* Get the number of connections in a particular role
Expand Down

0 comments on commit 499797a

Please sign in to comment.