Fledge
An open source edge computing platform for industrial users
AssetTracker Class Reference

The AssetTracker class provides the asset tracking functionality. More...

#include <asset_tracking.h>

Public Member Functions

 AssetTracker (ManagementClient *mgtClient, std::string service)
 AssetTracker class constructor. More...
 
 ~AssetTracker ()
 Destructor for the asset tracker. More...
 
void populateAssetTrackingCache (std::string plugin, std::string event)
 Fetch all asset tracking tuples from DB and populate local cache. More...
 
void populateStorageAssetTrackingCache ()
 Fetch all storage asset tracking tuples from DB and populate local cache. More...
 
bool checkAssetTrackingCache (AssetTrackingTuple &tuple)
 Check local cache for a given asset tracking tuple. More...
 
AssetTrackingTuplefindAssetTrackingCache (AssetTrackingTuple &tuple)
 Lookup tuple in the asset tracker cache. More...
 
void addAssetTrackingTuple (AssetTrackingTuple &tuple)
 Add asset tracking tuple via microservice management API and in cache. More...
 
void addAssetTrackingTuple (std::string plugin, std::string asset, std::string event)
 
void addStorageAssetTrackingTuple (StorageAssetTrackingTuple &tuple, std::set< std::string > &dpSet, bool addObj=false)
 Add asset tracking tuple via microservice management API and in cache. More...
 
StorageAssetTrackingTuplefindStorageAssetTrackingCache (StorageAssetTrackingTuple &tuple)
 Check if a StorageAssetTrackingTuple is in cache. More...
 
std::string getIngestService (const std::string &asset)
 
std::string getEgressService (const std::string &asset)
 
void workerThread ()
 The worker thread that will flush any pending asset tuples to the database.
 
bool getDeprecated (StorageAssetTrackingTuple *ptr)
 This function takes a StorageAssetTrackingTuple pointer and searches for it in cache, if found then returns its Deprecated status. More...
 
void updateCache (std::set< std::string > dpSet, StorageAssetTrackingTuple *ptr)
 Updates datapoints present in the arg dpSet in the cache. More...
 
std::set< std::string > * getStorageAssetTrackingCacheData (StorageAssetTrackingTuple *tuple)
 Get stored value in the StorageAssetTrackingTuple cache for the given tuple. More...
 
bool tune (unsigned long updateInterval)
 Set the update interval for the asset tracker. More...
 

Static Public Member Functions

static AssetTrackergetAssetTracker ()
 Get asset tracker singleton instance for the current south service. More...
 

Detailed Description

The AssetTracker class provides the asset tracking functionality.

There are methods to populate asset tracking cache from asset_tracker DB table, and methods to check/add asset tracking tuples to DB and to cache

Constructor & Destructor Documentation

◆ AssetTracker()

AssetTracker::AssetTracker ( ManagementClient mgtClient,
std::string  service 
)

AssetTracker class constructor.

Parameters
mgtClientManagement client object for this south service
serviceService name

◆ ~AssetTracker()

AssetTracker::~AssetTracker ( )

Destructor for the asset tracker.

We must make sure any pending tuples are written out before the asset tracker is destroyed.

Member Function Documentation

◆ addAssetTrackingTuple()

void AssetTracker::addAssetTrackingTuple ( AssetTrackingTuple tuple)

Add asset tracking tuple via microservice management API and in cache.

Parameters
tupleNew tuple to add in DB and in cache

◆ addStorageAssetTrackingTuple()

void AssetTracker::addStorageAssetTrackingTuple ( StorageAssetTrackingTuple tuple,
std::set< std::string > &  dpSet,
bool  addObj = false 
)

Add asset tracking tuple via microservice management API and in cache.

Parameters
tupleNew tuple to add to the queue
dpSetSet of datapoints to handle
addObjCreate a new obj for cache and queue if true. Otherwise just add current tuple to processing queue.

◆ checkAssetTrackingCache()

bool AssetTracker::checkAssetTrackingCache ( AssetTrackingTuple tuple)

Check local cache for a given asset tracking tuple.

Parameters
tupleTuple to find in cache
Returns
Returns whether tuple is present in cache

◆ findAssetTrackingCache()

AssetTrackingTuple * AssetTracker::findAssetTrackingCache ( AssetTrackingTuple tuple)

Lookup tuple in the asset tracker cache.

Parameters
tupleThe tuple to lookup
Returns
NULL if the tuple is not in the cache or the tuple from the cache

◆ findStorageAssetTrackingCache()

StorageAssetTrackingTuple * AssetTracker::findStorageAssetTrackingCache ( StorageAssetTrackingTuple tuple)

Check if a StorageAssetTrackingTuple is in cache.

Parameters
tupleThe StorageAssetTrackingTuple to find
Returns
Pointer to found tuple or NULL

◆ getAssetTracker()

AssetTracker * AssetTracker::getAssetTracker ( )
static

Get asset tracker singleton instance for the current south service.

Returns
Singleton asset tracker instance

◆ getDeprecated()

bool AssetTracker::getDeprecated ( StorageAssetTrackingTuple ptr)

This function takes a StorageAssetTrackingTuple pointer and searches for it in cache, if found then returns its Deprecated status.

Parameters
ptrStorageAssetTrackingTuple* , as key in cache (map)
Returns
bool Deprecation status

◆ getStorageAssetTrackingCacheData()

std::set< std::string > * AssetTracker::getStorageAssetTrackingCacheData ( StorageAssetTrackingTuple tuple)

Get stored value in the StorageAssetTrackingTuple cache for the given tuple.

Parameters
tupleThe StorageAssetTrackingTuple to find
Returns
Pointer to found std::set<std::string> result or NULL if tuble does not exist

◆ populateAssetTrackingCache()

void AssetTracker::populateAssetTrackingCache ( std::string  plugin,
std::string  event 
)

Fetch all asset tracking tuples from DB and populate local cache.

Return the vector of deprecated asset names

Parameters
pluginPlugin name
eventEvent name

◆ populateStorageAssetTrackingCache()

void AssetTracker::populateStorageAssetTrackingCache ( )

Fetch all storage asset tracking tuples from DB and populate local cache.

Return the vector of deprecated asset names

◆ tune()

bool AssetTracker::tune ( unsigned long  interval)

Set the update interval for the asset tracker.

Parameters
intervalThe number of milliseconds between update of the asset tracker
Returns
bool Was the update accepted

◆ updateCache()

void AssetTracker::updateCache ( std::set< std::string >  dpSet,
StorageAssetTrackingTuple ptr 
)

Updates datapoints present in the arg dpSet in the cache.

Parameters
dpSetset of datapoints string values to be updated in cache
ptrStorageAssetTrackingTuple* , as key in cache (map) Retval void

The documentation for this class was generated from the following files: