Storage Engine API
mongo::UUIDCatalog Class Reference

#include <uuid_catalog.h>

Public Member Functions

 UUIDCatalog ()=default
 
void onCreateCollection (OperationContext *opCtx, Collection *coll, CollectionUUID uuid)
 This function inserts the entry for uuid, coll into the UUID Collection. More...
 
void onDropCollection (OperationContext *opCtx, CollectionUUID uuid)
 This function removes the entry for uuid from the UUID catalog. More...
 
void onRenameCollection (OperationContext *opCtx, Collection *coll, CollectionUUID uuid)
 This function atomically removes any existing entry for uuid from the UUID catalog and adds a new entry for uuid associated with the Collection coll. More...
 
void onCloseDatabase (Database *db)
 Implies onDropCollection for all collections in db, but is not transactional. More...
 
CollectionreplaceUUIDCatalogEntry (CollectionUUID uuid, Collection *coll)
 
void registerUUIDCatalogEntry (CollectionUUID uuid, Collection *coll)
 
CollectionremoveUUIDCatalogEntry (CollectionUUID uuid)
 
CollectionlookupCollectionByUUID (CollectionUUID uuid) const
 This function gets the Collection* pointer that corresponds to CollectionUUID uuid. More...
 
NamespaceString lookupNSSByUUID (CollectionUUID uuid) const
 This function gets the NamespaceString from the Collection* pointer that corresponds to CollectionUUID uuid. More...
 
void onCloseCatalog ()
 Puts the catalog in closed state. More...
 
void onOpenCatalog ()
 Puts the catatlog back in open state, removing the pre-close state. More...
 
boost::optional< CollectionUUIDprev (const StringData &db, CollectionUUID uuid)
 Return the UUID lexicographically preceding uuid in the database named by db. More...
 
boost::optional< CollectionUUIDnext (const StringData &db, CollectionUUID uuid)
 Return the UUID lexicographically following uuid in the database named by db. More...
 

Static Public Member Functions

static UUIDCatalogget (ServiceContext *svcCtx)
 
static UUIDCatalogget (OperationContext *opCtx)
 

Private Member Functions

 MONGO_DISALLOW_COPYING (UUIDCatalog)
 
const std::vector< CollectionUUID > & _getOrdering_inlock (const StringData &db, const stdx::lock_guard< stdx::mutex > &)
 

Private Attributes

mongo::stdx::mutex _catalogLock
 
boost::optional< mongo::stdx::unordered_map< CollectionUUID, NamespaceString, CollectionUUID::Hash > > _shadowCatalog
 When present, indicates that the catalog is in closed state, and contains a map from UUID to pre-close NSS. More...
 
StringMap< std::vector< CollectionUUID > > _orderedCollections
 Map from database names to ordered vectors of their UUIDs. More...
 
mongo::stdx::unordered_map< CollectionUUID, Collection *, CollectionUUID::Hash > _catalog
 

Constructor & Destructor Documentation

◆ UUIDCatalog()

mongo::UUIDCatalog::UUIDCatalog ( )
default

Member Function Documentation

◆ _getOrdering_inlock()

const std::vector< CollectionUUID > & mongo::UUIDCatalog::_getOrdering_inlock ( const StringData &  db,
const stdx::lock_guard< stdx::mutex > &   
)
private

◆ get() [1/2]

UUIDCatalog & mongo::UUIDCatalog::get ( ServiceContext *  svcCtx)
static

◆ get() [2/2]

UUIDCatalog & mongo::UUIDCatalog::get ( OperationContext *  opCtx)
static

◆ lookupCollectionByUUID()

Collection * mongo::UUIDCatalog::lookupCollectionByUUID ( CollectionUUID  uuid) const

This function gets the Collection* pointer that corresponds to CollectionUUID uuid.

The required locks should be obtained prior to calling this function, or else the found Collection pointer might no longer be valid when the call returns.

◆ lookupNSSByUUID()

NamespaceString mongo::UUIDCatalog::lookupNSSByUUID ( CollectionUUID  uuid) const

