Class MemoryLimiter
- java.lang.Object
-
- org.apache.shenyu.common.concurrent.MemoryLimiter
-
public class MemoryLimiter extends java.lang.Objectmemory limiter.- See Also:
MemoryLimitCalculator
-
-
Constructor Summary
Constructors Constructor Description MemoryLimiter(long memoryLimit, java.lang.instrument.Instrumentation inst)MemoryLimiter(java.lang.instrument.Instrumentation inst)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquire(java.lang.Object o)acquire memory byObject.booleanacquire(java.lang.Object o, long timeout, java.util.concurrent.TimeUnit unit)acquire memory byObject.voidacquireInterruptibly(java.lang.Object o)acquire memory byObject.longgetCurrentMemory()get the current memory.longgetCurrentRemainMemory()get the current remain memory.longgetMemoryLimit()get the memory limit.voidrelease(java.lang.Object o)release memory byObject.voidreleaseInterruptibly(java.lang.Object o)release memory byObject.voidreleaseInterruptibly(java.lang.Object o, long timeout, java.util.concurrent.TimeUnit unit)release memory byObject.voidreset()reset this MemoryLimiter.voidsetMemoryLimit(long memoryLimit)set the memory limit.
-
-
-
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
-
acquire
public boolean acquire(java.lang.Object o)
acquire memory byObject. this method does not respond to interrupts.- Parameters:
o- memory size to be applied by calculating- Returns:
- true if acquire success
-
acquire
public boolean acquire(java.lang.Object o, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionacquire memory byObject. this method response to interrupts.- Parameters:
o- memory size to be applied by calculatingtimeout- max time to waitunit- time unit- Returns:
- true if acquire success
- Throws:
java.lang.InterruptedException- the InterruptedException
-
acquireInterruptibly
public void acquireInterruptibly(java.lang.Object o) throws java.lang.InterruptedExceptionacquire memory byObject. this method response to interrupts.- Parameters:
o- memory size to be applied by calculating- Throws:
java.lang.InterruptedException- the InterruptedException
-
release
public void release(java.lang.Object o)
release memory byObject. this method does not respond to interrupts.- Parameters:
o- memory size to be applied by calculating
-
releaseInterruptibly
public void releaseInterruptibly(java.lang.Object o) throws java.lang.InterruptedExceptionrelease memory byObject. this method response to interrupts.- Parameters:
o- memory size to be applied by calculating- Throws:
java.lang.InterruptedException- the InterruptedException
-
releaseInterruptibly
public void releaseInterruptibly(java.lang.Object o, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionrelease memory byObject. this method response to interrupts.- Parameters:
o- memory size to be applied by calculatingtimeout- max time to waitunit- time unit- Throws:
java.lang.InterruptedException- the InterruptedException
-
reset
public void reset()
reset this MemoryLimiter.
-
-