7 #include <boost/asio/io_service.hpp>
8 #include <boost/algorithm/string.hpp>
16 #include "config_client_show_types.h"
27 #include "ifmap/ifmap_server_show_types.h"
28 #include "ifmap/ifmap_log_types.h"
34 #include "schema/vnc_cfg_types.h"
36 #include "control-node/sandesh/control_node_types.h"
52 uint32_t nodes_deleted = 0, nodes_changed = 0, links_deleted = 0,
54 uint64_t curr_seq_num =
105 bool changed =
object->ResolveStaleness();
120 IFMAP_DEBUG(IFMapStaleEntriesCleanerInfo, curr_seq_num, nodes_deleted,
121 nodes_changed, links_deleted, objects_deleted);
126 return "IFMapServer::IFMapStaleEntriesCleaner";
138 const std::string &vr_name,
const std::string &vm_uuid,
139 bool subscribe,
bool has_vms):
149 assert(vm_table != NULL);
167 assert(vr_table != NULL);
169 std::string vm_name = vm_node->
name();
182 std::string
Description()
const {
return "IFMapServer::IFMapVmSubscribe"; }
194 boost::asio::io_context *io_service)
195 : db_(db), graph_(graph),
200 work_queue_(
TaskScheduler::GetInstance()->GetTaskId(
"db::IFMapTable"),
201 0, boost::bind(&
IFMapServer::ClientWorker, this, _1)),
202 io_service_(io_service), config_manager_(NULL),
203 ifmap_channel_manager_(NULL) {
226 std::pair<ClientMap::iterator, bool> cm_ret;
228 assert(cm_ret.second);
230 std::pair<IndexMap::iterator, bool> im_ret;
231 im_ret =
index_map_.insert(make_pair(index, client));
232 assert(im_ret.second);
236 IFMAP_DEBUG(IFMapServerClientRegUnreg,
"Register request for client ",
251 IFMAP_DEBUG(IFMapServerClientRegUnreg,
"Un-register request for client ",
253 size_t index = client->
index();
272 int index = client->
index();
308 bool add = (work_entry.
op ==
ADD) ?
true :
false;
319 std::vector<std::string> vmlist = client->
vm_list();
320 for (
size_t count = 0; count < vmlist.size(); ++count) {
328 assert(vr_table != NULL);
334 iter != node->
end(
graph_); iter = next) {
337 if (adj->
table()->
name() ==
"__ifmap__.virtual_machine.0") {
355 if (
exporter_->FilterNeighbor(node, link)) {
370 exporter_->CleanupClientConfigTrackedEntries(index);
371 exporter_->DeleteClientConfigTracker(index);
375 exporter_->ResetLinkDeleteClients(rm_bs);
397 *index = client->
index();
404 bool subscribe,
bool has_vms) {
420 scheduler->Enqueue(vm_sub);
424 std::string vr_name,
bool subscribe) {
425 IFMAP_DEBUG(IFMapServerPendingVmReg, vm_uuid, vr_name, subscribe);
434 const std::string &search_string) {
435 regex search_expr(search_string);
437 for (ClientMap::const_iterator iter =
client_map_.begin();
443 IFMapServerClientMapShowEntry entry;
445 entry.set_interest_tracker_entries(
exporter_->ClientConfigTrackerSize(
447 entry.set_advertised_tracker_entries(
exporter_->ClientConfigTrackerSize(
449 out_map->clients.push_back(entry);
451 out_map->set_print_count(out_map->clients.size());
455 const std::string &search_string) {
456 regex search_expr(search_string);
464 IFMapServerIndexMapShowEntry entry;
465 entry.set_client_index(iter->first);
467 out_map->clients.push_back(entry);
469 out_map->set_print_count(out_map->clients.size());
481 const std::string &search_string) {
482 regex search_expr(search_string);
490 IFMapServerClientHistoryEntry entry;
495 out_list->clients.push_back(entry);
497 out_list->set_print_count(out_list->clients.size());
507 ConfigDBConnInfo db_conn_info;
512 if (first || db_conn_info != state->get_db_conn_info()) {
513 state->set_db_conn_info(db_conn_info);
518 ConfigAmqpConnInfo amqp_conn_info;
520 if (first || amqp_conn_info != state->get_amqp_conn_info()) {
521 state->set_amqp_conn_info(amqp_conn_info);
526 IFMapServerInfoUI server_info;
528 if (first || server_info != state->get_ifmap_server_info()) {
529 state->set_ifmap_server_info(server_info);
edge_iterator edge_list_begin()
void Notify(IFMapNode *node)
boost::scoped_ptr< IFMapVmUuidMapper > vm_uuid_mapper_
void ClientExporterSetup(IFMapClient *client)
ClientMap::size_type CmSz_t
static const int kClientHistorySize
static void RemoveObjectAndDeleteNode(IFMapNode *node, const IFMapOrigin &origin)
virtual const std::string & identifier() const =0
ConfigClientManager * get_config_manager()
std::vector< std::string > vm_list() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
virtual void GetConnectionInfo(ConfigDBConnInfo &status) const
IFMapClient * FindClient(const std::string &id)
boost::scoped_ptr< IFMapExporter > exporter_
boost::scoped_ptr< IFMapUpdateSender > sender_
void CleanupStaleEntries()
BitSet & reset(size_t pos)
void Remove(IFMapObject *obj)
ConfigDbClient * config_db_client() const
IFMapLink::LinkOriginInfo GetOriginInfo(IFMapOrigin::Origin in_origin, bool *exists)
void Initialize(IFMapExporter *exporter, int index)
const std::string client_created_at_str() const
void FillClientHistory(IFMapServerClientHistoryList *out_list, const std::string &search_string)
ConfigAmqpClient * config_amqp_client() const
IFMapStaleEntriesCleaner(DB *db, DBGraph *graph, IFMapServer *server)
virtual void Change(DBEntryBase *entry)
bool ClientNameToIndex(const std::string &id, int *index)
const CmSz_t GetClientMapSize() const
adjacency_iterator end(DBGraph *graph)
void DeleteLink(IFMapLink *link, const IFMapOrigin &origin)
boost::scoped_ptr< IFMapUpdateQueue > queue_
vertex_iterator vertex_list_begin()
vertex_iterator vertex_list_end()
edge_iterator edge_list_end()
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
#define IFMAP_DEBUG(obj,...)
static bool regex_match(const std::string &input, const regex ®ex)
std::string Description() const
void GetConnectionInfo(ConfigAmqpConnInfo &info) const
void ClientRegister(IFMapClient *client)
size_t find_first_clear() const
IFMapClient * GetClient(int index)
IFMapVmSubscribe(DB *db, DBGraph *graph, IFMapServer *server, const std::string &vr_name, const std::string &vm_uuid, bool subscribe, bool has_vms)
void CleanupUuidMapper(IFMapClient *client)
void IFMapVmSubscribe(const std::string &vr_name, const std::string &vm_name, bool subscribe, bool has_vms)
uint64_t sequence_number()
const std::string history_created_at_str() const
static TaskScheduler * GetInstance()
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq...
void IFMapRemoveVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
IFMapNode * FindNode(const std::string &name)
std::string Description() const
IFMapNode * GetVmNodeByUuid(const std::string &vm_uuid)
IFMapServer(DB *db, DBGraph *graph, boost::asio::io_context *io_service)
#define CHECK_CONCURRENCY(...)
static const std::string duration_usecs_to_string(const uint64_t usecs)
void RemoveOriginInfo(IFMapOrigin::Origin in_origin)
IFMapObject * Find(IFMapOrigin origin)
void DeleteClient(IFMapClient *client)
const std::string & name() const
IndexMap::size_type ImSz_t
IFMapServer * ifmap_server_
static bool regex_search(const std::string &input, const regex ®ex)
const std::string & name() const
void ClientGraphDownload(IFMapClient *client)
void RemoveSelfAddedLinksAndObjects(IFMapClient *client)
bool ClientWorker(QueueEntry work_entry)
void ProcessVmSubscribe(std::string vr_name, std::string vm_uuid, bool subscribe, bool has_vms)
void SimulateDeleteClient(IFMapClient *client)
static uint64_t UTCTimestampUsec()
MapType::const_iterator const_iterator
static IFMapTable * FindTable(DB *db, const std::string &element_type)
bool CollectStats(BgpRouterState *state, bool first) const
MapType::iterator iterator
uint64_t created_at() const
void ClientUnregister(IFMapClient *client)
WorkQueue< QueueEntry > work_queue_
edge_iterator edge_list_end(DBGraph *graph)
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
void FillIndexMap(IFMapServerShowIndexMap *out_map, const std::string &search_string)
ClientHistory client_history_
void ClientExporterCleanup(int index)
void ProcessVmRegAsPending(std::string vm_uuid, std::string vr_name, bool subscribe)
boost::tuple< DBGraphVertex *, DBGraphVertex *, DBGraphEdge * > DBEdgeInfo
void FillClientMap(IFMapServerShowClientMap *out_map, const std::string &search_string)
IFMapServer * ifmap_server_
adjacency_iterator begin(DBGraph *graph)
bool DeleteIfEmpty(IFMapNode *node)
Task is a wrapper over tbb::task to support policies.
uint64_t get_config_generation_number()
uint64_t client_created_at
void SaveClientHistory(IFMapClient *client)
DBTableBase * FindTable(const std::string &name)
bool ProcessClientWork(bool add, IFMapClient *client)
void AddClient(IFMapClient *client)
edge_iterator edge_list_begin(DBGraph *graph)
void GetUIInfo(IFMapServerInfoUI *server_info) const