public abstract class WaarpConstraintLimitHandler extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
String |
lastAlert |
static long |
LOWBANDWIDTH_DEFAULT |
Constructor and Description |
---|
WaarpConstraintLimitHandler()
Empty constructor
|
WaarpConstraintLimitHandler(long waitForNetOp,
long timeOutCon,
boolean useCpuLimit,
boolean useJdKCpuLimit,
double cpulimit,
int channellimit)
This constructor enables only Connection check ability
|
WaarpConstraintLimitHandler(long waitForNetOp2,
long timeOutCon2,
boolean useCpuLimit,
boolean useJdKCpuLimit,
double cpulimit,
int channellimit,
double lowcpuLimit,
double highcpuLimit,
double percentageDecrease,
io.netty.handler.traffic.AbstractTrafficShapingHandler handler,
long delay,
long limitLowBandwidth)
This constructor enables both Connection check ability and throttling
bandwidth with cpu usage
|
WaarpConstraintLimitHandler(long waitForNetOp,
long timeOutCon,
boolean useJdkCpuLimit,
double lowcpuLimit,
double highcpuLimit,
double percentageDecrease,
io.netty.handler.traffic.AbstractTrafficShapingHandler handler,
long delay,
long limitLowBandwidth)
This constructor enables only throttling bandwidth with cpu usage
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkConstraints() |
boolean |
checkConstraintsSleep(int step)
Same as checkConstraints except that the thread will sleep some time
proportionally to the current Load (if
CPU related)
|
int |
getChannelLimit() |
double |
getCpuLimit() |
protected abstract int |
getNumberLocalChannel() |
protected abstract long |
getReadLimit()
Get the current setting on Read Limit (supposed to be not the value in
the
handler but in the
configuration)
|
long |
getSleepTime() |
protected abstract long |
getWriteLimit()
Get the current setting on Write Limit (supposed to be not the value in
the
handler but in the
configuration)
|
void |
release()
Release the resources
|
void |
run()
Check every delay if the current cpu usage needs to relax or to
constraint
the bandwidth
|
void |
setChannelLimit(int channelLimit) |
void |
setCpuLimit(double cpuLimit) |
void |
setHandler(io.netty.handler.traffic.AbstractTrafficShapingHandler handler)
Set the handler
|
void |
setServer(boolean isServer)
To explicitly set this handler as server mode
|
public static final long LOWBANDWIDTH_DEFAULT
public String lastAlert
public WaarpConstraintLimitHandler()
public WaarpConstraintLimitHandler(long waitForNetOp, long timeOutCon, boolean useJdkCpuLimit, double lowcpuLimit, double highcpuLimit, double percentageDecrease, io.netty.handler.traffic.AbstractTrafficShapingHandler handler, long delay, long limitLowBandwidth)
waitForNetOp
- 1000 ms as wait for a network operationtimeOutCon
- 10000 ms as timeout limituseJdkCpuLimit
- True to use JDK Cpu native or False for
JavaSysMonlowcpuLimit
- for proactive cpu limitation (throttling
bandwidth)
(0<= x < 1 & highcpulimit)highcpuLimit
- for proactive cpu limitation (throttling
bandwidth)
(0<= x <= 1) 0 meaning no
throttle activatedpercentageDecrease
- for proactive cpu limitation,
throttling
bandwidth reduction (0 < x < 1) as 0.25
for 25% of reductionhandler
- the GlobalTrafficShapingHandler associated (null
to have
no proactive cpu
limitation)delay
- the delay between 2 tests for proactive cpu
limitationlimitLowBandwidth
- the minimal bandwidth (read or write) to
apply
when decreasing bandwidth (low
limit = 4096)public WaarpConstraintLimitHandler(long waitForNetOp, long timeOutCon, boolean useCpuLimit, boolean useJdKCpuLimit, double cpulimit, int channellimit)
useCpuLimit
- True to enable cpuLimit on connection checkuseJdKCpuLimit
- True to use JDK Cpu native or False for
JavaSysMoncpulimit
- high cpu limit (0<= x < 1) to refuse new
connectionschannellimit
- number of connection limit (0<= x)public WaarpConstraintLimitHandler(long waitForNetOp2, long timeOutCon2, boolean useCpuLimit, boolean useJdKCpuLimit, double cpulimit, int channellimit, double lowcpuLimit, double highcpuLimit, double percentageDecrease, io.netty.handler.traffic.AbstractTrafficShapingHandler handler, long delay, long limitLowBandwidth)
waitForNetOp2
- 1000 ms as wait for a network operationtimeOutCon2
- 10000 ms as timeout limituseCpuLimit
- True to enable cpuLimit on connection checkuseJdKCpuLimit
- True to use JDK Cpu native or False for
JavaSysMoncpulimit
- high cpu limit (0<= x < 1) to refuse new
connectionschannellimit
- number of connection limit (0<= x)lowcpuLimit
- for proactive cpu limitation (throttling
bandwidth)
(0<= x < 1 & highcpulimit)highcpuLimit
- for proactive cpu limitation (throttling
bandwidth)
(0<= x <= 1) 0 meaning no
throttle activatedpercentageDecrease
- for proactive cpu limitation,
throttling
bandwidth reduction (0 < x < 1) as 0.25
for 25% of reductionhandler
- the GlobalTrafficShapingHandler associated (null
to have
no proactive cpu
limitation)delay
- the delay between 2 tests for proactive cpu
limitationlimitLowBandwidth
- the minimal bandwidth (read or write) to
apply
when decreasing bandwidth (low
limit = 4096)public void release()
public void setServer(boolean isServer)
isServer
- public boolean checkConstraints()
protected abstract int getNumberLocalChannel()
public boolean checkConstraintsSleep(int step)
step
- the current step in retrypublic long getSleepTime()
public double getCpuLimit()
public void setCpuLimit(double cpuLimit)
cpuLimit
- the cpuLimit to setpublic int getChannelLimit()
public void setChannelLimit(int channelLimit)
channelLimit
- the channelLimit to setprotected abstract long getReadLimit()
protected abstract long getWriteLimit()
public void setHandler(io.netty.handler.traffic.AbstractTrafficShapingHandler handler)
handler
- Copyright © 2009–2020 Waarp. All rights reserved.