Skip to content

Commit 944a80d

Browse files
authored
Port table should be ProducerTable (sonic-net#556)
* Port table should be ProducerTable * Fix vs test
1 parent ed6d750 commit 944a80d

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

orchagent/orch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ void Orch::addConsumer(DBConnector *db, string tableName, int pri)
364364
{
365365
addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this));
366366
}
367+
else if (tableName == APP_PORT_TABLE_NAME)
368+
{
369+
addExecutor(tableName, new Consumer(new ConsumerTable(db, tableName, gBatchSize, pri), this));
370+
}
367371
else
368372
{
369373
addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this));

portsyncd/linksync.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define __LINKSYNC__
33

44
#include "dbconnector.h"
5-
#include "producerstatetable.h"
5+
#include "producertable.h"
66
#include "netmsg.h"
77

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

2121
private:
22-
ProducerStateTable m_portTableProducer;
22+
ProducerTable m_portTableProducer;
2323
Table m_portTable, m_statePortTable;
2424

2525
std::map<unsigned int, std::string> m_ifindexNameMap;

portsyncd/portsyncd.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "netdispatcher.h"
1212
#include "netlink.h"
1313
#include "producerstatetable.h"
14+
#include "producertable.h"
1415
#include "portsyncd/linksync.h"
1516
#include "subscriberstatetable.h"
1617
#include "exec.h"
@@ -38,10 +39,11 @@ void usage()
3839
cout << " use configDB data if not specified" << endl;
3940
}
4041

41-
void handlePortConfigFile(ProducerStateTable &p, string file);
42-
void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb);
42+
// TODO: find a common base class for ProducerTable and ProducerStateTable
43+
void handlePortConfigFile(ProducerTable &p, string file);
44+
void handlePortConfigFromConfigDB(ProducerTable &p, DBConnector &cfgDb);
4345
void handleVlanIntfFile(string file);
44-
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map);
46+
void handlePortConfig(ProducerTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map);
4547

4648
int main(int argc, char **argv)
4749
{
@@ -69,7 +71,7 @@ int main(int argc, char **argv)
6971
DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
7072
DBConnector appl_db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
7173
DBConnector state_db(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
72-
ProducerStateTable p(&appl_db, APP_PORT_TABLE_NAME);
74+
ProducerTable p(&appl_db, APP_PORT_TABLE_NAME);
7375
SubscriberStateTable portCfg(&cfgDb, CFG_PORT_TABLE_NAME);
7476

7577
LinkSync sync(&appl_db, &state_db);
@@ -157,15 +159,15 @@ int main(int argc, char **argv)
157159
return 1;
158160
}
159161

160-
static void notifyPortConfigDone(ProducerStateTable &p)
162+
static void notifyPortConfigDone(ProducerTable &p)
161163
{
162164
/* Notify that all ports added */
163165
FieldValueTuple finish_notice("count", to_string(g_portSet.size()));
164166
vector<FieldValueTuple> attrs = { finish_notice };
165167
p.set("PortConfigDone", attrs);
166168
}
167169

168-
void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb)
170+
void handlePortConfigFromConfigDB(ProducerTable &p, DBConnector &cfgDb)
169171
{
170172
cout << "Get port configuration from ConfigDB..." << endl;
171173

@@ -188,7 +190,7 @@ void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb)
188190
notifyPortConfigDone(p);
189191
}
190192

191-
void handlePortConfigFile(ProducerStateTable &p, string file)
193+
void handlePortConfigFile(ProducerTable &p, string file)
192194
{
193195
cout << "Read port configuration file..." << endl;
194196

@@ -273,7 +275,7 @@ void handlePortConfigFile(ProducerStateTable &p, string file)
273275
notifyPortConfigDone(p);
274276
}
275277

276-
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
278+
void handlePortConfig(ProducerTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
277279
{
278280

279281
auto it = port_cfg_map.begin();

tests/test_port_an.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def test_PortAutoNeg(dvs):
66

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

9-
tbl = swsscommon.ProducerStateTable(db, "PORT_TABLE")
9+
tbl = swsscommon.ProducerTable(db, "PORT_TABLE")
1010

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

3232
# set speed = 100
3333
fvs = swsscommon.FieldValuePairs([("speed", "100")])
34-
34+
3535
tbl.set("Ethernet0", fvs)
3636

3737
time.sleep(1)

0 commit comments

Comments
 (0)