|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.generic.commonapi.behaviours.BehavioursPoolImpl
The BehavioursPool's class is aimed at providing an internal scheduler of
node's behaviuours. At startup, behaviours are registered to the pool from
Behaviour.properties file, following the next syntax:
Class = Type, Mode, Probability, When, RoleThen, a message interceptor is build up and is ready to invoke behaviours when a message pattern matches to those provided by Behaviour.properties file.
Field Summary | |
protected java.util.Vector[][] |
beh
BehavioursPool properties: mapping from patterns to behaviours. |
protected static int |
BEH_MAPPINGS
Total number of Behaviour's Queue:
|
protected java.util.Vector |
behaviours
Auxiliar Vector to use in the onMessage() method. |
protected java.util.Iterator |
behIt
Auxiliar Iterator to use in the onMessage() method. |
protected int |
behSlots
Number of behaviour's slots: numberTypes * numberModes; |
protected BehavioursFilter |
filter
Filter instance. |
protected static int |
NULL_MASK
Behaviour's Property: Lack Of Neutral and Always Mask. |
protected static int |
ROLE_BAD
Behaviour's Property: Bad modifier for Behaviour's role. |
protected static int |
ROLE_GOOD
Behaviour's Property: Good modifier for Behaviour's role. |
protected static int |
ROLE_NEUTRAL_MASK
Behaviour's Property: Neutral modifier applied to a behaviour ignores the distinction between local or remote traffic handled by a node. |
protected static int |
TRAFFIC_ALWAYS_MASK
Behaviour's Property: Always modifier applied to a behaviour ignores the distinction between local or remote traffic handled by a node. |
protected static int |
TRAFFIC_LOCAL
Behaviour's Property: Local modifier applied to a behaviour means it only will be scheduled when a RouteMessage has as destination the local node. |
protected static int |
TRAFFIC_REMOTE
Behaviour's Property: Remote modifier applied to a behaviour means it only will be scheduled when a RouteMessage has as destination a remote node and needs to be rerouted trough the overlay again. |
Constructor Summary | |
BehavioursPoolImpl()
Builds a non initialized pool. |
Method Summary | |
protected void |
build(java.util.Vector patterns)
Given the patterns sorted from more-to-less specific as input, builds a mapping from RouteMessage's patterns to behaviours. |
void |
onMessage(RouteMessage msg,
Node node)
Given a RouteMessage and a Node as input, onMessage's method intends to invoke some behaviours only if RouteMessage's type and mode fields matches some behaviour's pattern. |
protected void |
prettyPrintAll()
|
protected void |
printMap(int queue)
|
protected void |
setPattern(int queue,
int typePos,
java.lang.String modeOf,
BehavioursPatternImpl pattern)
Given the initial position for type on mapping typePos and mode as input, sets the pattern on the mapping taking into account the grammar tree extracted from wildcards semantics. |
protected boolean[] |
whichQueues(int Mask,
int RoleOf,
int WhenTo)
The WhichQueue's method selects for a given pattern what Queues must include a copy of the current behaviour. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Vector[][] beh
For each pattern on P do Mode = pattern.getMode(); Type = pattern.getType(); beh[Type * NumberOfModes + Mode] = pattern; done;Moreover, Pattern's definiton provides additional specifiers:
protected static final int ROLE_GOOD
protected static final int ROLE_BAD
protected static final int TRAFFIC_LOCAL
protected static int TRAFFIC_REMOTE
protected BehavioursFilter filter
protected int behSlots
protected java.util.Vector behaviours
protected java.util.Iterator behIt
protected static final int TRAFFIC_ALWAYS_MASK
protected static final int ROLE_NEUTRAL_MASK
protected static final int NULL_MASK
protected static final int BEH_MAPPINGS
Constructor Detail |
public BehavioursPoolImpl() throws InitializationException
Method Detail |
protected boolean[] whichQueues(int Mask, int RoleOf, int WhenTo)
Mask
- The Mask for Pattern.Always and Pattern.Neutral modifiers.RoleOf
- The Behaviour's Role for a Good or Bad peer.WhenTo
- Specifies Behaviour should be activated when incoming messages
refer to the local node or either when refer to a remote.
protected void build(java.util.Vector patterns) throws InitializationException
patterns
- The List of patterns.
InitializationException
protected void setPattern(int queue, int typePos, java.lang.String modeOf, BehavioursPatternImpl pattern) throws InitializationException
queue
- Identifies where to be queued the pattern.typePos
- Initial position on behaviours mapping array, i.e, [typePos..typePos + NumberOfModes]modeOf
- Mode of the pattern: Universal wildcard or '*', Complementary wildcard or '?' and Tag.pattern
- Pattern to be treat.
InitializationException
protected void prettyPrintAll()
protected void printMap(int queue)
public void onMessage(RouteMessage msg, Node node) throws NoSuchBehaviourException, NoBehaviourDispatchedException
onMessage
in interface BehavioursPool
msg
- RoteMessage taken as input.node
- Node taken as input.
NoSuchBehaviourException
- when no behaviour matches RouteMessage's
pattern.
NoBehaviourDispatchedException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |