|
1 | 1 | #include <unordered_map>
|
2 |
| -#include "flexcounterorch.h" |
3 | 2 | #include "portsorch.h"
|
4 | 3 | #include "fabricportsorch.h"
|
5 | 4 | #include "select.h"
|
@@ -49,6 +48,7 @@ unordered_map<string, string> flexCounterGroupMap =
|
49 | 48 |
|
50 | 49 | FlexCounterOrch::FlexCounterOrch(DBConnector *db, vector<string> &tableNames):
|
51 | 50 | Orch(db, tableNames),
|
| 51 | + m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME), |
52 | 52 | m_flexCounterDb(new DBConnector("FLEX_COUNTER_DB", 0)),
|
53 | 53 | m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE))
|
54 | 54 | {
|
@@ -188,3 +188,45 @@ bool FlexCounterOrch::getPortBufferDropCountersState() const
|
188 | 188 | {
|
189 | 189 | return m_port_buffer_drop_counter_enabled;
|
190 | 190 | }
|
| 191 | + |
| 192 | +bool FlexCounterOrch::bake() |
| 193 | +{ |
| 194 | + /* |
| 195 | + * bake is called during warmreboot reconciling procedure. |
| 196 | + * By default, it should fetch items from the tables the sub agents listen to, |
| 197 | + * and then push them into m_toSync of each sub agent. |
| 198 | + * The motivation is to make sub agents handle the saved entries first and then handle the upcoming entries. |
| 199 | + */ |
| 200 | + |
| 201 | + std::deque<KeyOpFieldsValuesTuple> entries; |
| 202 | + vector<string> keys; |
| 203 | + m_flexCounterConfigTable.getKeys(keys); |
| 204 | + for (const auto &key: keys) |
| 205 | + { |
| 206 | + if (!flexCounterGroupMap.count(key)) |
| 207 | + { |
| 208 | + SWSS_LOG_NOTICE("FlexCounterOrch: Invalid flex counter group intput %s is skipped during reconciling", key.c_str()); |
| 209 | + continue; |
| 210 | + } |
| 211 | + |
| 212 | + if (key == BUFFER_POOL_WATERMARK_KEY) |
| 213 | + { |
| 214 | + SWSS_LOG_NOTICE("FlexCounterOrch: Do not handle any FLEX_COUNTER table for %s update during reconciling", |
| 215 | + BUFFER_POOL_WATERMARK_KEY); |
| 216 | + continue; |
| 217 | + } |
| 218 | + |
| 219 | + KeyOpFieldsValuesTuple kco; |
| 220 | + |
| 221 | + kfvKey(kco) = key; |
| 222 | + kfvOp(kco) = SET_COMMAND; |
| 223 | + |
| 224 | + if (!m_flexCounterConfigTable.get(key, kfvFieldsValues(kco))) |
| 225 | + { |
| 226 | + continue; |
| 227 | + } |
| 228 | + entries.push_back(kco); |
| 229 | + } |
| 230 | + Consumer* consumer = dynamic_cast<Consumer *>(getExecutor(CFG_FLEX_COUNTER_TABLE_NAME)); |
| 231 | + return consumer->addToSync(entries); |
| 232 | +} |
0 commit comments