This function gets the NamespaceString from the Collection* pointer that corresponds to CollectionUUID uuid.

If there is no such pointer, an empty NamespaceString is returned. See onCloseCatalog/onOpenCatalog for more info.

◆ MONGO_DISALLOW_COPYING()

mongo::UUIDCatalog::MONGO_DISALLOW_COPYING ( UUIDCatalog  )
private

◆ next()

boost::optional< CollectionUUID > mongo::UUIDCatalog::next ( const StringData &  db,
CollectionUUID  uuid 
)

Return the UUID lexicographically following uuid in the database named by db.

Return boost::none if uuid is not found, or is the last UUID in that database.

◆ onCloseCatalog()

void mongo::UUIDCatalog::onCloseCatalog ( )

Puts the catalog in closed state.

In this state, the lookupNSSByUUID method will fall back to the pre-close state to resolve queries for currently unknown UUIDs. This allows authorization, which needs to do lookups outside of database locks, to proceed.

◆ onCloseDatabase()

void mongo::UUIDCatalog::onCloseDatabase ( Database db)

Implies onDropCollection for all collections in db, but is not transactional.

◆ onCreateCollection()

void mongo::UUIDCatalog::onCreateCollection ( OperationContext *  opCtx,
Collection coll,
CollectionUUID  uuid 
)

This function inserts the entry for uuid, coll into the UUID Collection.

It is called by the op observer when a collection is created.

◆ onDropCollection()

void mongo::UUIDCatalog::onDropCollection ( OperationContext *  opCtx,
CollectionUUID  uuid 
)

This function removes the entry for uuid from the UUID catalog.

It is called by the op observer when a collection is dropped.

◆ onOpenCatalog()

void mongo::UUIDCatalog::onOpenCatalog ( )

Puts the catatlog back in open state, removing the pre-close state.

See onCloseCatalog.

◆ onRenameCollection()

void mongo::UUIDCatalog::onRenameCollection ( OperationContext *  opCtx,
Collection coll,
CollectionUUID  uuid 
)

This function atomically removes any existing entry for uuid from the UUID catalog and adds a new entry for uuid associated with the Collection coll.

It is called by the op observer when a collection is renamed.

◆ prev()

boost::optional< CollectionUUID > mongo::UUIDCatalog::prev ( const StringData &  db,
CollectionUUID  uuid 
)

Return the UUID lexicographically preceding uuid in the database named by db.

Return boost::none if uuid is not found, or is the first UUID in that database.

◆ registerUUIDCatalogEntry()

void mongo::UUIDCatalog::registerUUIDCatalogEntry ( CollectionUUID  uuid,
Collection coll 
)

◆ removeUUIDCatalogEntry()

Collection * mongo::UUIDCatalog::removeUUIDCatalogEntry ( CollectionUUID  uuid)

◆ replaceUUIDCatalogEntry()

Collection * mongo::UUIDCatalog::replaceUUIDCatalogEntry ( CollectionUUID  uuid,
Collection coll 
)

Member Data Documentation

◆ _catalog

mongo::stdx::unordered_map<CollectionUUID, Collection*, CollectionUUID::Hash> mongo::UUIDCatalog::_catalog
private

◆ _catalogLock

mongo::stdx::mutex mongo::UUIDCatalog::_catalogLock
mutableprivate

◆ _orderedCollections

StringMap<std::vector<CollectionUUID> > mongo::UUIDCatalog::_orderedCollections
private

Map from database names to ordered vectors of their UUIDs.

Works as a cache of such orderings: every ordering in this map is guaranteed to be valid, but not all databases are guaranteed to have an ordering in it.

◆ _shadowCatalog

boost::optional< mongo::stdx::unordered_map<CollectionUUID, NamespaceString, CollectionUUID::Hash> > mongo::UUIDCatalog::_shadowCatalog
private

When present, indicates that the catalog is in closed state, and contains a map from UUID to pre-close NSS.

See also onCloseCatalog.


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