12 #include "../common/sandesh_uve_types.h"
26 const std::map<std::string, ds_conf_elem> &dsmap) {
30 for (map<string, ds_conf_elem>::const_iterator cit = dsmap.begin();
31 cit != dsmap.end(); cit++) {
32 uve_global_map::iterator it =
map_->find(cit->first);
33 if (it==
map_->end()) {
36 if (!(it->second.second)->InitDerivedStats(cit->second))
46 for (uve_global_map::iterator it =
map_->begin();
47 it !=
map_->end(); it++) {
48 uint32_t subcount = it->second.second->ClearUVEs(proxy, partition);
50 SANDESH_LOG(INFO, __func__ <<
" for " << it->first <<
" partition " <<
51 partition <<
" proxy " << proxy <<
" cleared " <<
61 static uint64_t periodic_count = 0;
62 if (periodic) periodic_count++;
63 for (uve_global_map::iterator it =
map_->begin();
64 it !=
map_->end(); it++) {
65 map<string,uint32_t>::const_iterator iit = inpMap.find(it->first);
68 uint64_t target_count =
70 if (target_count == 0)
continue;
71 if ((periodic_count % target_count) != 0)
continue;
72 cycle = (uint32_t) (periodic_count / target_count);
73 assert(inpMap.size() == 0);
76 if (iit == inpMap.end()) {
77 uint count = it->second.second->SyncUVE(
"", stype, 0, cycle,
"");
78 SANDESH_LOG(INFO, __func__ <<
" for " << it->first <<
":" << stype <<
79 " period " << it->second.first <<
" cycle " << cycle <<
80 " without seqno , total = " << count);
82 uint count = it->second.second->SyncUVE(
"", stype, iit->second, cycle,
"");
83 SANDESH_LOG(INFO, __func__ <<
" for " << it->first <<
":" << stype <<
84 " period " << it->second.first <<
" cycle " << cycle <<
85 " with seqno " << iit->second <<
86 ", total = " << count);
93 std::string tname, std::string table, std::string key) {
95 um.second->SendUVE(table, key,
"");
99 SandeshUVETypesReq::HandleRequest()
const {
100 std::vector<SandeshUVETypeInfo> stv;
102 SandeshUVETypeMaps::uve_global_map::const_iterator it =
105 SandeshUVETypeInfo sti;
106 sti.set_type_name(it->first);
107 sti.set_seq_num(it->second.second->TypeSeq());
108 sti.set_period(it->second.first);
109 sti.set_dsconf(it->second.second->GetDSConf());
110 sti.set_timeout(it->second.second->GetTimeout());
113 SandeshUVETypesResp *sur =
new SandeshUVETypesResp();
114 sur->set_type_info(stv);
119 SandeshUVEDSConfReq::HandleRequest()
const {
123 map<string,string> dsconf;
124 bool success =
false;
126 dsconf.insert(std::make_pair(get_dsattr(), get_dsconf()));
127 success = um.second->InitDerivedStats(dsconf);
129 SandeshUVEDSConfResp *sur =
new SandeshUVEDSConfResp();
130 sur->set_success(success);
131 if (success) sur->set_dsconf(um.second->GetDSConf());
137 SandeshUVECacheReq::HandleRequest()
const {
138 uint32_t returned = 0;
144 returned = um.second->SendUVE(
"", get_key(),
context());
150 SandeshUVECacheResp *sur =
new SandeshUVECacheResp();
151 sur->set_returned(returned);
152 if (um.second) sur->set_period(um.first);
static bool InitDerivedStats(const std::map< std::string, ds_conf_elem > &)
static const int kTickInterval
static void SyncIntrospect(std::string tname, std::string table, std::string key)
static uve_global_map::const_iterator Begin()
#define SANDESH_LOG(_Level, _Msg)
static void SyncAllMaps(const std::map< std::string, uint32_t > &, bool periodic=false)
std::string context() const
std::map< std::string, uve_global_elem > uve_global_map
static uint32_t Clear(const std::string &proxy, int partition)
static uve_global_map * map_
std::pair< int, SandeshUVEPerTypeMap * > uve_global_elem
static uve_global_map::const_iterator End()
static const uve_global_elem TypeMap(const std::string &s)