Skip to content

Commit

Permalink
Use priorities in orch (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-shirshov authored Apr 17, 2018
1 parent 57c9425 commit e849afe
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
4 changes: 3 additions & 1 deletion orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
4 changes: 3 additions & 1 deletion orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
20 changes: 14 additions & 6 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> &tableNames)
{
for(auto it : tableNames)
{
addConsumer(db, it);
addConsumer(db, it, default_orch_pri);
}
}

Orch::Orch(DBConnector *db, const vector<table_name_with_pri_t> &tableNames_with_pri)
{
for(const auto& it : tableNames_with_pri)
{
addConsumer(db, it.first, it.second);
}
}

Expand Down Expand Up @@ -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));
}
}

Expand Down
14 changes: 10 additions & 4 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <unordered_set>
#include <map>
#include <memory>
#include <utility>

extern "C" {
#include "sai.h"
Expand Down Expand Up @@ -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,
Expand All @@ -52,6 +55,8 @@ typedef map<string, object_map*> type_map;
typedef pair<string, object_map*> type_map_pair;
typedef map<string, KeyOpFieldsValuesTuple> SyncMap;

typedef pair<string, int> table_name_with_pri_t;

class Orch;

// Design assumption
Expand Down Expand Up @@ -134,8 +139,9 @@ typedef pair<DBConnector *, vector<string>> 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<string> &tableNames);
Orch(DBConnector *db, const vector<table_name_with_pri_t> &tableNameWithPri);
Orch(const vector<TableConnector>& tables);
virtual ~Orch();

Expand Down Expand Up @@ -165,16 +171,16 @@ 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"

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)
{
}

Expand Down
14 changes: 8 additions & 6 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ bool OrchDaemon::init()

SwitchOrch *switch_orch = new SwitchOrch(m_applDb, APP_SWITCH_TABLE_NAME);

vector<string> 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<table_name_with_pri_t> 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);
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> tableNames) :
PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames) :
Orch(db, tableNames)
{
SWSS_LOG_ENTER();
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct VlanMemberUpdate
class PortsOrch : public Orch, public Subject
{
public:
PortsOrch(DBConnector *db, vector<string> tableNames);
PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames);

bool isInitDone();

Expand Down
4 changes: 3 additions & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e849afe

Please sign in to comment.