diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index d55d1a724e..66e1d5af9b 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -16,8 +16,10 @@ extern sai_object_id_t gSwitchId; extern PortsOrch* gPortsOrch; extern CrmOrch * gCrmOrch; +const int fdborch_pri = 20; + FdbOrch::FdbOrch(DBConnector *db, string tableName, PortsOrch *port) : - Orch(db, tableName), + Orch(db, tableName, fdborch_pri), m_portsOrch(port), m_table(Table(db, tableName)) { diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 1659816a49..e97aed0192 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -21,8 +21,10 @@ extern PortsOrch *gPortsOrch; extern sai_object_id_t gSwitchId; extern CrmOrch *gCrmOrch; +const int intfsorch_pri = 35; + IntfsOrch::IntfsOrch(DBConnector *db, string tableName) : - Orch(db, tableName) + Orch(db, tableName, intfsorch_pri) { SWSS_LOG_ENTER(); } diff --git a/orchagent/neighorch.cpp b/orchagent/neighorch.cpp index 961fc1f414..585f91b967 100644 --- a/orchagent/neighorch.cpp +++ b/orchagent/neighorch.cpp @@ -13,8 +13,10 @@ extern sai_object_id_t gSwitchId; extern CrmOrch *gCrmOrch; extern RouteOrch *gRouteOrch; +const int neighorch_pri = 30; + NeighOrch::NeighOrch(DBConnector *db, string tableName, IntfsOrch *intfsOrch) : - Orch(db, tableName), m_intfsOrch(intfsOrch) + Orch(db, tableName, neighorch_pri), m_intfsOrch(intfsOrch) { SWSS_LOG_ENTER(); } diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 2dce67e267..330ea32879 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -22,16 +22,24 @@ extern ofstream gRecordOfs; extern bool gLogRotate; extern string gRecordFile; -Orch::Orch(DBConnector *db, const string tableName) +Orch::Orch(DBConnector *db, const string tableName, int pri) { - addConsumer(db, tableName); + addConsumer(db, tableName, pri); } Orch::Orch(DBConnector *db, const vector &tableNames) { for(auto it : tableNames) { - addConsumer(db, it); + addConsumer(db, it, default_orch_pri); + } +} + +Orch::Orch(DBConnector *db, const vector &tableNames_with_pri) +{ + for(const auto& it : tableNames_with_pri) + { + addConsumer(db, it.first, it.second); } } @@ -356,15 +364,15 @@ bool Orch::parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uin return true; } -void Orch::addConsumer(DBConnector *db, string tableName) +void Orch::addConsumer(DBConnector *db, string tableName, int pri) { if (db->getDbId() == CONFIG_DB) { - addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName), this)); + addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this)); } else { - addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize), this)); + addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this)); } } diff --git a/orchagent/orch.h b/orchagent/orch.h index 0eb693ae7a..eddece4081 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -5,6 +5,7 @@ #include #include #include +#include extern "C" { #include "sai.h" @@ -36,6 +37,8 @@ const char config_db_key_delimiter = '|'; #define CONFIGDB_KEY_SEPARATOR "|" #define DEFAULT_KEY_SEPARATOR ":" +const int default_orch_pri = 0; + typedef enum { task_success, @@ -52,6 +55,8 @@ typedef map type_map; typedef pair type_map_pair; typedef map SyncMap; +typedef pair table_name_with_pri_t; + class Orch; // Design assumption @@ -134,8 +139,9 @@ typedef pair> TablesConnector; class Orch { public: - Orch(DBConnector *db, const string tableName); + Orch(DBConnector *db, const string tableName, int pri = default_orch_pri); Orch(DBConnector *db, const vector &tableNames); + Orch(DBConnector *db, const vector &tableNameWithPri); Orch(const vector& tables); virtual ~Orch(); @@ -165,7 +171,7 @@ class Orch void addExecutor(string executorName, Executor* executor); Executor *getExecutor(string executorName); private: - void addConsumer(DBConnector *db, string tableName); + void addConsumer(DBConnector *db, string tableName, int pri = default_orch_pri); }; #include "request_parser.h" @@ -173,8 +179,8 @@ class Orch class Orch2 : public Orch { public: - Orch2(DBConnector *db, const std::string& tableName, Request& request) - : Orch(db, tableName), request_(request) + Orch2(DBConnector *db, const std::string& tableName, Request& request, int pri=default_orch_pri) + : Orch(db, tableName, pri), request_(request) { } diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index a167cce62b..50af799cd3 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -52,12 +52,14 @@ bool OrchDaemon::init() SwitchOrch *switch_orch = new SwitchOrch(m_applDb, APP_SWITCH_TABLE_NAME); - vector ports_tables = { - APP_PORT_TABLE_NAME, - APP_VLAN_TABLE_NAME, - APP_VLAN_MEMBER_TABLE_NAME, - APP_LAG_TABLE_NAME, - APP_LAG_MEMBER_TABLE_NAME + const int portsorch_base_pri = 40; + + vector ports_tables = { + { APP_PORT_TABLE_NAME, portsorch_base_pri + 5 }, + { APP_VLAN_TABLE_NAME, portsorch_base_pri + 2 }, + { APP_VLAN_MEMBER_TABLE_NAME, portsorch_base_pri }, + { APP_LAG_TABLE_NAME, portsorch_base_pri + 2 }, + { APP_LAG_MEMBER_TABLE_NAME, portsorch_base_pri } }; gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME); diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 644667f3bd..2cf741695b 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -114,7 +114,7 @@ static char* hostif_vlan_tag[] = { * bridge. By design, SONiC switch starts with all bridge ports removed from * default VLAN and all ports removed from .1Q bridge. */ -PortsOrch::PortsOrch(DBConnector *db, vector tableNames) : +PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNames) { SWSS_LOG_ENTER(); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index fa7ca42e50..2ea1bb874d 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -41,7 +41,7 @@ struct VlanMemberUpdate class PortsOrch : public Orch, public Subject { public: - PortsOrch(DBConnector *db, vector tableNames); + PortsOrch(DBConnector *db, vector &tableNames); bool isInitDone(); diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index ec8aeb5295..18e8d61769 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -18,8 +18,10 @@ extern CrmOrch *gCrmOrch; #define DEFAULT_NUMBER_OF_ECMP_GROUPS 128 #define DEFAULT_MAX_ECMP_GROUP_SIZE 32 +const int routeorch_pri = 5; + RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) : - Orch(db, tableName), + Orch(db, tableName, routeorch_pri), m_neighOrch(neighOrch), m_nextHopGroupCount(0), m_resync(false)