org.opends.server.loggers
Class FileNumberRetentionPolicy

java.lang.Object
  extended by org.opends.server.loggers.FileNumberRetentionPolicy
All Implemented Interfaces:
ConfigurationChangeListener<FileCountLogRetentionPolicyCfg>, RetentionPolicy<FileCountLogRetentionPolicyCfg>

public class FileNumberRetentionPolicy
extends java.lang.Object
implements RetentionPolicy<FileCountLogRetentionPolicyCfg>, ConfigurationChangeListener<FileCountLogRetentionPolicyCfg>

This class implements a retention policy based on the number of files. Files will be cleaned up based on the number of files on disk.


Constructor Summary
FileNumberRetentionPolicy()
           
 
Method Summary
 ConfigChangeResult applyConfigurationChange(FileCountLogRetentionPolicyCfg config)
          Applies the configuration changes to this change listener.
 java.io.File[] deleteFiles(FileNamingPolicy fileNamingPolicy)
          Returns all files that should be deleted according to the policy.
 void initializeLogRetentionPolicy(FileCountLogRetentionPolicyCfg config)
          Initializes this log retention policy based on the information in the provided retention policy configuration.
 boolean isConfigurationChangeAcceptable(FileCountLogRetentionPolicyCfg config, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileNumberRetentionPolicy

public FileNumberRetentionPolicy()
Method Detail

initializeLogRetentionPolicy

public void initializeLogRetentionPolicy(FileCountLogRetentionPolicyCfg config)
Initializes this log retention policy based on the information in the provided retention policy configuration.

Specified by:
initializeLogRetentionPolicy in interface RetentionPolicy<FileCountLogRetentionPolicyCfg>
Parameters:
config - The retention policy configuration that contains the information to use to initialize this policy.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(FileCountLogRetentionPolicyCfg config,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<FileCountLogRetentionPolicyCfg>
Parameters:
config - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(FileCountLogRetentionPolicyCfg config)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<FileCountLogRetentionPolicyCfg>
Parameters:
config - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.

deleteFiles

public java.io.File[] deleteFiles(FileNamingPolicy fileNamingPolicy)
                           throws DirectoryException
Returns all files that should be deleted according to the policy.

Specified by:
deleteFiles in interface RetentionPolicy<FileCountLogRetentionPolicyCfg>
Parameters:
fileNamingPolicy - The naming policy used generate the log file names.
Returns:
An array of files that should be deleted according to the policy or null if an error occured while obtaining the file list.
Throws:
DirectoryException - If an error occurs while obtaining a list of files to delete.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object