com.sun.enterprise.web.ara.rules
Class ThreadRatioRule

java.lang.Object
  extended by com.sun.enterprise.web.ara.rules.ThreadRatioRule
All Implemented Interfaces:
Rule<ReadTask>, Callable
Direct Known Subclasses:
HeapMemoryRule, PathRule

public class ThreadRatioRule
extends Object
implements Rule<ReadTask>

Based on the application context-root, configure the ReadTask Pipeline. Based on the thread-ratio defined in domain.xml, an application can have privileged Pipeline, configured to use specific percentage of the maximum number of threads. This Rule instanciate two types of Pipeline privilegedPipeline is will be used to execute privileged applications. victimsPipeline is will be used to execute others application that aren't included within the privileged tokens. An application is marked privileged if the set of Rule applied to the application requests is matched.

Author:
Jeanfrancois Arcand

Field Summary
protected static String ALLOCATION_MODE
           
protected static String allocationPolicy
          The allocation mode used: celling or Reserve.
protected static String CEILING
           
protected static 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,Pipeline> pipelines
          The Pipeline configured based on the threadRatio.
protected static ConcurrentHashMap<String,Double> privilegedTokens
          The list of privileged token used to decide if a request can be serviced by the privileged Pipeline.
protected static String QUERY_STRING
           
protected  ReadTask readTask
          The ReadTask attached to this Rule
protected static String RESERVE
           
protected static String RULE_TOKENS
           
 
Constructor Summary
ThreadRatioRule()
          Creates a new ThreadRationRule.
 
Method Summary
protected  Pipeline applyRule(String token)
          Apply the thread ratio.
 void attach(ReadTask o)
          Attach a ReadTask to this rule.
 ReadTask attachement()
          Return the current attachement.
 Integer call()
          Invoke the rule.
 void cancel()
          Cancel execution of this rule.
protected  String getContextRoot()
          Get the context-root from the ByteBuffer
 int getExecutionTime()
          Return the time in second before this rule will be executed.
protected  boolean isPipelineInUse()
          Check to see if the privileged pipeline are in-use right now.
protected  Pipeline newPipeline(int threadCount, Pipeline p)
          Creates a new Pipeline
 void setExecutionTime(int time)
          Set the interval in seconds to wait before executing this rule.
 void setFuture(Future future)
          Set the Future associated with this execution of this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESERVE

protected static final String RESERVE
See Also:
Constant Field Values

CEILING

protected static final String CEILING
See Also:
Constant Field Values

ALLOCATION_MODE

protected static final String ALLOCATION_MODE
See Also:
Constant Field Values

RULE_TOKENS

protected static final String RULE_TOKENS
See Also:
Constant Field Values

QUERY_STRING

protected static final String QUERY_STRING
See Also:
Constant Field Values

PATH_STRING

protected static final String PATH_STRING
See Also:
Constant Field Values

readTask

protected ReadTask readTask
The ReadTask attached to this Rule


pipelines

protected static final ConcurrentHashMap<String,Pipeline> pipelines
The Pipeline configured based on the threadRatio. This Pipeline is only used by privileged application.


privilegedTokens

protected static final ConcurrentHashMap<String,Double> privilegedTokens
The list of privileged token used to decide if a request can be serviced by the privileged Pipeline.


leftRatio

protected static double leftRatio
The thread ratio used when an application isn't listed as a privileged application.


allocationPolicy

protected static String allocationPolicy
The 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.

Constructor Detail

ThreadRatioRule

public ThreadRatioRule()
Creates a new ThreadRationRule.

Method Detail

attach

public void attach(ReadTask o)
Attach a ReadTask to this rule.

Specified by:
attach in interface Rule<ReadTask>

attachement

public ReadTask attachement()
Return the current attachement.

Specified by:
attachement in interface Rule<ReadTask>

call

public Integer call()
             throws Exception
Invoke the rule. Based on the result of the ContextRootAlgorithm, configure the ReadTask Pipeline.

Specified by:
call in interface Callable
Throws:
Exception

getContextRoot

protected String getContextRoot()
Get the context-root from the ByteBuffer


applyRule

protected Pipeline applyRule(String token)
Apply the thread ratio.


newPipeline

protected Pipeline newPipeline(int threadCount,
                               Pipeline p)
Creates a new Pipeline


isPipelineInUse

protected boolean isPipelineInUse()
Check to see if the privileged pipeline are in-use right now.


cancel

public void cancel()
Cancel execution of this rule.

Specified by:
cancel in interface Rule<ReadTask>

getExecutionTime

public int getExecutionTime()
Return the time in second before this rule will be executed.

Specified by:
getExecutionTime in interface Rule<ReadTask>

setExecutionTime

public void setExecutionTime(int time)
Set the interval in seconds to wait before executing this rule.

Specified by:
setExecutionTime in interface Rule<ReadTask>

setFuture

public void setFuture(Future future)
Set the Future associated with this execution of this rule.

Specified by:
setFuture in interface Rule<ReadTask>


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.