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; 021import org.apache.hadoop.conf.Configurable; 022import org.apache.hadoop.fs.FileStatus; 023import org.apache.hadoop.fs.Path; 024import org.apache.hadoop.hbase.Stoppable; 025import org.apache.yetus.audience.InterfaceAudience; 026 027/** 028 * General interface for cleaning files from a folder (generally an archive or backup folder). These 029 * are chained via the {@link CleanerChore} to determine if a given file should be deleted. 030 */ 031@InterfaceAudience.Private 032public interface FileCleanerDelegate extends Configurable, Stoppable { 033 034 /** 035 * Determines which of the given files are safe to delete 036 * @param files files to check for deletion 037 * @return files that are ok to delete according to this cleaner 038 */ 039 Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files); 040 041 /** 042 * this method is used to pass some instance into subclass 043 */ 044 void init(Map<String, Object> params); 045 046 /** 047 * Used to do some initialize work before every period clean 048 */ 049 default void preClean() { 050 } 051 052 /** 053 * Used to do some cleanup work 054 */ 055 default void postClean() { 056 } 057 058 /** 059 * Check if a empty directory with no subdirs or subfiles can be deleted 060 * @param dir Path of the directory 061 * @return True if the directory can be deleted, otherwise false 062 */ 063 default boolean isEmptyDirDeletable(Path dir) { 064 return true; 065 } 066}