dmlite  0.6
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
dmlite::BuiltInCatalog Class Reference

#include <Catalog.h>

Inheritance diagram for dmlite::BuiltInCatalog:
Inheritance graph
[legend]
Collaboration diagram for dmlite::BuiltInCatalog:
Collaboration graph
[legend]

Public Member Functions

 BuiltInCatalog (bool updateATime, unsigned symLinkLimit) throw (DmException)
 
 ~BuiltInCatalog ()
 
std::string getImplId (void) const throw ()
 String ID of the implementation. More...
 
void setStackInstance (StackInstance *si) throw (DmException)
 
void setSecurityContext (const SecurityContext *) throw (DmException)
 Set the security context. More...
 
void changeDir (const std::string &) throw (DmException)
 
std::string getWorkingDir (void) throw (DmException)
 
ExtendedStat extendedStat (const std::string &path, bool followSym=true) throw (DmException)
 
ExtendedStat extendedStatByRFN (const std::string &rfn) throw (DmException)
 
bool access (const std::string &path, int mode) throw (DmException)
 
bool accessReplica (const std::string &replica, int mode) throw (DmException)
 
void addReplica (const Replica &replica) throw (DmException)
 
void deleteReplica (const Replica &replica) throw (DmException)
 
std::vector< ReplicagetReplicas (const std::string &path) throw (DmException)
 
Location get (const std::string &path) throw (DmException)
 
Location put (const std::string &path) throw (DmException)
 
void putDone (const std::string &host, const std::string &rfn, const std::map< std::string, std::string > &params) throw (DmException)
 
void symlink (const std::string &oldpath, const std::string &newpath) throw (DmException)
 
std::string readLink (const std::string &path) throw (DmException)
 
void unlink (const std::string &path) throw (DmException)
 
void create (const std::string &path, mode_t mode) throw (DmException)
 
void makeDir (const std::string &path, mode_t mode) throw (DmException)
 
void removeDir (const std::string &path) throw (DmException)
 
void rename (const std::string &oldPath, const std::string &newPath) throw (DmException)
 
mode_t umask (mode_t mask) throw ()
 
void setMode (const std::string &path, mode_t mode) throw (DmException)
 
void setOwner (const std::string &path, uid_t newUid, gid_t newGid, bool followSymLink=true) throw (DmException)
 
void setSize (const std::string &path, size_t newSize) throw (DmException)
 
void setAcl (const std::string &path, const Acl &acls) throw (DmException)
 
void utime (const std::string &path, const struct utimbuf *buf) throw (DmException)
 
std::string getComment (const std::string &path) throw (DmException)
 
void setComment (const std::string &path, const std::string &comment) throw (DmException)
 
void setGuid (const std::string &path, const std::string &guid) throw (DmException)
 
void updateExtendedAttributes (const std::string &path, const Extensible &attr) throw (DmException)
 
DirectoryopenDir (const std::string &path) throw (DmException)
 
void closeDir (Directory *dir) throw (DmException)
 
struct dirent * readDir (Directory *dir) throw (DmException)
 
ExtendedStatreadDirx (Directory *dir) throw (DmException)
 
Replica getReplicaByRFN (const std::string &rfn) throw (DmException)
 
void updateReplica (const Replica &replica) throw (DmException)
 
- Public Member Functions inherited from dmlite::Catalog
virtual ~Catalog ()
 Destructor. More...
 
virtual void setChecksum (const std::string &path, const std::string &csumtype, const std::string &csumvalue) throw (DmException)
 
- Public Member Functions inherited from dmlite::BaseInterface
virtual ~BaseInterface ()
 Virtual destructor. More...
 

Protected Member Functions

ExtendedStat getParent (const std::string &path, std::string *parentPath, std::string *name) throw (DmException)
 
void updateAccessTime (const ExtendedStat &meta) throw (DmException)
 Update access time (if updateATime is true) More...
 
void traverseBackwards (const ExtendedStat &meta) throw (DmException)
 
void addFileSizeToParents (const std::string &fname, bool subtract) throw (DmException)
 
void addFileSizeToParents (const ExtendedStat &statinfo, bool subtract) throw (DmException)
 

Private Attributes

StackInstancesi_
 
const SecurityContextsecCtx_
 
std::string cwdPath_
 
ino_t cwd_
 
mode_t umask_
 
bool updateATime_
 
unsigned symLinkLimit_
 

Additional Inherited Members

- Static Protected Member Functions inherited from dmlite::BaseInterface
static void setStackInstance (BaseInterface *i, StackInstance *si) throw (DmException)
 These method allows plugins to call other plugins setStackInstance and setSecurityContext. More...
 
static void setSecurityContext (BaseInterface *i, const SecurityContext *ctx) throw (DmException)
 

Constructor & Destructor Documentation

dmlite::BuiltInCatalog::BuiltInCatalog ( bool  updateATime,
unsigned  symLinkLimit 
)
throw (DmException
)
dmlite::BuiltInCatalog::~BuiltInCatalog ( )

Member Function Documentation

bool dmlite::BuiltInCatalog::access ( const std::string &  path,
int  mode 
)
throw (DmException
)
virtual

