View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.master.cleaner;
19  
20  import org.apache.hadoop.classification.InterfaceAudience;
21  import org.apache.hadoop.fs.FileStatus;
22  import org.apache.hadoop.fs.Path;
23  import org.apache.hadoop.hbase.BaseConfigurable;
24  
25  /**
26   * Base class for the log cleaning function inside the master. By default, two
27   * cleaners: <code>TimeToLiveLogCleaner</code> and
28   * <code>ReplicationLogCleaner</code> are called in order. So if other effects
29   * are needed, implement your own LogCleanerDelegate and add it to the
30   * configuration "hbase.master.logcleaner.plugins", which is a comma-separated
31   * list of fully qualified class names. LogsCleaner will add it to the chain.
32   * <p>
33   * HBase ships with LogsCleaner as the default implementation.
34   * <p>
35   * This interface extends Configurable, so setConf needs to be called once
36   * before using the cleaner. Since LogCleanerDelegates are created in
37   * LogsCleaner by reflection. Classes that implements this interface should
38   * provide a default constructor.
39   */
40  @InterfaceAudience.Private
41  public abstract class BaseLogCleanerDelegate extends BaseConfigurable implements FileCleanerDelegate {
42  
43    @Override
44    public boolean isFileDeletable(FileStatus fStat) {
45      return isLogDeletable(fStat);
46    }
47  
48    /**
49     * Should the master delete the log or keep it?
50     * <p>
51     * Implementing classes should override {@link #isFileDeletable(FileStatus)} instead.
52     * @param fStat file status of the file
53     * @return true if the log is deletable, false (default) if not
54     */
55    @Deprecated
56    public boolean isLogDeletable(FileStatus fStat) {
57      return false;
58    }
59  }