com.sun.grizzly.rcm
Class ResourceAllocationFilter

java.lang.Object
  extended by com.sun.grizzly.filter.ReadFilter
      extended by com.sun.grizzly.filter.ParserProtocolFilter
          extended by com.sun.grizzly.rcm.ResourceAllocationFilter
All Implemented Interfaces:
ProtocolFilter

public class ResourceAllocationFilter
extends ParserProtocolFilter

This ProtocolFilter 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 ProtocolFiler uses a ProtocolParser 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.sun.grizzly.rcm.policyMetric="/myApplication|0.9" This ProtocolFilter will allocate 90% of the current threads count to application myApplication, and the remaining 10% to any other context-root (or application). See com.sun.grizzly.rcm.RCM for an example.

Author:
Jeanfrancois Arcand

Field Summary
protected static String ALLOCATION_MODE
           
protected static String allocationPolicy
          The allocation mode used: celling or Reserve.
static String BYTE_BUFFER
           
static String BYTEBUFFER_INPUTSTREAM
           
protected static String CEILING
           
static String INVOKE_NEXT
           
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 static String RESERVE
           
protected static String RULE_TOKENS
           
 
Fields inherited from class com.sun.grizzly.filter.ReadFilter
continousExecution, UDP_SOCKETADDRESS
 
Fields inherited from interface com.sun.grizzly.ProtocolFilter
SUCCESSFUL_READ
 
Constructor Summary
ResourceAllocationFilter()
           
 
Method Summary
 void closeConnection(Context ctx)
          Close the connection.
 Pipeline filterRequest(String token, Pipeline p)
          Filter the request and decide which Pipeline to use.
protected  String getContextRoot(ByteBuffer byteBuffer)
          Get the context-root from the ByteBuffer
 boolean invokeProtocolParser(Context ctx, ProtocolParser protocolParser)
          Invoke the ProtocolParser.
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
 ProtocolParser newProtocolParser()
          Return a new ProtocolParser>/code> or a cached
 
Methods inherited from class com.sun.grizzly.filter.ParserProtocolFilter
execute, postExecute
 
Methods inherited from class com.sun.grizzly.filter.ReadFilter
execute, isContinuousExecution, log, setContinuousExecution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE_BUFFER

public static final String BYTE_BUFFER
See Also:
Constant Field Values

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

BYTEBUFFER_INPUTSTREAM

public static final String BYTEBUFFER_INPUTSTREAM
See Also:
Constant Field Values

INVOKE_NEXT

public static final String INVOKE_NEXT
See Also:
Constant Field Values

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

ResourceAllocationFilter

public ResourceAllocationFilter()
Method Detail

invokeProtocolParser

public boolean invokeProtocolParser(Context ctx,
                                    ProtocolParser protocolParser)
Invoke the ProtocolParser. If more bytes are required, register the SelectionKey back to its associated SelectorHandler

Overrides:
invokeProtocolParser in class ParserProtocolFilter
Parameters:
ctx - the Context object.
Returns:
true if no more bytes are needed.

filterRequest

public Pipeline filterRequest(String token,
                              Pipeline p)
Filter the request and decide which Pipeline to use.


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.


getContextRoot

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


closeConnection

public void closeConnection(Context ctx)
Close the connection.


newProtocolParser

public ProtocolParser newProtocolParser()
Return a new ProtocolParser>/code> or a cached

Specified by:
newProtocolParser in class ParserProtocolFilter


Copyright © 2008 SUN Microsystems. All Rights Reserved.