00001 #ifndef CDBBDBSHARED_UTILS_HH 00002 #define CDBBDBSHARED_UTILS_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbSUtils.hh,v 1.7 2003/08/18 22:21:57 gapon Exp $ 00006 00007 #include "BdbUtil/Bdb.hh" 00008 00009 #include "CdbBase/CdbCommon.hh" 00010 00011 #include "CdbBdbShared/CdbBdbSMetaDataP.hh" 00012 00013 #include <string> 00014 00015 /// The utility cass 00016 /** 00017 * This is an utility class provides various operations with persistent store. 00018 */ 00019 class CdbBdbSUtils { 00020 00021 public: 00022 00023 /// Find out the name of the local BDID range 00024 00025 static CdbStatus getLocalDbIdRange( std::string& theName ); 00026 00027 /// Check if specified BDID range is known 00028 /** 00029 * The result of this operation is returned via its completions status, 00030 * which is: 00031 * 00032 * CdbStatus::NotFound - if there is no such DBID range found 00033 * CdbStatus::Success - if it's found, or 00034 * CdbStatus::Error - in case of any error. 00035 */ 00036 static CdbStatus verifyDbIdRange( const char* theName ); 00037 00038 /// Find out a persistent container 00039 /** 00040 * The returned container will be open in the specified mode. 00041 */ 00042 static CdbStatus findContainer( BdbHandle(BdbContObj)& theContH, 00043 const char* theDatabaseName, 00044 const char* theContainerName, 00045 const BdbMode theOpenMode = BdbcRead ); 00046 00047 /// Find out a persistent database 00048 /** 00049 * The returned database will be open in the specified mode. 00050 */ 00051 static CdbStatus findDatabase( BdbHandle(BdbDBObj)& theDatabaseH, 00052 const char* theDatabaseName, 00053 const BdbMode theOpenMode = BdbcRead ); 00054 00055 /// Find MetaData object at specified location 00056 /** 00057 * This method does the actual database/container mining work. 00058 */ 00059 static CdbStatus findMetaData( BdbRef(CdbBdbSMetaDataP)& theRef, 00060 const d_UShort theConditionId, 00061 bool isPartitionableFlag, 00062 d_UShort thePartitionId, 00063 d_UShort theClusterId, 00064 d_UShort theIncrementNumber, 00065 const std::string& theDbIdRange ); 00066 00067 /// Find the actual size of a database file corresponding to specified parameters 00068 /** 00069 * This method will use the specified parameters to build the name of the database. 00070 * Then it will return (into specified variables) the total number of pages 00071 * in this database and the page size (BYTES). 00072 */ 00073 static CdbStatus databaseSize( d_ULong& theNumPages, 00074 d_ULong& thePageSize, 00075 bool isPartitionableFlag, 00076 d_UShort thePartitionId, 00077 d_UShort theClusterId, 00078 d_UShort theIncrementNumber, 00079 const std::string& theDbIdRange ); 00080 00081 /// Find the actual size of the MASTER database file 00082 /** 00083 * This method will find the size of the main "bootstrap" file which is used 00084 * to startup the bootsrtap sequence and to store the global registries of 00085 * the distributed CDB. There must be just one file of this type originated 00086 * in the MASTER CDB. 00087 */ 00088 static CdbStatus databaseSize( d_ULong& theNumPages, 00089 d_ULong& thePageSize ); 00090 00091 /// Find the actual size of the local bootstrap database file 00092 /** 00093 * This method will find the size of the local (to specified DBID range) "bootstrap" 00094 * file which is used to store local registries, etc. 00095 * 00096 * If the local database is the MASTER one then CdbSatus::NotFound value 00097 * will be returned. 00098 */ 00099 static CdbStatus databaseSize( d_ULong& theNumPages, 00100 d_ULong& thePageSize, 00101 const std::string& theDbIdRange ); 00102 00103 /// Set the required File Placement Strategy at the Clustering Hint Service 00104 /** 00105 * Initialize desired File Placement Strategy. It can be either a default 00106 * value or some explicitly specified path if an optional switch passed 00107 * as a parameter is "false". If a non-default value of the path is required then 00108 * the second parameter will be used. 00109 * 00110 * IMPORTANT: 00111 * 00112 * The current implementation of the File Placement & Clustering Hint Service 00113 * requires to use this procedure at least once. Otherwise the application will 00114 * crash issuing the following message: 00115 * 00116 * "Call BdbCondFSNamesStr::setCustomRelativePath() first 00117 * "Abort (core dumped)" 00118 * 00119 * This File Placement Strategy specifies the default directory for newely created 00120 * databases, which in the old implementation of the Clustering Hint was: 00121 * 00122 * <base>/conditions/cdb 00123 * 00124 * The new implementation will have 00125 * 00126 * <base>/conditions/<local-dbid-range> 00127 * 00128 * By default the new scheme is used. Overriding the default value of 00129 * the optional 'useDefaultStrategyFlag' parameter to "false" would switch 00130 * the path back to the non-default policiy. In this case the second parameter 00131 * with the explicit path name will be used. The default value of the second 00132 * parameter corresponds to the old Strategy Policy. 00133 */ 00134 static CdbStatus setPlacementStrategy( bool useDefaultStrategyFlag = true, 00135 const char* theExplicitPathName = "conditions/cdb" ); 00136 00137 private: 00138 00139 /// Do the actual measurement on specified database 00140 /** 00141 * The database must exist. If it's not found then CdbStatus::NotFound will 00142 * be returned. Other status values are returned as usually. 00143 */ 00144 static CdbStatus measureDatabaseSize( d_ULong& theNumPages, 00145 d_ULong& thePageSize, 00146 const std::string& theDatabaseName ); 00147 00148 // Cached DBID range "native" to the Condition/DB domain of the local federation. 00149 00150 static std::string _localDbIdRange; 00151 }; 00152 00153 #endif // CDBBDBSHARED_UTILS_HH
1.3-rc3