Zero or more log files will be cleaned as necessary to bring the disk space utilization of the environment above the configured minimum utilization threshold. The threshold is determined by the {@link EnvironmentConfig#CLEANER_MIN_UTILIZATION} configuration setting.
Note that cleanLog
does not perform the complete task of cleaning a log file. Eviction and checkpointing migrate records that are marked by the cleaner, and a full checkpoint is necessary following cleaning before cleaned files will be deleted (or renamed). Checkpoints normally occur periodically and when the environment is closed.
This is an optional action for the application since this activity is, by default, handled by one or more database environment owned background threads.
There are two intended use cases for the cleanLog
method. The first case is where the application wishes to disable the built-in cleaner threads using the {@link EnvironmentConfig#ENV_RUN_CLEANER} property. To replace thefunctionality of the cleaner threads, the application should call cleanLog
periodically.
In the second use case, "batch cleaning", the application disables the cleaner threads for maximum performance during active periods, and calls cleanLog
during periods when the application is quiescent or less active than usual. If the cleaner has a large number of files to clean, cleanLog
may stop without reaching the target utilization; to ensure that the target utilization is reached, cleanLog
should be called in a loop until it returns zero. And to complete the work of cleaning, a checkpoint is necessary. An example of performing batch cleaning follows.
Environment env; boolean anyCleaned = false; while (env.cleanLog() > 0) { anyCleaned = true; } if (anyCleaned) { CheckpointConfig force = new CheckpointConfig(); force.setForce(true); env.checkpoint(force); }
WARNING:If batch cleaning (shown above) is performed immediately before closing the environment, then the built-in cleaner threads should normally be disabled using {@link EnvironmentConfig#ENV_RUN_CLEANER} during the batch cleaning process.If the built-in cleaner threads are actively working on one or more log files, then those files will not be processed by the {@code cleanLog}method. Closing the environment will abort the work being done by the built-in cleaner threads, and log cleaning may be incomplete.
@return The number of log files that were cleaned, and that will bedeleted (or renamed) when a qualifying checkpoint occurs. @throws EnvironmentFailureException if an unexpected, internal orenvironment-wide failure occurs. @throws UnsupportedOperationException if this is a read-only ormemory-only environment. @throws IllegalStateException if this handle or the underlyingenvironment has been closed.
|
|
|
|
|
|
|
|
|
|
|
|