Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends

ClassAdCollection Class Reference

#include <collectionBase.h>

Inheritance diagram for ClassAdCollection:
ClassAdCollectionInterface ClassAdCollectionInterface

List of all members.

Public Member Functions

virtual bool CreateSubView (const ViewName &viewName, const ViewName &parentViewName, const std::string &constraint, const std::string &rank, const std::string &partitionExprs)
virtual bool CreatePartition (const ViewName &viewName, const ViewName &parentViewName, const std::string &constraint, const std::string &rank, const std::string &partitionExprs, ClassAd *rep)
virtual bool DeleteView (const ViewName &viewName)
virtual bool SetViewInfo (const ViewName &viewName, const std::string &constraint, const std::string &rank, const std::string &partitionAttrs)
virtual bool GetViewInfo (const ViewName &viewName, ClassAd *&viewInfo)
virtual const ViewGetView (const ViewName &viewName)
virtual bool ViewExists (const ViewName &viewName)
virtual bool GetSubordinateViewNames (const ViewName &viewName, std::vector< std::string > &views)
virtual bool GetPartitionedViewNames (const ViewName &viewName, std::vector< std::string > &views)
virtual bool FindPartitionName (const ViewName &viewName, ClassAd *rep, ViewName &partition)
virtual bool OpenTransaction (const std::string &transactionName)
virtual bool CloseTransaction (const std::string &transactionName, bool commit, int &outcome)
virtual bool IsMyActiveTransaction (const std::string &transactionName)
virtual void GetMyActiveTransactions (std::vector< std::string > &)
virtual bool IsActiveTransaction (const std::string &transactionName)
virtual bool GetAllActiveTransactions (std::vector< std::string > &)
virtual bool IsCommittedTransaction (const std::string &transactionName)
virtual bool GetAllCommittedTransactions (std::vector< std::string > &)
bool DisplayView (const ViewName &viewName, FILE *)
bool dump_collection ()
int WriteCheckPoint ()
bool TruncateStorageFile ()
virtual bool CreateSubView (const ViewName &viewName, const ViewName &parentViewName, const std::string &constraint, const std::string &rank, const std::string &partitionExprs)
virtual bool CreatePartition (const ViewName &viewName, const ViewName &parentViewName, const std::string &constraint, const std::string &rank, const std::string &partitionExprs, ClassAd *rep)
virtual bool DeleteView (const ViewName &viewName)
virtual bool SetViewInfo (const ViewName &viewName, const std::string &constraint, const std::string &rank, const std::string &partitionAttrs)
virtual bool GetViewInfo (const ViewName &viewName, ClassAd *&viewInfo)
virtual const ViewGetView (const ViewName &viewName)
virtual bool ViewExists (const ViewName &viewName)
virtual bool GetSubordinateViewNames (const ViewName &viewName, std::vector< std::string > &views)
virtual bool GetPartitionedViewNames (const ViewName &viewName, std::vector< std::string > &views)
virtual bool FindPartitionName (const ViewName &viewName, ClassAd *rep, ViewName &partition)
virtual bool OpenTransaction (const std::string &transactionName)
virtual bool CloseTransaction (const std::string &transactionName, bool commit, int &outcome)
virtual bool IsMyActiveTransaction (const std::string &transactionName)
virtual void GetMyActiveTransactions (std::vector< std::string > &)
virtual bool IsActiveTransaction (const std::string &transactionName)
virtual bool GetAllActiveTransactions (std::vector< std::string > &)
virtual bool IsCommittedTransaction (const std::string &transactionName)
virtual bool GetAllCommittedTransactions (std::vector< std::string > &)
bool DisplayView (const ViewName &viewName, FILE *)
bool dump_collection ()
int WriteCheckPoint ()
bool TruncateStorageFile ()
Constructors/Destructor

Note that the ClassAdCollection constructors talk about caching. If caching is off, all ClassAds are stored in memory. For large collections, this may be a problem. If caching is on, only some ClassAds will be kept in memory, and all of them will be written to disk. This is similar to virtual memory. Please note, however, that caching has been barely tested, and is not production ready.

 ClassAdCollection ()
 ClassAdCollection (bool cacheOn)
