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

public abstract class ExecutionPolicy extends Object implements Serializable
Interface for all execution policy implementations. This API defines a DSL for predicate-oriented expressions.
Author:
Laurent Cohen
See Also:
  • Field Details

    • children

      protected final ExecutionPolicy[] children
      The children of this rule.
  • Constructor Details

    • ExecutionPolicy

      protected ExecutionPolicy()
      Initialize this policy with the specified children.
    • ExecutionPolicy

      protected ExecutionPolicy(ExecutionPolicy... children)
      Initialize this policy with the specified children.
      Parameters:
      children - the children of this policy.
  • Method Details

    • evaluate

      public boolean evaluate(PropertiesCollection<String> info)
      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

      public abstract boolean accepts(PropertiesCollection<String> info)
      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

      public ExecutionPolicy and(ExecutionPolicy rule)
      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

      public ExecutionPolicy and(ExecutionPolicy... rules)
      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

      public ExecutionPolicy 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.
      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

      public ExecutionPolicy andNot(ExecutionPolicy... rules)
      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

      public ExecutionPolicy or(ExecutionPolicy rule)
      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

      public ExecutionPolicy or(ExecutionPolicy... rules)
      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

      public ExecutionPolicy 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.
      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

      public ExecutionPolicy orNot(ExecutionPolicy... rules)
      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

      public ExecutionPolicy xor(ExecutionPolicy rule)
      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

      public ExecutionPolicy xor(ExecutionPolicy... rules)
      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

      public ExecutionPolicy not()
      Create an execution policy that is a negation of this policy.
      Returns:
      an execution policy that negates this policy.
    • negate

      public ExecutionPolicy negate()
      Create an execution policy that is a negation of this policy.
      Returns:
      an execution policy that negates this policy.
    • getChildren

      public ExecutionPolicy[] getChildren()
      Get the children of this rule.
      Returns:
      an array of ExecutionPolicy instances, or null for leaf rules.
    • getProperty

      public String getProperty(PropertiesCollection<String> info, String name)
      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

      protected String indent(int indentSize)
      Get an indented string.
      Parameters:
      indentSize - the size of the indent to produce.
      Returns:
      an indented string depending on the value of toStringIndent.
    • toString

      public abstract String toString(int indent)
      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

      public String toString()
      Overrides:
      toString in class Object
    • toXML

      public String 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

      public static ExecutionPolicy Not(ExecutionPolicy policy)
      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 null if the specified policy was null.
    • tagStart

      protected String tagStart(String name)
      Format the specified name as <name>.
      Parameters:
      name - the name of the tag.
      Returns:
      an XML start tag built from the name.
    • tagEnd

      protected String tagEnd(String name)
      Format the specified name as </name>.
      Parameters:
      name - the name of the tag.
      Returns:
      an XML end tag built from the name.
    • xmlElement

      protected String xmlElement(String tag, String value)
      Format an XML element as <tag;>value&lt/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

      protected String xmlElement(String tag, double value)
      Format an XML element as <tag;>value&lt/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

      protected void setContext(PolicyContext context)
      Set this policy's context.
      Parameters:
      context - the context to set.
    • getContext

      public PolicyContext getContext()
      Get the context for this policy.
      Returns:
      a PolicyContext object.
      Since:
      5.0
    • checkRules

      protected ExecutionPolicy[] checkRules(ExecutionPolicy... rules) throws JPPFRuntimeException
      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.