Class MongoDBRepository
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
-
- org.nuxeo.ecm.core.storage.mongodb.MongoDBRepository
-
- All Implemented Interfaces:
LockManager
,Repository
,DBSRepository
public class MongoDBRepository extends DBSRepositoryBase
MongoDB implementation of aRepository
.- Since:
- 5.9.4
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
DBSRepositoryBase.BlobFinder, DBSRepositoryBase.IdType
-
-
Field Summary
Fields Modifier and Type Field Description protected org.bson.conversions.Bson
binaryKeys
Keys used for document projection when marking all binaries for GC.protected com.mongodb.client.MongoCollection<org.bson.Document>
coll
protected MongoDBConverter
converter
static String
COUNTER_FIELD
static String
COUNTER_NAME_UUID
protected com.mongodb.client.MongoCollection<org.bson.Document>
countersColl
protected MongoDBCursorService
cursorService
protected MongoDBRepositoryDescriptor
descriptor
static String
FULLTEXT_INDEX_NAME
protected static String
GC_NO_CURSOR_TIMEOUT
protected String
idKey
The key to use to store the id in the database.protected boolean
indexInitialized
static String
LANGUAGE_FIELD
static Long
LONG_ZERO
protected static Duration
MAX_TIME_DEFAULT
Default maximum execution time for a query.protected long
maxTimeMS
Maximum execution time for a query when outside of a transaction.protected com.mongodb.client.MongoClient
mongoClient
static String
MONGODB_EACH
static String
MONGODB_ID
static String
MONGODB_INC
static String
MONGODB_META
static String
MONGODB_PULLALL
static String
MONGODB_PUSH
static String
MONGODB_SET
static String
MONGODB_TEXT_SCORE
static String
MONGODB_TYPE
static String
MONGODB_UNSET
static Double
ONE
static String
REPOSITORY_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection fromMongoDBConnectionService
.protected static int
SEQUENCE_RANDOMIZED_BLOCKSIZE_DEFAULT
protected long
sequenceBlockSize
Sequence allocation block size.protected static String
SETTING_DENORMALIZED_BLOB_KEYS
Settings key to determine whetherecm:blobKeys
is supported.protected static String
SETTING_VALUE
protected com.mongodb.client.MongoCollection<org.bson.Document>
settingsColl
protected boolean
supportsDenormalizedBlobKeys
protected boolean
supportsSessions
protected boolean
supportsTransactions
static Double
ZERO
-
Fields inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
blobKeysPaths, blobManager, capabilities, changeTokenEnabled, DEBUG_UUIDS, DISABLE_ECM_BLOB_KEYS, fulltextConfiguration, idType, lockManager, repositoryName, selfRegisteredLockManager, TYPE_ROOT, UUID_ZERO, UUID_ZERO_DEBUG
-
Fields inherited from interface org.nuxeo.ecm.core.model.Repository
CAPABILITY_QUERY_BLOB_KEYS, CAPABILITY_REPOSITORY
-
-
Constructor Summary
Constructors Constructor Description MongoDBRepository(MongoDBRepositoryDescriptor descriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<DBSRepositoryBase.IdType>
getAllowedIdTypes()
Gets the allowed id types for this DBS repository.protected com.mongodb.client.MongoClient
getClient()
protected com.mongodb.client.MongoCollection<org.bson.Document>
getCollection()
MongoDBConnection
getConnection()
Gets a new connection to this repository.protected MongoDBConverter
getConverter()
protected com.mongodb.client.MongoCollection<org.bson.Document>
getCountersCollection()
protected MongoDBCursorService
getCursorService()
protected String
getIdKey()
protected void
initBlobsPaths()
protected void
initCapabilities()
protected void
initRepository()
protected void
initSettings()
protected void
markReferencedBlob(Object value, BiConsumer<String,String> markerCallback)
void
markReferencedBlobs(BiConsumer<String,String> markerCallback)
Marks the blobs in use by passing them to the provided callback (taking the blob key and the repository name).protected void
markReferencedBlobs(org.bson.Document ob, BiConsumer<String,String> markerCallback)
protected void
markReferencedBlobsDenormalized(org.bson.Document ob, BiConsumer<String,String> markReferencedBlob)
protected void
readSettings()
void
shutdown()
protected boolean
supportsSessions()
boolean
supportsTransactions()
Checks whether this repository supports transactions.void
updateCapabilities()
Update repository capabilities after a migration.-
Methods inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
getBlobKeysPaths, getBlobManager, getCapability, getFulltextConfiguration, getIdType, getLock, getLockManager, getLockManagerName, getName, getSession, initLockManager, isChangeTokenEnabled, isFulltextDisabled, isFulltextSearchDisabled, isFulltextStoredInBlob, removeLock, setLock
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
Methods inherited from interface org.nuxeo.ecm.core.model.Repository
getActiveSessionsCount, hasCapability
-
-
-
-
Field Detail
-
REPOSITORY_CONNECTION_PREFIX
public static final String REPOSITORY_CONNECTION_PREFIX
Prefix used to retrieve a MongoDB connection fromMongoDBConnectionService
.The connection id will be
repository/[REPOSITORY_NAME]
.- See Also:
- Constant Field Values
-
LONG_ZERO
public static final Long LONG_ZERO
-
ZERO
public static final Double ZERO
-
ONE
public static final Double ONE
-
MONGODB_ID
public static final String MONGODB_ID
- See Also:
- Constant Field Values
-
MONGODB_INC
public static final String MONGODB_INC
- See Also:
- Constant Field Values
-
MONGODB_SET
public static final String MONGODB_SET
- See Also:
- Constant Field Values
-
MONGODB_UNSET
public static final String MONGODB_UNSET
- See Also:
- Constant Field Values
-
MONGODB_PUSH
public static final String MONGODB_PUSH
- See Also:
- Constant Field Values
-
MONGODB_PULLALL
public static final String MONGODB_PULLALL
- Since:
- 11.5
- See Also:
- Constant Field Values
-
MONGODB_EACH
public static final String MONGODB_EACH
- See Also:
- Constant Field Values
-
MONGODB_META
public static final String MONGODB_META
- See Also:
- Constant Field Values
-
MONGODB_TYPE
public static final String MONGODB_TYPE
- See Also:
- Constant Field Values
-
MONGODB_TEXT_SCORE
public static final String MONGODB_TEXT_SCORE
- See Also:
- Constant Field Values
-
FULLTEXT_INDEX_NAME
public static final String FULLTEXT_INDEX_NAME
- See Also:
- Constant Field Values
-
LANGUAGE_FIELD
public static final String LANGUAGE_FIELD
- See Also:
- Constant Field Values
-
SEQUENCE_RANDOMIZED_BLOCKSIZE_DEFAULT
protected static final int SEQUENCE_RANDOMIZED_BLOCKSIZE_DEFAULT
- See Also:
- Constant Field Values
-
COUNTER_NAME_UUID
public static final String COUNTER_NAME_UUID
- See Also:
- Constant Field Values
-
COUNTER_FIELD
public static final String COUNTER_FIELD
- See Also:
- Constant Field Values
-
MAX_TIME_DEFAULT
protected static final Duration MAX_TIME_DEFAULT
Default maximum execution time for a query.- Since:
- 11.1
-
SETTING_VALUE
protected static final String SETTING_VALUE
- See Also:
- Constant Field Values
-
SETTING_DENORMALIZED_BLOB_KEYS
protected static final String SETTING_DENORMALIZED_BLOB_KEYS
Settings key to determine whetherecm:blobKeys
is supported.The value is
true
on new or migrated repositories.- See Also:
- Constant Field Values
-
GC_NO_CURSOR_TIMEOUT
protected static final String GC_NO_CURSOR_TIMEOUT
- Since:
- 2021.14
- See Also:
- Constant Field Values
-
idKey
protected String idKey
The key to use to store the id in the database.
-
sequenceBlockSize
protected long sequenceBlockSize
Sequence allocation block size.
-
descriptor
protected final MongoDBRepositoryDescriptor descriptor
-
mongoClient
protected final com.mongodb.client.MongoClient mongoClient
-
converter
protected final MongoDBConverter converter
-
cursorService
protected final MongoDBCursorService cursorService
-
coll
protected final com.mongodb.client.MongoCollection<org.bson.Document> coll
-
countersColl
protected final com.mongodb.client.MongoCollection<org.bson.Document> countersColl
-
settingsColl
protected final com.mongodb.client.MongoCollection<org.bson.Document> settingsColl
-
supportsSessions
protected final boolean supportsSessions
-
supportsTransactions
protected final boolean supportsTransactions
-
maxTimeMS
protected final long maxTimeMS
Maximum execution time for a query when outside of a transaction.- Since:
- 11.1
-
supportsDenormalizedBlobKeys
protected boolean supportsDenormalizedBlobKeys
-
indexInitialized
protected volatile boolean indexInitialized
-
binaryKeys
protected org.bson.conversions.Bson binaryKeys
Keys used for document projection when marking all binaries for GC.Used when denormalized ecm:blobKeys is not available.
-
-
Constructor Detail
-
MongoDBRepository
public MongoDBRepository(MongoDBRepositoryDescriptor descriptor)
-
-
Method Detail
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceRepository
- Overrides:
shutdown
in classDBSRepositoryBase
-
initRepository
protected void initRepository()
-
initSettings
protected void initSettings()
-
updateCapabilities
public void updateCapabilities()
Description copied from interface:DBSRepository
Update repository capabilities after a migration. Internal use only.
-
readSettings
protected void readSettings()
-
initCapabilities
protected void initCapabilities()
-
getConnection
public MongoDBConnection getConnection()
Description copied from interface:DBSRepository
Gets a new connection to this repository.- Returns:
- a new connection
-
getAllowedIdTypes
public List<DBSRepositoryBase.IdType> getAllowedIdTypes()
Description copied from class:DBSRepositoryBase
Gets the allowed id types for this DBS repository. The first one is the default.- Specified by:
getAllowedIdTypes
in classDBSRepositoryBase
-
supportsSessions
protected boolean supportsSessions()
-
supportsTransactions
public boolean supportsTransactions()
Description copied from interface:DBSRepository
Checks whether this repository supports transactions.- Returns:
true
if the repository supports transactions- See Also:
DBSConnection.begin()
,DBSConnection.commit()
,DBSConnection.rollback()
-
getClient
protected com.mongodb.client.MongoClient getClient()
-
getCursorService
protected MongoDBCursorService getCursorService()
-
getCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection()
-
getCountersCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCountersCollection()
-
getIdKey
protected String getIdKey()
-
getConverter
protected MongoDBConverter getConverter()
-
initBlobsPaths
protected void initBlobsPaths()
- Overrides:
initBlobsPaths
in classDBSRepositoryBase
-
markReferencedBlobs
public void markReferencedBlobs(BiConsumer<String,String> markerCallback)
Description copied from interface:Repository
Marks the blobs in use by passing them to the provided callback (taking the blob key and the repository name).
-
markReferencedBlobsDenormalized
protected void markReferencedBlobsDenormalized(org.bson.Document ob, BiConsumer<String,String> markReferencedBlob)
-
markReferencedBlobs
protected void markReferencedBlobs(org.bson.Document ob, BiConsumer<String,String> markerCallback)
-
markReferencedBlob
protected void markReferencedBlob(Object value, BiConsumer<String,String> markerCallback)
-
-