Package org.eclipse.jetty.io
Class LeakTrackingByteBufferPool
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.io.LeakTrackingByteBufferPool
-
- All Implemented Interfaces:
ByteBufferPool,Container,Destroyable,Dumpable,Dumpable.DumpableContainer,LifeCycle
@ManagedObject public class LeakTrackingByteBufferPool extends ContainerLifeCycle implements ByteBufferPool
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.ByteBufferPool
ByteBufferPool.Bucket, ByteBufferPool.Lease
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBufferPooldelegateprivate LeakDetector<java.nio.ByteBuffer>leakDetectorprivate java.util.concurrent.atomic.AtomicLongleakedprivate java.util.concurrent.atomic.AtomicLongleakedAcquiresprivate java.util.concurrent.atomic.AtomicLongleakedReleasesprivate java.util.concurrent.atomic.AtomicLongleakedRemovesprivate static LoggerLOG
-
Constructor Summary
Constructors Constructor Description LeakTrackingByteBufferPool(ByteBufferPool delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferacquire(int size, boolean direct)Requests aByteBufferof the given size.voidclearTracking()Clears the tracking data returned bygetLeakedAcquires(),getLeakedReleases(),getLeakedResources().longgetLeakedAcquires()longgetLeakedReleases()longgetLeakedRemoves()longgetLeakedResources()protected voidleaked(LeakDetector.LeakInfo leakInfo)voidrelease(java.nio.ByteBuffer buffer)Returns aByteBuffer, usually obtained withByteBufferPool.acquire(int, boolean)(but not necessarily), making it available for recycling and reuse.voidremove(java.nio.ByteBuffer buffer)Removes aByteBufferthat was previously obtained withByteBufferPool.acquire(int, boolean).-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.io.ByteBufferPool
newByteBuffer
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
leakDetector
private final LeakDetector<java.nio.ByteBuffer> leakDetector
-
leakedAcquires
private final java.util.concurrent.atomic.AtomicLong leakedAcquires
-
leakedReleases
private final java.util.concurrent.atomic.AtomicLong leakedReleases
-
leakedRemoves
private final java.util.concurrent.atomic.AtomicLong leakedRemoves
-
leaked
private final java.util.concurrent.atomic.AtomicLong leaked
-
delegate
private final ByteBufferPool delegate
-
-
Constructor Detail
-
LeakTrackingByteBufferPool
public LeakTrackingByteBufferPool(ByteBufferPool delegate)
-
-
Method Detail
-
acquire
public java.nio.ByteBuffer acquire(int size, boolean direct)Description copied from interface:ByteBufferPoolRequests a
ByteBufferof the given size.The returned buffer may have a bigger capacity than the size being requested but it will have the limit set to the given size.
- Specified by:
acquirein interfaceByteBufferPool- Parameters:
size- the size of the bufferdirect- whether the buffer must be direct or not- Returns:
- the requested buffer
- See Also:
ByteBufferPool.release(ByteBuffer)
-
release
public void release(java.nio.ByteBuffer buffer)
Description copied from interface:ByteBufferPoolReturns a
ByteBuffer, usually obtained withByteBufferPool.acquire(int, boolean)(but not necessarily), making it available for recycling and reuse.- Specified by:
releasein interfaceByteBufferPool- Parameters:
buffer- the buffer to return- See Also:
ByteBufferPool.acquire(int, boolean)
-
remove
public void remove(java.nio.ByteBuffer buffer)
Description copied from interface:ByteBufferPoolRemoves a
ByteBufferthat was previously obtained withByteBufferPool.acquire(int, boolean).The buffer will not be available for further reuse.
- Specified by:
removein interfaceByteBufferPool- Parameters:
buffer- the buffer to remove- See Also:
ByteBufferPool.acquire(int, boolean),ByteBufferPool.release(ByteBuffer)
-
clearTracking
@ManagedAttribute("Clears the tracking data") public void clearTracking()
Clears the tracking data returned bygetLeakedAcquires(),getLeakedReleases(),getLeakedResources().
-
getLeakedAcquires
@ManagedAttribute("The number of acquires that produced a leak") public long getLeakedAcquires()
- Returns:
- count of ByteBufferPool.acquire() calls that detected a leak
-
getLeakedReleases
@ManagedAttribute("The number of releases that produced a leak") public long getLeakedReleases()
- Returns:
- count of ByteBufferPool.release() calls that detected a leak
-
getLeakedRemoves
@ManagedAttribute("The number of removes that produced a leak") public long getLeakedRemoves()
- Returns:
- count of ByteBufferPool.remove() calls that detected a leak
-
getLeakedResources
@ManagedAttribute("The number of resources that were leaked") public long getLeakedResources()
- Returns:
- count of resources that were acquired but not released
-
leaked
protected void leaked(LeakDetector.LeakInfo leakInfo)
-
-