public abstract class Usage<T extends Usage> extends Object implements Service
Modifier and Type | Field and Description |
---|---|
protected String |
name |
protected T |
parent |
protected int |
percentUsage |
protected ReentrantReadWriteLock |
usageLock |
protected Condition |
waitForSpaceCondition |
Constructor and Description |
---|
Usage(T parent,
String name,
float portion) |
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(T child) |
void |
addUsageListener(UsageListener listener) |
protected int |
caclPercentUsage() |
ThreadPoolExecutor |
getExecutor() |
long |
getLimit() |
UsageCapacity |
getLimiter() |
String |
getName() |
int |
getNumUsageListeners() |
T |
getParent() |
int |
getPercentUsage() |
int |
getPercentUsageMinDelta() |
int |
getPollingTime() |
long |
getUsage() |
float |
getUsagePortion() |
boolean |
isFull() |
boolean |
isFull(int highWaterMark) |
boolean |
isStarted() |
boolean |
notifyCallbackWhenNotFull(Runnable callback) |
protected void |
onLimitChange() |
protected void |
removeChild(T child) |
void |
removeUsageListener(UsageListener listener) |
protected abstract long |
retrieveUsage() |
void |
setExecutor(ThreadPoolExecutor executor) |
void |
setLimit(long limit)
Sets the memory limit in bytes.
|
void |
setLimiter(UsageCapacity limiter) |
void |
setName(String name) |
void |
setParent(T parent) |
protected void |
setPercentUsage(int value) |
void |
setPercentUsageMinDelta(int percentUsageMinDelta)
Sets the minimum number of percentage points the usage has to change before a UsageListener event is fired by the
manager.
|
void |
setPollingTime(int pollingTime) |
void |
setUsagePortion(float usagePortion) |
void |
start() |
void |
stop() |
String |
toString() |
void |
waitForSpace() |
boolean |
waitForSpace(long timeout) |
boolean |
waitForSpace(long timeout,
int highWaterMark) |
protected final ReentrantReadWriteLock usageLock
protected final Condition waitForSpaceCondition
protected int percentUsage
protected abstract long retrieveUsage()
public void waitForSpace() throws InterruptedException
InterruptedException
public boolean waitForSpace(long timeout) throws InterruptedException
InterruptedException
public boolean waitForSpace(long timeout, int highWaterMark) throws InterruptedException
timeout
- InterruptedException
public boolean isFull()
public boolean isFull(int highWaterMark)
public void addUsageListener(UsageListener listener)
public void removeUsageListener(UsageListener listener)
public int getNumUsageListeners()
public long getLimit()
public void setLimit(long limit)
protected void onLimitChange()
public float getUsagePortion()
public void setUsagePortion(float usagePortion)
public int getPercentUsage()
public int getPercentUsageMinDelta()
public void setPercentUsageMinDelta(int percentUsageMinDelta)
percentUsageMinDelta
- public long getUsage()
protected void setPercentUsage(int value)
protected int caclPercentUsage()
protected void removeChild(T child)
public boolean notifyCallbackWhenNotFull(Runnable callback)
callback
- public UsageCapacity getLimiter()
public void setLimiter(UsageCapacity limiter)
limiter
- the limiter to setpublic int getPollingTime()
public void setPollingTime(int pollingTime)
pollingTime
- the pollingTime to setpublic void setExecutor(ThreadPoolExecutor executor)
public ThreadPoolExecutor getExecutor()
public boolean isStarted()
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.