Checks wether the process would be allowed to read, write, or check existence.

Parameters
lfnLogical filename.
modeA mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
Returns
true if the file can be accessed.
Note
If the file does not exist, an exception will be thrown.

Reimplemented from dmlite::Catalog.

bool dmlite::BuiltInCatalog::accessReplica ( const std::string &  replica,
int  mode 
)
throw (DmException
)
virtual

Checks wether the process would be allowed to read, write, or check existence.

Parameters
rfnReplica filename.
modeA mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
Returns
true if the file can be accessed.
Note
If the file does not exist, an exception will be thrown.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::addFileSizeToParents ( const std::string &  fname,
bool  subtract 
)
throw (DmException
)
protected

addFileSizeToParents Add (or subtract) the size of the given file from all its parent directories

Parameters
fnameThe logical file name (SFN) of the file in question
subtractIf true then subtract instead of adding
void dmlite::BuiltInCatalog::addFileSizeToParents ( const ExtendedStat statinfo,
bool  subtract 
)
throw (DmException
)
protected

addFileSizeToParents Add (or subtract) the size of the given file from all its parent directories

Parameters
stThe stat information about the file in question
subtractIf true then subtract instead of adding
void dmlite::BuiltInCatalog::addReplica ( const Replica replica)
throw (DmException
)
virtual

Add a new replica for a file.

Parameters
replicaStores the data that is going to be added. fileid must point to the id of the logical file in the catalog.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::changeDir ( const std::string &  path)
throw (DmException
)
virtual

Change the working dir. Future not-absolute paths will use this as root.

Parameters
pathThe new working dir.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::closeDir ( Directory dir)
throw (DmException
)
virtual

Close a directory opened previously.

Parameters
dirThe directory handle as returned by NsInterface::openDir.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::create ( const std::string &  path,
mode_t  mode 
)
throw (DmException
)
virtual

Creates an entry in the catalog.

Parameters
pathThe new file.
modeThe creation mode.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::deleteReplica ( const Replica replica)
throw (DmException
)
virtual

Delete a replica.

Parameters
replicaThe replica to remove.

Reimplemented from dmlite::Catalog.

ExtendedStat dmlite::BuiltInCatalog::extendedStat ( const std::string &  path,
bool  followSym = true 
)
throw (DmException
)
virtual

Do an extended stat of a file or directory.

Parameters
pathThe path of the file or directory.
followSymIf true, symlinks will be followed.
Returns
The extended status of the file.

Reimplemented from dmlite::Catalog.

ExtendedStat dmlite::BuiltInCatalog::extendedStatByRFN ( const std::string &  rfn)
throw (DmException
)
virtual

Do an extended stat of a logical file using an associated replica file name.

Parameters
rfnThe replica.
Returns
The extended status of the file.

Reimplemented from dmlite::Catalog.

Location dmlite::BuiltInCatalog::get ( const std::string &  path)
throw (DmException
)
std::string dmlite::BuiltInCatalog::getComment ( const std::string &  path)
throw (DmException
)
virtual

Get the comment associated with a file.

Parameters
pathThe file or directory.
Returns
The associated comment.

Reimplemented from dmlite::Catalog.

std::string dmlite::BuiltInCatalog::getImplId ( void  ) const
throw (
)
virtual

String ID of the implementation.

Implements dmlite::BaseInterface.

ExtendedStat dmlite::BuiltInCatalog::getParent ( const std::string &  path,
std::string *  parentPath,
std::string *  name 
)
throw (DmException
)
protected

Get the parent of a directory.

Parameters
pathThe path to split.
parentPathWhere to put the parent path.
nameWhere to put the file name (stripping last /).
Returns
The parent metadata.
Replica dmlite::BuiltInCatalog::getReplicaByRFN ( const std::string &  rfn)
throw (DmException
)
virtual

Get a replica.

Parameters
rfnThe replica file name.

Reimplemented from dmlite::Catalog.

std::vector<Replica> dmlite::BuiltInCatalog::getReplicas ( const std::string &  path)
throw (DmException
)
virtual

Get replicas for a file.

Parameters
pathThe file for which replicas will be retrieved.

Reimplemented from dmlite::Catalog.

std::string dmlite::BuiltInCatalog::getWorkingDir ( void  )
throw (DmException
)
virtual

Get the current working dir.

Returns
The current working dir.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::makeDir ( const std::string &  path,
mode_t  mode 
)
throw (DmException
)
virtual

Create a new empty directory.

Parameters
pathThe path of the new directory.
modeThe creation mode.

Reimplemented from dmlite::Catalog.

Directory* dmlite::BuiltInCatalog::openDir ( const std::string &  path)
throw (DmException
)
virtual

Open a directory for reading.

Parameters
pathThe directory to open.
Returns
A pointer to a handle that can be used for later calls.

Reimplemented from dmlite::Catalog.

Location dmlite::BuiltInCatalog::put ( const std::string &  path)
throw (DmException
)
void dmlite::BuiltInCatalog::putDone ( const std::string &  host,
const std::string &  rfn,
const std::map< std::string, std::string > &  params 
)
throw (DmException
)
struct dirent* dmlite::BuiltInCatalog::readDir ( Directory dir)
throw (DmException
)
virtual

