Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util.thread

public Class ThreadPoolBudget

extends Object
Class Inheritance
Annotations
@ManagedObject
Imports
java.io.Closeable, java.util.Set, java.util.concurrent.CopyOnWriteArraySet, .Executor, java.util.concurrent.atomic.AtomicBoolean, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.slf4j.Logger, .LoggerFactory

A budget of required thread usage, used to warn or error for insufficient configured threads.

See Also
ThreadPool.SizedThreadPool#getThreadPoolBudget()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public class
ThreadPoolBudget.Leased

An allocation of threads

Field Summary

Modifier and TypeField and Description
private final Set<ThreadPoolBudget.Leased>
private static final Logger
private static final ThreadPoolBudget.Lease
private final ThreadPool.SizedThreadPool
private final int
private final AtomicBoolean

Constructor Summary

AccessConstructor and Description
public
ThreadPoolBudget(ThreadPool.SizedThreadPool
The pool to budget thread allocation for.
pool
)

Construct a budget for a SizedThreadPool.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if passes check, false if otherwise (see logs for details)
check
(int
A proposed change to the maximum threads to check.
maxThreads
)

Checks leases against the given number of maxThreads.

public int
public ThreadPool.SizedThreadPool
public static ThreadPoolBudget.Lease
leaseFrom(Executor executor, Object leasee, int threads)

public ThreadPoolBudget.Lease
leaseTo(Object leasee, int threads)

private void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

leasesback to summary
private final Set<ThreadPoolBudget.Leased> leases
LOGback to summary
private static final Logger LOG
NOOP_LEASEback to summary
private static final ThreadPoolBudget.Lease NOOP_LEASE
poolback to summary
private final ThreadPool.SizedThreadPool pool
warnAtback to summary
private final int warnAt
warnedback to summary
private final AtomicBoolean warned

Constructor Detail

ThreadPoolBudgetback to summary
public ThreadPoolBudget(ThreadPool.SizedThreadPool pool)

Construct a budget for a SizedThreadPool.

Parameters
pool:ThreadPool.SizedThreadPool

The pool to budget thread allocation for.

Method Detail

checkback to summary
public boolean check(int maxThreads) throws IllegalStateException

Checks leases against the given number of maxThreads.

Parameters
maxThreads:int

A proposed change to the maximum threads to check.

Returns:boolean

true if passes check, false if otherwise (see logs for details)

Exceptions
IllegalStateException:
if insufficient threads are configured.
getLeasedThreadsback to summary
public int getLeasedThreads()
Annotations
@ManagedAttribute:the number of threads leased to components
getSizedThreadPoolback to summary
public ThreadPool.SizedThreadPool getSizedThreadPool()
leaseFromback to summary
public static ThreadPoolBudget.Lease leaseFrom(Executor executor, Object leasee, int threads)
leaseToback to summary
public ThreadPoolBudget.Lease leaseTo(Object leasee, int threads)
printInfoOnLeasesback to summary
private void printInfoOnLeases()
resetback to summary
public void reset()
org.eclipse.jetty.util.thread back to summary

public Interface ThreadPoolBudget.Lease

extends Closeable
Known Direct Implementers
org.eclipse.jetty.util.thread.ThreadPoolBudget.Leased

Method Summary

Modifier and TypeMethod and Description
public int
Inherited from java.io.Closeable:
close

Method Detail

getThreadsback to summary
public int getThreads()
org.eclipse.jetty.util.thread back to summary

public Class ThreadPoolBudget.Leased

extends Object
implements Lease
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.ThreadPoolBudget.Lease, java.io.Closeable, java.lang.AutoCloseable

An allocation of threads

Field Summary

Modifier and TypeField and Description
private final Object
private final int

Constructor Summary

AccessConstructor and Description
private
Leased(Object leasee, int threads)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

leaseeback to summary
private final Object leasee
threadsback to summary
private final int threads

Constructor Detail

Leasedback to summary
private Leased(Object leasee, int threads)

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
getThreadsback to summary
public int getThreads()

Implements org.eclipse.jetty.util.thread.ThreadPoolBudget.Lease.getThreads.

Annotations
@Override