001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2013-2015 ForgeRock AS
026 */
027package org.opends.server.loggers;
028
029import java.io.File;
030
031import org.opends.server.admin.std.server.LogRetentionPolicyCfg;
032import org.forgerock.opendj.config.server.ConfigException;
033import org.opends.server.types.DirectoryException;
034import org.opends.server.types.InitializationException;
035
036/**
037 * This interface describes the retention policy that should be used
038 * for the logger. Supported policies include number of files and
039 * disk utilization.
040 *
041 * @param <T> The type of retention policy configuration handled by
042 *            this retention policy implementation.
043 */
044public interface RetentionPolicy<T extends LogRetentionPolicyCfg>
045{
046  /**
047   * Initializes this log retention policy based on the
048   * information in the provided retention policy configuration.
049   *
050   * @param config
051   *          The retention policy configuration that contains the
052   *          information to use to initialize this policy.
053   * @throws ConfigException
054   *           If an unrecoverable problem arises in the process of
055   *           performing the initialization as a result of the server
056   *           configuration.
057   * @throws InitializationException
058   *           If a problem occurs during initialization that is not
059   *           related to the server configuration.
060   */
061  void initializeLogRetentionPolicy(T config)
062      throws ConfigException, InitializationException;
063
064  /**
065   * Returns all files that should be deleted according to the policy.
066   *
067   * @param fileNamingPolicy The naming policy used generate the log file
068   *                         names.
069   *
070   * @return An array of files that should be deleted according to the
071   *         policy or <code>null</code> if an error occurred while
072   *         obtaining the file list.
073   * @throws DirectoryException If an error occurs while obtaining a list
074   *                            of files to delete.
075   */
076  File[] deleteFiles(FileNamingPolicy fileNamingPolicy)
077      throws DirectoryException;
078}
079