Read next entry from a directory (simple read).

Parameters
dirThe directory handle as returned by NsInterface::openDir.
Returns
0x00 on failure or end of directory.

Reimplemented from dmlite::Catalog.

ExtendedStat* dmlite::BuiltInCatalog::readDirx ( Directory dir)
throw (DmException
)
virtual

Read next entry from a directory (stat information added).

Parameters
dirThe directory handle as returned by NsInterface::openDir.
Returns
0x00 on failure (and errno is set) or end of directory.

Reimplemented from dmlite::Catalog.

std::string dmlite::BuiltInCatalog::readLink ( const std::string &  path)
throw (DmException
)
virtual

Returns the path pointed by the symlink path

Parameters
pathThe symlink file.
Returns
The symlink target.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::removeDir ( const std::string &  path)
throw (DmException
)
virtual

Remove a directory.

Parameters
pathThe path of the directory to remove.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::rename ( const std::string &  oldPath,
const std::string &  newPath 
)
throw (DmException
)
virtual

Rename a file or directory.

Parameters
oldPathThe old name.
newPathThe new name.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setAcl ( const std::string &  path,
const Acl acl 
)
throw (DmException
)
virtual

Set the ACLs

Parameters
pathThe file to modify.
aclThe Access Control List.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setComment ( const std::string &  path,
const std::string &  comment 
)
throw (DmException
)
virtual

Set the comment associated with a file.

Parameters
pathThe file or directory.
commentThe new comment.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setGuid ( const std::string &  path,
const std::string &  guid 
)
throw (DmException
)
virtual

Set GUID of a file.

Parameters
pathThe file.
guidThe new GUID.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setMode ( const std::string &  path,
mode_t  mode 
)
throw (DmException
)
virtual

Set the mode of a file.

Parameters
pathThe file to modify.
modeThe new mode as an integer (i.e. 0755)

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setOwner ( const std::string &  path,
uid_t  newUid,
gid_t  newGid,
bool  followSymLink = true 
)
throw (DmException
)
virtual

Set the owner of a file.

Parameters
pathThe file to modify.
newUidThe uid of the new owneer.
newGidThe gid of the new group.
followSymLinkIf set to true, symbolic links will be followed.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setSecurityContext ( const SecurityContext ctx)
throw (DmException
)
virtual

Set the security context.

Reimplemented from dmlite::BaseInterface.

void dmlite::BuiltInCatalog::setSize ( const std::string &  path,
size_t  newSize 
)
throw (DmException
)
virtual

Set the size of a file.

Parameters
pathThe file to modify.
newSizeThe new file size.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::setStackInstance ( StackInstance si)
throw (DmException
)
virtual

Set the StackInstance. Some plugins may need to access other stacks (i.e. the pool may need the catalog) However, at construction time not all the stacks have been populated, so this will be called once all are instantiated.

Reimplemented from dmlite::BaseInterface.

void dmlite::BuiltInCatalog::symlink ( const std::string &  path,
const std::string &  symlink 
)
throw (DmException
)
virtual

Creates a new symlink.

Parameters
pathThe existing path.
symlinkThe new access path.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::traverseBackwards ( const ExtendedStat meta)
throw (DmException
)
protected

Traverse backwards to check permissions.

Parameters
metaThe file at the end
Note
Throws an exception if it is not possible.
mode_t dmlite::BuiltInCatalog::umask ( mode_t  mask)
throw (
)
virtual

Sets the calling process’s file mode creation mask to mask & 0777.

Parameters
maskThe new mask.
Returns
The value of the previous mask.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::unlink ( const std::string &  path)
throw (DmException
)
virtual

Remove a file.

Parameters
pathThe path to remove.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::updateAccessTime ( const ExtendedStat meta)
throw (DmException
)
protected

Update access time (if updateATime is true)

void dmlite::BuiltInCatalog::updateExtendedAttributes ( const std::string &  path,
const Extensible attr 
)
throw (DmException
)
virtual

Update extended metadata on the catalog.

Parameters
pathThe file to update.
attrThe extended attributes struct.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::updateReplica ( const Replica replica)
throw (DmException
)
virtual

Update a replica.

Parameters
replicaThe replica to modify.
Returns
0 on success, error code otherwise.

Reimplemented from dmlite::Catalog.

void dmlite::BuiltInCatalog::utime ( const std::string &  path,
const struct utimbuf *  buf 
)
throw (DmException
)
virtual

Set access and/or modification time.

Parameters
pathThe file path.
bufA struct holding the new times.

Reimplemented from dmlite::Catalog.

Member Data Documentation

ino_t dmlite::BuiltInCatalog::cwd_
private
std::string dmlite::BuiltInCatalog::cwdPath_
private
const SecurityContext* dmlite::BuiltInCatalog::secCtx_
private
StackInstance* dmlite::BuiltInCatalog::si_
private
unsigned dmlite::BuiltInCatalog::symLinkLimit_
private
mode_t dmlite::BuiltInCatalog::umask_
private
bool dmlite::BuiltInCatalog::updateATime_
private

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