virtual ~ClassAdCollection ()
 Destructor. This will delete all ClassAds in the Collection.
 ClassAdCollection ()
 ClassAdCollection (bool cacheOn)
virtual ~ClassAdCollection ()
 Destructor. This will delete all ClassAds in the Collection.
Persistence

ClassAd collections are most useful when they are stored persistently to disk, otherwise they will not be saved between invocations of your program. The log file is a journal of the changes to the Collection. It is created or read by InitializeFromLog, and it can be compressed by TruncateLog()

virtual bool InitializeFromLog (const std::string &logfile, const std::string storagefile="", const std::string checkpointfile="")
virtual bool TruncateLog (void)
virtual bool InitializeFromLog (const std::string &logfile, const std::string storagefile="", const std::string checkpointfile="")
virtual bool TruncateLog (void)
Manipulating ClassAds in a collection

This set of functions allows you to manipulate ClassAds in a Collection. There are a couple of important things to be aware of. First, once you successfully give a ClassAd to a collection, it is owned by the collection, and you should not delete it. (If it is not successful--for instance, if AddClassAd() fails--you still own the ClassAd.) Second, once a ClassAd is owned by the collection, you should not directly modify it. Instead you should use UpdateClassAd or ModifyClassAd().

virtual bool AddClassAd (const std::string &key, ClassAd *newAd)
virtual bool UpdateClassAd (const std::string &key, ClassAd *updateAd)
virtual bool ModifyClassAd (const std::string &key, ClassAd *modifyAd)
virtual bool RemoveClassAd (const std::string &key)
virtual ClassAdGetClassAd (const std::string &key)
virtual bool AddClassAd (const std::string &key, ClassAd *newAd)
virtual bool UpdateClassAd (const std::string &key, ClassAd *updateAd)
virtual bool ModifyClassAd (const std::string &key, ClassAd *modifyAd)
virtual bool RemoveClassAd (const std::string &key)
virtual ClassAdGetClassAd (const std::string &key)

Public Attributes

IndexFile ClassAdStorage

Protected Member Functions

virtual bool OperateInRecoveryMode (ClassAd *)
virtual bool LogState (FILE *)
bool PlayClassAdOp (int, ClassAd *)
bool PlayXactionOp (int, const std::string &, ClassAd *, ServerTransaction *&)
bool PlayViewOp (int, ClassAd *)
bool RegisterView (const ViewName &viewName, View *)
bool UnregisterView (const ViewName &viewName)
bool LogViews (FILE *log, View *view, bool subView)
void Setup (bool CacheOn)
bool SelectClassadToReplace (std::string &key)
bool SetDirty (std::string key)
bool ClearDirty (std::string key)
bool CheckDirty (std::string key)
bool GetStringClassAd (std::string key, std::string &WriteBackClassad)
bool SwitchInClassAd (std::string key)
int ReadStorageEntry (int sfiled, int &offset, std::string &ckey)
bool ReadCheckPointFile ()
void MaybeSwapOutClassAd (void)
virtual bool OperateInRecoveryMode (ClassAd *)
virtual bool LogState (FILE *)
bool PlayClassAdOp (int, ClassAd *)
bool PlayXactionOp (int, const std::string &, ClassAd *, ServerTransaction *&)
bool PlayViewOp (int, ClassAd *)
bool RegisterView (const ViewName &viewName, View *)
bool UnregisterView (const ViewName &viewName)
bool LogViews (FILE *log, View *view, bool subView)
void Setup (bool CacheOn)
bool SelectClassadToReplace (std::string &key)
bool SetDirty (std::string key)
bool ClearDirty (std::string key)
bool CheckDirty (std::string key)
bool GetStringClassAd (std::string key, std::string &WriteBackClassad)
bool SwitchInClassAd (std::string key)
int ReadStorageEntry (int sfiled, int &offset, std::string &ckey)
bool ReadCheckPointFile ()
void MaybeSwapOutClassAd (void)

