View Javadoc

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