Fields Summary |
---|
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 com.sun.enterprise.web.connector.grizzly.ReadTask | readTaskThe ReadTask attached to this Rule |
protected static final ConcurrentHashMap | pipelinesThe Pipeline configured based on the
threadRatio . This Pipeline is only used
by privileged application. |
protected static final ConcurrentHashMap | privilegedTokensThe list of privileged token used to decide if a request can be
serviced by the privileged Pipeline . |
protected static double | leftRatioThe thread ratio used when an application isn't listed as a privileged
application. |
protected static String | allocationPolicyThe allocation mode used: celling or Reserve. With Ceiling policy,
the strategy is to wait until all apps queus are showing some slack.
With Reserve policiy, if 100% reservation is made by other apps,
cancel the request processing. |
Methods Summary |
---|
protected com.sun.enterprise.web.connector.grizzly.Pipeline | applyRule(java.lang.String token)Apply the thread ratio.
Pipeline p = readTask.getPipeline();
int maxThreads = p.getMaxThreads();
Double threadRatio = privilegedTokens.get(token);
if (threadRatio == null) {
threadRatio = (leftRatio == 0? 0.5:leftRatio);
}
int privilegedCount = (threadRatio==1 ? maxThreads :
(int) (maxThreads * threadRatio) + 1);
return newPipeline(privilegedCount,p);
|
public void | attach(com.sun.enterprise.web.connector.grizzly.ReadTask o)Attach a ReadTask to this rule.
this.readTask = o;
|
public com.sun.enterprise.web.connector.grizzly.ReadTask | attachement()Return the current attachement.
return readTask;
|
public java.lang.Integer | call()Invoke the rule. Based on the result of the
ContextRootAlgorithm , configure the ReadTask
Pipeline .
boolean noCache = false;
if ( leftRatio == 0 ) {
if ( allocationPolicy.equals(RESERVE) )
return IsolationRulesExecutor.RULE_BLOCKED;
else if ( allocationPolicy.equals(CEILING) ) {
// If true, then we need to wait for free space. If false, then
// we can go ahead and let the task execute with its default
// pipeline
if ( isPipelineInUse() )
return IsolationRulesExecutor.RULE_DELAY;
else
noCache = true;
}
}
String token = getContextRoot();
// Lazy instanciation
Pipeline pipeline = pipelines.get(token);
if ( pipeline == null ){
pipeline = applyRule(token);
pipelines.put(token,pipeline);
}
readTask.setPipeline(pipeline);
if (!noCache)
return IsolationRulesExecutor.RULE_OK;
else
return IsolationRulesExecutor.RULE_OK_NOCACHE;
|
public void | cancel()Cancel execution of this rule.
readTask = null;
|
protected java.lang.String | getContextRoot()Get the context-root from the ByteBuffer
// (1) Get the token the Algorithm has processed for us.
ByteBuffer byteBuffer = readTask.getByteBuffer();
byte[] chars = new byte[byteBuffer.limit() - byteBuffer.position()];
byteBuffer.get(chars);
String token = new String(chars);
int index = token.indexOf(PATH_STRING);
if ( index != -1){
token = token.substring(0,index);
}
// Remove query string.
index = token.indexOf(QUERY_STRING);
if ( index != -1){
token = token.substring(0,index);
}
boolean slash = token.endsWith(PATH_STRING);
if ( slash ){
token = token.substring(0,token.length() -1);
}
return token;
|
public int | getExecutionTime()Return the time in second before this rule will be executed.
return -1; // now
|
protected boolean | isPipelineInUse()Check to see if the privileged pipeline are in-use right now.
Collection<Pipeline> collection = pipelines.values();
for (Pipeline pipeline: collection){
if (pipeline.size() > 0) {
return true;
}
}
return false;
|
protected com.sun.enterprise.web.connector.grizzly.Pipeline | newPipeline(int threadCount, com.sun.enterprise.web.connector.grizzly.Pipeline p)Creates a new Pipeline
// Run the Task on the SelectorThread
if ( threadCount == 0){
return null;
}
Pipeline pipeline = new LinkedListPipeline();
pipeline.setMinThreads(1);
pipeline.setMaxThreads(threadCount);
pipeline.setName(p.getName());
pipeline.setQueueSizeInBytes(
readTask.getSelectorThread().getQueueSizeInBytes());
pipeline.initPipeline();
pipeline.startPipeline();
return pipeline;
|
public void | setExecutionTime(int time)Set the interval in seconds to wait before executing this rule.
;
|
public void | setFuture(java.util.concurrent.Future future)Set the Future associated with this execution of this rule.
;
|