@ManagedObject(value="Monitor for low resource conditions and activate a low resource mode if detected") public class LowResourceMonitor extends ContainerLifeCycle
ThreadPool.isLowOnThreads()
if Connector.getExecutor()
is
an instance of ThreadPool
and setMonitorThreads(boolean)
is true.setMaxMemory(long)
is non zero then low resources is detected if the JVMs
Runtime
instance has Runtime.totalMemory()
minus Runtime.freeMemory()
greater than getMaxMemory()
setMaxConnections(int)
is non zero then low resources is detected if the total number
of connections exceeds getMaxConnections()
. This feature is deprecated and replaced by
ConnectionLimit
Modifier and Type | Class and Description |
---|---|
class |
LowResourceMonitor.ConnectorsThreadPoolLowResourceCheck |
static interface |
LowResourceMonitor.LowResourceCheck |
class |
LowResourceMonitor.MainThreadPoolLowResourceCheck |
class |
LowResourceMonitor.MaxConnectionsLowResourceCheck |
class |
LowResourceMonitor.MemoryLowResourceCheck |
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
protected Server |
_server |
Constructor and Description |
---|
LowResourceMonitor(Server server) |
Modifier and Type | Method and Description |
---|---|
void |
addLowResourceCheck(LowResourceMonitor.LowResourceCheck lowResourceCheck) |
protected void |
clearLowResources() |
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
protected boolean |
enableLowOnResources(boolean expectedValue,
boolean newValue) |
java.util.Set<LowResourceMonitor.LowResourceCheck> |
getLowResourceChecks() |
int |
getLowResourcesIdleTimeout() |
java.lang.String |
getLowResourcesReasons() |
long |
getLowResourcesStarted() |
int |
getMaxConnections()
Deprecated.
Replaced by ConnectionLimit
|
int |
getMaxLowResourcesTime() |
long |
getMaxMemory() |
java.util.Collection<Connector> |
getMonitoredConnectors() |
protected Connector[] |
getMonitoredOrServerConnectors() |
boolean |
getMonitorThreads() |
int |
getPeriod() |
java.lang.String |
getReasons() |
boolean |
isAcceptingInLowResources() |
boolean |
isLowOnResources() |
protected java.lang.String |
low(java.lang.String reasons,
java.lang.String newReason) |
protected void |
monitor() |
void |
setAcceptingInLowResources(boolean acceptingInLowResources) |
void |
setLowResourceChecks(java.util.Set<LowResourceMonitor.LowResourceCheck> lowResourceChecks) |
protected void |
setLowResources() |
void |
setLowResourcesIdleTimeout(int lowResourcesIdleTimeoutMS) |
protected void |
setLowResourcesReasons(java.lang.String reasons) |
void |
setLowResourcesStarted(long lowStarted) |
void |
setMaxConnections(int maxConnections)
Deprecated.
Replaced by ConnectionLimit
|
void |
setMaxLowResourcesTime(int maxLowResourcesTimeMS) |
void |
setMaxMemory(long maxMemoryBytes) |
void |
setMonitoredConnectors(java.util.Collection<Connector> monitoredConnectors) |
void |
setMonitorThreads(boolean monitorThreads) |
void |
setPeriod(int periodMS) |
protected void |
setReasons(java.lang.String reasons) |
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, 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
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dumpObjects, dumpSelf
protected final Server _server
@ManagedAttribute(value="True if low available threads status is monitored") public boolean getMonitorThreads()
public void setMonitorThreads(boolean monitorThreads)
monitorThreads
- If true, check connectors executors to see if they are
ThreadPool
instances that are low on threads.@ManagedAttribute(value="The maximum connections allowed for the monitored connectors before low resource handling is activated") @Deprecated public int getMaxConnections()
@Deprecated public void setMaxConnections(int maxConnections)
maxConnections
- The maximum connections before low resources state is triggered@ManagedAttribute(value="The reasons the monitored connectors are low on resources") public java.lang.String getReasons()
protected void setReasons(java.lang.String reasons)
@ManagedAttribute(value="Are the monitored connectors low on resources?") public boolean isLowOnResources()
protected boolean enableLowOnResources(boolean expectedValue, boolean newValue)
@ManagedAttribute(value="The reason(s) the monitored connectors are low on resources") public java.lang.String getLowResourcesReasons()
protected void setLowResourcesReasons(java.lang.String reasons)
@ManagedAttribute(value="Get the timestamp in ms since epoch that low resources state started") public long getLowResourcesStarted()
public void setLowResourcesStarted(long lowStarted)
@ManagedAttribute(value="The monitored connectors. If null then all server connectors are monitored") public java.util.Collection<Connector> getMonitoredConnectors()
public void setMonitoredConnectors(java.util.Collection<Connector> monitoredConnectors)
monitoredConnectors
- The collections of Connectors that should be monitored for low resources.protected Connector[] getMonitoredOrServerConnectors()
@ManagedAttribute(value="If false, new connections are not accepted while in low resources") public boolean isAcceptingInLowResources()
public void setAcceptingInLowResources(boolean acceptingInLowResources)
@ManagedAttribute(value="The monitor period in ms") public int getPeriod()
public void setPeriod(int periodMS)
periodMS
- The period in ms to monitor for low resources@ManagedAttribute(value="The idletimeout in ms to apply to all existing connections when low resources is detected") public int getLowResourcesIdleTimeout()
public void setLowResourcesIdleTimeout(int lowResourcesIdleTimeoutMS)
lowResourcesIdleTimeoutMS
- The timeout in ms to apply to EndPoints when in the low resources state.@ManagedAttribute(value="The maximum time in ms that low resources condition can persist before lowResourcesIdleTimeout is applied to new connections as well as existing connections") public int getMaxLowResourcesTime()
public void setMaxLowResourcesTime(int maxLowResourcesTimeMS)
maxLowResourcesTimeMS
- The time in milliseconds that a low resource state can persist before the low resource idle timeout is reapplied to all connections@ManagedAttribute(value="The maximum memory (in bytes) that can be used before low resources is triggered. Memory used is calculated as (totalMemory-freeMemory).") public long getMaxMemory()
public void setMaxMemory(long maxMemoryBytes)
maxMemoryBytes
- The maximum memory in bytes in use before low resources is triggered.public java.util.Set<LowResourceMonitor.LowResourceCheck> getLowResourceChecks()
public void setLowResourceChecks(java.util.Set<LowResourceMonitor.LowResourceCheck> lowResourceChecks)
public void addLowResourceCheck(LowResourceMonitor.LowResourceCheck lowResourceCheck)
protected void monitor()
protected void doStart() throws java.lang.Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
java.lang.Exception
protected void doStop() throws java.lang.Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
java.lang.Exception
protected void setLowResources()
protected void clearLowResources()
protected java.lang.String low(java.lang.String reasons, java.lang.String newReason)
Copyright © 1995–2023 Webtide. All rights reserved.