Protected Attributes

ViewRegistry viewRegistry
ClassAdTable classadTable
View viewTree
XactionTable xactionTable
bool Cache
int Max_Classad
int CheckPoint
std::map< std::string, int > DirtyClassad
timeval LatestCheckpoint
std::string CheckFileName
int test_checkpoint

Friends

class View
class ServerTransaction
class ClassAd
class LocalCollectionQuery

Detailed Description

A ClassAdCollection stores a set of ClassAds. It is similar to a hash table, but with more interesting querying capabilities.


Constructor & Destructor Documentation

ClassAdCollection::ClassAdCollection (  ) 

Default constructor for a Collection. Caching will be turned off.

ClassAdCollection::ClassAdCollection ( bool  cacheOn  ) 

Constructor that allows you to enable or disable caching.

Parameters:
cacheOn true if you want caching on, false otherwise
ClassAdCollection::ClassAdCollection (  ) 

Default constructor for a Collection. Caching will be turned off.

ClassAdCollection::ClassAdCollection ( bool  cacheOn  ) 

Constructor that allows you to enable or disable caching.

Parameters:
cacheOn true if you want caching on, false otherwise

Member Function Documentation

virtual bool ClassAdCollection::AddClassAd ( const std::string &  key,
ClassAd newAd 
) [virtual]

Add a ClassAd to the collection. If a ClassAd is already in the Collection for the given key, the one in the Collection is deleted and the new one replaces it. If this function succeeds, the Collection now owns the ClassAd, and you should not change it or delete it directly. If this function fails, you still own the ClassAd and are responsible for deleting it when appropriate.

Parameters:
key The unique identifier for this ClassAd
newAd The new add to put into the Collection

Implements ClassAdCollectionInterface.

virtual bool ClassAdCollection::AddClassAd ( const std::string &  key,
ClassAd newAd 
) [virtual]

Add a ClassAd to the collection. If a ClassAd is already in the Collection for the given key, the one in the Collection is deleted and the new one replaces it. If this function succeeds, the Collection now owns the ClassAd, and you should not change it or delete it directly. If this function fails, you still own the ClassAd and are responsible for deleting it when appropriate.

Parameters:
key The unique identifier for this ClassAd
newAd The new add to put into the Collection

Implements ClassAdCollectionInterface.

virtual bool ClassAdCollection::InitializeFromLog ( const std::string &  logfile,
const std::string  storagefile = "",
const std::string  checkpointfile = "" 
) [virtual]

Setup persistence and caching. This function has two purposes, and should probably be two functions. First, it either creates the persistent log file if it is not there, or reads the collection back from the log file. Second, it sets up the caching, if caching is turned on.

Parameters:
logfile The name of the persistent log file.
storagefile The name of file to keep the cache. Leave empty if you are not using a cache
checkpointfile The name of the checkpoint file for the cache. Leave empty if you are not using a cache

Implements ClassAdCollectionInterface.

virtual bool ClassAdCollection::InitializeFromLog ( const std::string &  logfile,
const std::string  storagefile = "",
const std::string  checkpointfile = "" 
) [virtual]

Setup persistence and caching. This function has two purposes, and should probably be two functions. First, it either creates the persistent log file if it is not there, or reads the collection back from the log file. Second, it sets up the caching, if caching is turned on.

Parameters:
logfile The name of the persistent log file.
storagefile The name of file to keep the cache. Leave empty if you are not using a cache
checkpointfile The name of the checkpoint file for the cache. Leave empty if you are not using a cache

Implements ClassAdCollectionInterface.

bool ClassAdCollection::TruncateLog ( void   )  [virtual]

This function compresses the persistent log file. Before compression, the log file contains a list of changes to the collection. After compression, it contains the state of the collection.

Reimplemented from ClassAdCollectionInterface.

virtual bool ClassAdCollection::TruncateLog ( void   )  [virtual]

This function compresses the persistent log file. Before compression, the log file contains a list of changes to the collection. After compression, it contains the state of the collection.

Reimplemented from ClassAdCollectionInterface.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends