javax.management.MBeanRegistration
, Contained
, JmxEnabled
, Lifecycle
, Valve
public class SemaphoreValve extends ValveBase
Implementation of a Valve that limits concurrency.
This Valve may be attached to any Container, depending on the granularity of the concurrency control you wish to perform. Note that internally, some async requests may require multiple serial requests to complete what - to the user - appears as a single request.
Lifecycle.SingleUse
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
block |
Block until a permit is available.
|
protected int |
concurrency |
Concurrency level of the semaphore.
|
protected boolean |
fairness |
Fairness of the semaphore.
|
protected boolean |
interruptible |
Block interruptibly until a permit is available.
|
protected java.util.concurrent.Semaphore |
semaphore |
Semaphore.
|
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
mserver
asyncSupported, container, containerLog, next, sm
Constructor | Description |
---|---|
SemaphoreValve() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
controlConcurrency(Request request,
Response response) |
Subclass friendly method to add conditions.
|
boolean |
getBlock() |
|
int |
getConcurrency() |
|
boolean |
getFairness() |
|
boolean |
getInterruptible() |
|
void |
invoke(Request request,
Response response) |
Do concurrency control on the request using the semaphore.
|
void |
permitDenied(Request request,
Response response) |
Subclass friendly method to add error handling when a permit isn't
granted.
|
void |
setBlock(boolean block) |
|
void |
setConcurrency(int concurrency) |
|
void |
setFairness(boolean fairness) |
|
void |
setInterruptible(boolean interruptible) |
|
protected void |
startInternal() |
Start this component and implement the requirements
of
LifecycleBase.startInternal() . |
protected void |
stopInternal() |
Stop this component and implement the requirements
of
LifecycleBase.stopInternal() . |
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, toString
protected java.util.concurrent.Semaphore semaphore
protected int concurrency
protected boolean fairness
protected boolean block
protected boolean interruptible
public int getConcurrency()
public void setConcurrency(int concurrency)
public boolean getFairness()
public void setFairness(boolean fairness)
public boolean getBlock()
public void setBlock(boolean block)
public boolean getInterruptible()
public void setInterruptible(boolean interruptible)
protected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class ValveBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.stopInternal
in class ValveBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void invoke(Request request, Response response) throws java.io.IOException, ServletException
request
- The servlet request to be processedresponse
- The servlet response to be createdjava.io.IOException
- if an input/output error occursServletException
- if a servlet error occurspublic boolean controlConcurrency(Request request, Response response)
request
- The Servlet requestresponse
- The Servlet responsetrue
if the concurrency control should occur
on this requestpublic void permitDenied(Request request, Response response) throws java.io.IOException, ServletException
request
- The Servlet requestresponse
- The Servlet responsejava.io.IOException
- Error writing outputServletException
- Other errorCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.