diff --git a/orchagent/Makefile.am b/orchagent/Makefile.am index ece1d28041..2ac23ee77b 100644 --- a/orchagent/Makefile.am +++ b/orchagent/Makefile.am @@ -40,7 +40,6 @@ orchagent_SOURCES = \ orchdaemon.cpp \ orch.cpp \ notifications.cpp \ - nhgorch.cpp \ nhg/nhgbase.cpp \ nhg/nhghandler.cpp \ nhg/cbfnhghandler.cpp \ diff --git a/orchagent/nhgorch.cpp b/orchagent/nhgorch.cpp deleted file mode 100644 index fbea34a161..0000000000 --- a/orchagent/nhgorch.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "nhgorch.h" - -extern PortsOrch *gPortsOrch; - -NhgOrch::NhgOrch(DBConnector *db, const vector &table_names) : - Orch(db, table_names) -{ - SWSS_LOG_ENTER(); -} - -/* - * Purpose: Perform the operations requested by APPL_DB users. - * Description: Iterate over the untreated operations list and resolve them. - * The operations supported are SET and DEL. If an operation - * could not be resolved, it will either remain in the list, or be - * removed, depending on the case. - * Params: IN consumer - The cosumer object. - * Returns: Nothing. - */ -void NhgOrch::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); - } -} - -/* - * Purpose: Increase the ref count for a next hop group. - * Description: Increment the ref count for a next hop group by 1. - * Params: IN index - The index of the next hop group. - * Returns: Nothing. - */ -void NhgOrch::incNhgRefCount(const std::string& index) -{ - SWSS_LOG_ENTER(); - - if (nhgHandler.hasNhg(index)) - { - nhgHandler.incNhgRefCount(index); - } - else - { - cbfNhgHandler.incNhgRefCount(index); - } -} - -/* - * Purpose: Decrease the ref count for a next hop group. - * Description: Decrement the ref count for a next hop group by 1. - * Params: IN index - The index of the next hop group. - * Returns: Nothing. - */ -void NhgOrch::decNhgRefCount(const std::string& index) -{ - SWSS_LOG_ENTER(); - - if (nhgHandler.hasNhg(index)) - { - nhgHandler.decNhgRefCount(index); - } - else - { - cbfNhgHandler.decNhgRefCount(index); - } -} \ No newline at end of file diff --git a/orchagent/nhgorch.h b/orchagent/nhgorch.h index c75e0b2c56..a88d9cf2d5 100644 --- a/orchagent/nhgorch.h +++ b/orchagent/nhgorch.h @@ -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; /* @@ -19,8 +21,11 @@ class NhgOrch : public Orch /* * Constructor. */ - NhgOrch(DBConnector *db, const vector &table_names); - + NhgOrch(DBConnector *db, const vector &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 { @@ -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) @@ -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); + } + } }; diff --git a/tests/mock_tests/Makefile.am b/tests/mock_tests/Makefile.am index a1a6531daa..93c6b044dc 100644 --- a/tests/mock_tests/Makefile.am +++ b/tests/mock_tests/Makefile.am @@ -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 \