Class Storage
- java.lang.Object
-
- one.microstream.storage.types.Storage
-
public final class Storage extends Object
Static utility class containing static pseudo-constructor methods (indicated by a capital first letter) and various utility methods.To setup and start a database, see the class "EmbeddedStorage".
- See Also:
Persistence,StorageChannel
-
-
Method Summary
-
-
-
Method Detail
-
DefaultFileSystem
public static NioFileSystem DefaultFileSystem()
-
defaultStorageDirectory
public static one.microstream.afs.types.ADirectory defaultStorageDirectory()
-
defaultStorageDirectory
public static one.microstream.afs.types.ADirectory defaultStorageDirectory(one.microstream.afs.types.AFileSystem fileSystem)
Returns the default storage directory in the current working directory and with a filename defined byStorageLiveFileProvider.Defaults.defaultStorageDirectory().- Parameters:
fileSystem- the file system to use- Returns:
- the default storage directory located in the current working directory.
-
FileProvider
public static final StorageLiveFileProvider FileProvider()
Creates a newStorageLiveFileProvider.For a detailed explanation see
StorageLiveFileProvider.New().- Returns:
- a new
StorageLiveFileProviderinstance. - See Also:
FileProvider(Path),StorageLiveFileProvider.New(),StorageLiveFileProvider.Builder,StorageLiveFileProvider.Defaults
-
FileProvider
public static final StorageLiveFileProvider FileProvider(Path storageDirectory)
Creates a newStorageLiveFileProvider.For a detailed explanation see
StorageLiveFileProvider.New(ADirectory).- Parameters:
storageDirectory- the directory where the storage will be located.- Returns:
- a new
StorageLiveFileProviderinstance. - See Also:
FileProvider(),StorageLiveFileProvider.New(ADirectory),StorageLiveFileProvider.Builder,StorageLiveFileProvider.Defaults
-
FileProvider
public static final StorageLiveFileProvider FileProvider(one.microstream.afs.types.ADirectory storageDirectory)
-
FileProviderBuilder
public static final StorageLiveFileProvider.Builder<?> FileProviderBuilder()
Creates a newStorageLiveFileProvider.Builder.For a detailed explanation see
StorageLiveFileProvider.Builder().- Returns:
- a new
StorageLiveFileProvider.Builderinstance. - See Also:
FileProvider(),FileProvider(Path),StorageLiveFileProvider.Builder
-
FileProviderBuilder
public static final StorageLiveFileProvider.Builder<?> FileProviderBuilder(one.microstream.afs.types.AFileSystem fileSystem)
Creates a newStorageLiveFileProvider.Builder.For a detailed explanation see
StorageLiveFileProvider.Builder(AFileSystem).- Parameters:
fileSystem- the file system to use- Returns:
- a new
StorageLiveFileProvider.Builderinstance. - See Also:
FileProvider(),FileProvider(Path),StorageLiveFileProvider.Builder
-
BackupFileProvider
public static final StorageBackupFileProvider BackupFileProvider()
-
BackupFileProvider
@Deprecated public static final StorageBackupFileProvider BackupFileProvider(File storageDirectory)
Deprecated.
-
BackupFileProvider
public static final StorageBackupFileProvider BackupFileProvider(Path storageDirectory)
-
BackupFileProvider
public static final StorageBackupFileProvider BackupFileProvider(one.microstream.afs.types.ADirectory storageDirectory)
-
BackupFileProviderBuilder
public static final StorageBackupFileProvider.Builder<?> BackupFileProviderBuilder()
-
BackupFileProviderBuilder
public static final StorageBackupFileProvider.Builder<?> BackupFileProviderBuilder(one.microstream.afs.types.AFileSystem fileSystem)
-
Configuration
public static final StorageConfiguration Configuration()
Creates a newStorageConfiguration.For a detailed explanation see
StorageConfiguration.New().- Returns:
- a new
StorageConfigurationinstance. - See Also:
Configuration(StorageLiveFileProvider),StorageConfiguration.New(),StorageConfiguration.Builder
-
Configuration
public static final StorageConfiguration Configuration(StorageLiveFileProvider fileProvider)
Creates a newStorageConfiguration.For a detailed explanation see
StorageConfiguration.New(StorageLiveFileProvider).- Parameters:
fileProvider- theStorageLiveFileProviderto provide directory and file names.- Returns:
- a new
StorageConfigurationinstance. - See Also:
Configuration(),StorageConfiguration.New(StorageLiveFileProvider),StorageConfiguration.Builder
-
ConfigurationBuilder
public static final StorageConfiguration.Builder<?> ConfigurationBuilder()
Creates a newStorageConfiguration.Builder.For a detailed explanation see
StorageConfiguration.Builder().- Returns:
- a new
StorageConfiguration.Builderinstance. - See Also:
Configuration(),Configuration(StorageLiveFileProvider),StorageConfiguration.Builder(),StorageConfiguration.Builder
-
HousekeepingController
public static final StorageHousekeepingController HousekeepingController()
Creates a newStorageHousekeepingController.For a detailed explanation see
StorageHousekeepingController.New().- Returns:
- a new
StorageHousekeepingControllerinstance. - See Also:
HousekeepingController(long, long),StorageHousekeepingController.New(),StorageHousekeepingController.Defaults
-
HousekeepingController
public static final StorageHousekeepingController HousekeepingController(long housekeepingIntervalMs, long housekeepingTimeBudgetNs)
Creates a newStorageHousekeepingController.For a detailed explanation see
StorageHousekeepingController.New(long, long).- Parameters:
housekeepingIntervalMs- the interval in milliseconds that the storage threads shall execute their various housekeeping actions (like cache clearing checks, file consolidation, etc.). Must be greater than zero.housekeepingTimeBudgetNs- the time budget in nanoseconds that each storage thread will use to perform a housekeeping action. This is a best effort value, not a strictly reliable border value. This means a housekeeping action can occasionally take slightly longer than specified here. Must be greater than zero.- Returns:
- a new
StorageHousekeepingControllerinstance. - See Also:
HousekeepingController(),StorageHousekeepingController.New(long, long)
-
EntityCacheEvaluator
public static final StorageEntityCacheEvaluator EntityCacheEvaluator()
Creates a newStorageEntityCacheEvaluator.For a detailed explanation see
StorageEntityCacheEvaluator.New().- Returns:
- a new
StorageEntityCacheEvaluatorinstance. - See Also:
EntityCacheEvaluator(long),EntityCacheEvaluator(long, long),StorageEntityCacheEvaluator.New()
-
EntityCacheEvaluator
public static final StorageEntityCacheEvaluator EntityCacheEvaluator(long timeoutMs)
Creates a newStorageEntityCacheEvaluator.For a detailed explanation see
StorageEntityCacheEvaluator.New(long).- Parameters:
timeoutMs- the time (in milliseconds, greater than 0) of not being read (the "age"), after which a particular entity's data will be cleared from the Storage's internal cache.- Returns:
- a new
StorageEntityCacheEvaluatorinstance. - Throws:
one.microstream.exceptions.NumberRangeException- if the passed value is equal to or lower than 0.- See Also:
EntityCacheEvaluator(),EntityCacheEvaluator(long, long),StorageEntityCacheEvaluator.New(long)
-
EntityCacheEvaluator
public static final StorageEntityCacheEvaluator EntityCacheEvaluator(long timeoutMs, long threshold)
Creates a newStorageEntityCacheEvaluator.For a detailed explanation see
StorageEntityCacheEvaluator.New(long, long).- Parameters:
timeoutMs- the time (in milliseconds, greater than 0) of not being read (the "age"), after which a particular entity's data will be cleared from the Storage's internal cache.threshold- an abstract value (greater than 0) to evaluate the product of size and age of an entity in relation to the current cache size in order to determine if the entity's data shall be cleared from the cache.- Returns:
- a new
StorageEntityCacheEvaluatorinstance. - Throws:
one.microstream.exceptions.NumberRangeException- if any of the passed values is equal to or lower than 0.- See Also:
EntityCacheEvaluator(),EntityCacheEvaluator(long),StorageEntityCacheEvaluator.New(long, long)
-
ChannelCountProvider
public static final StorageChannelCountProvider ChannelCountProvider()
Creates a newStorageChannelCountProvider.For a detailed explanation see
StorageChannelCountProvider.New().- Returns:
- a new
StorageChannelCountProviderinstance. - See Also:
ChannelCountProvider(int),StorageChannelCountProvider.New()
-
ChannelCountProvider
public static final StorageChannelCountProvider ChannelCountProvider(int channelCount)
Creates a newStorageChannelCountProvider.For a detailed explanation see
StorageChannelCountProvider.New(int).- Parameters:
channelCount- the number of channels. Must be a 2^n number with n greater than or equal 0.- Returns:
- a new
StorageChannelCountProviderinstance. - Throws:
IllegalArgumentException- if the passed value is higher than the value returned byStorageChannelCountProvider.Validation.maximumChannelCount()
-
DataFileEvaluator
public static final StorageDataFileEvaluator DataFileEvaluator()
Creates a newStorageDataFileEvaluator.For a detailed explanation see
StorageDataFileEvaluator.New().- Returns:
- a new
StorageDataFileEvaluatorinstance. - See Also:
DataFileEvaluator(int, int),DataFileEvaluator(int, int, double),StorageDataFileEvaluator.New()
-
DataFileEvaluator
public static final StorageDataFileEvaluator DataFileEvaluator(int fileMinimumSize, int fileMaximumSize)
Creates a newStorageDataFileEvaluator.For a detailed explanation see
StorageDataFileEvaluator.New(int, int).- Parameters:
fileMinimumSize- the minimum file size in bytes that a single storage file must have. Smaller files will be dissolved.fileMaximumSize- the maximum file size in bytes that a single storage file may have. Larger files will be dissolved.
Note that a file can exceed this limit if it contains a single entity that already exceeds the limit. E.g. an int array with 10 million elements would be about 40 MB in size and would exceed a file size limit of, for example, 30 MB.- Returns:
- a new
StorageDataFileEvaluatorinstance. - See Also:
DataFileEvaluator(),DataFileEvaluator(int, int, double),StorageDataFileEvaluator.New(int, int)
-
DataFileEvaluator
public static final StorageDataFileEvaluator DataFileEvaluator(int fileMinimumSize, int fileMaximumSize, double minimumUseRatio)
Creates a newStorageDataFileEvaluator.For a detailed explanation see
StorageDataFileEvaluator.New(int, int, double).- Parameters:
fileMinimumSize- the minimum file size in bytes that a single storage file must have. Smaller files will be dissolved.fileMaximumSize- the maximum file size in bytes that a single storage file may have. Larger files will be dissolved.
Note that a file can exceed this limit if it contains a single entity that already exceeds the limit. E.g. an int array with 10 million elements would be about 40 MB in size and would exceed a file size limit of, for example, 30 MB.minimumUseRatio- the ratio (value in ]0.0;1.0]) of non-gap data contained in a storage file to prevent the file from being dissolved. "Gap" data is anything that is not the latest version of an entity's data, inluding older versions of an entity and "comment" bytes (a sequence of bytes beginning with its length as a negative value length header).
The closer this value is to 1.0 (100%), the less disk space is occupied by storage files, but the more file dissolving (data transfers to new files) is required and vice versa.- Returns:
- a new
StorageDataFileEvaluatorinstance. - See Also:
DataFileEvaluator(),DataFileEvaluator(int, int),StorageDataFileEvaluator.New(int, int, double)
-
DataFileEvaluator
public static final StorageDataFileEvaluator DataFileEvaluator(int fileMinimumSize, int fileMaximumSize, double minimumUseRatio, boolean cleanUpHeadFile)
Creates a newStorageDataFileEvaluator.For a detailed explanation see
StorageDataFileEvaluator.New(int, int, double, boolean).- Parameters:
fileMinimumSize- the minimum file size in bytes that a single storage file must have. Smaller files will be dissolved.fileMaximumSize- the maximum file size in bytes that a single storage file may have. Larger files will be dissolved.
Note that a file can exceed this limit if it contains a single entity that already exceeds the limit. E.g. an int array with 10 million elements would be about 40 MB in size and would exceed a file size limit of, for example, 30 MB.minimumUseRatio- the ratio (value in ]0.0;1.0]) of non-gap data contained in a storage file to prevent the file from being dissolved. "Gap" data is anything that is not the latest version of an entity's data, including older versions of an entity and "comment" bytes (a sequence of bytes beginning with its length as a negative value length header).
The closer this value is to 1.0 (100%), the less disk space is occupied by storage files, but the more file dissolving (data transfers to new files) is required and vice versa.cleanUpHeadFile- a flag defining wether the current head file (the only file actively written to) shall be subjected to file cleanups as well.- Returns:
- a new
StorageDataFileEvaluatorinstance. - See Also:
DataFileEvaluator(),DataFileEvaluator(int, int),DataFileEvaluator(int, int, double),StorageDataFileEvaluator.New(int, int, double, boolean)
-
BackupSetup
public static final StorageBackupSetup BackupSetup(Path backupDirectory)
Creates a newStorageBackupSetup.For a detailed explanation see
StorageBackupSetup.New(ADirectory).- Parameters:
backupDirectory- the directory where the backup shall be located.- Returns:
- a new
StorageBackupSetupinstance. - See Also:
StorageBackupSetup.New(StorageBackupFileProvider),StorageBackupHandler
-
BackupSetup
public static final StorageBackupSetup BackupSetup(one.microstream.afs.types.ADirectory backupDirectory)
Creates a newStorageBackupSetup.For a detailed explanation see
StorageBackupSetup.New(ADirectory).- Parameters:
backupDirectory- the directory where the backup shall be located.- Returns:
- a new
StorageBackupSetupinstance. - See Also:
StorageBackupSetup.New(ADirectory),StorageBackupHandler
-
BackupSetup
public static final StorageBackupSetup BackupSetup(String backupDirectoryPath)
Creates a newStorageBackupSetup.For a detailed explanation see
StorageBackupSetup.New(ADirectory).- Parameters:
backupDirectoryPath- the directory where the backup shall be located.- Returns:
- a new
StorageBackupSetupinstance. - See Also:
StorageBackupSetup.New(ADirectory),StorageBackupSetup.New(StorageBackupFileProvider),StorageBackupHandler
-
BackupSetup
public static final StorageBackupSetup BackupSetup(StorageBackupFileProvider backupFileProvider)
Creates a newStorageBackupSetup.For a detailed explanation see
StorageBackupSetup.New(StorageBackupFileProvider).- Parameters:
backupFileProvider- theStorageBackupFileProviderto define where the backup files will be located.- Returns:
- a new
StorageBackupSetupinstance. - See Also:
StorageBackupSetup.New(StorageBackupFileProvider),StorageBackupHandler
-
LockFileSetupProvider
public static StorageLockFileSetup.Provider LockFileSetupProvider()
Creates a newStorageLockFileSetup.Provider.For a detailed explanation see
StorageLockFileSetup.Provider().- Returns:
- a new
StorageLockFileSetup.Providerinstance. - See Also:
StorageLockFileSetup,LockFileSetupProvider(Charset),LockFileSetupProvider(long),LockFileSetupProvider(Charset, long)
-
LockFileSetupProvider
public static StorageLockFileSetup.Provider LockFileSetupProvider(Charset charset)
Creates a newStorageLockFileSetup.Provider.For a detailed explanation see
StorageLockFileSetup.Provider(Charset).- Parameters:
charset- theCharsetto be used for the lock file content.- Returns:
- a new
StorageLockFileSetup.Providerinstance. - See Also:
StorageLockFileSetup,LockFileSetupProvider(),LockFileSetupProvider(long),LockFileSetupProvider(Charset, long)
-
LockFileSetupProvider
public static StorageLockFileSetup.Provider LockFileSetupProvider(long updateInterval)
Creates a newStorageLockFileSetup.Provider.For a detailed explanation see
StorageLockFileSetup.Provider(long).- Parameters:
updateInterval- the update interval in ms.- Returns:
- a new
StorageLockFileSetup.Providerinstance. - See Also:
StorageLockFileSetup,LockFileSetupProvider(),LockFileSetupProvider(Charset),LockFileSetupProvider(Charset, long)
-
LockFileSetupProvider
public static StorageLockFileSetup.Provider LockFileSetupProvider(Charset charset, long updateInterval)
Creates a newStorageLockFileSetup.Provider.For a detailed explanation see
StorageLockFileSetup.Provider(Charset, long).- Parameters:
charset- theCharsetto be used for the lock file content.updateInterval- the update interval in ms.- Returns:
- a new
StorageLockFileSetup.Providerinstance. - See Also:
StorageLockFileSetup,LockFileSetupProvider(),LockFileSetupProvider(Charset),LockFileSetupProvider(long)
-
consolidate
public static final <C extends StorageConnection> C consolidate(C storageConnection, StorageEntityCacheEvaluator entityEvaluator)
Consolidates the storage system represented by the passedStorageConnectionby calling
StorageConnection.issueFullGarbageCollection()
StorageConnection.issueFullFileCheck()
StorageConnection.issueFullCacheCheck(StorageEntityCacheEvaluator)
in that order.Depending on the passed functions, this call can do anything from cleaning/optimizing the storage a little to fully reorganize/optimize the storage files, clear the complete cache and making the storage virtually dormant until the next store.
- Type Parameters:
C- the storage connection type- Parameters:
storageConnection- The connection to the storage that shall be consolidated.entityEvaluator- The function evaluating whether to clear an entity from the cache.
May be null to indicate the use of the live configuration as a default.- Returns:
- the passed storageConnection instance.
-
consolidate
public static final <C extends StorageConnection> C consolidate(C storageConnection)
Callsconsolidate(StorageConnection, StorageEntityCacheEvaluator)with null as additional parameters (causing live configuration to be used instead).- Type Parameters:
C- the storage connection type- Parameters:
storageConnection- The connection to the storage that shall be consolidated.- Returns:
- the passed storageConnection instance.
-
-