Skip to content

Commit

Permalink
Merge branch 'master' into mclag_enhacements
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen-Brcm authored Nov 16, 2020
2 parents cc73dc5 + 40b255b commit b5603a2
Show file tree
Hide file tree
Showing 60 changed files with 3,135 additions and 504 deletions.
32 changes: 23 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,50 @@
*.la
*.lo
*.o
*.swp

# Generated Source #
####################
pyext/swsscommon.py
pyext/swsscommon_wrap.cpp
pyext/py2/swsscommon.py
pyext/py2/swsscommon_wrap.cpp
pyext/py3/swsscommon.py
pyext/py3/swsscommon_wrap.cpp

# Packaging Files #
###################
debian/.debhelper/
debian/autoreconf.after
debian/autoreconf.before
debian/debhelper-build-stamp
debian/files
debian/libswsscommon-dev.debhelper.log
debian/libswsscommon-dev.substvars
debian/libswsscommon.debhelper.log
debian/*.debhelper.log
debian/*.substvars
debian/libswsscommon/
debian/libswsscommon-dbg/
debian/libswsscommon-dev/
debian/libswsscommon.postinst.debhelper
debian/libswsscommon.postrm.debhelper
debian/libswsscommon.substvars

debian/libswsscommon-dev/
debian/libswsscommon/
debian/python-swsscommon/
debian/python3-swsscommon/
debian/tmp/

aclocal.m4
autom4te.cache/
config
config.h
config.h.in
config.h.in~
config.log
config.status
configure
libtool
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
Makefile.in
stamp-h1
**/.deps/
Expand All @@ -41,5 +57,3 @@ stamp-h1
###############
common/swssloglevel
tests/tests


4 changes: 3 additions & 1 deletion common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ EXTRA_DIST = \
consumer_table_pops.lua \
producer_state_table_apply_view.lua \
table_dump.lua \
redis_multi.lua \
fdb_flush.lua

EXTRA_CONF_DIST = database_config.json
Expand All @@ -29,11 +30,12 @@ libswsscommon_la_SOURCES = \
logger.cpp \
redisreply.cpp \
dbconnector.cpp \
dbinterface.cpp \
sonicv2connector.cpp \
table.cpp \
json.cpp \
producertable.cpp \
producerstatetable.cpp \
redisclient.cpp \
rediscommand.cpp \
redistran.cpp \
redisselect.cpp \
Expand Down
6 changes: 5 additions & 1 deletion common/consumer_table_pops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ for i = n, 1, -3 do
end
table.insert(rets, ret)

if op == 'bulkset' or op == 'bulkcreate' or op == 'bulkremove' then
if ARGV[2] == "0" then
-- do nothing, we don't want to modify redis during pop
elseif op == 'bulkset' or op == 'bulkcreate' or op == 'bulkremove' then

-- key is "OBJECT_TYPE:num", extract object type from key
key = key:sub(1, string.find(key, ':') - 1)
Expand Down Expand Up @@ -81,6 +83,8 @@ for i = n, 1, -3 do
op == 'notify' or
op == 'get_stats' or
op == 'clear_stats' or
op == 'attribute_capability_query' or
op == 'attribute_capability_response' or
op == 'attr_enum_values_capability_query' or
op == 'attr_enum_values_capability_response' or
op == 'object_type_get_availability_query' or
Expand Down
13 changes: 11 additions & 2 deletions common/consumertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace swss {
ConsumerTable::ConsumerTable(DBConnector *db, const string &tableName, int popBatchSize, int pri)
: ConsumerTableBase(db, tableName, popBatchSize, pri)
, TableName_KeyValueOpQueues(tableName)
, m_modifyRedis(true)
{
std::string luaScript = loadLuaScript("consumer_table_pops.lua");
m_shaPop = loadRedisScript(db, luaScript);
Expand All @@ -39,15 +40,23 @@ ConsumerTable::ConsumerTable(DBConnector *db, const string &tableName, int popBa
setQueueLength(len/3);
}

void ConsumerTable::setModifyRedis(bool modify)
{
SWSS_LOG_ENTER();

m_modifyRedis = modify;
}

void ConsumerTable::pops(deque<KeyOpFieldsValuesTuple> &vkco, const string &prefix)
{
RedisCommand command;
command.format(
"EVALSHA %s 2 %s %s %d ''",
"EVALSHA %s 2 %s %s %d %d",
m_shaPop.c_str(),
getKeyValueOpQueueTableName().c_str(),
(prefix+getTableName()).c_str(),
POP_BATCH_SIZE);
POP_BATCH_SIZE,
m_modifyRedis ? 1 : 0);

RedisReply r(m_db, command, REDIS_REPLY_ARRAY);

Expand Down
11 changes: 11 additions & 0 deletions common/consumertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ class ConsumerTable : public ConsumerTableBase, public TableName_KeyValueOpQueue
/* Get multiple pop elements */
void pops(std::deque<KeyOpFieldsValuesTuple> &vkco, const std::string &prefix = EMPTY_PREFIX);

void setModifyRedis(bool modify);
private:
std::string m_shaPop;

/**
* @brief Modify Redis database.
*
* If set to false, will not make changes to database during POPs operation.
* This will be utilized during synchronous mode.
*
* Default is true.
*/
bool m_modifyRedis;
};

}
Expand Down
35 changes: 35 additions & 0 deletions common/database_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"hostname" : "127.0.0.1",
"port" : 6379,
"unix_socket_path" : "/var/run/redis/redis.sock"
},
"redis_chassis":{
"hostname" : "redis_chassis.server",
"port" : 6380,
"unix_socket_path" : "/var/run/redis/redis_chassis.sock"
}
},
"DATABASES" : {
Expand Down Expand Up @@ -51,6 +56,36 @@
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"RESTAPI_DB" : {
"id" : 8,
"separator": "|",
"instance" : "redis"
},
"GB_ASIC_DB" : {
"id" : 9,
"separator": "|",
"instance" : "redis"
},
"GB_COUNTERS_DB" : {
"id" : 10,
"separator": "|",
"instance" : "redis"
},
"GB_FLEX_COUNTER_DB" : {
"id" : 11,
"separator": "|",
"instance" : "redis"
},
"CHASSIS_APP_DB" : {
"id" : 12,
"separator": "|",
"instance" : "redis_chassis"
},
"CHASSIS_STATE_DB" : {
"id" : 13,
"separator": "|",
"instance" : "redis_chassis"
}
},
"VERSION" : "1.0"
Expand Down
Loading

0 comments on commit b5603a2

Please sign in to comment.