Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbBdbSView.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbSView.cc,v 1.11 2005/02/02 15:04:24 gapon Exp $
00003 
00004 /// The implementation of the CdbBdbSView class.
00005 /**
00006   * @see CdbBdbSView
00007   */
00008 #include "BaBar/BaBar.hh"
00009 
00010 #include "CdbBdbShared/CdbBdbSView.hh"
00011 
00012 #include "CdbBase/Cdb.hh"
00013 #include "CdbBase/CdbId.hh"
00014 #include "CdbBase/CdbStateId.hh"
00015 #include "CdbBase/CdbFolder.hh"
00016 #include "CdbBase/CdbPathName.hh"
00017 #include "CdbBase/CdbRevisionPolicy.hh"
00018 
00019 #include "CdbBdbShared/CdbBdbSFolder.hh"
00020 #include "CdbBdbShared/CdbBdbSPartitionP.hh"
00021 #include "CdbBdbShared/CdbBdbSViewP.hh"
00022 #include "CdbBdbShared/CdbBdbSConditionAtFolderP.hh"
00023 #include "CdbBdbShared/CdbBdbSConfigCollectionP.hh"
00024 
00025 #include "BdbTime/BdbTime.hh"
00026 
00027 #include <iostream>
00028 using std::cout;
00029 using std::endl;
00030 
00031 namespace {
00032 
00033     /////////////////////////////
00034     // Class: CdbBdbSConfigItr //
00035     /////////////////////////////
00036 
00037     class CdbBdbSConfigItr : public CdbItr<CdbConfigElement>::InterfaceType {
00038 
00039     private:
00040 
00041         CdbBdbSConfigItr( );
00042 
00043         CdbBdbSConfigItr& operator=( const CdbBdbSConfigItr& theItr );
00044 
00045     protected:
00046 
00047         CdbBdbSConfigItr( const CdbBdbSConfigItr& theItr ) :
00048             _itr  (theItr._itr),
00049             _value(theItr._value)
00050         { }
00051 
00052     public:
00053 
00054         CdbBdbSConfigItr( const CdbBdbSConfigCollectionP::IteratorOfIntervals& theInputItr ) :
00055             _itr(theInputItr)
00056         { }
00057 
00058         virtual ~CdbBdbSConfigItr( )
00059         { }
00060 
00061         virtual CdbStatus reset( )
00062         {
00063             return _itr.reset( );
00064         }
00065 
00066         virtual bool next( )
00067         {
00068             bool result = _itr.next( );
00069             if( result ) {
00070 
00071                 CdbBdbSConfigInterval in = _itr.value( );
00072                 if( in.value.accessIsAllowed( )) {
00073 
00074                   // This interval is allowed for accessing the database.
00075 
00076                     CdbRevisionPolicy policy;
00077                     if( in.value.useRevision ) {
00078                         policy = CdbRevisionPolicy( in.value.revision,
00079                                                     in.value.partition );
00080                     }
00081                     _value = CdbConfigElement( policy,
00082                                                in.begin,
00083                                                in.end );
00084                 } else {
00085 
00086                   // This interval is NOT allowed.
00087 
00088                     _value = CdbConfigElement( in.begin,
00089                                                in.end );
00090                 }
00091 
00092             } else {
00093 
00094               // The default constructor will construct an element disallowing any
00095               // access to the database for the whole range of the validity time.
00096 
00097                 _value = CdbConfigElement( );
00098             }
00099             return result;
00100         }
00101 
00102         virtual ValueType value( )
00103         {
00104             if( ! isValid( )) {
00105                 assert( 0 );
00106             }
00107             return _value;
00108         }
00109 
00110         virtual bool isValid( )
00111         {
00112             return _itr.isValid( );
00113         }
00114 
00115         virtual InterfaceType* clone( ) const
00116         {
00117             return new CdbBdbSConfigItr( *this );
00118         }
00119 
00120     private:
00121 
00122         CdbBdbSConfigCollectionP::IteratorOfIntervals _itr;
00123 
00124         CdbConfigElement _value;
00125     };
00126 };
00127 
00128 ////////////////////////
00129 // Class: CdbBdbSView //
00130 ////////////////////////
00131 
00132 CdbView*
00133 CdbBdbSView::clone( ) const
00134 {
00135   // Get rid of the "const" to access non-const methods
00136 
00137     CdbBdbSView* mySelf = const_cast<CdbBdbSView*>( this );
00138     return new CdbBdbSView( mySelf->parent( ),
00139                             mySelf->name( ),
00140                             mySelf->id( ),
00141                             _viewH,
00142                             _masterRegistryH,
00143                             _localRegistryH );
00144 }
00145 
00146 CdbBdbSView::CdbBdbSView( const CdbDatabasePtr&              thePtr,
00147                           const char*                        theName,
00148                           const CdbId&                       theId,
00149                           const BdbHandle(CdbBdbSViewP)&     theViewH,
00150                           const BdbHandle(CdbBdbSRegistryP)& theMasterRegistryH ,
00151                           const BdbHandle(CdbBdbSRegistryP)& theLocalRegistryH ) :
00152     CdbView( thePtr,
00153              theName,
00154              theId ),
00155     _viewH(theViewH),
00156     _masterRegistryH(theMasterRegistryH),
00157     _localRegistryH(theLocalRegistryH)
00158 { }
00159 
00160 CdbBdbSView::~CdbBdbSView( )
00161 { }
00162 
00163 bool
00164 CdbBdbSView::isValid( )
00165 {
00166     return true;
00167 }
00168 
00169 bool
00170 CdbBdbSView::isOpen( )
00171 {
00172     return true;
00173 }
00174 
00175 CdbStatus
00176 CdbBdbSView::open( )
00177 {
00178     return CdbStatus::Success;
00179 }
00180 
00181 CdbStatus
00182 CdbBdbSView::close( )
00183 {
00184     return CdbStatus::Success;
00185 }
00186 
00187 BdbTime
00188 CdbBdbSView::minValidity( ) const
00189 {
00190     return _viewH->minValidity( );
00191 }
00192 
00193 BdbTime
00194 CdbBdbSView::maxValidity( ) const
00195 {
00196     return _viewH->maxValidity( );
00197 }
00198 
00199 BdbTime
00200 CdbBdbSView::created( ) const
00201 {
00202     return _viewH->created( );
00203 }
00204 
00205 std::string
00206 CdbBdbSView::description( ) const
00207 {
00208     return std::string( _viewH->description( ).head( ));
00209 }
00210 
00211 bool
00212 CdbBdbSView::hasDefaultConfig( ) const
00213 {
00214     return ! BdbIsNull( _viewH->defaultConfig( ));
00215 }
00216 
00217 bool
00218 CdbBdbSView::isLocal( ) const
00219 {
00220     return id( ).origin == _localRegistryH->originId( );
00221 }
00222 
00223 bool 
00224 CdbBdbSView::isFrozen( ) const
00225 {
00226     return _viewH->isFrozen( );
00227 }
00228 
00229 CdbStatus
00230 CdbBdbSView::findFolder( CdbFolderPtr& thePtr,
00231                          const char*   theName
00232                        )
00233 {
00234     CdbStatus result = CdbStatus::Error;
00235 
00236     thePtr = 0;
00237 
00238     do {
00239 
00240         if( 0 != strcmp( theName, CdbPathName::separator( ))) {
00241 
00242             cout << "CdbBdbSView::findFolder() -- ERROR" << endl
00243                  << "    No such folder in this implementation: \"" << theName                   << "\"" << endl
00244                  << "    The only name allowed is the rood one: \"" << CdbPathName::separator( ) << "\"" << endl;
00245 
00246             break;
00247         }
00248 
00249       // Find out persistent folder for sp[ecified name
00250 
00251         BdbRef(CdbBdbSFolderP) fRef;
00252         if( CdbStatus::Success != _viewH->findFolder( theName,
00253                                                       fRef )) {
00254             result = CdbStatus::NotFound;
00255             break;
00256         }
00257 
00258       // DESIGN NOTE: We need to construct a smart pointer against a clone since
00259       //              we don't know a smart pointer pointing to the current
00260       //              instance, therefore we can't guarantee the lifetime
00261       //              of the current instance.
00262 
00263         CdbViewPtr   myPtr( this->clone( ));
00264         CdbFolderPtr fPtr( 0 );
00265 
00266         thePtr = new CdbBdbSFolder( myPtr,
00267                                     fPtr,
00268                                     theName,
00269                                     fRef,
00270                                     _masterRegistryH,
00271                                     _localRegistryH );
00272 
00273       // Done.
00274 
00275         result = CdbStatus::Success;
00276 
00277     } while( false );
00278 
00279     return result;
00280 }
00281 
00282 CdbStatus
00283 CdbBdbSView::folderIterator( CdbFolderItr& theItr )
00284 {
00285     return _viewH->folderIterator( theItr );
00286 }
00287 
00288 CdbStatus
00289 CdbBdbSView::getDefault( const BdbTime&    theValidityTime,
00290                          CdbConfigElement& theConfigElement ) const
00291 {
00292     const char* errorStr = "CdbBdbSView::getDefault() -- ERROR.";
00293 
00294     CdbStatus result = CdbStatus::Error;
00295     do {
00296 
00297       // Check if specified time fits into the validity interval covered by
00298       // the current view.
00299 
00300         if(( theValidityTime <  _viewH->minValidity( )) ||
00301            ( theValidityTime >= _viewH->maxValidity( ))) {
00302 
00303             cout << errorStr << endl
00304                  << "    The pased validity time is out of the validity interval covered" << endl
00305                  << "    by the current view." << endl
00306                  << "        Passed  validity time: " << theValidityTime << endl
00307                  << "        Minimum validity time: " << _viewH->minValidity( ) << endl
00308                  << "        Maximum validity time: " << _viewH->maxValidity( ) << endl;
00309             break;
00310         }
00311 
00312       // Use default configuration only (if any).
00313 
00314         BdbRef(CdbBdbSConfigCollectionP) configCollRef = _viewH->defaultConfig( );
00315         if( BdbIsNull(configCollRef)) {
00316             result = CdbStatus::NotFound;
00317             break;
00318         }
00319 
00320       // Get the configuration interval.
00321 
00322         CdbBdbSConfigInterval configInterval;
00323         if( CdbStatus::Success != configCollRef->find( theValidityTime,
00324                                                        configInterval )) {
00325             cout << errorStr << endl
00326                  << "    The default configuration of the current view is inproperly configured." << endl
00327                  << "    No configuration record found for specified validity time." << endl
00328                  << "    at the view level." << endl
00329                  << "        Current view name:     \"" << name( ) << "\"" << endl
00330                  << "        Passed validity time:  "   << theValidityTime << endl;
00331             break;
00332         }
00333 
00334       // Build the configuration element
00335 
00336         if( configInterval.value.accessIsAllowed( )) {
00337 
00338             CdbRevisionPolicy policy;
00339             if( configInterval.value.useRevision ) {
00340                 policy = CdbRevisionPolicy( configInterval.value.revision,
00341                                             configInterval.value.partition );
00342             } else {
00343                 policy = CdbRevisionPolicy( );
00344             }
00345             theConfigElement = CdbConfigElement( policy,
00346                                                  configInterval.begin,
00347                                                  configInterval.end );
00348 
00349         } else {
00350 
00351           // This element will prohibit accessing the database
00352           // for specified validity interval
00353 
00354             theConfigElement = CdbConfigElement( configInterval.begin,
00355                                                  configInterval.end );
00356         }
00357 
00358       // Done
00359 
00360         result = CdbStatus::Success;
00361 
00362     } while( false );
00363 
00364     return result;
00365 }
00366 
00367 CdbStatus
00368 CdbBdbSView::defaultConfigIterator( CdbItr<CdbConfigElement>& theItr ) const
00369 {
00370     CdbStatus result = CdbStatus::NotFound;
00371     do {
00372 
00373         BdbRef(CdbBdbSConfigCollectionP) configCollRef = _viewH->defaultConfig( );
00374         if( BdbIsNull(configCollRef)) break;
00375 
00376       // ATTENTION: This is not a memory leak - the created object
00377       //            will be destroyed by the iterator.
00378 
00379         theItr = CdbItr<CdbConfigElement>( new CdbBdbSConfigItr( configCollRef->iterator( )));
00380 
00381       // Done
00382 
00383         result = CdbStatus::Success;
00384 
00385     } while( false );
00386 
00387     return result;
00388 }
00389 
00390 CdbStatus
00391 CdbBdbSView::get( const char*       theName,
00392                   const BdbTime&    theValidityTime,
00393                   CdbConfigElement& theConfigElement ) const
00394 {
00395     const char* errorStr = "CdbBdbSView::get() -- ERROR.";
00396 
00397     CdbStatus result = CdbStatus::Error;
00398     do {
00399 
00400       // Verify the condition path name.
00401 
00402         if( 0 == theName ) {
00403             cout << errorStr << endl
00404                  << "    Non 0 pointer onto a fully qualified condition path name was expected." << endl;
00405             break;
00406         }
00407 
00408         CdbPathName fullPath( theName );
00409 
00410         if( ! ( fullPath.isValid( ) &&
00411                 fullPath.isAbsolute( ) &&
00412                 fullPath.isComposite( ))) {
00413 
00414             cout << errorStr << endl
00415                  << "    Unsupported format of the condition name. Fully qualified" << endl
00416                  << "    condition name including its folder path was expected." << endl
00417                  << "        Passed condition name: \"" << theName << "\"" << endl;
00418             break;
00419         }
00420 
00421       // Check if specified time fits into the validity interval covered by
00422       // the current view.
00423 
00424         if(( theValidityTime <  _viewH->minValidity( )) ||
00425            ( theValidityTime >= _viewH->maxValidity( ))) {
00426 
00427             cout << errorStr << endl
00428                  << "    The pased validity time is out of the validity interval covered" << endl
00429                  << "    by the current view." << endl
00430                  << "        Passed  validity time: " << theValidityTime << endl
00431                  << "        Minimum validity time: " << _viewH->minValidity( ) << endl
00432                  << "        Maximum validity time: " << _viewH->maxValidity( ) << endl;
00433             break;
00434         }
00435 
00436       // First we're going to see if specified condition has  its own revision
00437       // configuration. This always superseeds the default configuration at
00438       // the level of the view.
00439 
00440         BdbRef(CdbBdbSConditionAtFolderP) cRef;
00441         if( CdbStatus::Success != _viewH->findCondition( theName,
00442                                                          cRef )) {
00443             result = CdbStatus::NotFound;
00444             break;
00445         }
00446 
00447         BdbRef(CdbBdbSConfigCollectionP) configCollRef = cRef->config( );
00448         if( BdbIsNull(configCollRef)) {
00449 
00450           // No configuration found at the conditin level. Get the default
00451           // configuration at the view level then.
00452 
00453             configCollRef = _viewH->defaultConfig( );
00454             if( BdbIsNull(configCollRef)) {
00455                 cout << errorStr << endl
00456                      << "    The current view is inproperly configured for specified condition." << endl
00457                      << "    No configuration found both at specified condition scope and" << endl
00458                      << "    at the view level." << endl
00459                      << "        Current view name:     \"" << name( ) << "\"" << endl
00460                      << "        Passed condition name: \"" << theName << "\"" << endl;
00461                 break;
00462             }
00463         }
00464 
00465       // Get the configuration interval.
00466 
00467         CdbBdbSConfigInterval configInterval;
00468         if( CdbStatus::Success != configCollRef->find( theValidityTime,
00469                                                        configInterval )) {
00470             cout << errorStr << endl
00471                  << "    The current view is inproperly configured for specified condition." << endl
00472                  << "    No configuration record found for specified validity time." << endl
00473                  << "    at the view level." << endl
00474                  << "        Current view name:     \"" << name( ) << "\"" << endl
00475                  << "        Passed condition name: \"" << theName << "\"" << endl
00476                  << "        Passed validity time:  "   << theValidityTime << endl;
00477             break;
00478         }
00479 
00480       // Build the configuration element
00481 
00482         if( configInterval.value.accessIsAllowed( )) {
00483 
00484             CdbRevisionPolicy policy;
00485             if( configInterval.value.useRevision ) {
00486                 policy = CdbRevisionPolicy( configInterval.value.revision,
00487                                             configInterval.value.partition );
00488             } else {
00489                 policy = CdbRevisionPolicy( );
00490             }
00491             theConfigElement = CdbConfigElement( policy,
00492                                                  configInterval.begin,
00493                                                  configInterval.end );
00494 
00495         } else {
00496 
00497           // This element will prohibit accessing the database
00498           // for specified validity interval
00499 
00500             theConfigElement = CdbConfigElement( configInterval.begin,
00501                                                  configInterval.end );
00502         }
00503 
00504       // Done
00505 
00506         result = CdbStatus::Success;
00507 
00508     } while( false );
00509 
00510     return result;
00511 }
00512 
00513 CdbStatus
00514 CdbBdbSView::configIterator( const char*               theName,
00515                              CdbItr<CdbConfigElement>& theItr ) const
00516 {
00517     const char* errorStr = "CdbBdbSView::configIterator() -- ERROR.";
00518 
00519     CdbStatus result = CdbStatus::Error;
00520     do {
00521 
00522       // Verify the condition path name.
00523 
00524         if( 0 == theName ) {
00525             cout << errorStr << endl
00526                  << "    Non 0 pointer onto a fully qualified condition path name was expected." << endl;
00527             break;
00528         }
00529 
00530         CdbPathName fullPath( theName );
00531 
00532         if( ! ( fullPath.isValid( ) &&
00533                 fullPath.isAbsolute( ) &&
00534                 fullPath.isComposite( ))) {
00535 
00536             cout << errorStr << endl
00537                  << "    Unsupported format of the condition name. Fully qualified" << endl
00538                  << "    condition name including its folder path was expected." << endl
00539                  << "        Passed condition name: \"" << theName << "\"" << endl;
00540             break;
00541         }
00542 
00543       // First we're going to see if specified condition has  its own revision
00544       // configuration. This always superseeds the default configuration at
00545       // the level of the view.
00546 
00547         BdbRef(CdbBdbSConditionAtFolderP) cRef;
00548         if( CdbStatus::Success != _viewH->findCondition( theName,
00549                                                          cRef )) {
00550             result = CdbStatus::NotFound;
00551             break;
00552         }
00553 
00554         BdbRef(CdbBdbSConfigCollectionP) configCollRef = cRef->config( );
00555         if( BdbIsNull(configCollRef)) {
00556 
00557           // No configuration found at the conditin level. Get the default
00558           // configuration at the view level then.
00559 
00560             configCollRef = _viewH->defaultConfig( );
00561             if( BdbIsNull(configCollRef)) {
00562                 cout << errorStr << endl
00563                      << "    The current view is inproperly configured for specified condition." << endl
00564                      << "    No configuration found both at specified condition scope and" << endl
00565                      << "    at the view level." << endl
00566                      << "        Current view name:     \"" << name( ) << "\"" << endl
00567                      << "        Passed condition name: \"" << theName << "\"" << endl;
00568                 break;
00569             }
00570         }
00571 
00572       // ATTENTION: This is not a memory leak - the created object
00573       //            will be destroyed by the iterator.
00574 
00575         theItr = CdbItr<CdbConfigElement>( new CdbBdbSConfigItr( configCollRef->iterator( )));
00576 
00577       // Done
00578 
00579         result = CdbStatus::Success;
00580 
00581     } while( false );
00582 
00583     return result;
00584 }
00585 
00586 CdbStateId
00587 CdbBdbSView::currentStateId( const BdbTime& theValidityTime ) const
00588 {
00589     const char* errorStr = "CdbBdbSView::currentStateId() -- ERROR.";
00590 
00591     CdbStateId result;  // REMEMBER: default value of the State ID is invalid
00592     do {
00593 
00594       // Find out a 'topmost' partition corresponding to specified validity time
00595       // and obtain its modification time.
00596       //
00597       // NOTE: The logic implemented by the current code is slightly different from
00598       //       the one found in previous implementations. Here are the differences:
00599       //
00600       //       (1) The previous implementations used _current_ wall-clock time if
00601       //           a 'closed' partition was found. The new logic will always use
00602       //           the modification time.
00603       //
00604       //           [ That older logic didn't seem right from the optimization point of view
00605       //             since the actual _meaning_ of StateId-s does not change with wall-clock
00606       //             time for closed partition. In this case an identifier of a views
00607       //             alone stored as a part of the StateId provides full description of
00608       //             the same state of CDB. ]
00609       //
00610       //       (2) Another tiny change in the logic is related to so called "non-instantiated"
00611       //           partition not owned by the current CDB. This transitional scenario is quite
00612       //           normal in a distributed CDB when a remote origin has not delivered its
00613       //           instance of a known to MASTER partition (unless this instance is supposed
00614       //           to belong to the current 'origin'. Having a non-instantiated partition
00615       //           belonging to  the current 'origin' is supposed to be a CDB initialization
00616       //           error.). When this transition scenario is detected the creation time of the
00617       //           partition (in fact - the 'bottom' of the partition in the modification
00618       //           time dimension) will be put into the StateID.
00619       //
00620       //       (3) The current wall-clock time will only be used if no partition will be
00621       //           found for the specified validity time. It's quite an unusual situation
00622       //           meaning that 'partitionable' conditions are not in use at all.
00623       //
00624       // If the found partition is still not 'closed' (is 'under construction')
00625       // and if the current database is not the MASTER one and (finally :-)) if found
00626       // partition belongs to the local database then we should switch to the local
00627       // partition object. Then we'll have the most 'up-to-date' information about
00628       // the modification time of that partition.
00629       //
00630       // This kind of logic will not only provide us with the 'up-to-date' modification
00631       // time of a partition in its owner database, but will also ensure the correctness
00632       // of its ('modification time') in other databases.
00633       //
00634       // NOTE: The modification time as a way to refine the current state of the database
00635       //       _ONLY_ makes sense for the 'partitionable' conditions. In case of 'regular'
00636       //       conditions one should rely on the regular revisions mechanizm (sufficiently 
00637       //       supported by views)  to acheive the reproducability of the database contents.
00638 
00639         BdbTime partitionModificationTime( BdbTime::now( ));    // _current_ time by default
00640         {
00641             BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = _masterRegistryH->partitionsLayout( );
00642             assert( !BdbIsNull(pLayoutRef));
00643 
00644           // NOTE: The following operation will look for an 'topmost' partition at
00645           //       at the MASTER registry.
00646 
00647             BdbRef(CdbBdbSPartitionP) pRef;
00648             if( CdbStatus::Success == pLayoutRef->topmost( theValidityTime,
00649                                                            pRef )) {
00650 
00651               // Refine which partition object to use
00652 
00653                 if( !pRef->isClosed( )) {
00654 
00655                   // Switch from the MASTER partition to the local one if needed, which
00656                   // is going to happen in acase when the found partition belongs to
00657                   // the local 'origin'.
00658 
00659                     if( _masterRegistryH->originId( ) != _localRegistryH->originId( )) {
00660                         if( _localRegistryH->originId( ) == pRef->originId( )) {
00661 
00662                           // Since we're switching to the final partition then we have one extra requirement
00663                           // to this partition - it must exist.
00664 
00665                             pLayoutRef = _localRegistryH->partitionsLayout( );
00666                             assert( !BdbIsNull(pLayoutRef));
00667 
00668                           // NOTE: Unlike the previou step when we're looking for the preliminary information
00669                           //       about the partition now we also need to find 'closed' partitions
00670                           //       This is why we're looking this partition by it's ID, not requering
00671                           //       its "openness".
00672 
00673                             BdbRef(CdbBdbSPartitionP) pFinalRef;
00674                             if( CdbStatus::Success != pLayoutRef->find( pRef->id( ),
00675                                                                         pFinalRef )) {
00676                                 cout << errorStr << endl
00677                                      << "    Failed to locate a final partition with ID=" << pRef->id( ) << endl
00678                                      << "    at the local database where it's supposed to belong to." << endl
00679                                      << "    The local database may not be properly initialized/loaded." << endl;
00680                                 break;
00681                             }
00682 
00683                           // Okay, finished switching the partition to the final one.
00684 
00685                             pRef = pFinalRef;
00686                         }
00687                     }
00688                 }
00689 
00690               // Check one more time if that partition is in the 'open' state because
00691               // the previous step was switch us to the final partition owned
00692               // by the current SLAVE database. Therefore the information we're looking
00693               // for must be 'up-to-date'.
00694 
00695                 if( pRef->isClosed( )) {
00696 
00697                   // Get the modification time of the 'closed' partition. It will correspond
00698                   // to the time when the partition was closed.
00699 
00700                     partitionModificationTime = pRef->modified( );
00701 
00702                 } else {
00703 
00704                   // The non-local partition is allowed to be not instantiated since
00705                   // its owner database may not have delivered the corresponding updated version of it.
00706                   //
00707                   // Otherwise we treat the non-instantiated partition as a database inconsistency problem...
00708 
00709                     if( pRef->isInstantiated( )) {
00710                         partitionModificationTime = pRef->modified( );
00711                     } else {
00712                         if( _localRegistryH->originId( ) == pRef->originId( )) {
00713                             cout << errorStr << endl
00714                                  << "    The partition with ID=" << pRef->id( ) << " corresponding to the following" << endl
00715                                  << "    validity time: " << theValidityTime << endl
00716                                  << "    belonging to the local database is not properly instantiated." << endl
00717                                  << "    The local database may not be properly initialized/loaded." << endl;
00718                             break;
00719 
00720                         } else {
00721 
00722                           // This is pretty normal 'transitional' situation - a remote database has
00723                           // not delivered its instantiated partition yet. Therefore we don't know yet
00724                           // when the partition was modified. So we just go along with 'creation' time
00725                           // of the partition. This 'creation' time represents the 'bottom' of the partition
00726                           // in the modification timeline. It will guarantee that we'll be relying on
00727                           // the values of 'partitionable' conditions stored _before_ the found partition.
00728 
00729                             partitionModificationTime = pRef->created( );
00730                         }
00731                     }
00732                 }
00733             }
00734         }
00735 
00736       // Build the valid state identifier
00737 
00738         result = CdbStateId( id( ), partitionModificationTime );
00739 
00740     } while( false );
00741 
00742     return result;
00743 }
00744 
00745 CdbStatus
00746 CdbBdbSView::historyEventIterator( CdbHistoryEventItr& theItr,
00747                                    const BdbTime&      theBeginTime,
00748                                    const BdbTime&      theEndTime,
00749                                    const char**        theEventsToSelect )
00750 {
00751     return CdbStatus::Error;
00752 }
00753 
00754 CdbStatus
00755 CdbBdbSView::historyEventTypeIterator( CdbHistoryEventTypeItr& theItr )
00756 {
00757     return CdbStatus::Error;
00758 }
00759 
00760 /////////////////
00761 // End Of File //
00762 /////////////////

Generated on Mon Dec 5 18:22:03 2005 for CDB by doxygen1.3-rc3