View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.regionserver;
20  
21  import java.io.IOException;
22  import java.util.List;
23  
24  import org.apache.hadoop.hbase.classification.InterfaceAudience;
25  import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
26  import org.apache.hadoop.hbase.util.Pair;
27  
28  @InterfaceAudience.Private
29  public interface CompactionRequestor {
30    /**
31     * @param r Region to compact
32     * @param why Why compaction was requested -- used in debug messages
33     * @return The created {@link CompactionRequest CompactionRequests} or an empty list if no
34     *         compactions were started
35     * @throws IOException
36     */
37    List<CompactionRequest> requestCompaction(final HRegion r, final String why)
38        throws IOException;
39  
40    /**
41     * @param r Region to compact
42     * @param why Why compaction was requested -- used in debug messages
43     * @param requests custom compaction requests. Each compaction must specify the store on which it
44     *          is acting. Can be <tt>null</tt> in which case a compaction will be attempted on all
45     *          stores for the region.
46     * @return The created {@link CompactionRequest CompactionRequests} or an empty list if no
47     *         compactions were started
48     * @throws IOException
49     */
50    List<CompactionRequest> requestCompaction(
51      final HRegion r, final String why, List<Pair<CompactionRequest, Store>> requests
52    )
53        throws IOException;
54  
55    /**
56     * @param r Region to compact
57     * @param s Store within region to compact
58     * @param why Why compaction was requested -- used in debug messages
59     * @param request custom compaction request for the {@link HRegion} and {@link Store}. Custom
60     *          request must be <tt>null</tt> or be constructed with matching region and store.
61     * @return The created {@link CompactionRequest} or <tt>null</tt> if no compaction was started.
62     * @throws IOException
63     */
64    CompactionRequest requestCompaction(
65      final HRegion r, final Store s, final String why, CompactionRequest request
66    ) throws IOException;
67  
68    /**
69     * @param r Region to compact
70     * @param why Why compaction was requested -- used in debug messages
71     * @param pri Priority of this compaction. minHeap. <=0 is critical
72     * @param requests custom compaction requests. Each compaction must specify the store on which it
73     *          is acting. Can be <tt>null</tt> in which case a compaction will be attempted on all
74     *          stores for the region.
75     * @return The created {@link CompactionRequest CompactionRequests} or an empty list if no
76     *         compactions were started.
77     * @throws IOException
78     */
79    List<CompactionRequest> requestCompaction(
80      final HRegion r, final String why, int pri, List<Pair<CompactionRequest, Store>> requests
81    ) throws IOException;
82  
83    /**
84     * @param r Region to compact
85     * @param s Store within region to compact
86     * @param why Why compaction was requested -- used in debug messages
87     * @param pri Priority of this compaction. minHeap. <=0 is critical
88     * @param request custom compaction request to run. {@link Store} and {@link HRegion} for the
89     *          request must match the region and store specified here.
90     * @return The created {@link CompactionRequest} or <tt>null</tt> if no compaction was started
91     * @throws IOException
92     */
93    CompactionRequest requestCompaction(
94      final HRegion r, final Store s, final String why, int pri, CompactionRequest request
95    ) throws IOException;
96  }