Class MemoryLimitedLinkedBlockingQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.LinkedBlockingQueue<E>
-
- org.apache.shenyu.common.concurrent.MemoryLimitedLinkedBlockingQueue<E>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.concurrent.BlockingQueue<E>,java.util.Queue<E>
- Direct Known Subclasses:
MemoryLimitedTaskQueue
public class MemoryLimitedLinkedBlockingQueue<E> extends java.util.concurrent.LinkedBlockingQueue<E>Can completely solve the OOM problem caused byLinkedBlockingQueue.- See Also:
MemoryLimiter,MemoryLimitCalculator, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MemoryLimitedLinkedBlockingQueue(long memoryLimit, java.lang.instrument.Instrumentation inst)MemoryLimitedLinkedBlockingQueue(java.lang.instrument.Instrumentation inst)MemoryLimitedLinkedBlockingQueue(java.util.Collection<? extends E> c, long memoryLimit, java.lang.instrument.Instrumentation inst)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()longgetCurrentMemory()get the current memory.longgetCurrentRemainMemory()get the current remain memory.longgetMemoryLimit()get the memory limit.booleanoffer(E e)booleanoffer(E e, long timeout, java.util.concurrent.TimeUnit unit)Epoll()Epoll(long timeout, java.util.concurrent.TimeUnit unit)voidput(E e)booleanremove(java.lang.Object o)voidsetMemoryLimit(long memoryLimit)set the memory limit.Etake()-
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
contains, drainTo, drainTo, forEach, iterator, peek, remainingCapacity, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
MemoryLimitedLinkedBlockingQueue
public MemoryLimitedLinkedBlockingQueue(java.lang.instrument.Instrumentation inst)
-
MemoryLimitedLinkedBlockingQueue
public MemoryLimitedLinkedBlockingQueue(long memoryLimit, java.lang.instrument.Instrumentation inst)
-
MemoryLimitedLinkedBlockingQueue
public MemoryLimitedLinkedBlockingQueue(java.util.Collection<? extends E> c, long memoryLimit, java.lang.instrument.Instrumentation inst)
-
-
Method Detail
-
setMemoryLimit
public void setMemoryLimit(long memoryLimit)
set the memory limit.- Parameters:
memoryLimit- the memory limit
-
getMemoryLimit
public long getMemoryLimit()
get the memory limit.- Returns:
- the memory limit
-
getCurrentMemory
public long getCurrentMemory()
get the current memory.- Returns:
- the current memory
-
getCurrentRemainMemory
public long getCurrentRemainMemory()
get the current remain memory.- Returns:
- the current remain memory
-
put
public void put(E e) throws java.lang.InterruptedException
-
offer
public boolean offer(E e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
-
offer
public boolean offer(E e)
-
take
public E take() throws java.lang.InterruptedException
-
poll
public E poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
-
poll
public E poll()
-
remove
public boolean remove(java.lang.Object o)
-
-