LCOV - code coverage report
Current view: top level - ifmap - ifmap_exporter.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 2 2 100.0 %
Date: 2026-11-09 02:10:49 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __DB_IFMAP_EXPORTER_H__
       7             : #define __DB_IFMAP_EXPORTER_H__
       8             : 
       9             : #include <list>
      10             : #include <memory>
      11             : #include <map>
      12             : #include <string>
      13             : #include <boost/crc.hpp>      // for boost::crc_32_type
      14             : #include <boost/scoped_ptr.hpp>
      15             : #include <boost/unordered_set.hpp>
      16             : 
      17             : #include "db/db_table.h"
      18             : 
      19             : class BitSet;
      20             : 
      21             : class IFMapClient;
      22             : class IFMapGraphWalker;
      23             : class IFMapLink;
      24             : class IFMapLinkState;
      25             : class IFMapNode;
      26             : class IFMapNodeState;
      27             : class IFMapServer;
      28             : class IFMapState;
      29             : class IFMapTable;
      30             : class IFMapUpdate;
      31             : class IFMapUpdateQueue;
      32             : class IFMapUpdateSender;
      33             : 
      34             : struct IFMapTypenameWhiteList;
      35             : 
      36             : // The IFMapExporter makes sure that the right entries are added to the update
      37             : // queue. It uses the GraphWalker to calculate the 'interest' set for each node
      38             : // and then ensures that all clients see the necessary information. It also
      39             : // enforces ordering. All link add/change operations must come after the nodes
      40             : // they refer to have been advertised to the client. Add node delete operations
      41             : // must come after the links that refer to the node have been deleted.
      42             : class IFMapExporter {
      43             : public:
      44             :     enum TrackerType {
      45             :         INTEREST,
      46             :         ADVERTISED,
      47             :         TT_END,
      48             :     };
      49             :     typedef boost::unordered_set<IFMapState *> ConfigSet;
      50             :     typedef ConfigSet::size_type CsSz_t;
      51             :     typedef ConfigSet::const_iterator Cs_citer;
      52             :     typedef std::vector<ConfigSet *> ClientConfigTracker;
      53             :     typedef boost::crc_32_type::value_type crc32type;
      54             :     explicit IFMapExporter(IFMapServer *server);
      55             :     ~IFMapExporter();
      56             : 
      57             :     void Initialize(DB *db);
      58             :     void Shutdown();
      59             : 
      60             :     void StateUpdateOnDequeue(IFMapUpdate *update, const BitSet &dequeue_set,
      61             :                               bool is_delete);
      62             : 
      63             :     // GraphWalker API
      64             :     DBTable::ListenerId TableListenerId(const DBTable *table) const;
      65             : 
      66             :     IFMapNodeState *NodeStateLocate(IFMapNode *node);
      67             :     IFMapNodeState *NodeStateLookup(IFMapNode *node);
      68             :     IFMapLinkState *LinkStateLookup(IFMapLink *link);
      69             : 
      70         576 :     DBTable *link_table() { return link_table_; }
      71          20 :     IFMapServer *server() { return server_; }
      72             : 
      73             :     bool FilterNeighbor(IFMapNode *lnode, IFMapLink *link);
      74             : 
      75             :     void AddClientConfigTracker(int index);
      76             :     void DeleteClientConfigTracker(int index);
      77             :     void UpdateClientConfigTracker(IFMapState *state, const BitSet& client_bits,
      78             :                                    bool add, TrackerType tracker_type);
      79             :     void CleanupClientConfigTrackedEntries(int index);
      80             :     bool ClientHasConfigTracker(TrackerType tracker_type, int index);
      81             :     bool ClientConfigTrackerHasState(TrackerType tracker_type, int index,
      82             :                                      IFMapState *state);
      83             :     bool ClientConfigTrackerEmpty(TrackerType tracker_type, int index);
      84             :     size_t ClientConfigTrackerSize(TrackerType tracker_type, int index);
      85             :     Cs_citer ClientConfigTrackerBegin(TrackerType tracker_type, int index) const;
      86             :     Cs_citer ClientConfigTrackerEnd(TrackerType tracker_type, int index) const;
      87             : 
      88             :     void StateInterestSet(IFMapState *state, const BitSet& interest_bits);
      89             :     void StateInterestOr(IFMapState *state, const BitSet& interest_bits);
      90             :     void StateInterestReset(IFMapState *state, const BitSet& interest_bits);
      91             :     void StateAdvertisedOr(IFMapState *state, const BitSet& interest_bits);
      92             :     void StateAdvertisedReset(IFMapState *state, const BitSet& interest_bits);
      93             : 
      94             :     const IFMapTypenameWhiteList &get_traversal_white_list() const;
      95             :     void ResetLinkDeleteClients(const BitSet &bset);
      96             : 
      97             : private:
      98             :     friend class XmppIfmapTest;
      99             :     class TableInfo;
     100             :     typedef std::map<DBTable *, TableInfo *> TableMap;
     101             : 
     102             :     // Database listener for IFMap identifier (and link attr) tables.
     103             :     void NodeTableExport(DBTablePartBase *partition, DBEntryBase *entry);
     104             :     // Database listener for the IFMapLink DB Table.
     105             :     void LinkTableExport(DBTablePartBase *partition, DBEntryBase *entry);
     106             : 
     107             :     template <class ObjectType>
     108             :     bool UpdateAddChange(ObjectType *obj, IFMapState *state,
     109             :                          const BitSet &add_set, const BitSet &rm_set,
     110             :                          bool change);
     111             :     template <class ObjectType>
     112             :     bool UpdateRemove(ObjectType *obj, IFMapState *state,
     113             :                       const BitSet &rm_set);
     114             :     template <class ObjectType>
     115             :     void EnqueueDelete(ObjectType *obj, IFMapState *state);
     116             : 
     117             :     void MoveDependentLinks(IFMapNodeState *state);
     118             :     void RemoveDependentLinks(IFMapNodeState *state, const BitSet &rm_set);
     119             :     void MoveAdjacentNode(IFMapNodeState *state);
     120             :     void ProcessAdjacentNode(IFMapNode *node, const BitSet &add_set,
     121             :                              IFMapNodeState *state, bool force_process=false);
     122             : 
     123             :     bool IsFeasible(const IFMapNode *node);
     124             : 
     125             :     const BitSet *MergeClientInterest(IFMapNode *node, IFMapNodeState *state,
     126             :                                       std::unique_ptr<BitSet> *ptr);
     127             : 
     128             :     const TableInfo *Find(const DBTable *table) const;
     129             : 
     130             :     void TableStateClear(DBTable *table, DBTable::ListenerId tsid);
     131             :     bool ConfigChanged(IFMapNode *node);
     132             :     void DeleteStateIfAppropriate(DBTable *table, DBEntryBase *entry,
     133             :                                   IFMapState *state);
     134             : 
     135             :     IFMapUpdateQueue *queue();
     136             :     IFMapUpdateSender *sender();
     137             : 
     138             :     IFMapServer *server_;
     139             :     boost::scoped_ptr<IFMapGraphWalker> walker_;
     140             :     TableMap table_map_;
     141             : 
     142             :     DBTable *link_table_;
     143             :     ClientConfigTracker client_config_tracker_[TT_END];
     144             : };
     145             : 
     146             : #endif

Generated by: LCOV version 1.14