Package de.bwaldvogel.mongo.backend
Class AbstractMongoDatabase<P>
java.lang.Object
de.bwaldvogel.mongo.backend.AbstractMongoDatabase<P>
- All Implemented Interfaces:
AsyncMongoDatabase,MongoDatabase
- Direct Known Subclasses:
AbstractSynchronizedMongoDatabase
public abstract class AbstractMongoDatabase<P> extends java.lang.Object implements MongoDatabase
-
Field Summary
Fields Modifier and Type Field Description protected CursorRegistrycursorRegistryprotected java.lang.StringdatabaseNameprotected java.util.concurrent.atomic.AtomicReference<MongoCollection<P>>indexes -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMongoDatabase(java.lang.String databaseName, CursorRegistry cursorRegistry) -
Method Summary
Modifier and Type Method Description protected voidclearLastStatus(io.netty.channel.Channel channel)protected intcountIndexes()MongoCollection<P>createCollectionOrThrowIfExists(java.lang.String collectionName, CollectionOptions options)voiddrop(Oplog oplog)voiddropCollection(java.lang.String collectionName, Oplog oplog)protected voiddropIndex(MongoCollection<P> collection, java.lang.String indexName)java.lang.StringgetDatabaseName()protected abstract longgetFileSize()protected java.lang.StringgetFullCollectionNamespace(java.lang.String collectionName)protected MongoCollection<P>getOrCreateIndexesCollection()protected abstract longgetStorageSize()voidhandleClose(io.netty.channel.Channel channel)DocumenthandleCommand(io.netty.channel.Channel channel, java.lang.String command, Document query, Oplog oplog)java.util.concurrent.CompletionStage<Document>handleCommandAsync(io.netty.channel.Channel channel, java.lang.String command, Document query, Oplog oplog)voidhandleDelete(MongoDelete delete, Oplog oplog)voidhandleInsert(MongoInsert insert, Oplog oplog)QueryResulthandleQuery(MongoQuery query)java.util.concurrent.CompletionStage<QueryResult>handleQueryAsync(MongoQuery query)voidhandleUpdate(MongoUpdate updateCommand, Oplog oplog)protected voidinitializeNamespacesAndIndexes()booleanisEmpty()protected booleanisPrimaryKeyIndex(Document key)voidmoveCollection(MongoDatabase oldDatabase, MongoCollection<?> collection, java.lang.String newCollectionName)protected abstract MongoCollection<P>openOrCreateCollection(java.lang.String collectionName, CollectionOptions options)protected Index<P>openOrCreateSecondaryIndex(java.lang.String collectionName, java.lang.String indexName, java.util.List<IndexKey> keys, boolean sparse)protected abstract Index<P>openOrCreateUniqueIndex(java.lang.String collectionName, java.lang.String indexName, java.util.List<IndexKey> keys, boolean sparse)protected voidputLastResult(io.netty.channel.Channel channel, Document result)MongoCollection<P>resolveCollection(java.lang.String collectionName, boolean throwIfNotFound)protected MongoCollection<P>resolveOrCreateCollection(java.lang.String collectionName)java.lang.StringtoString()voidunregisterCollection(java.lang.String collectionName)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.bwaldvogel.mongo.MongoDatabase
handleDeleteAsync, handleInsertAsync, handleUpdateAsync
-
Field Details
-
databaseName
protected final java.lang.String databaseName -
indexes
-
cursorRegistry
-
-
Constructor Details
-
Method Details
-
initializeNamespacesAndIndexes
protected void initializeNamespacesAndIndexes() -
getDatabaseName
public final java.lang.String getDatabaseName()- Specified by:
getDatabaseNamein interfaceMongoDatabase
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
handleCommand
public Document handleCommand(io.netty.channel.Channel channel, java.lang.String command, Document query, Oplog oplog)- Specified by:
handleCommandin interfaceMongoDatabase
-
handleCommandAsync
public java.util.concurrent.CompletionStage<Document> handleCommandAsync(io.netty.channel.Channel channel, java.lang.String command, Document query, Oplog oplog)- Specified by:
handleCommandAsyncin interfaceAsyncMongoDatabase- Specified by:
handleCommandAsyncin interfaceMongoDatabase
-
resolveOrCreateCollection
-
createCollectionOrThrowIfExists
public MongoCollection<P> createCollectionOrThrowIfExists(java.lang.String collectionName, CollectionOptions options)- Specified by:
createCollectionOrThrowIfExistsin interfaceMongoDatabase
-
dropIndex
-
countIndexes
protected int countIndexes() -
getFileSize
protected abstract long getFileSize() -
getStorageSize
protected abstract long getStorageSize() -
handleQuery
- Specified by:
handleQueryin interfaceMongoDatabase
-
handleQueryAsync
- Specified by:
handleQueryAsyncin interfaceAsyncMongoDatabase- Specified by:
handleQueryAsyncin interfaceMongoDatabase
-
handleClose
public void handleClose(io.netty.channel.Channel channel)- Specified by:
handleClosein interfaceMongoDatabase
-
clearLastStatus
protected void clearLastStatus(io.netty.channel.Channel channel) -
handleInsert
- Specified by:
handleInsertin interfaceMongoDatabase
-
resolveCollection
public MongoCollection<P> resolveCollection(java.lang.String collectionName, boolean throwIfNotFound)- Specified by:
resolveCollectionin interfaceMongoDatabase
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceMongoDatabase
-
handleDelete
- Specified by:
handleDeletein interfaceMongoDatabase
-
handleUpdate
- Specified by:
handleUpdatein interfaceMongoDatabase
-
getOrCreateIndexesCollection
-
isPrimaryKeyIndex
-
openOrCreateSecondaryIndex
-
openOrCreateUniqueIndex
-
putLastResult
-
openOrCreateCollection
protected abstract MongoCollection<P> openOrCreateCollection(java.lang.String collectionName, CollectionOptions options) -
drop
- Specified by:
dropin interfaceMongoDatabase
-
dropCollection
- Specified by:
dropCollectionin interfaceMongoDatabase
-
unregisterCollection
public void unregisterCollection(java.lang.String collectionName)- Specified by:
unregisterCollectionin interfaceMongoDatabase
-
moveCollection
public void moveCollection(MongoDatabase oldDatabase, MongoCollection<?> collection, java.lang.String newCollectionName)- Specified by:
moveCollectionin interfaceMongoDatabase
-
getFullCollectionNamespace
protected java.lang.String getFullCollectionNamespace(java.lang.String collectionName)
-