org.apache.hadoop.hbase.regionserver
Class PriorityCompactionQueue

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue
All Implemented Interfaces:
java.lang.Iterable<HRegion>, java.util.Collection<HRegion>, java.util.concurrent.BlockingQueue<HRegion>, java.util.Queue<HRegion>

public class PriorityCompactionQueue
extends java.lang.Object
implements java.util.concurrent.BlockingQueue<HRegion>

This class delegates to the BlockingQueue but wraps all HRegions in compaction requests that hold the priority and the date requested. Implementation Note: With an elevation time of -1 there is the potential for starvation of the lower priority compaction requests as long as there is a constant stream of high priority requests.


Field Summary
protected  java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest> queue
          The actual blocking queue we delegate to
 
Constructor Summary
PriorityCompactionQueue()
          Creates a new PriorityCompactionQueue with no priority elevation time
 
Method Summary
 boolean add(HRegion e)
           
 boolean add(HRegion e, int p)
           
 boolean addAll(java.util.Collection<? extends HRegion> c)
           
protected  org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest addToRegionsInQueue(HRegion r, int p)
          If the region is not already in the queue it will add it and return a new compaction request object.
 void clear()
           
 boolean contains(java.lang.Object r)
           
 boolean containsAll(java.util.Collection<?> c)
           
 int drainTo(java.util.Collection<? super HRegion> c)
           
 int drainTo(java.util.Collection<? super HRegion> c, int maxElements)
           
 HRegion element()
           
 boolean isEmpty()
           
 java.util.Iterator<HRegion> iterator()
           
 boolean offer(HRegion e)
           
 boolean offer(HRegion e, int p)
           
 boolean offer(HRegion e, int p, long timeout, java.util.concurrent.TimeUnit unit)
           
 boolean offer(HRegion e, long timeout, java.util.concurrent.TimeUnit unit)
           
 HRegion peek()
           
 HRegion poll()
           
 HRegion poll(long timeout, java.util.concurrent.TimeUnit unit)
           
 void put(HRegion e)
           
 void put(HRegion e, int p)
           
 int remainingCapacity()
           
 HRegion remove()
           
 boolean remove(java.lang.Object r)
           
 boolean removeAll(java.util.Collection<?> c)
           
protected  org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest removeFromRegionsInQueue(org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest remove)
          Removes the request from the regions in queue
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 HRegion take()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

queue

protected final java.util.concurrent.BlockingQueue<org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest> queue
The actual blocking queue we delegate to

Constructor Detail

PriorityCompactionQueue

public PriorityCompactionQueue()
Creates a new PriorityCompactionQueue with no priority elevation time

Method Detail

addToRegionsInQueue

protected org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest addToRegionsInQueue(HRegion r,
                                                                                                             int p)
If the region is not already in the queue it will add it and return a new compaction request object. If it is already present in the queue then it will return null.

Parameters:
p - If null it will use the default priority
Returns:
returns a compaction request if it isn't already in the queue

removeFromRegionsInQueue

protected org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest removeFromRegionsInQueue(org.apache.hadoop.hbase.regionserver.PriorityCompactionQueue.CompactionRequest remove)
Removes the request from the regions in queue

Parameters:
remove -

add

public boolean add(HRegion e,
                   int p)

add

public boolean add(HRegion e)
Specified by:
add in interface java.util.Collection<HRegion>
Specified by:
add in interface java.util.concurrent.BlockingQueue<HRegion>
Specified by:
add in interface java.util.Queue<HRegion>

offer

public boolean offer(HRegion e,
                     int p)

offer

public boolean offer(HRegion e)
Specified by:
offer in interface java.util.concurrent.BlockingQueue<HRegion>
Specified by:
offer in interface java.util.Queue<HRegion>

put

public void put(HRegion e,
                int p)
         throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

put

public void put(HRegion e)
         throws java.lang.InterruptedException
Specified by:
put in interface java.util.concurrent.BlockingQueue<HRegion>
Throws:
java.lang.InterruptedException

offer

public boolean offer(HRegion e,
                     int p,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

offer

public boolean offer(HRegion e,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Specified by:
offer in interface java.util.concurrent.BlockingQueue<HRegion>
Throws:
java.lang.InterruptedException

take

public HRegion take()
             throws java.lang.InterruptedException
Specified by:
take in interface java.util.concurrent.BlockingQueue<HRegion>
Throws:
java.lang.InterruptedException

poll

public HRegion poll(long timeout,
                    java.util.concurrent.TimeUnit unit)
             throws java.lang.InterruptedException
Specified by:
poll in interface java.util.concurrent.BlockingQueue<HRegion>
Throws:
java.lang.InterruptedException

remove

public boolean remove(java.lang.Object r)
Specified by:
remove in interface java.util.Collection<HRegion>
Specified by:
remove in interface java.util.concurrent.BlockingQueue<HRegion>

remove

public HRegion remove()
Specified by:
remove in interface java.util.Queue<HRegion>

poll

public HRegion poll()
Specified by:
poll in interface java.util.Queue<HRegion>

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<HRegion>

contains

public boolean contains(java.lang.Object r)
Specified by:
contains in interface java.util.Collection<HRegion>
Specified by:
contains in interface java.util.concurrent.BlockingQueue<HRegion>

element

public HRegion element()
Specified by:
element in interface java.util.Queue<HRegion>

peek

public HRegion peek()
Specified by:
peek in interface java.util.Queue<HRegion>

size

public int size()
Specified by:
size in interface java.util.Collection<HRegion>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<HRegion>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<HRegion>

iterator

public java.util.Iterator<HRegion> iterator()
Specified by:
iterator in interface java.lang.Iterable<HRegion>
Specified by:
iterator in interface java.util.Collection<HRegion>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<HRegion>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<HRegion>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<HRegion>

addAll

public boolean addAll(java.util.Collection<? extends HRegion> c)
Specified by:
addAll in interface java.util.Collection<HRegion>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<HRegion>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<HRegion>

drainTo

public int drainTo(java.util.Collection<? super HRegion> c)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<HRegion>

drainTo

public int drainTo(java.util.Collection<? super HRegion> c,
                   int maxElements)
Specified by:
drainTo in interface java.util.concurrent.BlockingQueue<HRegion>


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