Skip to content

Commit 1053967

Browse files
committed
CTT argument parsing - adjust cache opt parser
1 parent 06e469a commit 1053967

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

storage/cache.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ void NHTFlowCache::init(const char *params)
206206
m_line_mask = (m_cache_size - 1) & ~(m_line_size - 1);
207207
m_line_new_idx = m_line_size / 2;
208208
#ifdef WITH_CTT
209-
m_ctt_controller.init(parser.m_dev, 0);
209+
std::cout << "Cache created with device=" << parser.m_dev << " and component index=" << parser.m_component_index << "\n";
210+
m_ctt_controller.init(parser.m_dev, parser.m_component_index);
210211
#endif /* WITH_CTT */
211212

212213
if (m_export_queue == nullptr) {
@@ -752,4 +753,4 @@ std::vector<std::byte> CttController::assemble_state(
752753
return state;
753754
}
754755
#endif // WITH_CTT
755-
}
756+
}

storage/cache.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class CacheOptParser : public OptionsParser
197197
time_t m_frag_cache_timeout;
198198
#ifdef WITH_CTT
199199
std::string m_dev;
200+
uint16_t m_component_index;
200201
#endif /* WITH_CTT */
201202

202203
CacheOptParser() : OptionsParser("cache", "Storage plugin implemented as a hash table"),
@@ -263,6 +264,14 @@ class CacheOptParser : public OptionsParser
263264
return true;
264265
},
265266
OptionFlags::RequiredArgument);
267+
register_option("ci", "compidx", "NUM", "Index of the ctt component", [this](const char *arg) {
268+
try {
269+
m_component_index = str2num<decltype(m_component_index)>(arg)/16;
270+
} catch(std::invalid_argument &e) {
271+
return false;
272+
}
273+
return true;
274+
});
266275
#endif /* WITH_CTT */
267276

268277
}
@@ -422,4 +431,4 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin
422431
};
423432

424433
}
425-
#endif /* IPXP_STORAGE_CACHE_HPP */
434+
#endif /* IPXP_STORAGE_CACHE_HPP */

0 commit comments

Comments
 (0)