Package de.caluga.morphium.driver.inmem
Class InMemoryDriver
java.lang.Object
de.caluga.morphium.driver.inmem.InMemoryDriver
- All Implemented Interfaces:
MorphiumDriver,MongoConnection,Closeable,AutoCloseable
User: Stephan Bösebeck
Date: 28.11.15
Time: 23:25
InMemory implementation of the MorphiumDriver interface. can be used for testing or caching. Does not cover all functionality yet.
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.caluga.morphium.driver.MorphiumDriver
MorphiumDriver.DriverStatsKey -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()voidvoidvoidconnect()connect(MorphiumDriver drv, String host, int port) voidlongcount(String db, String collection, Map<String, Object> query, Collation collation, ReadPreference rp) <T,R> Aggregator<T, R> createAggregator(Morphium morphium, Class<? extends T> type, Class<? extends R> resultType) createBulkContext(Morphium m, String db, String collection, boolean ordered, WriteConcern wc) voiddelete(String db, String collection, Map<String, Object> query, Map<String, Object> sort, boolean multiple, Map<String, Object> collation, WriteConcern wc) distinct(String db, String collection, String field, Map<String, Object> filter, Map<String, Object> collation) voiddrop(String db, WriteConcern wc) voiddrop(String db, String collection, WriteConcern wc) voiddump(Morphium m, String db, OutputStream out) voiddumpToFile(Morphium m, String db, File f) longestimatedDocumentCount(String db, String collection, ReadPreference rp) booleanbooleanfind(String db, String collection, Map<String, Object> query, Map<String, Object> sort, Map<String, Object> projection, int skip, int limit) findAndOneAndDelete(String db, String col, Map<String, Object> query, Map<String, Object> sort, Map<String, Object> collation) findAndOneAndReplace(String db, String col, Map<String, Object> query, Map<String, Object> replacement, Map<String, Object> sort, Map<String, Object> collation) findAndOneAndUpdate(String db, String col, Map<String, Object> query, Map<String, Object> update, Map<String, Object> sort, Map<String, Object> collation) findByFieldValue(String db, String coll, String field, Object value) getAnswer(int queryId) getAnswerFor(int queryId, int batchsize) getCollStats(String db, String coll) intintString[]getCredentials(String db) getDatabase(String dbn) getDBStats(String db) intbooleanintintintintgetIndexDataForCollection(String db, String collection, String fields) getIndexes(String db, String collection) intintintintintintintintintintgetName()intgetReplyFor(int msgid, long timeout) intintintintinitIteration(String db, String collection, Map<String, Object> query, Map<String, Object> sort, Map<String, Object> projection, int skip, int limit, int batchSize, ReadPreference readPreference, Collation coll, Map<String, Object> findMetaData) booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisUseSSL()killCursors(String db, String coll, long... ids) listCollections(String db, String pattern) mapReduce(String db, String collection, String mapping, String reducing, Map<String, Object> query, Map<String, Object> sorting, Collation collation) readAnswerFor(int queryId) readSingleAnswer(int id) voidrelease()voidbooleanreplyAvailableFor(int msgId) voidvoidrestore(InputStream in) voidintrunCommand(GenericCommand cmd) intsendCommand(MongoCommand cmd) voidsetConnectionTimeout(int timeout) voidsetConnectionUrl(String connectionUrl) voidsetCredentials(String db, String login, char[] pwd) voidsetCredentials(String db, String login, String pwd) voidvoidsetDefaultBatchSize(int defaultBatchSize) voidsetDefaultJ(boolean j) voidvoidsetDefaultW(int w) voidsetDefaultWriteTimeout(int wt) setExpireCheck(int expireCheck) voidsetHeartbeatFrequency(int heartbeatFrequency) voidsetHostSeed(String... host) voidsetHostSeed(List<String> hosts) voidsetMaxBsonObjectSize(int maxBsonObjectSize) voidsetMaxConnectionIdleTime(int time) voidsetMaxConnectionLifetime(int timeout) setMaxConnections(int maxConnections) voidsetMaxConnectionsPerHost(int maxConnectionsPerHost) voidsetMaxMessageSize(int maxMessageSize) voidsetMaxWaitTime(int maxWaitTime) voidsetMaxWriteBatchSize(int maxWriteBatchSize) setMinConnections(int minConnections) voidsetMinConnectionsPerHost(int minConnectionsPerHost) voidsetReadTimeout(int readTimeout) voidsetReplicaSet(boolean replicaSet) voidsetReplicaSetName(String replicaSetName) setRetriesOnNetworkError(int r) setRetryReads(boolean retryReads) setRetryWrites(boolean retryWrites) voidsetServerSelectionTimeout(int serverSelectionTimeout) setSleepBetweenErrorRetries(int s) voidsetSslContext(SSLContext sslContext) voidsetSslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed) voidvoidsetUseSSL(boolean useSSL) startTransaction(boolean autoCommit) voidtailableIteration(String db, String collection, Map<String, Object> query, Map<String, Object> sort, Map<String, Object> projection, int skip, int limit, int batchSize, ReadPreference readPreference, int timeout, DriverTailableIterationCallback cb) update(String db, String collection, Map<String, Object> query, Map<String, Object> sort, Map<String, Object> op, boolean multiple, boolean upsert, Map<String, Object> collation, Map<String, Object> wc) voidwatch(WatchCommand settings) voidwatch(String db, String collection, int timeout, boolean fullDocumentOnUpdate, List<Map<String, Object>> pipeline, DriverTailableIterationCallback cb) void
-
Field Details
-
driverName
- See Also:
-
-
Constructor Details
-
InMemoryDriver
public InMemoryDriver()
-
-
Method Details
-
getDatabase
-
createAggregator
public <T,R> Aggregator<T,R> createAggregator(Morphium morphium, Class<? extends T> type, Class<? extends R> resultType) - Specified by:
createAggregatorin interfaceMorphiumDriver
-
setDatabase
-
restore
- Throws:
IOExceptionorg.json.simple.parser.ParseException
-
restoreFromFile
- Throws:
IOExceptionorg.json.simple.parser.ParseException
-
dumpToFile
- Throws:
IOException
-
dump
- Throws:
IOException
-
listDatabases
- Specified by:
listDatabasesin interfaceMorphiumDriver
-
listCollections
- Specified by:
listCollectionsin interfaceMorphiumDriver
-
getReplicaSetName
- Specified by:
getReplicaSetNamein interfaceMorphiumDriver
-
setReplicaSetName
- Specified by:
setReplicaSetNamein interfaceMorphiumDriver
-
resetData
public void resetData() -
setCredentials
-
getAnswer
-
watch
- Specified by:
watchin interfaceMongoConnection- Specified by:
watchin interfaceMorphiumDriver- Throws:
MorphiumDriverException
-
readAnswerFor
- Specified by:
readAnswerForin interfaceMongoConnection- Throws:
MorphiumDriverException
-
getAnswerFor
- Specified by:
getAnswerForin interfaceMongoConnection- Throws:
MorphiumDriverException
-
readAnswerFor
- Specified by:
readAnswerForin interfaceMongoConnection- Throws:
MorphiumDriverException
-
sendCommand
- Specified by:
sendCommandin interfaceMongoConnection- Throws:
MorphiumDriverException
-
runCommand
-
getReadConnection
- Specified by:
getReadConnectionin interfaceMorphiumDriver
-
getPrimaryConnection
- Specified by:
getPrimaryConnectionin interfaceMorphiumDriver
-
releaseConnection
- Specified by:
releaseConnectionin interfaceMorphiumDriver
-
getName
- Specified by:
getNamein interfaceMorphiumDriver
-
getMaxBsonObjectSize
public int getMaxBsonObjectSize()- Specified by:
getMaxBsonObjectSizein interfaceMorphiumDriver
-
setMaxBsonObjectSize
public void setMaxBsonObjectSize(int maxBsonObjectSize) - Specified by:
setMaxBsonObjectSizein interfaceMorphiumDriver
-
getMaxMessageSize
public int getMaxMessageSize()- Specified by:
getMaxMessageSizein interfaceMorphiumDriver
-
setMaxMessageSize
public void setMaxMessageSize(int maxMessageSize) - Specified by:
setMaxMessageSizein interfaceMorphiumDriver
-
getMaxWriteBatchSize
public int getMaxWriteBatchSize()- Specified by:
getMaxWriteBatchSizein interfaceMorphiumDriver
-
setMaxWriteBatchSize
public void setMaxWriteBatchSize(int maxWriteBatchSize) - Specified by:
setMaxWriteBatchSizein interfaceMorphiumDriver
-
isReplicaSet
public boolean isReplicaSet()- Specified by:
isReplicaSetin interfaceMorphiumDriver
-
setReplicaSet
public void setReplicaSet(boolean replicaSet) - Specified by:
setReplicaSetin interfaceMorphiumDriver
-
getDefaultJ
public boolean getDefaultJ()- Specified by:
getDefaultJin interfaceMorphiumDriver
-
getDefaultWriteTimeout
public int getDefaultWriteTimeout()- Specified by:
getDefaultWriteTimeoutin interfaceMorphiumDriver
-
setDefaultWriteTimeout
public void setDefaultWriteTimeout(int wt) - Specified by:
setDefaultWriteTimeoutin interfaceMorphiumDriver
-
setHostSeed
- Specified by:
setHostSeedin interfaceMorphiumDriver
-
setConnectionUrl
- Specified by:
setConnectionUrlin interfaceMorphiumDriver
-
connect
public void connect()- Specified by:
connectin interfaceMorphiumDriver
-
getExpireCheck
public int getExpireCheck() -
setExpireCheck
-
connect
- Specified by:
connectin interfaceMorphiumDriver
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceMongoConnection- Specified by:
isConnectedin interfaceMorphiumDriver
-
getConnectedTo
- Specified by:
getConnectedToin interfaceMongoConnection
-
getConnectedToHost
- Specified by:
getConnectedToHostin interfaceMongoConnection
-
getConnectedToPort
public int getConnectedToPort()- Specified by:
getConnectedToPortin interfaceMongoConnection
-
getRetriesOnNetworkError
public int getRetriesOnNetworkError()- Specified by:
getRetriesOnNetworkErrorin interfaceMorphiumDriver
-
setRetriesOnNetworkError
- Specified by:
setRetriesOnNetworkErrorin interfaceMorphiumDriver
-
getSleepBetweenErrorRetries
public int getSleepBetweenErrorRetries()- Specified by:
getSleepBetweenErrorRetriesin interfaceMorphiumDriver
-
setSleepBetweenErrorRetries
- Specified by:
setSleepBetweenErrorRetriesin interfaceMorphiumDriver
-
getMaxConnections
public int getMaxConnections()- Specified by:
getMaxConnectionsin interfaceMorphiumDriver
-
setMaxConnections
- Specified by:
setMaxConnectionsin interfaceMorphiumDriver
-
getMinConnections
public int getMinConnections()- Specified by:
getMinConnectionsin interfaceMorphiumDriver
-
setMinConnections
- Specified by:
setMinConnectionsin interfaceMorphiumDriver
-
isRetryReads
public boolean isRetryReads()- Specified by:
isRetryReadsin interfaceMorphiumDriver
-
setRetryReads
- Specified by:
setRetryReadsin interfaceMorphiumDriver
-
isRetryWrites
public boolean isRetryWrites()- Specified by:
isRetryWritesin interfaceMorphiumDriver
-
setRetryWrites
- Specified by:
setRetryWritesin interfaceMorphiumDriver
-
getReadTimeout
public int getReadTimeout()- Specified by:
getReadTimeoutin interfaceMorphiumDriver
-
setReadTimeout
public void setReadTimeout(int readTimeout) - Specified by:
setReadTimeoutin interfaceMorphiumDriver
-
getMinConnectionsPerHost
public int getMinConnectionsPerHost()- Specified by:
getMinConnectionsPerHostin interfaceMorphiumDriver
-
setMinConnectionsPerHost
public void setMinConnectionsPerHost(int minConnectionsPerHost) - Specified by:
setMinConnectionsPerHostin interfaceMorphiumDriver
-
getMaxConnectionsPerHost
public int getMaxConnectionsPerHost()- Specified by:
getMaxConnectionsPerHostin interfaceMorphiumDriver
-
setMaxConnectionsPerHost
public void setMaxConnectionsPerHost(int maxConnectionsPerHost) - Specified by:
setMaxConnectionsPerHostin interfaceMorphiumDriver
-
setCredentials
- Specified by:
setCredentialsin interfaceMongoConnection- Specified by:
setCredentialsin interfaceMorphiumDriver
-
startTransaction
- Specified by:
startTransactionin interfaceMorphiumDriver
-
isTransactionInProgress
public boolean isTransactionInProgress()- Specified by:
isTransactionInProgressin interfaceMorphiumDriver
-
getTransactionContext
- Specified by:
getTransactionContextin interfaceMorphiumDriver
-
connect
public HelloResult connect(MorphiumDriver drv, String host, int port) throws IOException, MorphiumDriverException - Specified by:
connectin interfaceMongoConnection- Throws:
IOExceptionMorphiumDriverException
-
getDriver
- Specified by:
getDriverin interfaceMongoConnection
-
getSourcePort
public int getSourcePort()- Specified by:
getSourcePortin interfaceMongoConnection
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceMongoConnection
-
release
public void release()- Specified by:
releasein interfaceMongoConnection
-
isReplicaset
public boolean isReplicaset()- Specified by:
isReplicasetin interfaceMorphiumDriver
-
getReplsetStatus
- Specified by:
getReplsetStatusin interfaceMorphiumDriver
-
getDBStats
- Specified by:
getDBStatsin interfaceMorphiumDriver
-
getCollStats
- Specified by:
getCollStatsin interfaceMorphiumDriver- Throws:
MorphiumDriverException
-
initIteration
public MorphiumCursor initIteration(String db, String collection, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, Map<String, Object> projection, int skip, int limit, int batchSize, ReadPreference readPreference, Collation coll, Map<String, Object> findMetaData) - Throws:
MorphiumDriverException
-
watch
public void watch(String db, String collection, int timeout, boolean fullDocumentOnUpdate, List<Map<String, Object>> pipeline, DriverTailableIterationCallback cb) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
nextIteration
- Throws:
MorphiumDriverException
-
find
public List<Map<String,Object>> find(String db, String collection, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, Map<String, Object> projection, int skip, int limit) - Throws:
MorphiumDriverException
-
count
public long count(String db, String collection, Map<String, Object> query, Collation collation, ReadPreference rp) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
estimatedDocumentCount
public long estimatedDocumentCount(String db, String collection, ReadPreference rp) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
findByFieldValue
public List<Map<String,Object>> findByFieldValue(String db, String coll, String field, Object value) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
getIndexDataForCollection
-
insert
public List<Map<String,Object>> insert(String db, String collection, List<Map<String, Object>> objs, Map<String, throws MorphiumDriverExceptionObject> wc) - Throws:
MorphiumDriverException
-
store
public Map<String,Integer> store(String db, String collection, List<Map<String, Object>> objs, Map<String, throws MorphiumDriverExceptionObject> wc) - Throws:
MorphiumDriverException
-
closeIteration
- Specified by:
closeIterationin interfaceMongoConnection
-
killCursors
public Map<String,Object> killCursors(String db, String coll, long... ids) throws MorphiumDriverException - Specified by:
killCursorsin interfaceMongoConnection- Throws:
MorphiumDriverException
-
replyAvailableFor
public boolean replyAvailableFor(int msgId) - Specified by:
replyAvailableForin interfaceMongoConnection
-
getReplyFor
- Specified by:
getReplyForin interfaceMongoConnection- Throws:
MorphiumDriverException
-
readSingleAnswer
- Specified by:
readSingleAnswerin interfaceMongoConnection- Throws:
MorphiumDriverException
-
update
public Map<String,Object> update(String db, String collection, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, Map<String, Object> op, boolean multiple, boolean upsert, Map<String, Object> collation, Map<String, Object> wc) - Throws:
MorphiumDriverException
-
delete
public Map<String,Object> delete(String db, String collection, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, boolean multiple, Map<String, Object> collation, WriteConcern wc) - Throws:
MorphiumDriverException
-
drop
-
drop
-
exists
- Specified by:
existsin interfaceMorphiumDriver
-
getMaxConnectionLifetime
public int getMaxConnectionLifetime()- Specified by:
getMaxConnectionLifetimein interfaceMorphiumDriver
-
setMaxConnectionLifetime
public void setMaxConnectionLifetime(int timeout) - Specified by:
setMaxConnectionLifetimein interfaceMorphiumDriver
-
getMaxConnectionIdleTime
public int getMaxConnectionIdleTime()- Specified by:
getMaxConnectionIdleTimein interfaceMorphiumDriver
-
setMaxConnectionIdleTime
public void setMaxConnectionIdleTime(int time) - Specified by:
setMaxConnectionIdleTimein interfaceMorphiumDriver
-
getConnectionTimeout
public int getConnectionTimeout()- Specified by:
getConnectionTimeoutin interfaceMorphiumDriver
-
setConnectionTimeout
public void setConnectionTimeout(int timeout) - Specified by:
setConnectionTimeoutin interfaceMorphiumDriver
-
getDefaultW
public int getDefaultW()- Specified by:
getDefaultWin interfaceMorphiumDriver
-
setDefaultW
public void setDefaultW(int w) - Specified by:
setDefaultWin interfaceMorphiumDriver
-
getHeartbeatFrequency
public int getHeartbeatFrequency()- Specified by:
getHeartbeatFrequencyin interfaceMorphiumDriver
-
setHeartbeatFrequency
public void setHeartbeatFrequency(int heartbeatFrequency) - Specified by:
setHeartbeatFrequencyin interfaceMorphiumDriver
-
getDefaultReadPreference
- Specified by:
getDefaultReadPreferencein interfaceMorphiumDriver
-
setDefaultReadPreference
- Specified by:
setDefaultReadPreferencein interfaceMorphiumDriver
-
getDefaultBatchSize
public int getDefaultBatchSize()- Specified by:
getDefaultBatchSizein interfaceMorphiumDriver
-
setDefaultBatchSize
public void setDefaultBatchSize(int defaultBatchSize) - Specified by:
setDefaultBatchSizein interfaceMorphiumDriver
-
isUseSSL
public boolean isUseSSL()- Specified by:
isUseSSLin interfaceMorphiumDriver
-
setUseSSL
public void setUseSSL(boolean useSSL) - Specified by:
setUseSSLin interfaceMorphiumDriver
-
isDefaultJ
public boolean isDefaultJ()- Specified by:
isDefaultJin interfaceMorphiumDriver
-
setDefaultJ
public void setDefaultJ(boolean j) - Specified by:
setDefaultJin interfaceMorphiumDriver
-
distinct
public List<Object> distinct(String db, String collection, String field, Map<String, Object> filter, Map<String, throws MorphiumDriverExceptionObject> collation) - Throws:
MorphiumDriverException
-
exists
- Specified by:
existsin interfaceMorphiumDriver
-
getIndexes
-
getCollectionNames
-
findAndOneAndDelete
public Map<String,Object> findAndOneAndDelete(String db, String col, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, Map<String, Object> collation) - Throws:
MorphiumDriverException
-
findAndOneAndUpdate
public Map<String,Object> findAndOneAndUpdate(String db, String col, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> update, Map<String, Object> sort, Map<String, Object> collation) - Throws:
MorphiumDriverException
-
findAndOneAndReplace
public Map<String,Object> findAndOneAndReplace(String db, String col, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> replacement, Map<String, Object> sort, Map<String, Object> collation) - Throws:
MorphiumDriverException
-
tailableIteration
public void tailableIteration(String db, String collection, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sort, Map<String, Object> projection, int skip, int limit, int batchSize, ReadPreference readPreference, int timeout, DriverTailableIterationCallback cb) - Throws:
MorphiumDriverException
-
getMaxWaitTime
public int getMaxWaitTime()- Specified by:
getMaxWaitTimein interfaceMorphiumDriver
-
setMaxWaitTime
public void setMaxWaitTime(int maxWaitTime) - Specified by:
setMaxWaitTimein interfaceMorphiumDriver
-
getCredentials
- Specified by:
getCredentialsin interfaceMorphiumDriver
-
getHostSeed
- Specified by:
getHostSeedin interfaceMorphiumDriver
-
setHostSeed
- Specified by:
setHostSeedin interfaceMorphiumDriver
-
getServerSelectionTimeout
public int getServerSelectionTimeout() -
setServerSelectionTimeout
public void setServerSelectionTimeout(int serverSelectionTimeout) -
isCapped
- Specified by:
isCappedin interfaceMorphiumDriver
-
getNumConnectionsByHost
- Specified by:
getNumConnectionsByHostin interfaceMorphiumDriver
-
createBulkContext
public BulkRequestContext createBulkContext(Morphium m, String db, String collection, boolean ordered, WriteConcern wc) - Specified by:
createBulkContextin interfaceMorphiumDriver
-
getDriverStats
- Specified by:
getDriverStatsin interfaceMorphiumDriver
-
createIndex
public void createIndex(String db, String collection, Map<String, Object> indexDef, Map<String, throws MorphiumDriverExceptionObject> options) - Throws:
MorphiumDriverException
-
mapReduce
public List<Map<String,Object>> mapReduce(String db, String collection, String mapping, String reducing) throws MorphiumDriverException - Throws:
MorphiumDriverException
-
mapReduce
public List<Map<String,Object>> mapReduce(String db, String collection, String mapping, String reducing, Map<String, Object> query) throws MorphiumDriverException- Throws:
MorphiumDriverException
-
mapReduce
public List<Map<String,Object>> mapReduce(String db, String collection, String mapping, String reducing, Map<String, Object> query, Map<String, throws MorphiumDriverExceptionObject> sorting, Collation collation) - Throws:
MorphiumDriverException
-
commitTransaction
public void commitTransaction()- Specified by:
commitTransactionin interfaceMorphiumDriver
-
abortTransaction
public void abortTransaction()- Specified by:
abortTransactionin interfaceMorphiumDriver
-
setTransactionContext
- Specified by:
setTransactionContextin interfaceMorphiumDriver
-
writeDump
-
getSslContext
-
setSslContext
-
isSslInvalidHostNameAllowed
public boolean isSslInvalidHostNameAllowed() -
setSslInvalidHostNameAllowed
public void setSslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed)
-