Skip to content

Commit

Permalink
Restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
TACappleman committed Oct 19, 2021
1 parent 0ae4eb7 commit cd49fff
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 86 deletions.
1 change: 0 additions & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ orchagent_SOURCES = \
orchdaemon.cpp \
orch.cpp \
notifications.cpp \
nhgorch.cpp \
nhg/nhgbase.cpp \
nhg/nhghandler.cpp \
nhg/cbfnhghandler.cpp \
Expand Down
79 changes: 0 additions & 79 deletions orchagent/nhgorch.cpp

This file was deleted.

58 changes: 53 additions & 5 deletions orchagent/nhgorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include "nhg/cbfnhghandler.h"
#include "nhg/nhghandler.h"
#include "vector"
#include "portsorch.h"
#include "routeorch.h"

using namespace std;

extern PortsOrch *gPortsOrch;
extern RouteOrch *gRouteOrch;

/*
Expand All @@ -19,8 +21,11 @@ class NhgOrch : public Orch
/*
* Constructor.
*/
NhgOrch(DBConnector *db, const vector<string> &table_names);

NhgOrch(DBConnector *db, const vector<string> &table_names) :
Orch(db, table_names)
{
SWSS_LOG_ENTER();
}
/* Check if the next hop group given by it's index exists. */
inline bool hasNhg(const std::string& index) const
{
Expand Down Expand Up @@ -54,8 +59,32 @@ class NhgOrch : public Orch
inline void decSyncedNhgCount() { NhgBase::decSyncedCount(); }

/* Increase / Decrease ref count for a NHG given by it's index. */
void incNhgRefCount(const std::string& index);
void decNhgRefCount(const std::string& index);
void incNhgRefCount(const std::string& index)
{
SWSS_LOG_ENTER();

if (nhgHandler.hasNhg(index))
{
nhgHandler.incNhgRefCount(index);
}
else
{
cbfNhgHandler.incNhgRefCount(index);
}
}
void decNhgRefCount(const std::string& index)
{
SWSS_LOG_ENTER();

if (nhgHandler.hasNhg(index))
{
nhgHandler.decNhgRefCount(index);
}
else
{
cbfNhgHandler.decNhgRefCount(index);
}
}

/* Handling SAI status*/
task_process_status handleSaiCreateStatus(sai_api_t api, sai_status_t status, void *context = nullptr)
Expand All @@ -72,5 +101,24 @@ class NhgOrch : public Orch
CbfNhgHandler cbfNhgHandler;
private:

void doTask(Consumer& consumer);
void doTask(Consumer& consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->allPortsReady())
{
return;
}

string table_name = consumer.getTableName();

if (table_name == APP_NEXTHOP_GROUP_TABLE_NAME)
{
nhgHandler.doTask(consumer);
}
else if (table_name == APP_CLASS_BASED_NEXT_HOP_GROUP_TABLE_NAME)
{
cbfNhgHandler.doTask(consumer);
}
}
};
1 change: 0 additions & 1 deletion tests/mock_tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ tests_SOURCES = aclorch_ut.cpp \
$(top_srcdir)/orchagent/routeorch.cpp \
$(top_srcdir)/orchagent/mplsrouteorch.cpp \
$(top_srcdir)/orchagent/fgnhgorch.cpp \
$(top_srcdir)/orchagent/nhgorch.cpp \
$(top_srcdir)/orchagent/nhg/nhgbase.cpp \
$(top_srcdir)/orchagent/nhg/nhghandler.cpp \
$(top_srcdir)/orchagent/nhg/cbfnhghandler.cpp \
Expand Down

0 comments on commit cd49fff

Please sign in to comment.