Package org.eclipse.jetty.server
Class LowResourceMonitor
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.LowResourceMonitor
- All Implemented Interfaces:
Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
@ManagedObject("Monitor for low resource conditions and activate a low resource mode if detected")
public class LowResourceMonitor
extends ContainerLifeCycle
A monitor for low resources, low resources can be detected by:
ThreadPool.isLowOnThreads()
ifConnector.getExecutor()
is an instance ofThreadPool
andsetMonitorThreads(boolean)
is true.- If
setMaxMemory(long)
is non zero then low resources is detected if the JVMsRuntime
instance hasRuntime.totalMemory()
minusRuntime.freeMemory()
greater thangetMaxMemory()
- If
setMaxConnections(int)
is non zero then low resources is detected if the total number of connections exceedsgetMaxConnections()
. This feature is deprecated and replaced byConnectionLimit
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
static interface
private static class
class
class
class
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Set<AbstractConnector>
private boolean
private final AtomicBoolean
private Set<LowResourceMonitor.LowResourceCheck>
private int
private long
private int
private final Runnable
private Connector[]
private int
private String
private Scheduler
protected final Server
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLowResourceCheck
(LowResourceMonitor.LowResourceCheck lowResourceCheck) protected void
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) int
long
int
Deprecated.Replaced by ConnectionLimitint
long
protected Connector[]
boolean
int
boolean
boolean
protected String
protected void
monitor()
void
setAcceptingInLowResources
(boolean acceptingInLowResources) void
setLowResourceChecks
(Set<LowResourceMonitor.LowResourceCheck> lowResourceChecks) protected void
void
setLowResourcesIdleTimeout
(int lowResourcesIdleTimeoutMS) protected void
setLowResourcesReasons
(String reasons) void
setLowResourcesStarted
(long lowStarted) void
setMaxConnections
(int maxConnections) Deprecated.Replaced byConnectionLimit
void
setMaxLowResourcesTime
(int maxLowResourcesTimeMS) void
setMaxMemory
(long maxMemoryBytes) void
setMonitoredConnectors
(Collection<Connector> monitoredConnectors) void
setMonitorThreads
(boolean monitorThreads) void
setPeriod
(int periodMS) protected void
setReasons
(String reasons) Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
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
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
LOG
-
_server
-
_scheduler
-
_monitoredConnectors
-
_acceptingConnectors
-
_period
private int _period -
_lowResourcesIdleTimeout
private int _lowResourcesIdleTimeout -
_maxLowResourcesTime
private int _maxLowResourcesTime -
_low
-
_reasons
-
_lowStarted
private long _lowStarted -
_acceptingInLowResources
private boolean _acceptingInLowResources -
_lowResourceChecks
-
_monitor
-
-
Constructor Details
-
LowResourceMonitor
-
-
Method Details
-
getMonitorThreads
@ManagedAttribute("True if low available threads status is monitored") public boolean getMonitorThreads() -
setMonitorThreads
public void setMonitorThreads(boolean monitorThreads) - Parameters:
monitorThreads
- If true, check connectors executors to see if they areThreadPool
instances that are low on threads.
-
getMaxConnections
@ManagedAttribute("The maximum connections allowed for the monitored connectors before low resource handling is activated") @Deprecated public int getMaxConnections()Deprecated.Replaced by ConnectionLimit- Returns:
- The maximum connections allowed for the monitored connectors before low resource handling is activated
-
setMaxConnections
Deprecated.Replaced byConnectionLimit
- Parameters:
maxConnections
- The maximum connections before low resources state is triggered
-
getReasons
@ManagedAttribute("The reasons the monitored connectors are low on resources") public String getReasons() -
setReasons
-
isLowOnResources
@ManagedAttribute("Are the monitored connectors low on resources?") public boolean isLowOnResources() -
enableLowOnResources
protected boolean enableLowOnResources(boolean expectedValue, boolean newValue) -
getLowResourcesReasons
@ManagedAttribute("The reason(s) the monitored connectors are low on resources") public String getLowResourcesReasons() -
setLowResourcesReasons
-
getLowResourcesStarted
@ManagedAttribute("Get the timestamp in ms since epoch that low resources state started") public long getLowResourcesStarted() -
setLowResourcesStarted
public void setLowResourcesStarted(long lowStarted) -
getMonitoredConnectors
@ManagedAttribute("The monitored connectors. If null then all server connectors are monitored") public Collection<Connector> getMonitoredConnectors() -
setMonitoredConnectors
- Parameters:
monitoredConnectors
- The collections of Connectors that should be monitored for low resources.
-
getMonitoredOrServerConnectors
-
isAcceptingInLowResources
@ManagedAttribute("If false, new connections are not accepted while in low resources") public boolean isAcceptingInLowResources() -
setAcceptingInLowResources
public void setAcceptingInLowResources(boolean acceptingInLowResources) -
getPeriod
-
setPeriod
public void setPeriod(int periodMS) - Parameters:
periodMS
- The period in ms to monitor for low resources
-
getLowResourcesIdleTimeout
@ManagedAttribute("The idletimeout in ms to apply to all existing connections when low resources is detected") public int getLowResourcesIdleTimeout() -
setLowResourcesIdleTimeout
public void setLowResourcesIdleTimeout(int lowResourcesIdleTimeoutMS) - Parameters:
lowResourcesIdleTimeoutMS
- The timeout in ms to apply to EndPoints when in the low resources state.
-
getMaxLowResourcesTime
@ManagedAttribute("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() -
setMaxLowResourcesTime
public void setMaxLowResourcesTime(int maxLowResourcesTimeMS) - Parameters:
maxLowResourcesTimeMS
- The time in milliseconds that a low resource state can persist before the low resource idle timeout is reapplied to all connections
-
getMaxMemory
@ManagedAttribute("The maximum memory (in bytes) that can be used before low resources is triggered. Memory used is calculated as (totalMemory-freeMemory).") public long getMaxMemory() -
setMaxMemory
public void setMaxMemory(long maxMemoryBytes) - Parameters:
maxMemoryBytes
- The maximum memory in bytes in use before low resources is triggered.
-
getLowResourceChecks
-
setLowResourceChecks
-
addLowResourceCheck
-
monitor
protected void monitor() -
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
Exception
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
Exception
-
setLowResources
protected void setLowResources() -
clearLowResources
protected void clearLowResources() -
low
-