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.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 public 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 public List<CompactionRequest> requestCompaction(final HRegion r, final String why, 51 List<Pair<CompactionRequest, Store>> requests) 52 throws IOException; 53 54 /** 55 * @param r Region to compact 56 * @param s Store within region to compact 57 * @param why Why compaction was requested -- used in debug messages 58 * @param request custom compaction request for the {@link HRegion} and {@link Store}. Custom 59 * request must be <tt>null</tt> or be constructed with matching region and store. 60 * @return The created {@link CompactionRequest} or <tt>null</tt> if no compaction was started. 61 * @throws IOException 62 */ 63 public CompactionRequest requestCompaction(final HRegion r, final Store s, final String why, 64 CompactionRequest request) throws IOException; 65 66 /** 67 * @param r Region to compact 68 * @param why Why compaction was requested -- used in debug messages 69 * @param pri Priority of this compaction. minHeap. <=0 is critical 70 * @param requests custom compaction requests. Each compaction must specify the store on which it 71 * is acting. Can be <tt>null</tt> in which case a compaction will be attempted on all 72 * stores for the region. 73 * @return The created {@link CompactionRequest CompactionRequests} or an empty list if no 74 * compactions were started. 75 * @throws IOException 76 */ 77 public List<CompactionRequest> requestCompaction(final HRegion r, final String why, int pri, 78 List<Pair<CompactionRequest, Store>> requests) throws IOException; 79 80 /** 81 * @param r Region to compact 82 * @param s Store within region to compact 83 * @param why Why compaction was requested -- used in debug messages 84 * @param pri Priority of this compaction. minHeap. <=0 is critical 85 * @param request custom compaction request to run. {@link Store} and {@link HRegion} for the 86 * request must match the region and store specified here. 87 * @return The created {@link CompactionRequest} or <tt>null</tt> if no compaction was started 88 * @throws IOException 89 */ 90 public CompactionRequest requestCompaction(final HRegion r, final Store s, final String why, 91 int pri, CompactionRequest request) throws IOException; 92 }