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