org.apache.hadoop.hbase.regionserver.compactions
Class CompactionRequest

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest
All Implemented Interfaces:
Comparable<CompactionRequest>, Runnable

public class CompactionRequest
extends Object
implements Comparable<CompactionRequest>, Runnable

This class holds all details necessary to run a compaction.


Nested Class Summary
static class CompactionRequest.CompactionState
          An enum for the region compaction state
static class CompactionRequest.Rejection
          Cleanup class to use when rejecting a compaction request from the queue.
 
Constructor Summary
CompactionRequest(HRegion r, Store s, CompactSelection files, boolean isMajor, int p)
           
CompactionRequest(HRegion region, Store store, int priority)
          Constructor for a custom compaction.
 
Method Summary
 int compareTo(CompactionRequest request)
          This function will define where in the priority queue the request will end up.
 void finishRequest()
           
static CompactionRequest.CompactionState getCompactionState(long regionId)
          Find out if a given region in compaction now.
 CompactSelection getCompactSelection()
          Gets the compact selection object for the request
 List<StoreFile> getFiles()
          Gets the StoreFiles for the request
 HRegion getHRegion()
          Gets the HRegion for the request
 int getPriority()
          Gets the priority for the request
static CompactionRequest getRequestForTesting(Store store, org.apache.hadoop.conf.Configuration conf, Collection<StoreFile> selection, boolean isMajor)
          Create a simple compaction request just for testing - this lets you specify everything you would need in the general case of testing compactions from an external perspective (e.g.
 long getSize()
          Gets the total size of all StoreFiles in compaction
 Store getStore()
          Gets the Store for the request
 boolean isMajor()
           
static void postRequest(CompactionRequest cr)
           
static void preRequest(CompactionRequest cr)
           
 void run()
           
 void setIsMajor(boolean isMajor)
          Specify if this compaction should be a major compaction based on the state of the store
 void setPriority(int p)
          Gets the priority for the request
 void setSelection(CompactSelection files)
          Set the files (and, implicitly, the size of the compaction based on those files)
 void setServer(HRegionServer hrs)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompactionRequest

public CompactionRequest(HRegion region,
                         Store store,
                         int priority)
Constructor for a custom compaction. Uses the setXXX methods to update the state of the compaction before being used. Uses the current system time on creation as the start time.

Parameters:
region - region that is being compacted
store - store which is being compacted
priority - specified priority with which this compaction should enter the queue.

CompactionRequest

public CompactionRequest(HRegion r,
                         Store s,
                         CompactSelection files,
                         boolean isMajor,
                         int p)
Method Detail

getRequestForTesting

public static CompactionRequest getRequestForTesting(Store store,
                                                     org.apache.hadoop.conf.Configuration conf,
                                                     Collection<StoreFile> selection,
                                                     boolean isMajor)
Create a simple compaction request just for testing - this lets you specify everything you would need in the general case of testing compactions from an external perspective (e.g. requesting a compaction through the HRegion).

Parameters:
store -
conf -
selection -
isMajor -
Returns:
a request that is useful in requesting compactions for testing

getCompactionState

public static CompactionRequest.CompactionState getCompactionState(long regionId)
Find out if a given region in compaction now.

Parameters:
regionId -
Returns:

preRequest

public static void preRequest(CompactionRequest cr)

postRequest

public static void postRequest(CompactionRequest cr)

finishRequest

public void finishRequest()

compareTo

public int compareTo(CompactionRequest request)
This function will define where in the priority queue the request will end up. Those with the highest priorities will be first. When the priorities are the same it will first compare priority then date to maintain a FIFO functionality.

Note: The date is only accurate to the millisecond which means it is possible that two requests were inserted into the queue within a millisecond. When that is the case this function will break the tie arbitrarily.

Specified by:
compareTo in interface Comparable<CompactionRequest>

getHRegion

public HRegion getHRegion()
Gets the HRegion for the request


getStore

public Store getStore()
Gets the Store for the request


getCompactSelection

public CompactSelection getCompactSelection()
Gets the compact selection object for the request


getFiles

public List<StoreFile> getFiles()
Gets the StoreFiles for the request


getSize

public long getSize()
Gets the total size of all StoreFiles in compaction


isMajor

public boolean isMajor()

getPriority

public int getPriority()
Gets the priority for the request


setPriority

public void setPriority(int p)
Gets the priority for the request


setServer

public void setServer(HRegionServer hrs)

setSelection

public void setSelection(CompactSelection files)
Set the files (and, implicitly, the size of the compaction based on those files)

Parameters:
files - files that should be included in the compaction

setIsMajor

public void setIsMajor(boolean isMajor)
Specify if this compaction should be a major compaction based on the state of the store

Parameters:
isMajor - true if the system determines that this compaction should be a major compaction

toString

public String toString()
Overrides:
toString in class Object

run

public void run()
Specified by:
run in interface Runnable


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.