Class MorphiumConfig
- java.lang.Object
-
- de.caluga.morphium.MorphiumConfig
-
public class MorphiumConfig extends Object
Stores the configuration for the MongoDBLayer.- Author:
- stephan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMorphiumConfig.CappedCheckstatic classMorphiumConfig.IndexCheck
-
Constructor Summary
Constructors Constructor Description MorphiumConfig()MorphiumConfig(String db, int maxConnections, int globalCacheValidTime, int housekeepingTimeout)MorphiumConfig(String prefix, MorphiumConfigResolver resolver)MorphiumConfig(String prefix, Properties prop)MorphiumConfig(Properties prop)
-
Method Summary
-
-
-
Constructor Detail
-
MorphiumConfig
public MorphiumConfig(Properties prop)
-
MorphiumConfig
public MorphiumConfig(String prefix, Properties prop)
-
MorphiumConfig
public MorphiumConfig(String prefix, MorphiumConfigResolver resolver)
-
MorphiumConfig
public MorphiumConfig()
-
MorphiumConfig
public MorphiumConfig(String db, int maxConnections, int globalCacheValidTime, int housekeepingTimeout)
-
-
Method Detail
-
createFromJson
public static MorphiumConfig createFromJson(String json) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException, org.json.simple.parser.ParseException, NoSuchMethodException, InvocationTargetException
- Throws:
NoSuchFieldExceptionClassNotFoundExceptionIllegalAccessExceptionInstantiationExceptionorg.json.simple.parser.ParseExceptionNoSuchMethodExceptionInvocationTargetException
-
getMessagingWindowSize
public int getMessagingWindowSize()
-
setMessagingWindowSize
public void setMessagingWindowSize(int messagingWindowSize)
-
fromProperties
public static MorphiumConfig fromProperties(String prefix, Properties p)
-
fromProperties
public static MorphiumConfig fromProperties(Properties p)
-
isAtlas
public boolean isAtlas()
-
getAtlasUrl
public String getAtlasUrl()
-
setAtlasUrl
public void setAtlasUrl(String atlasUrl)
-
isReplicaset
public boolean isReplicaset()
-
setReplicasetMonitoring
public MorphiumConfig setReplicasetMonitoring(boolean replicaset)
-
getValueEncryptionProviderClass
public Class<? extends ValueEncryptionProvider> getValueEncryptionProviderClass()
-
setValueEncryptionProviderClass
public MorphiumConfig setValueEncryptionProviderClass(Class<? extends ValueEncryptionProvider> valueEncryptionProviderClass)
-
getEncryptionKeyProviderClass
public Class<? extends EncryptionKeyProvider> getEncryptionKeyProviderClass()
-
setEncryptionKeyProviderClass
public void setEncryptionKeyProviderClass(Class<? extends EncryptionKeyProvider> encryptionKeyProviderClass)
-
getCredentialsEncryptionKey
public String getCredentialsEncryptionKey()
-
setCredentialsEncryptionKey
public MorphiumConfig setCredentialsEncryptionKey(String credentialsEncryptionKey)
-
getCredentialsDecryptionKey
public String getCredentialsDecryptionKey()
-
setCredentialsDecryptionKey
public MorphiumConfig setCredentialsDecryptionKey(String credentialsDecryptionKey)
-
getDriverName
public String getDriverName()
-
setDriverName
public MorphiumConfig setDriverName(String driverName)
-
isAutoIndexAndCappedCreationOnWrite
public boolean isAutoIndexAndCappedCreationOnWrite()
-
setAutoIndexAndCappedCreationOnWrite
public MorphiumConfig setAutoIndexAndCappedCreationOnWrite(boolean autoIndexAndCappedCreationOnWrite)
-
isWarnOnNoEntitySerialization
public boolean isWarnOnNoEntitySerialization()
-
setWarnOnNoEntitySerialization
public void setWarnOnNoEntitySerialization(boolean warnOnNoEntitySerialization)
-
isCheckForNew
public boolean isCheckForNew()
-
setCheckForNew
public MorphiumConfig setCheckForNew(boolean checkForNew)
if set to false, all checks if an entity is new when CreationTime is used is switched off if set to true, only those, whose CreationTime settings use checkfornew will work default false- Parameters:
checkForNew- boolean, check if object is really not stored yet
-
getRetriesOnNetworkError
public int getRetriesOnNetworkError()
-
setRetriesOnNetworkError
public MorphiumConfig setRetriesOnNetworkError(int retriesOnNetworkError)
-
getSleepBetweenNetworkErrorRetries
public int getSleepBetweenNetworkErrorRetries()
-
setSleepBetweenNetworkErrorRetries
public MorphiumConfig setSleepBetweenNetworkErrorRetries(int sleepBetweenNetworkErrorRetries)
-
getReplicaSetMonitoringTimeout
public int getReplicaSetMonitoringTimeout()
-
setReplicaSetMonitoringTimeout
public MorphiumConfig setReplicaSetMonitoringTimeout(int replicaSetMonitoringTimeout)
-
getWriteBufferTimeGranularity
public int getWriteBufferTimeGranularity()
-
setWriteBufferTimeGranularity
public MorphiumConfig setWriteBufferTimeGranularity(int writeBufferTimeGranularity)
-
getCache
public MorphiumCache getCache()
-
setCache
public MorphiumConfig setCache(MorphiumCache cache)
-
getWriteBufferTime
public int getWriteBufferTime()
-
setWriteBufferTime
public MorphiumConfig setWriteBufferTime(int writeBufferTime)
-
getGlobalW
public int getGlobalW()
-
setGlobalW
public MorphiumConfig setGlobalW(int globalW)
-
getThreadConnectionMultiplier
public int getThreadConnectionMultiplier()
-
setThreadConnectionMultiplier
public void setThreadConnectionMultiplier(int threadConnectionMultiplier)
-
isGlobalJ
public boolean isGlobalJ()
-
setGlobalJ
public MorphiumConfig setGlobalJ(boolean globalJ)
-
isGlobalFsync
public boolean isGlobalFsync()
-
setGlobalFsync
public MorphiumConfig setGlobalFsync(boolean globalFsync)
-
getBufferedWriter
public MorphiumWriter getBufferedWriter()
-
setBufferedWriter
public MorphiumConfig setBufferedWriter(MorphiumWriter bufferedWriter)
-
getWriter
public MorphiumWriter getWriter()
-
setWriter
public MorphiumConfig setWriter(MorphiumWriter writer)
-
getConnectionTimeout
public int getConnectionTimeout()
-
setConnectionTimeout
public MorphiumConfig setConnectionTimeout(int connectionTimeout)
-
getMaxWaitTime
public int getMaxWaitTime()
-
setMaxWaitTime
public MorphiumConfig setMaxWaitTime(int maxWaitTime)
Sets the maximum time that a thread will block waiting for a connection.- Parameters:
maxWaitTime- the maximum wait time, in milliseconds- Returns:
this
-
getServerSelectionTimeout
public int getServerSelectionTimeout()
-
setServerSelectionTimeout
public MorphiumConfig setServerSelectionTimeout(int serverSelectionTimeout)
Sets the server selection timeout in milliseconds, which defines how long the driver will wait for server selection to succeed before throwing an exception.
A value of 0 means that it will timeout immediately if no server is available. A negative value means to wait indefinitely.
- Parameters:
serverSelectionTimeout- the server selection timeout, in milliseconds- Returns:
this
-
getCredentialsEncrypted
public Boolean getCredentialsEncrypted()
-
setCredentialsEncrypted
public MorphiumConfig setCredentialsEncrypted(Boolean credentialsEncrypted)
-
getMongoAuthDb
public String getMongoAuthDb()
-
decryptAuthDb
public String decryptAuthDb()
-
decryptMongoLogin
public String decryptMongoLogin()
-
decryptMongoPassword
public String decryptMongoPassword()
-
setMongoAuthDb
public MorphiumConfig setMongoAuthDb(String mongoAuthDb)
-
getMongoLogin
public String getMongoLogin()
-
setMongoLogin
public MorphiumConfig setMongoLogin(String mongoLogin)
-
getMongoPassword
public String getMongoPassword()
-
setMongoPassword
public MorphiumConfig setMongoPassword(String mongoPassword)
-
getDefaultReadPreference
public ReadPreference getDefaultReadPreference()
-
setDefaultReadPreference
public MorphiumConfig setDefaultReadPreference(ReadPreference defaultReadPreference)
-
getDefaultReadPreferenceType
public String getDefaultReadPreferenceType()
-
setDefaultReadPreferenceType
public MorphiumConfig setDefaultReadPreferenceType(String stringDefaultReadPreference)
-
getWriteCacheTimeout
public int getWriteCacheTimeout()
-
setWriteCacheTimeout
public MorphiumConfig setWriteCacheTimeout(int writeCacheTimeout)
-
setHostSeed
public MorphiumConfig setHostSeed(List<String> str)
setting hosts as Host:Port- Parameters:
str- list of hosts, with or without port
-
setHostSeed
public MorphiumConfig setHostSeed(List<String> str, List<Integer> ports)
-
setHostSeed
public MorphiumConfig setHostSeed(String... hostPorts)
-
setHostSeed
public MorphiumConfig setHostSeed(String hostPorts)
-
setHostSeed
public MorphiumConfig setHostSeed(String hosts, String ports)
-
addHostToSeed
public MorphiumConfig addHostToSeed(String host, int port)
-
addHostToSeed
public MorphiumConfig addHostToSeed(String host)
-
getMaxConnections
public int getMaxConnections()
-
setMaxConnections
public MorphiumConfig setMaxConnections(int maxConnections)
-
getGlobalCacheValidTime
public int getGlobalCacheValidTime()
for future use - set Global Caching time- Returns:
- the global cache valid time
-
setGlobalCacheValidTime
public MorphiumConfig setGlobalCacheValidTime(int globalCacheValidTime)
-
getDatabase
public String getDatabase()
-
setDatabase
public MorphiumConfig setDatabase(String database)
-
getHousekeepingTimeout
public int getHousekeepingTimeout()
-
setHousekeepingTimeout
public MorphiumConfig setHousekeepingTimeout(int housekeepingTimeout)
-
getValidTime
public long getValidTime()
-
setValidTime
public MorphiumConfig setValidTime(int tm)
-
toString
public String toString()
returns json representation of this object containing all values
-
getAsyncWriter
public MorphiumWriter getAsyncWriter()
-
setAsyncWriter
public MorphiumConfig setAsyncWriter(MorphiumWriter asyncWriter)
-
getMaximumRetriesBufferedWriter
public int getMaximumRetriesBufferedWriter()
-
setMaximumRetriesBufferedWriter
public MorphiumConfig setMaximumRetriesBufferedWriter(int maximumRetriesBufferedWriter)
-
getMaximumRetriesWriter
public int getMaximumRetriesWriter()
-
setMaximumRetriesWriter
public MorphiumConfig setMaximumRetriesWriter(int maximumRetriesWriter)
-
getMaximumRetriesAsyncWriter
public int getMaximumRetriesAsyncWriter()
-
setMaximumRetriesAsyncWriter
public MorphiumConfig setMaximumRetriesAsyncWriter(int maximumRetriesAsyncWriter)
-
getRetryWaitTimeBufferedWriter
public int getRetryWaitTimeBufferedWriter()
-
setRetryWaitTimeBufferedWriter
public MorphiumConfig setRetryWaitTimeBufferedWriter(int retryWaitTimeBufferedWriter)
-
getRetryWaitTimeWriter
public int getRetryWaitTimeWriter()
-
setRetryWaitTimeWriter
public MorphiumConfig setRetryWaitTimeWriter(int retryWaitTimeWriter)
-
getRetryWaitTimeAsyncWriter
public int getRetryWaitTimeAsyncWriter()
-
setRetryWaitTimeAsyncWriter
public MorphiumConfig setRetryWaitTimeAsyncWriter(int retryWaitTimeAsyncWriter)
-
asProperties
public Properties asProperties()
returns a property set only containing non-default values set- Returns:
- properties
-
asProperties
public Properties asProperties(String prefix)
-
asProperties
public Properties asProperties(String prefix, boolean effectiveConfig)
- Parameters:
prefix- prefix to use in property keyseffectiveConfig- when true, use the current effective config, including overrides from Environment- Returns:
- the properties
-
isReadCacheEnabled
public boolean isReadCacheEnabled()
-
setReadCacheEnabled
public MorphiumConfig setReadCacheEnabled(boolean readCacheEnabled)
-
disableReadCache
public MorphiumConfig disableReadCache()
-
enableReadCache
public MorphiumConfig enableReadCache()
-
isAsyncWritesEnabled
public boolean isAsyncWritesEnabled()
-
setAsyncWritesEnabled
public MorphiumConfig setAsyncWritesEnabled(boolean asyncWritesEnabled)
-
disableAsyncWrites
public MorphiumConfig disableAsyncWrites()
-
enableAsyncWrites
public MorphiumConfig enableAsyncWrites()
-
isBufferedWritesEnabled
public boolean isBufferedWritesEnabled()
-
setBufferedWritesEnabled
public MorphiumConfig setBufferedWritesEnabled(boolean bufferedWritesEnabled)
-
disableBufferedWrites
public MorphiumConfig disableBufferedWrites()
-
enableBufferedWrites
public MorphiumConfig enableBufferedWrites()
-
isAutoValuesEnabled
public boolean isAutoValuesEnabled()
-
setAutoValuesEnabled
public MorphiumConfig setAutoValuesEnabled(boolean enabled)
-
enableAutoValues
public MorphiumConfig enableAutoValues()
-
disableAutoValues
public MorphiumConfig disableAutoValues()
-
isCamelCaseConversionEnabled
public boolean isCamelCaseConversionEnabled()
-
setCamelCaseConversionEnabled
public MorphiumConfig setCamelCaseConversionEnabled(boolean camelCaseConversionEnabled)
-
getThreadPoolMessagingCoreSize
public int getThreadPoolMessagingCoreSize()
-
setThreadPoolMessagingCoreSize
public MorphiumConfig setThreadPoolMessagingCoreSize(int threadPoolMessagingCoreSize)
-
getThreadPoolMessagingMaxSize
public int getThreadPoolMessagingMaxSize()
-
setThreadPoolMessagingMaxSize
public MorphiumConfig setThreadPoolMessagingMaxSize(int threadPoolMessagingMaxSize)
-
getThreadPoolMessagingKeepAliveTime
public long getThreadPoolMessagingKeepAliveTime()
-
setThreadPoolMessagingKeepAliveTime
public MorphiumConfig setThreadPoolMessagingKeepAliveTime(long threadPoolMessagingKeepAliveTime)
-
getThreadPoolAsyncOpCoreSize
public int getThreadPoolAsyncOpCoreSize()
-
setThreadPoolAsyncOpCoreSize
public MorphiumConfig setThreadPoolAsyncOpCoreSize(int threadPoolAsyncOpCoreSize)
-
getThreadPoolAsyncOpMaxSize
public int getThreadPoolAsyncOpMaxSize()
-
setThreadPoolAsyncOpMaxSize
public MorphiumConfig setThreadPoolAsyncOpMaxSize(int threadPoolAsyncOpMaxSize)
-
getThreadPoolAsyncOpKeepAliveTime
public long getThreadPoolAsyncOpKeepAliveTime()
-
setThreadPoolAsyncOpKeepAliveTime
public MorphiumConfig setThreadPoolAsyncOpKeepAliveTime(long threadPoolAsyncOpKeepAliveTime)
-
isObjectSerializationEnabled
public boolean isObjectSerializationEnabled()
-
setObjectSerializationEnabled
public MorphiumConfig setObjectSerializationEnabled(boolean objectSerializationEnabled)
-
getHeartbeatFrequency
public int getHeartbeatFrequency()
-
setHeartbeatFrequency
public MorphiumConfig setHeartbeatFrequency(int heartbeatFrequency)
-
getMinConnectionsHost
public int getMinConnectionsHost()
-
setMinConnections
public MorphiumConfig setMinConnections(int minConnections)
-
getLocalThreshold
public int getLocalThreshold()
-
setLocalThreshold
public MorphiumConfig setLocalThreshold(int localThreshold)
Sets the local threshold. When choosing among multiple MongoDB servers to send a request, the MongoClient will only send that request to a server whose ping time is less than or equal to the server with the fastest ping time plus the local threshold.
For example, let's say that the client is choosing a server to send a query when the read preference is
ReadPreference.secondary(), and that there are three secondaries, server1, server2, and server3, whose ping times are 10, 15, and 16 milliseconds, respectively. With a local threshold of 5 milliseconds, the client will send the query to either server1 or server2 (randomly selecting between the two).Default is 15 milliseconds.
- Returns:
- the local threshold, in milliseconds
- Since:
- 2.13.0
-
getMaxConnectionIdleTime
public int getMaxConnectionIdleTime()
-
setMaxConnectionIdleTime
public MorphiumConfig setMaxConnectionIdleTime(int maxConnectionIdleTime)
-
getMaxConnectionLifeTime
public int getMaxConnectionLifeTime()
-
setMaxConnectionLifeTime
public MorphiumConfig setMaxConnectionLifeTime(int maxConnectionLifeTime)
-
getRequiredReplicaSetName
public String getRequiredReplicaSetName()
-
setRequiredReplicaSetName
public MorphiumConfig setRequiredReplicaSetName(String requiredReplicaSetName)
-
getDefaultTags
public String getDefaultTags()
-
addDefaultTag
public MorphiumConfig addDefaultTag(String name, String value)
-
getCursorBatchSize
public int getCursorBatchSize()
-
setCursorBatchSize
public MorphiumConfig setCursorBatchSize(int cursorBatchSize)
-
getSslContext
public SSLContext getSslContext()
-
setSslContext
public void setSslContext(SSLContext sslContext)
-
isUseSSL
public boolean isUseSSL()
-
setUseSSL
public void setUseSSL(boolean useSSL)
-
isSslInvalidHostNameAllowed
public boolean isSslInvalidHostNameAllowed()
-
setSslInvalidHostNameAllowed
public void setSslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed)
-
getReadTimeout
public int getReadTimeout()
-
setReadTimeout
public void setReadTimeout(int readTimeout)
-
isRetryReads
public boolean isRetryReads()
-
setRetryReads
public void setRetryReads(boolean retryReads)
-
isRetryWrites
public boolean isRetryWrites()
-
setRetryWrites
public void setRetryWrites(boolean retryWrites)
-
getUuidRepresentation
public String getUuidRepresentation()
-
setUuidRepresentation
public void setUuidRepresentation(String uuidRepresentation)
Sets the UUID representation to use when encoding instances ofUUIDand when decoding BSON binary values with subtype of 3.The default is UNSPECIFIED, If your application stores UUID values in MongoDB, you must set this value to the desired representation. New applications should prefer STANDARD, while existing Java applications should prefer JAVA_LEGACY. Applications wishing to interoperate with existing Python or .NET applications should prefer PYTHON_LEGACY or C_SHARP_LEGACY, respectively. Applications that do not store UUID values in MongoDB don't need to set this value.
- Parameters:
uuidRepresentation- the UUID representation- Since:
- 3.12
-
getIndexCheck
public MorphiumConfig.IndexCheck getIndexCheck()
-
setIndexCheck
public void setIndexCheck(MorphiumConfig.IndexCheck indexCheck)
-
getCappedCheck
public MorphiumConfig.CappedCheck getCappedCheck()
-
setCappedCheck
public MorphiumConfig setCappedCheck(MorphiumConfig.CappedCheck cappedCheck)
-
-