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:
org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle
@ManagedObject("Monitor for low resource conditions and activate a low resource mode if detected")
public class LowResourceMonitor
extends org.eclipse.jetty.util.component.ContainerLifeCycle
A monitor for low resources, low resources can be detected by:
ThreadPool.isLowOnThreads()ifConnector.getExecutor()is an instance ofThreadPoolandsetMonitorThreads(boolean)is true.- If
setMaxMemory(long)is non zero then low resources is detected if the JVMsRuntimeinstance hasRuntime.totalMemory()minusRuntime.freeMemory()greater thangetMaxMemory()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassstatic interfaceclassclassclassNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLowResourceCheck(LowResourceMonitor.LowResourceCheck lowResourceCheck) protected voidprotected voiddoStart()protected voiddoStop()protected booleanenableLowOnResources(boolean expectedValue, boolean newValue) intlongintlongprotected Connector[]booleanintbooleanbooleanprotected Stringprotected voidmonitor()voidsetAcceptingInLowResources(boolean acceptingInLowResources) voidsetLowResourceChecks(Set<LowResourceMonitor.LowResourceCheck> lowResourceChecks) protected voidvoidsetLowResourcesIdleTimeout(int lowResourcesIdleTimeoutMS) protected voidsetLowResourcesReasons(String reasons) voidsetLowResourcesStarted(long lowStarted) voidsetMaxLowResourcesTime(int maxLowResourcesTimeMS) voidsetMaxMemory(long maxMemoryBytes) voidsetMonitoredConnectors(Collection<Connector> monitoredConnectors) voidsetMonitorThreads(boolean monitorThreads) voidsetPeriod(int periodMS) protected voidsetReasons(String reasons) Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListenersMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
_server
-
-
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 areThreadPoolinstances that are low on threads.
-
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
@ManagedAttribute("The monitor period in ms") public int 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
-
doStop
-
setLowResources
protected void setLowResources() -
clearLowResources
protected void clearLowResources() -
low
-