blob: 8070a690072ea56776cb9659e002547d053ac9a2 [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (17) -->
<title>ByteBuffAllocator (Apache HBase 4.0.0-alpha-1-SNAPSHOT API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: package: org.apache.hadoop.hbase.io, class: ByteBuffAllocator">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-3.6.1.min.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var evenRowColor = "even-row-color";
var oddRowColor = "odd-row-color";
var tableTab = "table-tab";
var activeTableTab = "active-table-tab";
var pathtoroot = "../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top">
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="class-use/ByteBuffAllocator.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html#class">Help</a></li>
</ul>
</div>
<div class="sub-nav">
<div>
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li><a href="#nested-class-summary">Nested</a>&nbsp;|&nbsp;</li>
<li><a href="#field-summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor-summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li><a href="#field-detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor-detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><label for="search-input">SEARCH:</label>
<input type="text" id="search-input" value="search" disabled="disabled">
<input type="reset" id="reset-button" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.hadoop.hbase.io</a></div>
<h1 title="Class ByteBuffAllocator" class="title">Class ByteBuffAllocator</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">org.apache.hadoop.hbase.io.ByteBuffAllocator</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="DeallocateRewriteByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">DeallocateRewriteByteBuffAllocator</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="annotations">@Private
</span><span class="modifiers">public class </span><span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-55">ByteBuffAllocator</a></span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span></div>
<div class="block">ByteBuffAllocator is a nio ByteBuffer pool. It returns <a href="../nio/ByteBuff.html" title="class in org.apache.hadoop.hbase.nio"><code>ByteBuff</code></a>s which are wrappers of
offheap <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link"><code>ByteBuffer</code></a> usually. If we are sure that the returned ByteBuffs have reached the
end of their life cycle, we must call <a href="../nio/ByteBuff.html#release()"><code>ByteBuff.release()</code></a> to return buffers to the pool
otherwise the pool will leak. If the desired memory size is larger than what the ByteBufferPool
has available, we'll downgrade to allocate ByteBuffers from the heap. Increase the ByteBufferPool
size if detect this case.<br/>
<br/>
For better memory/pool utilization, there is a lower bound named
<code>minSizeForReservoirUse</code> in this allocator, and if the desired size is less than
<code>minSizeForReservoirUse</code>, the allocator will just allocate the ByteBuffer from heap
and let the JVM manage memory, because it better to not waste pool slots allocating a single
fixed-size ByteBuffer for a small object.<br/>
<br/>
This pool can be used anywhere it makes sense managing memory. Currently used at least by RPC.</div>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<li>
<section class="nested-class-summary" id="nested-class-summary">
<h2>Nested Class Summary</h2>
<div class="caption"><span>Nested Classes</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Class</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>static interface&nbsp;</code></div>
<div class="col-second even-row-color"><code><a href="ByteBuffAllocator.Recycler.html" class="type-name-link" title="interface in org.apache.hadoop.hbase.io">ByteBuffAllocator.Recycler</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
</div>
</section>
</li>
<!-- =========== FIELD SUMMARY =========== -->
<li>
<section class="field-summary" id="field-summary">
<h2>Field Summary</h2>
<div class="caption"><span>Fields</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Field</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color"><code><a href="#ALLOCATOR_POOL_ENABLED_KEY" class="member-name-link">ALLOCATOR_POOL_ENABLED_KEY</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second odd-row-color"><code><a href="#BUFFER_SIZE_KEY" class="member-name-link">BUFFER_SIZE_KEY</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Queue.html" title="class or interface in java.util" class="external-link">Queue</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a>&gt;</code></div>
<div class="col-second even-row-color"><code><a href="#buffers" class="member-name-link">buffers</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>protected final int</code></div>
<div class="col-second odd-row-color"><code><a href="#bufSize" class="member-name-link">bufSize</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color"><code><a href="#BYTEBUFF_ALLOCATOR_CLASS" class="member-name-link">BYTEBUFF_ALLOCATOR_CLASS</a></code></div>
<div class="col-last even-row-color">
<div class="block">Set an alternate bytebuffallocator by setting this config, e.g.</div>
</div>
<div class="col-first odd-row-color"><code>static final int</code></div>
<div class="col-second odd-row-color"><code><a href="#DEFAULT_BUFFER_SIZE" class="member-name-link">DEFAULT_BUFFER_SIZE</a></code></div>
<div class="col-last odd-row-color">
<div class="block">There're some reasons why better to choose 65KB(rather than 64KB) as the default buffer size:</div>
</div>
<div class="col-first even-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color"><code><a href="#DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY" class="member-name-link">DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY</a></code></div>
<div class="col-last even-row-color">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0.</div>
</div>
</div>
<div class="col-first odd-row-color"><code>(package private) static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second odd-row-color"><code><a href="#DEPRECATED_BUFFER_SIZE_KEY" class="member-name-link">DEPRECATED_BUFFER_SIZE_KEY</a></code></div>
<div class="col-last odd-row-color">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0.</div>
</div>
</div>
<div class="col-first even-row-color"><code>(package private) static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color"><code><a href="#DEPRECATED_MAX_BUFFER_COUNT_KEY" class="member-name-link">DEPRECATED_MAX_BUFFER_COUNT_KEY</a></code></div>
<div class="col-last even-row-color">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0.</div>
</div>
</div>
<div class="col-first odd-row-color"><code>static final <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></code></div>
<div class="col-second odd-row-color"><code><a href="#HEAP" class="member-name-link">HEAP</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/LongAdder.html" title="class or interface in java.util.concurrent.atomic" class="external-link">LongAdder</a></code></div>
<div class="col-second even-row-color"><code><a href="#heapAllocationBytes" class="member-name-link">heapAllocationBytes</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>private long</code></div>
<div class="col-second odd-row-color"><code><a href="#lastHeapAllocationBytes" class="member-name-link">lastHeapAllocationBytes</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private long</code></div>
<div class="col-second even-row-color"><code><a href="#lastPoolAllocationBytes" class="member-name-link">lastPoolAllocationBytes</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>private static final org.slf4j.Logger</code></div>
<div class="col-second odd-row-color"><code><a href="#LOG" class="member-name-link">LOG</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color"><code><a href="#MAX_BUFFER_COUNT_KEY" class="member-name-link">MAX_BUFFER_COUNT_KEY</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>private final int</code></div>
<div class="col-second odd-row-color"><code><a href="#maxBufCount" class="member-name-link">maxBufCount</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private boolean</code></div>
<div class="col-second even-row-color"><code><a href="#maxPoolSizeInfoLevelLogged" class="member-name-link">maxPoolSizeInfoLevelLogged</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>static final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div>
<div class="col-second odd-row-color"><code><a href="#MIN_ALLOCATE_SIZE_KEY" class="member-name-link">MIN_ALLOCATE_SIZE_KEY</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private final int</code></div>
<div class="col-second even-row-color"><code><a href="#minSizeForReservoirUse" class="member-name-link">minSizeForReservoirUse</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>static final <a href="ByteBuffAllocator.Recycler.html" title="interface in org.apache.hadoop.hbase.io">ByteBuffAllocator.Recycler</a></code></div>
<div class="col-second odd-row-color"><code><a href="#NONE" class="member-name-link">NONE</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/LongAdder.html" title="class or interface in java.util.concurrent.atomic" class="external-link">LongAdder</a></code></div>
<div class="col-second even-row-color"><code><a href="#poolAllocationBytes" class="member-name-link">poolAllocationBytes</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
<div class="col-first odd-row-color"><code>protected final boolean</code></div>
<div class="col-second odd-row-color"><code><a href="#reservoirEnabled" class="member-name-link">reservoirEnabled</a></code></div>
<div class="col-last odd-row-color">&nbsp;</div>
<div class="col-first even-row-color"><code>private final <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/AtomicInteger.html" title="class or interface in java.util.concurrent.atomic" class="external-link">AtomicInteger</a></code></div>
<div class="col-second even-row-color"><code><a href="#usedBufCount" class="member-name-link">usedBufCount</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
</div>
</section>
</li>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li>
<section class="constructor-summary" id="constructor-summary">
<h2>Constructor Summary</h2>
<div class="caption"><span>Constructors</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier</div>
<div class="table-header col-second">Constructor</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>protected </code></div>
<div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E(boolean,int,int,int)" class="member-name-link">ByteBuffAllocator</a><wbr>(boolean&nbsp;reservoirEnabled,
int&nbsp;maxBufCount,
int&nbsp;bufSize,
int&nbsp;minSizeForReservoirUse)</code></div>
<div class="col-last even-row-color">&nbsp;</div>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab1" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab1', 3)" class="table-tab">Static Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="../nio/ByteBuff.html" title="class in org.apache.hadoop.hbase.nio">ByteBuff</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#allocate(int)" class="member-name-link">allocate</a><wbr>(int&nbsp;size)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Allocate size bytes from the ByteBufAllocator, Note to call the <a href="../nio/ByteBuff.html#release()"><code>ByteBuff.release()</code></a> if
no need any more, otherwise the memory leak happen in NIO ByteBuffer pool.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="../nio/SingleByteBuff.html" title="class in org.apache.hadoop.hbase.nio">SingleByteBuff</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#allocateOneBuffer()" class="member-name-link">allocateOneBuffer</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Allocate an buffer with buffer size from ByteBuffAllocator, Note to call the
<a href="../nio/ByteBuff.html#release()"><code>ByteBuff.release()</code></a> if no need any more, otherwise the memory leak happen in NIO
ByteBuffer pool.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>private <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#allocateOnHeap(int)" class="member-name-link">allocateOnHeap</a><wbr>(int&nbsp;size)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#clean()" class="member-name-link">clean</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Free all direct buffers if allocated, mainly used for testing.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#create(org.apache.hadoop.conf.Configuration,boolean)" class="member-name-link">create</a><wbr>(org.apache.hadoop.conf.Configuration&nbsp;conf,
boolean&nbsp;reservoirEnabled)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Initialize an <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io"><code>ByteBuffAllocator</code></a> which will try to allocate ByteBuffers from off-heap if
reservoir is enabled and the reservoir has enough buffers, otherwise the allocator will just
allocate the insufficient buffers from on-heap to meet the requirement.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>private static <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#createOnHeap()" class="member-name-link">createOnHeap</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Initialize an <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io"><code>ByteBuffAllocator</code></a> which only allocate ByteBuffer from on-heap, it's
designed for testing purpose or disabled reservoir case.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>private <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getBuffer()" class="member-name-link">getBuffer</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getBufferSize()" class="member-name-link">getBufferSize</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getFreeBufferCount()" class="member-name-link">getFreeBufferCount</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">The <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ConcurrentLinkedQueue.html#size()" title="class or interface in java.util.concurrent" class="external-link"><code>ConcurrentLinkedQueue.size()</code></a> is O(N) complexity and time-consuming, so DO NOT use
the method except in UT.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>long</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getHeapAllocationBytes()" class="member-name-link">getHeapAllocationBytes</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static long</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#getHeapAllocationBytes(org.apache.hadoop.hbase.io.ByteBuffAllocator...)" class="member-name-link">getHeapAllocationBytes</a><wbr>(<a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a>...&nbsp;allocators)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static double</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#getHeapAllocationRatio(org.apache.hadoop.hbase.io.ByteBuffAllocator...)" class="member-name-link">getHeapAllocationRatio</a><wbr>(<a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a>...&nbsp;allocators)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>long</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getPoolAllocationBytes()" class="member-name-link">getPoolAllocationBytes</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getTotalBufferCount()" class="member-name-link">getTotalBufferCount</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>int</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getUsedBufferCount()" class="member-name-link">getUsedBufferCount</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#isReservoirEnabled()" class="member-name-link">isReservoirEnabled</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#putbackBuffer(java.nio.ByteBuffer)" class="member-name-link">putbackBuffer</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a>&nbsp;buf)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Return back a ByteBuffer after its use.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-java.lang.Object">Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hashCode</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">toString</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ FIELD DETAIL =========== -->
<li>
<section class="field-details" id="field-detail">
<h2>Field Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="LOG">
<h3>LOG</h3>
<div class="member-signature"><span class="modifiers">private static final</span>&nbsp;<span class="return-type">org.slf4j.Logger</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-58">LOG</a></span></div>
</section>
</li>
<li>
<section class="detail" id="HEAP">
<h3>HEAP</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-63">HEAP</a></span></div>
</section>
</li>
<li>
<section class="detail" id="ALLOCATOR_POOL_ENABLED_KEY">
<h3>ALLOCATOR_POOL_ENABLED_KEY</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-65">ALLOCATOR_POOL_ENABLED_KEY</a></span></div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="MAX_BUFFER_COUNT_KEY">
<h3>MAX_BUFFER_COUNT_KEY</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-67">MAX_BUFFER_COUNT_KEY</a></span></div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.MAX_BUFFER_COUNT_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="BUFFER_SIZE_KEY">
<h3>BUFFER_SIZE_KEY</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-69">BUFFER_SIZE_KEY</a></span></div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.BUFFER_SIZE_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="MIN_ALLOCATE_SIZE_KEY">
<h3>MIN_ALLOCATE_SIZE_KEY</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-71">MIN_ALLOCATE_SIZE_KEY</a></span></div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.MIN_ALLOCATE_SIZE_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="BYTEBUFF_ALLOCATOR_CLASS">
<h3>BYTEBUFF_ALLOCATOR_CLASS</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-77">BYTEBUFF_ALLOCATOR_CLASS</a></span></div>
<div class="block">Set an alternate bytebuffallocator by setting this config, e.g. we can config
<a href="DeallocateRewriteByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io"><code>DeallocateRewriteByteBuffAllocator</code></a> to find out prematurely release issues</div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.BYTEBUFF_ALLOCATOR_CLASS">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY">
<h3>DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-83">DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY</a></span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0. Use
<a href="#ALLOCATOR_POOL_ENABLED_KEY"><code>ALLOCATOR_POOL_ENABLED_KEY</code></a> instead.</div>
</div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.DEPRECATED_ALLOCATOR_POOL_ENABLED_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="DEPRECATED_MAX_BUFFER_COUNT_KEY">
<h3>DEPRECATED_MAX_BUFFER_COUNT_KEY</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-91">DEPRECATED_MAX_BUFFER_COUNT_KEY</a></span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0. Use
<a href="#MAX_BUFFER_COUNT_KEY"><code>MAX_BUFFER_COUNT_KEY</code></a> instead.</div>
</div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.DEPRECATED_MAX_BUFFER_COUNT_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="DEPRECATED_BUFFER_SIZE_KEY">
<h3>DEPRECATED_BUFFER_SIZE_KEY</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">static final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-98">DEPRECATED_BUFFER_SIZE_KEY</a></span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.3.0 and will be removed in 4.0.0. Use
<a href="#BUFFER_SIZE_KEY"><code>BUFFER_SIZE_KEY</code></a> instead.</div>
</div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.DEPRECATED_BUFFER_SIZE_KEY">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="DEFAULT_BUFFER_SIZE">
<h3>DEFAULT_BUFFER_SIZE</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-117">DEFAULT_BUFFER_SIZE</a></span></div>
<div class="block">There're some reasons why better to choose 65KB(rather than 64KB) as the default buffer size:
<p>
1. Almost all of the data blocks have the block size: 64KB + delta, whose delta is very small,
depends on the size of lastKeyValue. If we set buffer.size=64KB, then each block will be
allocated as a MultiByteBuff: one 64KB DirectByteBuffer and delta bytes HeapByteBuffer, the
HeapByteBuffer will increase the GC pressure. Ideally, we should let the data block to be
allocated as a SingleByteBuff, it has simpler data structure, faster access speed, less heap
usage.
<p>
2. Since the blocks are MultiByteBuff when using buffer.size=64KB, so we have to calculate the
checksum by an temp heap copying (see HBASE-21917), while if it's a SingleByteBuff, we can
speed the checksum by calling the hadoop' checksum in native lib, which is more faster.
<p>
For performance comparison, please see HBASE-22483.</div>
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.io.ByteBuffAllocator.DEFAULT_BUFFER_SIZE">Constant Field Values</a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="NONE">
<h3>NONE</h3>
<div class="member-signature"><span class="modifiers">public static final</span>&nbsp;<span class="return-type"><a href="ByteBuffAllocator.Recycler.html" title="interface in org.apache.hadoop.hbase.io">ByteBuffAllocator.Recycler</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-119">NONE</a></span></div>
</section>
</li>
<li>
<section class="detail" id="reservoirEnabled">
<h3>reservoirEnabled</h3>
<div class="member-signature"><span class="modifiers">protected final</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-126">reservoirEnabled</a></span></div>
</section>
</li>
<li>
<section class="detail" id="bufSize">
<h3>bufSize</h3>
<div class="member-signature"><span class="modifiers">protected final</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-127">bufSize</a></span></div>
</section>
</li>
<li>
<section class="detail" id="maxBufCount">
<h3>maxBufCount</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-128">maxBufCount</a></span></div>
</section>
</li>
<li>
<section class="detail" id="usedBufCount">
<h3>usedBufCount</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/AtomicInteger.html" title="class or interface in java.util.concurrent.atomic" class="external-link">AtomicInteger</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-129">usedBufCount</a></span></div>
</section>
</li>
<li>
<section class="detail" id="maxPoolSizeInfoLevelLogged">
<h3>maxPoolSizeInfoLevelLogged</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-131">maxPoolSizeInfoLevelLogged</a></span></div>
</section>
</li>
<li>
<section class="detail" id="minSizeForReservoirUse">
<h3>minSizeForReservoirUse</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-135">minSizeForReservoirUse</a></span></div>
</section>
</li>
<li>
<section class="detail" id="buffers">
<h3>buffers</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Queue.html" title="class or interface in java.util" class="external-link">Queue</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a>&gt;</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-137">buffers</a></span></div>
</section>
</li>
<li>
<section class="detail" id="poolAllocationBytes">
<h3>poolAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/LongAdder.html" title="class or interface in java.util.concurrent.atomic" class="external-link">LongAdder</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-141">poolAllocationBytes</a></span></div>
</section>
</li>
<li>
<section class="detail" id="heapAllocationBytes">
<h3>heapAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">private final</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/LongAdder.html" title="class or interface in java.util.concurrent.atomic" class="external-link">LongAdder</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-142">heapAllocationBytes</a></span></div>
</section>
</li>
<li>
<section class="detail" id="lastPoolAllocationBytes">
<h3>lastPoolAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-143">lastPoolAllocationBytes</a></span></div>
</section>
</li>
<li>
<section class="detail" id="lastHeapAllocationBytes">
<h3>lastHeapAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-144">lastHeapAllocationBytes</a></span></div>
</section>
</li>
</ul>
</section>
</li>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li>
<section class="constructor-details" id="constructor-detail">
<h2>Constructor Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="&lt;init&gt;(boolean,int,int,int)">
<h3>ByteBuffAllocator</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-204">ByteBuffAllocator</a></span><wbr><span class="parameters">(boolean&nbsp;reservoirEnabled,
int&nbsp;maxBufCount,
int&nbsp;bufSize,
int&nbsp;minSizeForReservoirUse)</span></div>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="create(org.apache.hadoop.conf.Configuration,boolean)">
<h3>create</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-158">create</a></span><wbr><span class="parameters">(org.apache.hadoop.conf.Configuration&nbsp;conf,
boolean&nbsp;reservoirEnabled)</span></div>
<div class="block">Initialize an <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io"><code>ByteBuffAllocator</code></a> which will try to allocate ByteBuffers from off-heap if
reservoir is enabled and the reservoir has enough buffers, otherwise the allocator will just
allocate the insufficient buffers from on-heap to meet the requirement.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>conf</code> - which get the arguments to initialize the allocator.</dd>
<dd><code>reservoirEnabled</code> - indicate whether the reservoir is enabled or disabled. NOTICE: if
reservoir is enabled, then we will use the pool allocator to allocate
off-heap ByteBuffers and use the HEAP allocator to allocate heap
ByteBuffers. Otherwise if reservoir is disabled then all allocations
will happen in HEAP instance.</dd>
<dt>Returns:</dt>
<dd>ByteBuffAllocator to manage the byte buffers.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="createOnHeap()">
<h3>createOnHeap</h3>
<div class="member-signature"><span class="modifiers">private static</span>&nbsp;<span class="return-type"><a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-200">createOnHeap</a></span>()</div>
<div class="block">Initialize an <a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io"><code>ByteBuffAllocator</code></a> which only allocate ByteBuffer from on-heap, it's
designed for testing purpose or disabled reservoir case.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>allocator to allocate on-heap ByteBuffer.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="isReservoirEnabled()">
<h3>isReservoirEnabled</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-212">isReservoirEnabled</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getHeapAllocationBytes()">
<h3>getHeapAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-216">getHeapAllocationBytes</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getPoolAllocationBytes()">
<h3>getPoolAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-220">getPoolAllocationBytes</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getBufferSize()">
<h3>getBufferSize</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-224">getBufferSize</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getUsedBufferCount()">
<h3>getUsedBufferCount</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-228">getUsedBufferCount</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getFreeBufferCount()">
<h3>getFreeBufferCount</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-236">getFreeBufferCount</a></span>()</div>
<div class="block">The <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ConcurrentLinkedQueue.html#size()" title="class or interface in java.util.concurrent" class="external-link"><code>ConcurrentLinkedQueue.size()</code></a> is O(N) complexity and time-consuming, so DO NOT use
the method except in UT.</div>
</section>
</li>
<li>
<section class="detail" id="getTotalBufferCount()">
<h3>getTotalBufferCount</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">int</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-240">getTotalBufferCount</a></span>()</div>
</section>
</li>
<li>
<section class="detail" id="getHeapAllocationBytes(org.apache.hadoop.hbase.io.ByteBuffAllocator...)">
<h3>getHeapAllocationBytes</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-244">getHeapAllocationBytes</a></span><wbr><span class="parameters">(<a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a>...&nbsp;allocators)</span></div>
</section>
</li>
<li>
<section class="detail" id="getHeapAllocationRatio(org.apache.hadoop.hbase.io.ByteBuffAllocator...)">
<h3>getHeapAllocationRatio</h3>
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type">double</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-252">getHeapAllocationRatio</a></span><wbr><span class="parameters">(<a href="ByteBuffAllocator.html" title="class in org.apache.hadoop.hbase.io">ByteBuffAllocator</a>...&nbsp;allocators)</span></div>
</section>
</li>
<li>
<section class="detail" id="allocateOneBuffer()">
<h3>allocateOneBuffer</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="../nio/SingleByteBuff.html" title="class in org.apache.hadoop.hbase.nio">SingleByteBuff</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-280">allocateOneBuffer</a></span>()</div>
<div class="block">Allocate an buffer with buffer size from ByteBuffAllocator, Note to call the
<a href="../nio/ByteBuff.html#release()"><code>ByteBuff.release()</code></a> if no need any more, otherwise the memory leak happen in NIO
ByteBuffer pool.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>an ByteBuff with the buffer size.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="allocateOnHeap(int)">
<h3>allocateOnHeap</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-291">allocateOnHeap</a></span><wbr><span class="parameters">(int&nbsp;size)</span></div>
</section>
</li>
<li>
<section class="detail" id="allocate(int)">
<h3>allocate</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="../nio/ByteBuff.html" title="class in org.apache.hadoop.hbase.nio">ByteBuff</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-302">allocate</a></span><wbr><span class="parameters">(int&nbsp;size)</span></div>
<div class="block">Allocate size bytes from the ByteBufAllocator, Note to call the <a href="../nio/ByteBuff.html#release()"><code>ByteBuff.release()</code></a> if
no need any more, otherwise the memory leak happen in NIO ByteBuffer pool.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>size</code> - to allocate</dd>
<dt>Returns:</dt>
<dd>an ByteBuff with the desired size.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="clean()">
<h3>clean</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-351">clean</a></span>()</div>
<div class="block">Free all direct buffers if allocated, mainly used for testing.</div>
</section>
</li>
<li>
<section class="detail" id="getBuffer()">
<h3>getBuffer</h3>
<div class="member-signature"><span class="modifiers">private</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a></span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-372">getBuffer</a></span>()</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>One free DirectByteBuffer from the pool. If no free ByteBuffer and we have not reached
the maximum pool size, it will create a new one and return. In case of max pool size
also reached, will return null. When pool returned a ByteBuffer, make sure to return it
back to pool after use.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="putbackBuffer(java.nio.ByteBuffer)">
<h3>putbackBuffer</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name"><a href="../../../../../src-html/org/apache/hadoop/hbase/io/ByteBuffAllocator.html#line-402">putbackBuffer</a></span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/ByteBuffer.html" title="class or interface in java.nio" class="external-link">ByteBuffer</a>&nbsp;buf)</span></div>
<div class="block">Return back a ByteBuffer after its use. Don't read/write the ByteBuffer after the returning.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>buf</code> - ByteBuffer to return.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
<footer role="contentinfo">
<hr>
<p class="legal-copy"><small>Copyright &#169; 2007&#x2013;2020 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</footer>
</div>
</div>
</body>
</html>