public class ResourceAllocationFilter extends BaseFilter
Filter
is an implementation of a Resource Consumption Management
(RCM) system. RCM system are allowing you to enable virtualization of system
resources per web application, similar to Solaris 10 Zone or the outcome of
the upcoming JSR 284.
This Filter
uses system properties to determine which
token to use to enable virtualization. As an example, configuring this class
to use the ContextRootAlgorithm
will allow virtualization
and isolation of http request. As an example, if you define:
-Dcom.glassfish.grizzly.rcm.policyMetric="/myApplication|0.9"
This Filter
will allocate 90% of the current threads count to
application myApplication, and the remaining 10% to any other context-root
(or application).Modifier and Type | Field and Description |
---|---|
protected static String |
ALLOCATION_MODE |
protected String |
allocationPolicy
The allocation mode used: ceiling or Reserve.
|
protected static String |
CEILING |
protected double |
leftRatio
The thread ratio used when an application isn't listed as a privileged
application.
|
protected static String |
PATH_STRING |
protected static ConcurrentHashMap<String,Double> |
privilegedTokens
The list of privileged token used to decide if a request can be
serviced by the privileged
ExecutorService . |
protected static String |
QUERY_STRING |
protected static String |
RESERVE |
protected static String |
RULE_TOKENS |
protected static ConcurrentHashMap<String,ExecutorService> |
threadPools
The
ExecutorService configured based on the
threadRatio . |
Constructor and Description |
---|
ResourceAllocationFilter() |
ResourceAllocationFilter(int standardThreadPoolSize) |
Modifier and Type | Method and Description |
---|---|
ExecutorService |
filterRequest(String token)
Filter the request and decide which thread pool to use.
|
protected String |
getContextRoot(String token)
Get the context-root from the
StreamReader |
int |
getStandardThreadPoolSize() |
NextAction |
handleRead(FilterChainContext ctx)
Execute a unit of processing work to be performed, when channel will
become available for reading.
|
protected boolean |
isThreadPoolInUse()
Check to see if the privileged thread pool are in-use right now.
|
protected ExecutorService |
newThreadPool(int threadCount)
Creates a new
ExecutorService |
protected boolean |
parse(Buffer inputMessage,
int state,
StringBuilder sb) |
createContext, exceptionOccurred, getFilterChain, getIndex, handleAccept, handleClose, handleConnect, handleEvent, handleWrite, onAdded, onFilterChainChanged, onRemoved
protected static final String RESERVE
protected static final String CEILING
protected static final String ALLOCATION_MODE
protected static final String RULE_TOKENS
protected static final String QUERY_STRING
protected static final String PATH_STRING
protected static final ConcurrentHashMap<String,ExecutorService> threadPools
ExecutorService
configured based on the
threadRatio
. This ExecutorService
is only used
by privileged application.protected static final ConcurrentHashMap<String,Double> privilegedTokens
ExecutorService
.protected double leftRatio
protected String allocationPolicy
public ResourceAllocationFilter()
public ResourceAllocationFilter(int standardThreadPoolSize)
public NextAction handleRead(FilterChainContext ctx) throws IOException
BaseFilter
Filter
may either complete the required processing and
return false, or delegate remaining processing to the next
Filter
in a FilterChain
containing this Filter
by returning true.handleRead
in interface Filter
handleRead
in class BaseFilter
ctx
- FilterChainContext
NextAction
instruction for FilterChain
, how it
should continue the executionIOException
public int getStandardThreadPoolSize()
public ExecutorService filterRequest(String token)
protected ExecutorService newThreadPool(int threadCount)
ExecutorService
protected boolean isThreadPoolInUse()
protected String getContextRoot(String token)
StreamReader
protected boolean parse(Buffer inputMessage, int state, StringBuilder sb) throws IOException
IOException
Copyright © 2013 Oracle Corporation. All Rights Reserved.