|
CAPIO-CL 1.2.0
CAPIO-CL: Cross Application Programmable I/O - Coordination Language
|
Engine for managing CAPIO-CL configuration entries. The CapioCLEngine class stores and manages configuration rules for files and directories as defined in the CAPIO-CL configuration file. It maintains producers, consumers, commit rules, fire rules, and other metadata associated with files or directories. Each entry in the configuration associates a path with: More...
#include <engine.h>
Public Member Functions | |
| Engine (bool use_default_settings=true) | |
| Class constructor. | |
| void | print () const |
| Print the current CAPIO-CL configuration. | |
| bool | contains (const std::filesystem::path &file) const |
| Check whether a file is contained in the configuration. The lookup is performed by exact match or by regex globbing. | |
| size_t | size () const |
| return the number of entries in the current configuration | |
| void | add (std::filesystem::path &path, std::vector< std::string > &producers, std::vector< std::string > &consumers, const std::string &commit_rule, const std::string &fire_rule, bool permanent, bool exclude, std::vector< std::filesystem::path > &dependencies) |
| Add a new CAPIO-CL configuration entry. | |
| void | addProducer (const std::filesystem::path &path, std::string &producer) |
| Add a new producer to a file entry. | |
| void | addConsumer (const std::filesystem::path &path, std::string &consumer) |
| Add a new consumer to a file entry. | |
| void | addFileDependency (const std::filesystem::path &path, std::filesystem::path &file_dependency) |
| Add a new file dependency, when rule is commit_on_file As a side effect, the file identified by path, has the commit rule set to Commit on Files. | |
| void | newFile (const std::filesystem::path &path) |
| Create a new CAPIO file entry. Commit and fire rules are automatically computed using the longest prefix match from the configuration. | |
| void | remove (const std::filesystem::path &path) const |
| Remove a file from the configuration. | |
| void | setCommitRule (const std::filesystem::path &path, const std::string &commit_rule) |
| Set the commit rule of a file. | |
| void | setFireRule (const std::filesystem::path &path, const std::string &fire_rule) |
| Set the fire rule of a file. | |
| void | setPermanent (const std::filesystem::path &path, bool value) |
| Mark a file as permanent or not. | |
| void | setExclude (const std::filesystem::path &path, bool value) |
| Mark a file as excluded or not. | |
| void | setDirectory (const std::filesystem::path &path) |
| Mark a path as a directory. | |
| void | setFile (const std::filesystem::path &path) |
| Mark a path as a file. | |
| void | setCommitedCloseNumber (const std::filesystem::path &path, long num) |
Set the commit-on-close counter. The file will be committed after num close operations. | |
| void | setDirectoryFileCount (const std::filesystem::path &path, long num) |
| Sets the expected number of files in a directory. | |
| void | setFileDeps (const std::filesystem::path &path, const std::vector< std::filesystem::path > &dependencies) |
| Set the dependencies of a file. This method as a side effect sets the commit rule to Commit on Files. | |
| void | setStoreFileInMemory (const std::filesystem::path &path) |
| Store the file in memory only. | |
| void | setAllStoreInMemory () |
| set all files to be stored in memory. Once this method is called, all new files will be stored in memory unless afterward an explicit call to setStoreFileInFileSystem() is issued targeting the newly created file | |
| void | setStoreFileInFileSystem (const std::filesystem::path &path) |
| Store the file on the file system. | |
| void | setWorkflowName (const std::string &name) |
| long | getDirectoryFileCount (const std::filesystem::path &path) const |
| Get the expected number of files in a directory. | |
| std::string | getCommitRule (const std::filesystem::path &path) const |
| Get the commit rule of a file. | |
| std::string | getFireRule (const std::filesystem::path &path) const |
| Get the fire rule of a file. | |
| std::vector< std::string > | getProducers (const std::filesystem::path &path) const |
| Get the producers of a file. | |
| std::vector< std::string > | getConsumers (const std::filesystem::path &path) const |
| Get the consumers of a file. | |
| long | getCommitCloseCount (const std::filesystem::path::iterator::reference &path) const |
| Get the commit-on-close counter for a file. | |
| std::vector< std::filesystem::path > | getCommitOnFileDependencies (const std::filesystem::path &path) const |
| Get file dependencies. | |
| std::vector< std::string > | getFileToStoreInMemory () const |
| Get the list of files stored in memory. | |
| std::set< std::string > | getHomeNode (const std::filesystem::path &path) const |
| Get the home node of a file. | |
| void | setHomeNode (const std::filesystem::path &path) const |
| Set the home node for a given path. | |
| const std::string & | getWorkflowName () const |
| Get current workflow name loaded from memory. | |
| bool | isProducer (const std::filesystem::path &path, const std::string &app_name) const |
| Check if a process is a producer for a file. | |
| bool | isConsumer (const std::filesystem::path &path, const std::string &app_name) const |
| Check if a process is a consumer for a file. | |
| bool | isFirable (const std::filesystem::path &path) const |
| Check if a file is firable, that is fire rule is no_update. | |
| bool | isFile (const std::filesystem::path &path) const |
| Check if a path refers to a file. | |
| bool | isExcluded (const std::filesystem::path &path) const |
| Check if a path is excluded. | |
| bool | isDirectory (const std::filesystem::path &path) const |
| Check if a path is a directory. | |
| bool | isStoredInMemory (const std::filesystem::path &path) const |
| Check if a file is stored in memory. | |
| bool | isPermanent (const std::filesystem::path &path) const |
| Check if file should remain on file system after workflow terminates. | |
| bool | isCommitted (const std::filesystem::path &path) const |
| void | setCommitted (const std::filesystem::path &path) const |
| std::vector< std::string > | getPaths () const |
| bool | operator== (const Engine &other) const |
| Check for equality between two instances of Engine. | |
| void | loadConfiguration (const std::string &path) |
| void | useDefaultConfiguration () |
Friends | |
| class | serializer::Serializer |
Engine for managing CAPIO-CL configuration entries. The CapioCLEngine class stores and manages configuration rules for files and directories as defined in the CAPIO-CL configuration file. It maintains producers, consumers, commit rules, fire rules, and other metadata associated with files or directories. Each entry in the configuration associates a path with:
| void capiocl::engine::Engine::add | ( | std::filesystem::path & | path, |
| std::vector< std::string > & | producers, | ||
| std::vector< std::string > & | consumers, | ||
| const std::string & | commit_rule, | ||
| const std::string & | fire_rule, | ||
| bool | permanent, | ||
| bool | exclude, | ||
| std::vector< std::filesystem::path > & | dependencies ) |
Add a new CAPIO-CL configuration entry.
| path | Path of the file or directory. |
| producers | List of producer applications. |
| consumers | List of consumer applications. |
| commit_rule | Commit rule to apply. |
| fire_rule | Fire rule to apply. |
| permanent | Whether the file/directory is permanent. |
| exclude | Whether the file/directory is excluded. |
| dependencies | List of dependent files. |
| void capiocl::engine::Engine::addConsumer | ( | const std::filesystem::path & | path, |
| std::string & | consumer ) |
Add a new consumer to a file entry.
| path | File path. |
| consumer | Application name of the consumer. |
| void capiocl::engine::Engine::addFileDependency | ( | const std::filesystem::path & | path, |
| std::filesystem::path & | file_dependency ) |
Add a new file dependency, when rule is commit_on_file As a side effect, the file identified by path, has the commit rule set to Commit on Files.
| path | targeted file path |
| file_dependency | the new file for this the path is subject to commit rule |
| void capiocl::engine::Engine::addProducer | ( | const std::filesystem::path & | path, |
| std::string & | producer ) |
Add a new producer to a file entry.
| path | File path. |
| producer | Application name of the producer. |
| bool capiocl::engine::Engine::contains | ( | const std::filesystem::path & | file | ) | const |
Check whether a file is contained in the configuration. The lookup is performed by exact match or by regex globbing.
| file | Path of the file to check. |
| long capiocl::engine::Engine::getDirectoryFileCount | ( | const std::filesystem::path & | path | ) | const |
Get the expected number of files in a directory.
| path | Directory path. |
| std::vector< std::string > capiocl::engine::Engine::getPaths | ( | ) | const |
Get all the paths that are presents within the Current instance of Engine
| bool capiocl::engine::Engine::isCommitted | ( | const std::filesystem::path & | path | ) | const |
Check whether the path is committed or not
| path |
| bool capiocl::engine::Engine::isConsumer | ( | const std::filesystem::path & | path, |
| const std::string & | app_name ) const |
Check if a process is a consumer for a file.
| path | File path. |
| app_name | Application name. |
| bool capiocl::engine::Engine::isDirectory | ( | const std::filesystem::path & | path | ) | const |
Check if a path is a directory.
| path | Directory path. |
| bool capiocl::engine::Engine::isExcluded | ( | const std::filesystem::path & | path | ) | const |
Check if a path is excluded.
| path | File path. |
| bool capiocl::engine::Engine::isFile | ( | const std::filesystem::path & | path | ) | const |
Check if a path refers to a file.
| path | File path. |
| bool capiocl::engine::Engine::isFirable | ( | const std::filesystem::path & | path | ) | const |
Check if a file is firable, that is fire rule is no_update.
| path | File path. |
| bool capiocl::engine::Engine::isPermanent | ( | const std::filesystem::path & | path | ) | const |
Check if file should remain on file system after workflow terminates.
| path | File path to query |
| bool capiocl::engine::Engine::isProducer | ( | const std::filesystem::path & | path, |
| const std::string & | app_name ) const |
Check if a process is a producer for a file.
| path | File path. |
| app_name | Application name. |
| bool capiocl::engine::Engine::isStoredInMemory | ( | const std::filesystem::path & | path | ) | const |
Check if a file is stored in memory.
| path | File path to query |
| void capiocl::engine::Engine::loadConfiguration | ( | const std::string & | path | ) |
Load a CAPIO-CL TOML configuration file
| path |
| void capiocl::engine::Engine::newFile | ( | const std::filesystem::path & | path | ) |
Create a new CAPIO file entry. Commit and fire rules are automatically computed using the longest prefix match from the configuration.
| path | Path of the new file. |
| bool capiocl::engine::Engine::operator== | ( | const Engine & | other | ) | const |
| void capiocl::engine::Engine::remove | ( | const std::filesystem::path & | path | ) | const |
Remove a file from the configuration.
| path | Path of the file to remove. |
| void capiocl::engine::Engine::setCommitedCloseNumber | ( | const std::filesystem::path & | path, |
| long | num ) |
Set the commit-on-close counter. The file will be committed after num close operations.
| path | File path. |
| num | Number of close operations before commit. |
| void capiocl::engine::Engine::setCommitRule | ( | const std::filesystem::path & | path, |
| const std::string & | commit_rule ) |
Set the commit rule of a file.
| path | File path. |
| commit_rule | Commit rule string. |
| std::invalid_argument | if commit rule is not a valid CAPIO-CL commit rule |
| void capiocl::engine::Engine::setCommitted | ( | const std::filesystem::path & | path | ) | const |
Set file indicated by path as committed
| path |
| void capiocl::engine::Engine::setDirectory | ( | const std::filesystem::path & | path | ) |
Mark a path as a directory.
| path | Path to mark. |
| void capiocl::engine::Engine::setDirectoryFileCount | ( | const std::filesystem::path & | path, |
| long | num ) |
Sets the expected number of files in a directory.
path. This is because there is no way to determine whether the user-provided count includes or excludes the files automatically detected by CAPIO-CL. Also, there is no way to know whether the provided number is already inclusive of the possible future generated children files.| path | The directory path. |
| num | The expected number of files in the directory. |
| void capiocl::engine::Engine::setExclude | ( | const std::filesystem::path & | path, |
| bool | value ) |
Mark a file as excluded or not.
| path | File path. |
| value | true to exclude, false otherwise. |
| void capiocl::engine::Engine::setFile | ( | const std::filesystem::path & | path | ) |
Mark a path as a file.
| path | Path to mark. |
| void capiocl::engine::Engine::setFileDeps | ( | const std::filesystem::path & | path, |
| const std::vector< std::filesystem::path > & | dependencies ) |
Set the dependencies of a file. This method as a side effect sets the commit rule to Commit on Files.
| path | File path. |
| dependencies | List of dependent files. |
| void capiocl::engine::Engine::setFireRule | ( | const std::filesystem::path & | path, |
| const std::string & | fire_rule ) |
Set the fire rule of a file.
| path | File path. |
| fire_rule | Fire rule string. |
| std::invalid_argument | if fire rule is not a valid CAPIO-CL Firing rule |
| void capiocl::engine::Engine::setPermanent | ( | const std::filesystem::path & | path, |
| bool | value ) |
Mark a file as permanent or not.
| path | File path. |
| value | true to mark permanent, false otherwise. |
| void capiocl::engine::Engine::setStoreFileInFileSystem | ( | const std::filesystem::path & | path | ) |
Store the file on the file system.
| path | File path. |
| void capiocl::engine::Engine::setStoreFileInMemory | ( | const std::filesystem::path & | path | ) |
Store the file in memory only.
| path | File path. |
| void capiocl::engine::Engine::setWorkflowName | ( | const std::string & | name | ) |
Set current orkflow name
| name | Name of the workflow |
| void capiocl::engine::Engine::useDefaultConfiguration | ( | ) |
Use default CAPIO-CL TOML configuration.