Skip to content

Commit

Permalink
HBASE-24827 BackPort HBASE-11554 Remove Reusable poolmap Rpc client t…
Browse files Browse the repository at this point in the history
…ype. (#2208)

Co-authored-by: niuyulin <[email protected]>
Signed-off-by: stack <[email protected]>
  • Loading branch information
2 people authored and busbey committed Aug 12, 2020
1 parent b9c415a commit 8646ac1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ protected interface Pool<R> {
}

public enum PoolType {
Reusable, ThreadLocal, RoundRobin;
ThreadLocal, RoundRobin;

public static PoolType valueOf(String poolTypeName,
PoolType defaultPoolType, PoolType... allowedPoolTypes) {
Expand Down Expand Up @@ -270,8 +270,6 @@ public static PoolType fuzzyMatch(String name) {

protected Pool<V> createPool() {
switch (poolType) {
case Reusable:
return new ReusablePool<>(poolMaxSize);
case RoundRobin:
return new RoundRobinPool<>(poolMaxSize);
case ThreadLocal:
Expand All @@ -280,51 +278,6 @@ protected Pool<V> createPool() {
return null;
}

/**
* The <code>ReusablePool</code> represents a {@link PoolMap.Pool} that builds
* on the {@link java.util.LinkedList} class. It essentially allows resources to be
* checked out, at which point it is removed from this pool. When the resource
* is no longer required, it should be returned to the pool in order to be
* reused.
*
* <p>
* If {@link #maxSize} is set to {@link Integer#MAX_VALUE}, then the size of
* the pool is unbounded. Otherwise, it caps the number of consumers that can
* check out a resource from this pool to the (non-zero positive) value
* specified in {@link #maxSize}.
* </p>
*
* @param <R>
* the type of the resource
*/
@SuppressWarnings("serial")
public static class ReusablePool<R> extends ConcurrentLinkedQueue<R> implements Pool<R> {
private int maxSize;

public ReusablePool(int maxSize) {
this.maxSize = maxSize;

}

@Override
public R get() {
return poll();
}

@Override
public R put(R resource) {
if (super.size() < maxSize) {
add(resource);
}
return null;
}

@Override
public Collection<R> values() {
return this;
}
}

/**
* The <code>RoundRobinPool</code> represents a {@link PoolMap.Pool}, which
* stores its resources in an {@link ArrayList}. It load-balances access to
Expand Down

This file was deleted.

0 comments on commit 8646ac1

Please sign in to comment.