Skip to content

Commit

Permalink
Revert "Port table should be ProducerTable" (sonic-net#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiluo-msft authored Aug 7, 2018
1 parent 6556b26 commit b1cf199
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
4 changes: 0 additions & 4 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,6 @@ void Orch::addConsumer(DBConnector *db, string tableName, int pri)
{
addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this));
}
else if (tableName == APP_PORT_TABLE_NAME)
{
addExecutor(tableName, new Consumer(new ConsumerTable(db, tableName, gBatchSize, pri), this));
}
else
{
addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this));
Expand Down
4 changes: 2 additions & 2 deletions portsyncd/linksync.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __LINKSYNC__

#include "dbconnector.h"
#include "producertable.h"
#include "producerstatetable.h"
#include "netmsg.h"

#include <map>
Expand All @@ -19,7 +19,7 @@ class LinkSync : public NetMsg
virtual void onMsg(int nlmsg_type, struct nl_object *obj);

private:
ProducerTable m_portTableProducer;
ProducerStateTable m_portTableProducer;
Table m_portTable, m_statePortTable;

std::map<unsigned int, std::string> m_ifindexNameMap;
Expand Down
18 changes: 8 additions & 10 deletions portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "netdispatcher.h"
#include "netlink.h"
#include "producerstatetable.h"
#include "producertable.h"
#include "portsyncd/linksync.h"
#include "subscriberstatetable.h"
#include "exec.h"
Expand Down Expand Up @@ -39,11 +38,10 @@ void usage()
cout << " use configDB data if not specified" << endl;
}

// TODO: find a common base class for ProducerTable and ProducerStateTable
void handlePortConfigFile(ProducerTable &p, string file);
void handlePortConfigFromConfigDB(ProducerTable &p, DBConnector &cfgDb);
void handlePortConfigFile(ProducerStateTable &p, string file);
void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb);
void handleVlanIntfFile(string file);
void handlePortConfig(ProducerTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map);
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map);

int main(int argc, char **argv)
{
Expand Down Expand Up @@ -71,7 +69,7 @@ int main(int argc, char **argv)
DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appl_db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
ProducerTable p(&appl_db, APP_PORT_TABLE_NAME);
ProducerStateTable p(&appl_db, APP_PORT_TABLE_NAME);
SubscriberStateTable portCfg(&cfgDb, CFG_PORT_TABLE_NAME);

LinkSync sync(&appl_db, &state_db);
Expand Down Expand Up @@ -159,15 +157,15 @@ int main(int argc, char **argv)
return 1;
}

static void notifyPortConfigDone(ProducerTable &p)
static void notifyPortConfigDone(ProducerStateTable &p)
{
/* Notify that all ports added */
FieldValueTuple finish_notice("count", to_string(g_portSet.size()));
vector<FieldValueTuple> attrs = { finish_notice };
p.set("PortConfigDone", attrs);
}

void handlePortConfigFromConfigDB(ProducerTable &p, DBConnector &cfgDb)
void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb)
{
cout << "Get port configuration from ConfigDB..." << endl;

Expand All @@ -190,7 +188,7 @@ void handlePortConfigFromConfigDB(ProducerTable &p, DBConnector &cfgDb)
notifyPortConfigDone(p);
}

void handlePortConfigFile(ProducerTable &p, string file)
void handlePortConfigFile(ProducerStateTable &p, string file)
{
cout << "Read port configuration file..." << endl;

Expand Down Expand Up @@ -275,7 +273,7 @@ void handlePortConfigFile(ProducerTable &p, string file)
notifyPortConfigDone(p);
}

void handlePortConfig(ProducerTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
{

auto it = port_cfg_map.begin();
Expand Down
4 changes: 2 additions & 2 deletions tests/test_port_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_PortAutoNeg(dvs):

db = swsscommon.DBConnector(0, dvs.redis_sock, 0)

tbl = swsscommon.ProducerTable(db, "PORT_TABLE")
tbl = swsscommon.ProducerStateTable(db, "PORT_TABLE")

# set autoneg = false and speed = 1000
fvs = swsscommon.FieldValuePairs([("autoneg","1"), ("speed", "1000")])
Expand All @@ -31,7 +31,7 @@ def test_PortAutoNeg(dvs):

# set speed = 100
fvs = swsscommon.FieldValuePairs([("speed", "100")])

tbl.set("Ethernet0", fvs)

time.sleep(1)
Expand Down

0 comments on commit b1cf199

Please sign in to comment.