Package org.jppf.node.policy
Class ExecutionPolicy
java.lang.Object
org.jppf.node.policy.ExecutionPolicy
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractIsInIPSubnet,AcceptAll,AtLeast,AtMost,BetweenEE,BetweenEI,BetweenIE,BetweenII,Contains,CustomPolicy,Equal,ExecutionPolicy.NotRule,IsLocalChannel,IsMasterNode,IsPeerDriver,IsSlaveNode,LessThan,LogicalRule,MoreThan,NodesMatching,OneOf,RegExp,RejectAll,ScriptedPolicy
Interface for all execution policy implementations.
This API defines a DSL for predicate-oriented expressions.
- Author:
- Laurent Cohen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn execution policy that realizes a logical "AND" combination of multiple policies specified as operands.static classAn execution policy that realizes the negation of a policy specified as operand.static classAn execution policy that realizes a logical "OR" combination of multiple policies specified as operands.static classAn execution policy that realizes a logical "XOR" combination of multiple policies specified as operands. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitialize this policy with the specified children.protectedExecutionPolicy(ExecutionPolicy... children) Initialize this policy with the specified children. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanaccepts(PropertiesCollection<String> info) Determines whether this policy accepts the specified node.and(ExecutionPolicy rule) Create an execution policy that is a logical "AND" combination of this policy and the one specified as operand.and(ExecutionPolicy... rules) Create an execution policy that is a logical "AND" combination of this policy and those specified as operands.andNot(ExecutionPolicy rule) Create an execution policy that is a logical "NOT" combination of this policy and the negations of the one specified as argument.andNot(ExecutionPolicy... rules) Create an execution policy that is a logical "AND" combination of this policy and the negations of those specified as argumens.protected ExecutionPolicy[]checkRules(ExecutionPolicy... rules) Check whether the policy has valid arguments.booleanevaluate(PropertiesCollection<String> info) Determines whether this policy accepts the specified node.Get the children of this rule.Get the context for this policy.getProperty(PropertiesCollection<String> info, String name) Get the value of the specified property in the specified set of system information.protected Stringindent(int indentSize) Get an indented string.negate()Create an execution policy that is a negation of this policy.not()Create an execution policy that is a negation of this policy.static ExecutionPolicyNot(ExecutionPolicy policy) A convenience method to provide a way to negate a policy that is consistent with the execution policy DSL.or(ExecutionPolicy rule) Create an execution policy that is a logical "OR" combination of this policy and the one specified as operand.or(ExecutionPolicy... rules) Create an execution policy that is a logical "OR" combination of this policy and those specified as operands.orNot(ExecutionPolicy rule) Create an execution policy that is a logical "OR" combination of this policy and the negations of the one specified as argument.orNot(ExecutionPolicy... rules) Create an execution policy that is a logical "OR" combination of this policy and the negations of those specified as arguments.protected voidsetContext(PolicyContext context) Set this policy's context.voidsetContext(JobSLA sla, JobClientSLA clientSla, JobMetadata metadata, int jobDispatches, JPPFStatistics stats) Set the parameters used as bound variables in the script.protected StringFormat the specified name as </name>.protected StringFormat the specified name as <name>.toString()abstract StringtoString(int indent) Get an xml string representation of this policy with the specified starting indentation level.toXML()Convert this execution policy to XML.protected StringxmlElement(String tag, double value) Format an XML element as <tag;>value</tag>.protected StringxmlElement(String tag, String value) Format an XML element as <tag;>value</tag>.xor(ExecutionPolicy rule) Create an execution policy that is a logical "XOR" combination of this policy and the one specified as operand.xor(ExecutionPolicy... rules) Create an execution policy that is a logical "XOR" combination of the this policy and those specified as operands.
-
Field Details
-
children
The children of this rule.
-
-
Constructor Details
-
ExecutionPolicy
protected ExecutionPolicy()Initialize this policy with the specified children. -
ExecutionPolicy
Initialize this policy with the specified children.- Parameters:
children- the children of this policy.
-
-
Method Details
-
evaluate
Determines whether this policy accepts the specified node.- Parameters:
info- system information for the node on which the tasks will run if accepted.- Returns:
- true if the node is accepted, false otherwise.*
-
accepts
Determines whether this policy accepts the specified node. This method must be overriden in subclasses.- Parameters:
info- system information for the node on which the tasks will run if accepted.- Returns:
- true if the node is accepted, false otherwise.
-
and
Create an execution policy that is a logical "AND" combination of this policy and the one specified as operand.- Parameters:
rule- the rule to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "AND" operation.
-
and
Create an execution policy that is a logical "AND" combination of this policy and those specified as operands.- Parameters:
rules- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "AND" operation.
-
andNot
Create an execution policy that is a logical "NOT" combination of this policy and the negations of the one specified as argument.- Parameters:
rule- the rule to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "AND" operation.
-
andNot
Create an execution policy that is a logical "AND" combination of this policy and the negations of those specified as argumens.- Parameters:
rules- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "AND" operation.
-
or
Create an execution policy that is a logical "OR" combination of this policy and the one specified as operand.- Parameters:
rule- the rule to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "OR" operation.
-
or
Create an execution policy that is a logical "OR" combination of this policy and those specified as operands.- Parameters:
rules- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "OR" operation.
-
orNot
Create an execution policy that is a logical "OR" combination of this policy and the negations of the one specified as argument.- Parameters:
rule- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the negated operand in an "OR NOT" operation.
-
orNot
Create an execution policy that is a logical "OR" combination of this policy and the negations of those specified as arguments.- Parameters:
rules- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the negated operand in an "OR NOT" operation.
-
xor
Create an execution policy that is a logical "XOR" combination of this policy and the one specified as operand.- Parameters:
rule- the rule to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "XOR" operation.
-
xor
Create an execution policy that is a logical "XOR" combination of the this policy and those specified as operands.- Parameters:
rules- rules to combine this one with.- Returns:
- an execution policy that combines the this policy with the operand in an "XOR" operation.
-
not
Create an execution policy that is a negation of this policy.- Returns:
- an execution policy that negates this policy.
-
negate
Create an execution policy that is a negation of this policy.- Returns:
- an execution policy that negates this policy.
-
getChildren
Get the children of this rule.- Returns:
- an array of
ExecutionPolicyinstances, ornullfor leaf rules.
-
getProperty
Get the value of the specified property in the specified set of system information.- Parameters:
info- the system information in which to lookup the property.name- the name of the property to look for.- Returns:
- the value of the property, or null if it could not be found.
-
indent
Get an indented string.- Parameters:
indentSize- the size of the indent to produce.- Returns:
- an indented string depending on the value of
toStringIndent.
-
toString
Get an xml string representation of this policy with the specified starting indentation level.- Parameters:
indent- the size of the indent to startwith.- Returns:
- an indented string depending on the value of
toStringIndent.
-
toString
-
toXML
Convert this execution policy to XML.- Returns:
- an XML representation of this policy, fully compliant with the JPPF execution policy XML schema at http://www.jppf.org/schemas/ExecutionPolicy.xsd.
-
Not
A convenience method to provide a way to negate a policy that is consistent with the execution policy DSL.- Parameters:
policy- the policy to negate.- Returns:
- An execution policy which negates the specified policy, or
nullif the specified policy wasnull.
-
tagStart
Format the specified name as <name>.- Parameters:
name- the name of the tag.- Returns:
- an XML start tag built from the name.
-
tagEnd
Format the specified name as </name>.- Parameters:
name- the name of the tag.- Returns:
- an XML end tag built from the name.
-
xmlElement
Format an XML element as <tag;>value</tag>.- Parameters:
tag- the name of the XML tag.value- the string value of the XML element.- Returns:
- an XML element built from the tag name and value.
-
xmlElement
Format an XML element as <tag;>value</tag>.- Parameters:
tag- the name of the XML tag.value- the value of the XML element as a double.- Returns:
- an XML element built from the tag name and value.
-
setContext
public void setContext(JobSLA sla, JobClientSLA clientSla, JobMetadata metadata, int jobDispatches, JPPFStatistics stats) Set the parameters used as bound variables in the script.- Parameters:
sla- the job server-side sla.clientSla- the job client-side sla.metadata- the job metadata.jobDispatches- the number of nodes the job is already dispatched to.stats- the server statistics.
-
setContext
Set this policy's context.- Parameters:
context- the context to set.
-
getContext
Get the context for this policy.- Returns:
- a
PolicyContextobject. - Since:
- 5.0
-
checkRules
Check whether the policy has valid arguments.- Parameters:
rules- the arguments to check.- Returns:
- the non-null arguments, possibly a subset of the provided arguments.
- Throws:
JPPFRuntimeException- if the arguments are not valid.
-