Skip to content

Commit

Permalink
CTT argument parsing - adjust cache opt parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Zadamsa committed Dec 9, 2024
1 parent 06e469a commit 1053967
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions storage/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void NHTFlowCache::init(const char *params)
m_line_mask = (m_cache_size - 1) & ~(m_line_size - 1);
m_line_new_idx = m_line_size / 2;
#ifdef WITH_CTT
m_ctt_controller.init(parser.m_dev, 0);
std::cout << "Cache created with device=" << parser.m_dev << " and component index=" << parser.m_component_index << "\n";
m_ctt_controller.init(parser.m_dev, parser.m_component_index);
#endif /* WITH_CTT */

if (m_export_queue == nullptr) {
Expand Down Expand Up @@ -752,4 +753,4 @@ std::vector<std::byte> CttController::assemble_state(
return state;
}
#endif // WITH_CTT
}
}
11 changes: 10 additions & 1 deletion storage/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class CacheOptParser : public OptionsParser
time_t m_frag_cache_timeout;
#ifdef WITH_CTT
std::string m_dev;
uint16_t m_component_index;
#endif /* WITH_CTT */

CacheOptParser() : OptionsParser("cache", "Storage plugin implemented as a hash table"),
Expand Down Expand Up @@ -263,6 +264,14 @@ class CacheOptParser : public OptionsParser
return true;
},
OptionFlags::RequiredArgument);
register_option("ci", "compidx", "NUM", "Index of the ctt component", [this](const char *arg) {
try {
m_component_index = str2num<decltype(m_component_index)>(arg)/16;
} catch(std::invalid_argument &e) {
return false;
}
return true;
});
#endif /* WITH_CTT */

}
Expand Down Expand Up @@ -422,4 +431,4 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin
};

}
#endif /* IPXP_STORAGE_CACHE_HPP */
#endif /* IPXP_STORAGE_CACHE_HPP */

0 comments on commit 1053967

Please sign in to comment.