![]() |
Fledge
An open source edge computing platform for industrial users
|
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... | |
AssetTrackingTuple * | findAssetTrackingCache (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... | |
StorageAssetTrackingTuple * | findStorageAssetTrackingCache (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 AssetTracker * | getAssetTracker () |
Get asset tracker singleton instance for the current south service. More... | |
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
AssetTracker::AssetTracker | ( | ManagementClient * | mgtClient, |
std::string | service | ||
) |
AssetTracker class constructor.
mgtClient | Management client object for this south service |
service | Service name |
AssetTracker::~AssetTracker | ( | ) |
Destructor for the asset tracker.
We must make sure any pending tuples are written out before the asset tracker is destroyed.
void AssetTracker::addAssetTrackingTuple | ( | AssetTrackingTuple & | tuple | ) |
Add asset tracking tuple via microservice management API and in cache.
tuple | New tuple to add in DB and in cache |
void AssetTracker::addStorageAssetTrackingTuple | ( | StorageAssetTrackingTuple & | tuple, |
std::set< std::string > & | dpSet, | ||
bool | addObj = false |
||
) |
Add asset tracking tuple via microservice management API and in cache.
tuple | New tuple to add to the queue |
dpSet | Set of datapoints to handle |
addObj | Create a new obj for cache and queue if true. Otherwise just add current tuple to processing queue. |
bool AssetTracker::checkAssetTrackingCache | ( | AssetTrackingTuple & | tuple | ) |
Check local cache for a given asset tracking tuple.
tuple | Tuple to find in cache |
AssetTrackingTuple * AssetTracker::findAssetTrackingCache | ( | AssetTrackingTuple & | tuple | ) |
Lookup tuple in the asset tracker cache.
tuple | The tuple to lookup |
StorageAssetTrackingTuple * AssetTracker::findStorageAssetTrackingCache | ( | StorageAssetTrackingTuple & | tuple | ) |
Check if a StorageAssetTrackingTuple is in cache.
tuple | The StorageAssetTrackingTuple to find |
|
static |
Get asset tracker singleton instance for the current south service.
bool AssetTracker::getDeprecated | ( | StorageAssetTrackingTuple * | ptr | ) |
This function takes a StorageAssetTrackingTuple pointer and searches for it in cache, if found then returns its Deprecated status.
ptr | StorageAssetTrackingTuple* , as key in cache (map) |
std::set< std::string > * AssetTracker::getStorageAssetTrackingCacheData | ( | StorageAssetTrackingTuple * | tuple | ) |
Get stored value in the StorageAssetTrackingTuple cache for the given tuple.
tuple | The StorageAssetTrackingTuple to find |
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
plugin | Plugin name |
event | Event name |
void AssetTracker::populateStorageAssetTrackingCache | ( | ) |
Fetch all storage asset tracking tuples from DB and populate local cache.
Return the vector of deprecated asset names
bool AssetTracker::tune | ( | unsigned long | interval | ) |
Set the update interval for the asset tracker.
interval | The number of milliseconds between update of the asset tracker |
void AssetTracker::updateCache | ( | std::set< std::string > | dpSet, |
StorageAssetTrackingTuple * | ptr | ||
) |
Updates datapoints present in the arg dpSet in the cache.
dpSet | set of datapoints string values to be updated in cache |
ptr | StorageAssetTrackingTuple* , as key in cache (map) Retval void |