A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
|
#include <PDBCatalog.h>
Public Member Functions | |
PDBCatalog (PDBLoggerPtr logger, string location) | |
~PDBCatalog () | |
void | open () |
bool | registerUserDefinedObject (int16_t typeCode, pdb::Handle< CatalogUserTypeMetadata > &objectToRegister, const string &objectBytes, const string &typeName, const string &fileName, const string &tableName, string &errorMessage) |
template<class CatalogMetadataType > | |
bool | addMetadataToCatalog (Handle< CatalogMetadataType > &metadataValue, int &metadataCategory, string &errorMessage) |
template<class CatalogMetadataType > | |
bool | addItemToVector (Handle< CatalogMetadataType > &item, int &key) |
template<class CatalogMetadataType > | |
bool | updateMetadataInCatalog (pdb::Handle< CatalogMetadataType > &metadataValue, int &metadataCategory, string &errorMessage) |
template<class CatalogMetadataType > | |
bool | deleteMetadataInCatalog (pdb::Handle< CatalogMetadataType > metadataValue, int &metadataCategory, string &errorMessage) |
template<class CatalogMetadataType > | |
bool | updateItemInVector (int &index, Handle< CatalogMetadataType > &item) |
template<class CatalogMetadataType > | |
bool | deleteItemInVector (int &index, Handle< CatalogMetadataType > &item) |
map< string, CatalogNodeMetadata > | getListOfNodesInCluster () |
bool | getSerializedCatalog (string fileName, string version, string &returnedBytes, string &errorMessage) |
void | setCatalogVersion (string version) |
string | getCatalogVersion () |
void | getModifiedMetadata (Handle< CatalogPrintMetadata > &itemMetadata) |
template<class CatalogMetadataType > | |
bool | getMetadataFromCatalog (bool onlyModified, string key, Handle< pdb::Vector< CatalogMetadataType >> &returnedEntries, string &errorMessage, int metadataCategory) |
int | getLastId (int &metadataCategory) |
string | itemName2ItemId (int &metadataCategory, string &key) |
bool | keyIsFound (int &metadataCategory, string &key, string &value) |
PDBLoggerPtr | getLogger () |
map< string, CatalogUserTypeMetadata > | getUserDefinedTypesList () |
void | printsAllCatalogMetadata (std::string &outputString, std::string &errMsg) |
void | listRegisteredDatabases (std::string &outputString, std::string &errMsg) |
void | listRegisteredSetsForADatabase (std::string databaseName, std::string &outputString, std::string &errMsg) |
void | listNodesInCluster (std::string &outputString, std::string &errMsg) |
void | listUserDefinedTypes (std::string &outputString, std::string &errMsg) |
bool | retrievesDynamicLibrary (string fileName, string tableName, Handle< CatalogUserTypeMetadata > &returnedItem, string &returnedSoLibrary, string &errorName) |
void | getListOfDatabases (Handle< Vector< CatalogDatabaseMetadata >> &databasesInCatalog, const string &key) |
void | getListOfSets (Handle< Vector< CatalogSetMetadata >> &setsInCatalog, const string &key) |
void | getListOfNodes (Handle< Vector< CatalogNodeMetadata >> &nodesInCatalog, const string &key) |
void | closeSQLiteHandler () |
template<> | |
bool | addItemToVector (Handle< CatalogDatabaseMetadata > &item, int &key) |
template<> | |
bool | addItemToVector (Handle< CatalogNodeMetadata > &item, int &key) |
template<> | |
bool | addItemToVector (Handle< CatalogSetMetadata > &item, int &key) |
template<> | |
bool | addItemToVector (Handle< CatalogUserTypeMetadata > &item, int &key) |
template<> | |
bool | updateItemInVector (int &index, Handle< CatalogDatabaseMetadata > &item) |
template<> | |
bool | updateItemInVector (int &index, Handle< CatalogSetMetadata > &item) |
template<> | |
bool | updateItemInVector (int &index, Handle< CatalogNodeMetadata > &item) |
template<> | |
bool | updateItemInVector (int &index, Handle< CatalogUserTypeMetadata > &item) |
template<> | |
bool | deleteItemInVector (int &index, Handle< CatalogSetMetadata > &item) |
template<> | |
bool | deleteItemInVector (int &index, Handle< CatalogNodeMetadata > &item) |
template<> | |
bool | deleteItemInVector (int &index, Handle< CatalogDatabaseMetadata > &item) |
template<> | |
bool | deleteItemInVector (int &index, Handle< CatalogUserTypeMetadata > &item) |
Private Member Functions | |
string | getMapsPDBOjbect2SQLiteTable (int typeOfObject) |
void | loadsMetadataIntoMemory () |
bool | catalogSqlQuery (string statement) |
bool | catalogSqlStep (sqlite3_stmt *stmt, string &errorMsg) |
int | createsTempPath () |
void | setUriPath (string thePath) |
void | deleteTempSoFiles (string filePath) |
Friends | |
std::ostream & | operator<< (std::ostream &out, PDBCatalog &catalog) |
Definition at line 80 of file PDBCatalog.h.
PDBCatalog::PDBCatalog | ( | PDBLoggerPtr | logger, |
string | location | ||
) |
Constructor
logger | the catalog logger |
location | the path to the location of the catalog (is relative to the pdb root directory |
Definition at line 165 of file PDBCatalog.cc.
PDBCatalog::~PDBCatalog | ( | ) |
Destructor, deletes temporary files.
Definition at line 255 of file PDBCatalog.cc.
bool PDBCatalog::addItemToVector | ( | Handle< CatalogDatabaseMetadata > & | item, |
int & | key | ||
) |
Definition at line 22 of file PDBCatalog.cc.
bool PDBCatalog::addItemToVector | ( | Handle< CatalogNodeMetadata > & | item, |
int & | key | ||
) |
Definition at line 30 of file PDBCatalog.cc.
bool PDBCatalog::addItemToVector | ( | Handle< CatalogSetMetadata > & | item, |
int & | key | ||
) |
Definition at line 38 of file PDBCatalog.cc.
bool PDBCatalog::addItemToVector | ( | Handle< CatalogUserTypeMetadata > & | item, |
int & | key | ||
) |
Definition at line 46 of file PDBCatalog.cc.
bool PDBCatalog::addItemToVector | ( | Handle< CatalogMetadataType > & | item, |
int & | key | ||
) |
loads a registered Metadata item into memory so it can be accessed by the CatalogServer
item | encapsulates the object with the metadata |
key | is a string key used for maps |
template bool PDBCatalog::addMetadataToCatalog | ( | Handle< CatalogMetadataType > & | metadataValue, |
int & | metadataCategory, | ||
string & | errorMessage | ||
) |
addMetadataToCatalog registers a Metadata item into the Catalog, basically saving it as serialized bytes in an Sqlite table, it then adds that metadata item into memory.
metadataValue | encapsulates the object with the metadata |
metadataCategory | identifies the metadata category (values are defined in PDBCatalogMsgType) |
errorMessage | error message |
Definition at line 941 of file PDBCatalog.cc.
|
private |
Creates a statement from a string and executes the query, returning true if successful
Definition at line 1325 of file PDBCatalog.cc.
|
private |
Executes an sql statement in sqlite3 (insert, update or delete)
Definition at line 1349 of file PDBCatalog.cc.
void PDBCatalog::closeSQLiteHandler | ( | ) |
closes the SQLite DB handler once is no longer needed
Definition at line 271 of file PDBCatalog.cc.
|
private |
Creates a temporary folder to place the shared library files, returns 0 if success
bool PDBCatalog::deleteItemInVector | ( | int & | index, |
Handle< CatalogSetMetadata > & | item | ||
) |
Definition at line 93 of file PDBCatalog.cc.
bool PDBCatalog::deleteItemInVector | ( | int & | index, |
Handle< CatalogNodeMetadata > & | item | ||
) |
Definition at line 110 of file PDBCatalog.cc.
bool PDBCatalog::deleteItemInVector | ( | int & | index, |
Handle< CatalogDatabaseMetadata > & | item | ||
) |
Definition at line 127 of file PDBCatalog.cc.
bool PDBCatalog::deleteItemInVector | ( | int & | index, |
Handle< CatalogUserTypeMetadata > & | item | ||
) |
Definition at line 145 of file PDBCatalog.cc.
bool PDBCatalog::deleteItemInVector | ( | int & | index, |
Handle< CatalogMetadataType > & | item | ||
) |
deletes a registered Metadata item in memory so the changes are visible to the CatalogServer
index | is the position in the container |
item | is the new metadata content |
template bool PDBCatalog::deleteMetadataInCatalog | ( | pdb::Handle< CatalogMetadataType > | metadataValue, |
int & | metadataCategory, | ||
string & | errorMessage | ||
) |
deletes an existing Metadata item in Sqlite along with its content in memory
metadataValue | encapsulates the object with the metadata |
metadataCategory | identifies the metadata category (values are defined in PDBCatalogMsgType) |
errorMessage | error message |
Definition at line 1094 of file PDBCatalog.cc.
|
private |
Deletes all shared library files from the temp directory (is called by the destructor)
Definition at line 923 of file PDBCatalog.cc.
string PDBCatalog::getCatalogVersion | ( | ) |
gets the version of the catalog as a string
Definition at line 280 of file PDBCatalog.cc.
int PDBCatalog::getLastId | ( | int & | metadataCategory | ) |
gets the number of items in a given Metadata category, so the id can be properly set prior to the addition of a new item.
metadataCategory | is an enum to identify the category of metadata (values are defined in PDBCatalogMsgType) |
Definition at line 1157 of file PDBCatalog.cc.
void PDBCatalog::getListOfDatabases | ( | Handle< Vector< CatalogDatabaseMetadata >> & | databasesInCatalog, |
const string & | key | ||
) |
returns the metadata for all Databases registered in the catalog. The information is retrieved from memory rather than disk (SQLite).
key | to search for |
Definition at line 1365 of file PDBCatalog.cc.
void PDBCatalog::getListOfNodes | ( | Handle< Vector< CatalogNodeMetadata >> & | nodesInCatalog, |
const string & | key | ||
) |
returns the metadata for all Nodes registered in the catalog. The information is retrieved from memory rather than disk (SQLite).
key | to search for |
Definition at line 1400 of file PDBCatalog.cc.
map< string, CatalogNodeMetadata > PDBCatalog::getListOfNodesInCluster | ( | ) |
returns the list of nodes in the cluster registered in the catalog
Definition at line 1149 of file PDBCatalog.cc.
void PDBCatalog::getListOfSets | ( | Handle< Vector< CatalogSetMetadata >> & | setsInCatalog, |
const string & | key | ||
) |
returns the metadata for all Sets registered in the catalog. The information is retrieved from memory rather than disk (SQLite).
key | to search for |
Definition at line 1385 of file PDBCatalog.cc.
PDBLoggerPtr PDBCatalog::getLogger | ( | ) |
Gets the logger for the Catalog
Definition at line 269 of file PDBCatalog.cc.
|
private |
returns the name of a Sqlite table for a given category of metadata
Definition at line 1153 of file PDBCatalog.cc.
bool PDBCatalog::getMetadataFromCatalog | ( | bool | onlyModified, |
string | key, | ||
Handle< pdb::Vector< CatalogMetadataType >> & | returnedEntries, | ||
string & | errorMessage, | ||
int | metadataCategory | ||
) |
retrieves all Metadata from Sqlite for a given category and returns it in a container
onlyModified,if | true will return only entries that were created after a given timestamp, which is passed with the "key" parameter |
key | if blank returns all items in the category, otherwise, only the one matching the key (in the case of timestamp the format is Timestamp in milliseconds, for example January 1, 2014 12:00:00 AM is passed as: 1388534400000) and will return all entries created after that given timestamp |
returnedEntries | is a Vector of the Objects |
errorMessage | error message |
metadataCategory | identifies the metadata category (values are defined in PDBCatalogMsgType) |
Definition at line 637 of file PDBCatalog.cc.
void PDBCatalog::getModifiedMetadata | ( | Handle< CatalogPrintMetadata > & | itemMetadata | ) |
gets a version of the content of the catalog as a printable object
Definition at line 477 of file PDBCatalog.cc.
bool PDBCatalog::getSerializedCatalog | ( | string | fileName, |
string | version, | ||
string & | returnedBytes, | ||
string & | errorMessage | ||
) |
retrieves the bytes of the entire catalog, this could be used it one wants to ship the catalog from the manager node to a different machine
fileName | is the name of the catalog file |
version | is the version to retrieve |
returnedBytes | contains the bytes encapsulated in a string |
errorMessage | the error returned |
Definition at line 284 of file PDBCatalog.cc.
map< string, CatalogUserTypeMetadata > PDBCatalog::getUserDefinedTypesList | ( | ) |
Returns a map with metadata for all user-defined types registered in the catalog
Definition at line 828 of file PDBCatalog.cc.
string PDBCatalog::itemName2ItemId | ( | int & | metadataCategory, |
string & | key | ||
) |
maps the id of a Metadata item given its name
metadataCategory | is an enum to identify the category of metadata (values are defined in PDBCatalogMsgType) |
Definition at line 1245 of file PDBCatalog.cc.
bool PDBCatalog::keyIsFound | ( | int & | metadataCategory, |
string & | key, | ||
string & | value | ||
) |
checks if a Metadata item is found in its container
metadataCategory | is an enum to identify the category of metadata (values are defined in PDBCatalogMsgType) |
key | to search for |
Definition at line 1275 of file PDBCatalog.cc.
void PDBCatalog::listNodesInCluster | ( | std::string & | outputString, |
std::string & | errMsg | ||
) |
Lists the Nodes registered in the catalog.
Definition at line 579 of file PDBCatalog.cc.
void PDBCatalog::listRegisteredDatabases | ( | std::string & | outputString, |
std::string & | errMsg | ||
) |
Lists the Databases registered in the catalog.
Definition at line 593 of file PDBCatalog.cc.
void PDBCatalog::listRegisteredSetsForADatabase | ( | std::string | databaseName, |
std::string & | outputString, | ||
std::string & | errMsg | ||
) |
Lists the Sets for a given database registered in the catalog.
Definition at line 607 of file PDBCatalog.cc.
void PDBCatalog::listUserDefinedTypes | ( | std::string & | outputString, |
std::string & | errMsg | ||
) |
Lists the user-defined types registered in the catalog.
Definition at line 622 of file PDBCatalog.cc.
|
private |
loads all Metadata stored in Sqlite and populates the corresponding containers
Definition at line 359 of file PDBCatalog.cc.
void PDBCatalog::open | ( | ) |
Opens an instance of the catalog, retrieves metadata from the sqlite instance and invokes a method for loading retrieved metadata into memory.
Definition at line 309 of file PDBCatalog.cc.
void PDBCatalog::printsAllCatalogMetadata | ( | std::string & | outputString, |
std::string & | errMsg | ||
) |
Prints all metadata registered in the catalog
Definition at line 570 of file PDBCatalog.cc.
bool PDBCatalog::registerUserDefinedObject | ( | int16_t | typeCode, |
pdb::Handle< CatalogUserTypeMetadata > & | objectToRegister, | ||
const string & | objectBytes, | ||
const string & | typeName, | ||
const string & | fileName, | ||
const string & | tableName, | ||
string & | errorMessage | ||
) |
registers a user-defined type in the Catalog is the typeID already assigned
objectToRegister | contains the metadata for this object |
objectBytes | are the binary bytes of the Shared Library encapsulated as an string |
typeName | is a string obtained from the shared library, which identifies the type (e.g. myCoolType) |
fileName | is the path+filename of the Shared Library in the local file system (e.g. mypath/mylibs/libMyCoolType.so |
tableName | is a string identifying the type of the object (e.g. metrics, data_type) |
Definition at line 712 of file PDBCatalog.cc.
bool PDBCatalog::retrievesDynamicLibrary | ( | string | fileName, |
string | tableName, | ||
Handle< CatalogUserTypeMetadata > & | returnedItem, | ||
string & | returnedSoLibrary, | ||
string & | errorName | ||
) |
Retrieves a dynamic library stored as BLOB in the Catalog returns 1 if success, 0 otherwise.
Definition at line 835 of file PDBCatalog.cc.
void PDBCatalog::setCatalogVersion | ( | string | version | ) |
sets the version of the catalog, this is typically called when updates are made to the catalog
version | contains the signature of the version |
Definition at line 276 of file PDBCatalog.cc.
|
inlineprivate |
Sets the URI path where the SQLite database is located
Definition at line 563 of file PDBCatalog.h.
bool PDBCatalog::updateItemInVector | ( | int & | index, |
Handle< CatalogDatabaseMetadata > & | item | ||
) |
Definition at line 60 of file PDBCatalog.cc.
bool PDBCatalog::updateItemInVector | ( | int & | index, |
Handle< CatalogSetMetadata > & | item | ||
) |
Definition at line 69 of file PDBCatalog.cc.
bool PDBCatalog::updateItemInVector | ( | int & | index, |
Handle< CatalogNodeMetadata > & | item | ||
) |
Definition at line 77 of file PDBCatalog.cc.
bool PDBCatalog::updateItemInVector | ( | int & | index, |
Handle< CatalogUserTypeMetadata > & | item | ||
) |
Definition at line 85 of file PDBCatalog.cc.
bool PDBCatalog::updateItemInVector | ( | int & | index, |
Handle< CatalogMetadataType > & | item | ||
) |
updates a registered Metadata item in memory so the changes are visible to the CatalogServer
index | is the position in the container |
item | is the new metadata content |
template bool PDBCatalog::updateMetadataInCatalog | ( | pdb::Handle< CatalogMetadataType > & | metadataValue, |
int & | metadataCategory, | ||
string & | errorMessage | ||
) |
updates an existing Metadata item in Sqlite along with its content in memory
metadataValue | encapsulates the object with the metadata |
metadataCategory | identifies the metadata category (values are defined in PDBCatalogMsgType) |
errorMessage | error message |
Definition at line 1021 of file PDBCatalog.cc.
|
friend |
Overloads the << operator so other classes can print the content of the catalog metadata
Definition at line 1179 of file PDBCatalog.cc.
Container for keeping in memory all the metadata registered in the catalog. Used when a remote catalog (i.e. non-manager catalog) requests an update "pull" of newly registered metadata.
Definition at line 518 of file PDBCatalog.h.
|
private |
String that contains the full name of the catalog file, to be used in SQLite statements
Definition at line 535 of file PDBCatalog.h.
|
private |
Root path where the catalog resides, relative to where PlinyCompute runs
Definition at line 529 of file PDBCatalog.h.
|
private |
A string that indicates the version of this catalog instance
Definition at line 428 of file PDBCatalog.h.
|
private |
List unique metadata entries
Definition at line 443 of file PDBCatalog.h.
|
private |
Contains information of users registered in the catalog. (To be implemented)
Definition at line 449 of file PDBCatalog.h.
|
private |
The logger for this catalog instance
Definition at line 433 of file PDBCatalog.h.
|
private |
Maps the name of an SQLite table given the type of metadata it contains. Used for composing prepared SQL statements in SQLite, given a tyep of Metadata in a container
Definition at line 582 of file PDBCatalog.h.
|
private |
Maps the name of an SQLite table given the type of metadata it contains. Used for composing prepared SQL statements in SQLite, given a type Metadata
Definition at line 575 of file PDBCatalog.h.
|
private |
Maps a typeID to its typeName for a user-defined type registered in the catalog
Definition at line 467 of file PDBCatalog.h.
|
private |
Maps a typeName to its typeID for a user-defined type registered in the catalog
Definition at line 461 of file PDBCatalog.h.
|
private |
Map of users, given the name of a user as a string, lists all databases belonging to that user. (To be implemented)
Definition at line 455 of file PDBCatalog.h.
|
private |
Maps a database name to its Metadata
Definition at line 494 of file PDBCatalog.h.
|
private |
Container for keeping in memory metadata for all registered databases in the catalog
Definition at line 500 of file PDBCatalog.h.
|
private |
Maps a node IP:Port to its Metadata
Definition at line 472 of file PDBCatalog.h.
|
private |
Container for keeping in memory metadata for all registered nodes in the catalog
Definition at line 478 of file PDBCatalog.h.
|
private |
Maps a set ID to its Metadata
Definition at line 483 of file PDBCatalog.h.
|
private |
Container for keeping in memory metadata for all registered sets in the catalog
Definition at line 489 of file PDBCatalog.h.
|
private |
Maps a user-defined type to its Metadata
Definition at line 505 of file PDBCatalog.h.
|
private |
Container for keeping in memory metadata for all registered user-defined types in the catalog
Definition at line 511 of file PDBCatalog.h.
|
private |
Mutex for ensuring proper synchronization of catalog metadata access
Definition at line 423 of file PDBCatalog.h.
|
private |
Handler for the SQLite instance, which stores all catalog metadata
Definition at line 438 of file PDBCatalog.h.
|
private |
String that represents the temporary location where shared library files will be stored at runtime
Definition at line 541 of file PDBCatalog.h.
|
private |
URI string that represents the location of the plinyCatalog.db instance so it can be use for opening connections to the SQLite catalog file
Definition at line 524 of file PDBCatalog.h.