Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion warmrestart/warmRestartAssist.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <string>
#include <algorithm>
#include "logger.h"
#include "schema.h"
#include "warm_restart.h"
Expand Down Expand Up @@ -173,7 +174,7 @@ void AppRestartAssist::insertToMap(string key, vector<FieldValueTuple> fvVector,
else if (found != appTableCacheMap.end())
{
// check only the original vector range (exclude cache-state field/value)
if(!equal(fvVector.begin(), fvVector.end(), found->second.begin()))
if(! contains(found->second, fvVector))
{
SWSS_LOG_NOTICE("%s, found key: %s, new value ", m_appTableName.c_str(), key.c_str());

Expand Down Expand Up @@ -280,3 +281,18 @@ bool AppRestartAssist::checkReconcileTimer(Selectable *s)
}
return false;
}

// check if left vector contains all elements of right vector
bool AppRestartAssist::contains(const std::vector<FieldValueTuple>& left,
const std::vector<FieldValueTuple>& right)
{
for (auto const& rv : right)
{
if (std::find(left.begin(), left.end(), rv) == left.end())
{
return false;
}
}

return true;
}
2 changes: 2 additions & 0 deletions warmrestart/warmRestartAssist.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class AppRestartAssist
std::string joinVectorString(const std::vector<FieldValueTuple> &fv);
void setCacheEntryState(std::vector<FieldValueTuple> &fvVector, cache_state_t state);
cache_state_t getCacheEntryState(const std::vector<FieldValueTuple> &fvVector);
bool contains(const std::vector<FieldValueTuple>& left,
const std::vector<FieldValueTuple>& right);
};

}
Expand Down