CAPIO-CL 1.2.0
CAPIO-CL: Cross Application Programmable I/O - Coordination Language
Loading...
Searching...
No Matches
capiocl::engine::Engine Class Referencefinal

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

Detailed Description

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:

  • Producers and consumers
  • Commit and fire rules
  • Flags such as permanent, excluded, directory/file type
  • Commit-on-close counters and expected directory file counts
  • File dependencies
  • Regex matchers for globbing
  • Storage policy (in-memory or on filesystem)

Member Function Documentation

◆ add()

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.

Parameters
pathPath of the file or directory.
producersList of producer applications.
consumersList of consumer applications.
commit_ruleCommit rule to apply.
fire_ruleFire rule to apply.
permanentWhether the file/directory is permanent.
excludeWhether the file/directory is excluded.
dependenciesList of dependent files.

◆ addConsumer()

void capiocl::engine::Engine::addConsumer ( const std::filesystem::path & path,
std::string & consumer )

Add a new consumer to a file entry.

Parameters
pathFile path.
consumerApplication name of the consumer.

◆ addFileDependency()

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.

Parameters
pathtargeted file path
file_dependencythe new file for this the path is subject to commit rule

◆ addProducer()

void capiocl::engine::Engine::addProducer ( const std::filesystem::path & path,
std::string & producer )

Add a new producer to a file entry.

Parameters
pathFile path.
producerApplication name of the producer.

◆ contains()

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.

Parameters
filePath of the file to check.
Returns
true if the file is contained, false otherwise.

◆ getDirectoryFileCount()

long capiocl::engine::Engine::getDirectoryFileCount ( const std::filesystem::path & path) const

Get the expected number of files in a directory.

Parameters
pathDirectory path.
Returns
Expected file count.

◆ getPaths()

std::vector< std::string > capiocl::engine::Engine::getPaths ( ) const

Get all the paths that are presents within the Current instance of Engine

Returns

◆ isCommitted()

bool capiocl::engine::Engine::isCommitted ( const std::filesystem::path & path) const

Check whether the path is committed or not

Parameters
path
Returns

◆ isConsumer()

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.

Parameters
pathFile path.
app_nameApplication name.
Returns
true if the process is a consumer, false otherwise.

◆ isDirectory()

bool capiocl::engine::Engine::isDirectory ( const std::filesystem::path & path) const

Check if a path is a directory.

Parameters
pathDirectory path.
Returns
true if directory, false otherwise.

◆ isExcluded()

bool capiocl::engine::Engine::isExcluded ( const std::filesystem::path & path) const

Check if a path is excluded.

Parameters
pathFile path.
Returns
true if excluded, false otherwise.

◆ isFile()

bool capiocl::engine::Engine::isFile ( const std::filesystem::path & path) const

Check if a path refers to a file.

Parameters
pathFile path.
Returns
true if the path is a file, false otherwise.

◆ isFirable()

bool capiocl::engine::Engine::isFirable ( const std::filesystem::path & path) const

Check if a file is firable, that is fire rule is no_update.

Parameters
pathFile path.
Returns
true if the file is firable, false otherwise.

◆ isPermanent()

bool capiocl::engine::Engine::isPermanent ( const std::filesystem::path & path) const

Check if file should remain on file system after workflow terminates.

Parameters
pathFile path to query
Returns
True if file should persist on storage after workflow termination.

◆ isProducer()

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.

Parameters
pathFile path.
app_nameApplication name.
Returns
true if the process is a producer, false otherwise.

◆ isStoredInMemory()

bool capiocl::engine::Engine::isStoredInMemory ( const std::filesystem::path & path) const

Check if a file is stored in memory.

Parameters
pathFile path to query
Returns
true if stored in memory, false otherwise.

◆ loadConfiguration()

void capiocl::engine::Engine::loadConfiguration ( const std::string & path)

Load a CAPIO-CL TOML configuration file

Parameters
path

◆ newFile()

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.

Parameters
pathPath of the new file.

◆ operator==()

bool capiocl::engine::Engine::operator== ( const Engine & other) const

Check for equality between two instances of Engine.

Parameters
otherreference to another Engine class instance
Returns
true if both this instance and other are equivalent. false otherwise.

◆ remove()

void capiocl::engine::Engine::remove ( const std::filesystem::path & path) const

Remove a file from the configuration.

Parameters
pathPath of the file to remove.

◆ setCommitedCloseNumber()

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.

Parameters
pathFile path.
numNumber of close operations before commit.

◆ setCommitRule()

void capiocl::engine::Engine::setCommitRule ( const std::filesystem::path & path,
const std::string & commit_rule )

Set the commit rule of a file.

Parameters
pathFile path.
commit_ruleCommit rule string.
Exceptions
std::invalid_argumentif commit rule is not a valid CAPIO-CL commit rule

◆ setCommitted()

void capiocl::engine::Engine::setCommitted ( const std::filesystem::path & path) const

Set file indicated by path as committed

Parameters
path

◆ setDirectory()

void capiocl::engine::Engine::setDirectory ( const std::filesystem::path & path)

Mark a path as a directory.

Parameters
pathPath to mark.

◆ setDirectoryFileCount()

void capiocl::engine::Engine::setDirectoryFileCount ( const std::filesystem::path & path,
long num )

Sets the expected number of files in a directory.

Note
When using this method, capiocl::Engine will no longer automatically compute the number of files contained within the directory specified by 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.
Parameters
pathThe directory path.
numThe expected number of files in the directory.

◆ setExclude()

void capiocl::engine::Engine::setExclude ( const std::filesystem::path & path,
bool value )

Mark a file as excluded or not.

Parameters
pathFile path.
valuetrue to exclude, false otherwise.

◆ setFile()

void capiocl::engine::Engine::setFile ( const std::filesystem::path & path)

Mark a path as a file.

Parameters
pathPath to mark.

◆ setFileDeps()

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.

Parameters
pathFile path.
dependenciesList of dependent files.

◆ setFireRule()

void capiocl::engine::Engine::setFireRule ( const std::filesystem::path & path,
const std::string & fire_rule )

Set the fire rule of a file.

Parameters
pathFile path.
fire_ruleFire rule string.
Exceptions
std::invalid_argumentif fire rule is not a valid CAPIO-CL Firing rule

◆ setPermanent()

void capiocl::engine::Engine::setPermanent ( const std::filesystem::path & path,
bool value )

Mark a file as permanent or not.

Parameters
pathFile path.
valuetrue to mark permanent, false otherwise.

◆ setStoreFileInFileSystem()

void capiocl::engine::Engine::setStoreFileInFileSystem ( const std::filesystem::path & path)

Store the file on the file system.

Parameters
pathFile path.

◆ setStoreFileInMemory()

void capiocl::engine::Engine::setStoreFileInMemory ( const std::filesystem::path & path)

Store the file in memory only.

Parameters
pathFile path.

◆ setWorkflowName()

void capiocl::engine::Engine::setWorkflowName ( const std::string & name)

Set current orkflow name

Parameters
nameName of the workflow

◆ useDefaultConfiguration()

void capiocl::engine::Engine::useDefaultConfiguration ( )

Use default CAPIO-CL TOML configuration.


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