001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master.cleaner; 019 020import java.util.Map; 021 022import org.apache.hadoop.fs.Path; 023import org.apache.hadoop.conf.Configurable; 024import org.apache.hadoop.fs.FileStatus; 025import org.apache.hadoop.hbase.Stoppable; 026import org.apache.yetus.audience.InterfaceAudience; 027 028/** 029 * General interface for cleaning files from a folder (generally an archive or 030 * backup folder). These are chained via the {@link CleanerChore} to determine 031 * if a given file should be deleted. 032 */ 033@InterfaceAudience.Private 034public interface FileCleanerDelegate extends Configurable, Stoppable { 035 036 /** 037 * Determines which of the given files are safe to delete 038 * @param files files to check for deletion 039 * @return files that are ok to delete according to this cleaner 040 */ 041 Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files); 042 043 044 /** 045 * this method is used to pass some instance into subclass 046 * */ 047 void init(Map<String, Object> params); 048 049 /** 050 * Used to do some initialize work before every period clean 051 */ 052 default void preClean() { 053 } 054 055 /** 056 * Check if a empty directory with no subdirs or subfiles can be deleted 057 * @param dir Path of the directory 058 * @return True if the directory can be deleted, otherwise false 059 */ 060 default boolean isEmptyDirDeletable(Path dir) { 061 return true; 062 } 063}