Execution Policy Elements
From JPPF 6.2 Documentation
1 NOT
Negates a test
Class name: ExecutionPolicy.NotRule
Usage:
policy = otherPolicy.not();
XML Element: <NOT>
Nested element: any other policy element, min = 1, max = 1
Usage:
<NOT> <Equal ignoreCase="true" valueType="string"> <Property>some.property</Property> <Value>some value here</Value> </Equal> </NOT>
2 AND
Combines multiple tests through a logical AND operator
Class name: ExecutionPolicy.AndRule
Usage:
policy = policy1.and(policy2).and(policy3); policy = policy1.and(policy2, policy3);
XML Element: <AND>
Nested element: any other policy element, min = 2, max = unbounded
Usage:
<AND> <Equal ignoreCase="true" valueType="string"> <Property>some.property.1</Property> <Value>some value here</Value> </Equal> <LessThan> <Property>some.property.2</Property> <Value>100</Value> </LessThan> <Contains ignoreCase="true" valueType="string"> <Property>some.property.3</Property> <Value>substring</Value> </Contains> </AND>
3 OR
Combines multiple tests through a logical OR operator
Class name: ExecutionPolicy.OrRule
Usage:
policy = policy1.or(policy2).or(policy3); policy = policy1.or(policy2, policy3);
XML Element: <OR>
Nested element: any other policy element, min = 2, max = unbounded
Usage:
<OR> <Equal ignoreCase="true" valueType="string"> <Property>some.property.1</Property> <Value>some value here</Value> </Equal> <LessThan> <Property>some.property.2</Property> <Value>100</Value> </LessThan> <Contains ignoreCase="true" valueType="string"> <Property>some.property.3</Property> <Value>substring</Value> </Contains> </OR>
4 XOR
Combines multiple tests through a logical XOR operator
Class name: ExecutionPolicy.XorRule
Usage:
policy = policy1.xor(policy2).xor(policy3); policy = policy1.xor(policy2, policy3);
XML Element: <XOR>
Nested element: any other policy element, min = 2, max = unbounded
Usage:
<XOR> <Equal ignoreCase="true" valueType="string"> <Property>some.property.1</Property> <Value>some value here</Value> </Equal> <LessThan> <Property>some.property.2</Property> <Value>100</Value> </LessThan> <Contains ignoreCase="true" valueType="string"> <Property>some.property.3</Property> <Value>substring</Value> </Contains> </XOR>
5 Equal
Performs a test of type a = b. The value can be either numeric, boolean or a string.
Class name: Equal
Constructors:
public Equal(ValueType valueType, String propertyNameOrExpression, String value) Equal(String propertyNameOrExpression, boolean ignoreCase, String value) Equal(String propertyNameOrExpression, double value) Equal(String propertyNameOrExpression, boolean value)
Usage:
policy = new Equal(ValueType.NUMERIC, "jppf.processing.threads", "$S{ 2 * ${availableProcessors} }$"); policy = new Equal("some.property", true, "some_value"); policy = new Equal("$script{ 2 * ${some.property} }$", 15); policy = new Equal("some.property", true);
XML Element: <Equal>
Attributes:
ignoreCase : one of "true" or "false", optional, defaults to "false"
valueType : one of "string", "numeric" or "boolean", optional, defaults to "string"
Nested elements:
<Property> : name of a node property or expression of the related type, min = 1, max = 1
<Value> : literal value or expression of the related type to compare with, min = 1, max = 1
Usage:
<Equal valueType="numeric"> <Property>jppf.processing.threads</Property> <Value>$script{ 2 * ${availableProcessors} }$</Value> </Equal>
<Equal ignoreCase="true" valueType="string"> <Property>some.property</Property> <Value>some value here</Value> </Equal>
<Equal valueType="numeric"> <Property>$script{ 2 * ${some.property} }$</Property> <Value>15</Value> </Equal>
<Equal valueType="boolean"> <Property>some.property</Property> <Value>true</Value> </Equal>
6 LessThan
Performs a test of type a < b
The values can only be numeric.
Class name: LessThan
Constructor:
LessThan(String propertyNameOrExpression, double value) LessThan(String propertyNameOrExpression, String expression)
Usage:
policy = new LessThan("some.property", 15.50); policy = new LessThan("some.property", "$script{ 10 + 5.5 }$");
XML Element: <LessThan>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : literal value or expression to compare with, min = 1, max = 1
Usage:
<LessThan> <Property>some.property</Property> <Value>15.50</Value> </LessThan>
<LessThan> <Property>some.property</Property> <Value>$script{ 10 + 5.5 }$</Value> </LessThan>
7 AtMost
Performs a test of type a <= b
The value can only be numeric.
Class name: AtMost
Constructor:
AtMost(String propertyNameOrExpression, double value) AtMost(String propertyNameOrExpression, String expression)
Usage:
policy = new AtMost("some.property", 15.50); policy = new AtMost("some.property", "$script{ 10 + 5.5 }$");
XML Element: <AtMost>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : literal value or expression to compare with, min = 1, max = 1
Usage:
<AtMost> <Property>some.property</Property> <Value>15.49</Value> </AtMost>
<AtMost> <Property>some.property</Property> <Value>$script{ 10 + 5.5 }$</Value> </AtMost>
8 MoreThan
Performs a test of type a > b
The value can only be numeric.
Class name: MoreThan
Constructor:
MoreThan(String propertyNameOrExpression, double value) MoreThan(String propertyNameOrExpression, String expression)
Usage:
policy = new MoreThan("some.property", 15.50); policy = new MoreThan("some.property", "$script{ 10 + 5.5 }$");
XML Element: <MoreThan>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : literal value or expression to compare with, min = 1, max = 1
Usage:
<MoreThan> <Property>some.property</Property> <Value>15.50</Value> </MoreThan>
<MoreThan> <Property>some.property</Property> <Value>$script{ 10 + 5.5 }$</Value> </MoreThan>
9 AtLeast
Performs a test of type property_value >= value
The value can only be numeric.
Class name: AtLeast
Constructor:
AtLeast(String propertyNameOrExpression, double value) AtLeast(String propertyNameOrExpression, String expression)
Usage:
policy = new AtLeast("some.property", 15.51); policy = new AtLeast("some.property", "$script{ 10 + 5.5 }$");
XML Element: <AtLeast>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : literal value or expression to compare with, min = 1, max = 1
Usage:
<AtLeast> <Property>some.property</Property> <Value>15.51</Value> </AtLeast>
<AtLeast> <Property>some.property</Property> <Value>$script{ 10 + 5.5 }$</Value> </AtLeast>
10 BetweenII
Performs a test of type a <= value <= b (range interval with lower and upper bounds included)
The values a and b can only be numeric.
Class name: BetweenII
Constructors:
BetweenII(String propertyNameOrExpression, double a, double b) BetweenII(String propertyNameOrExpression, String a, double b) BetweenII(String propertyNameOrExpression, double a, String b) BetweenII(String propertyNameOrExpression, String a, String b)
Usage:
policy = new BetweenII("my.prop", 1, 3); policy = new BetweenII("$script{2 * ${other.prop}}$", "$script{1 + 0.5}$", 3); policy = new BetweenII("my.prop", 1, "$script{2 * ${other.prop}}$"); policy = new BetweenII("my.prop", "$script{2 * ${prop1}}$", "${prop2}");
XML Element: <BetweenII>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : numeric literals or expressions for the bounds of the interval, min = 2, max = 2
Usage:
<BetweenII> <Property>my.prop</Property> <Value>1</Value> <Value>3</Value> </BetweenII>
<BetweenII> <Property>$script{2 * ${other.prop}}$</Property> <Value>$script{1 + 0.5}$</Value> <Value>3</Value> </BetweenII>
<BetweenII> <Property>my.prop</Property> <Value>1</Value> <Value>$script{2 * ${other.prop}}$</Value> </BetweenII>
<BetweenII> <Property>my.prop</Property> <Value>$script{2 * ${prop1}}$</Value> <Value>${prop2}</Value> </BetweenII>
11 BetweenIE
Performs a test of type “property_value in [a, b[“ (lower bound included, upper bound excluded)
The values a and b can only be numeric.
Class name: BetweenIE
Constructor:
BetweenIE(String propertyNameOrExpression, double a, double b) BetweenIE(String propertyNameOrExpression, String a, double b) BetweenIE(String propertyNameOrExpression, double a, String b) BetweenIE(String propertyNameOrExpression, String a, String b)
Usage:
policy = new BetweenIE("my.prop", 1, 3); policy = new BetweenIE("$script{2 * ${other.prop}}$", "$script{1 + 0.5}$", 3); policy = new BetweenIE("my.prop", 1, "$script{2 * ${other.prop}}$"); policy = new BetweenIE("my.prop", "$script{2 * ${prop1}}$", "${prop2}");
XML Element: <BetweenIE>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : numeric literals or expressions for the bounds of the interval, min = 2, max = 2
Usage:
<BetweenIE> <Property>my.prop</Property> <Value>1</Value> <Value>3</Value> </BetweenIE>
<BetweenIE> <Property>$script{2 * ${other.prop}}$</Property> <Value>$script{1 + 0.5}$</Value> <Value>3</Value> </BetweenIE>
<BetweenIE> <Property>my.prop</Property> <Value>1</Value> <Value>$script{2 * ${other.prop}}$</Value> </BetweenIE>
<BetweenIE> <Property>my.prop</Property> <Value>$script{2 * ${prop1}}$</Value> <Value>${prop2}</Value> </BetweenIE>
12 BetweenEI
Performs a test of type “property_value in ]a, b]” (lower bound excluded, upper bound included)
The values a and b can only be numeric.
Class name: BetweenEI
Constructor:
BetweenEI(String propertyNameOrExpression, double a, double b) BetweenEI(String propertyNameOrExpression, String a, double b) BetweenEI(String propertyNameOrExpression, double a, String b) BetweenEI(String propertyNameOrExpression, String a, String b)
Usage:
policy = new BetweenEI("my.prop", 1, 3); policy = new BetweenEI("$script{2 * ${other.prop}}$", "$script{1 + 0.5}$", 3); policy = new BetweenEI("my.prop", 1, "$script{2 * ${other.prop}}$"); policy = new BetweenEI("my.prop", "$script{2 * ${prop1}}$", "${prop2}");
XML Element: <BetweenEI>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : numeric literals or expressions for the bounds of the interval, min = 2, max = 2
Usage:
<BetweenEI> <Property>my.prop</Property> <Value>1</Value> <Value>3</Value> </BetweenEI>
<BetweenEI> <Property>$script{2 * ${other.prop}}$</Property> <Value>$script{1 + 0.5}$</Value> <Value>3</Value> </BetweenEI>
<BetweenEI> <Property>my.prop</Property> <Value>1</Value> <Value>$script{2 * ${other.prop}}$</Value> </BetweenEI>
<BetweenEI> <Property>my.prop</Property> <Value>$script{2 * ${prop1}}$</Value> <Value>${prop2}</Value> </BetweenEI>
13 BetweenEE
Performs a test of type “property_value in ]a, b[“ (lower and upper bounds excluded)
The values a and b can only be numeric.
Class name: BetweenEE
Constructor:
BetweenEE(String propertyNameOrExpression, double a, double b) BetweenEE(String propertyNameOrExpression, String a, double b) BetweenEE(String propertyNameOrExpression, double a, String b) BetweenEE(String propertyNameOrExpression, String a, String b)
Usage:
policy = new BetweenEE("my.prop", 1, 3); policy = new BetweenEE("$script{2 * ${other.prop}}$", "$script{1 + 0.5}$", 3); policy = new BetweenEE("my.prop", 1, "$script{2 * ${other.prop}}$"); policy = new BetweenEE("my.prop", "$script{2 * ${prop1}}$", "${prop2}");
XML Element: <BetweenEE>
Nested elements:
<Property> : name of a node property or numeric expression, min = 1, max = 1
<Value> : numeric literals or expressions for the bounds of the interval, min = 2, max = 2
Usage:
<BetweenEE> <Property>my.prop</Property> <Value>1</Value> <Value>3</Value> </BetweenEE>
<BetweenEE> <Property>$script{2 * ${other.prop}}$</Property> <Value>$script{1 + 0.5}$</Value> <Value>3</Value> </BetweenEE>
<BetweenEE> <Property>my.prop</Property> <Value>1</Value> <Value>$script{2 * ${other.prop}}$</Value> </BetweenEE>
<BetweenEE> <Property>my.prop</Property> <Value>$script{2 * ${prop1}}$</Value> <Value>${prop2}</Value> </BetweenEE>
14 Contains
Performs a test of type “'property_value contains substring”
The value can be only a string.
Class name: Contains
Constructor:
Contains(String propertyNameOrExpression, boolean ignoreCase, String valueOrExpression)
Usage:
policy = new Contains("some.property", true, "$script{'${otherr.prop}' + 'abc'}$");
XML Element: <Contains>
Attribute: ignoreCase: one of "true" or "false", optional, defaults to "false"
Nested elements:
<Property> : name of a node property, min = 1, max = 1
<Value> : substring literal or expression to lookup, min = 1, max = 1
Usage:
<Contains ignoreCase="true"> <Property>some.property</Property> <Value>$script{'${otherr.prop}' + 'abc'}$</Value> </Contains>
15 OneOf
Performs a test of type “property_value in { A1, ... , An }” (discrete set).
The values A1 ... An can be either all strings or all numeric.
Class name: OneOf
Constructors:
OneOf(String propertyNameOrExpression, boolean ignoreCase, String...valuesOrExpressiosn) OneOf(String propertyNameOrExpression, double...values) OneOf(String propertyNameOrExpression, String...numericValuesOrExpressions)
Usage:
policy = new OneOf("user.language", true, "en", "fr", "it"); policy = new OneOf("$script{${prop1} + 2.1}$", 1.2, 5.1); policy = new OneOf("my.prop", "1.2", "$script{1.2}$", "$script{${other.prop} + 2.1}$");
XML Element: <OneOf>
Attributes:
ignoreCase: one of "true" or "false", optional, defaults to "false"
valueType: one of "string" or "numeric", optional, defaults to "string"
Nested elements:
<Property> : name of a node property or expression of the related type, min = 1, max = 1
<Value> : literal or expression of the related type, min = 1, max = unbounded
Usage:
<OneOf ignoreCase="true"> <Property>user.language</Property> <Value>en</Value> <Value>fr</Value> <Value>it</Value> </OneOf>
<OneOf> <Property>$script{${prop1} + 2.1}$</Property> <Value>1.2</Value> <Value>5.1</Value> </OneOf>
<OneOf> <Property>my.prop</Property> <Value>1.2</Value> <Value>$script{1.2}$</Value> <Value>$script{${other.prop} + 2.1}$</Value> </OneOf>
16 RegExp
Performs a test of type “property_value_or_expression matches regular_expression”
The regular expression must follow the syntax for the Java regular expression patterns.
Class name: RegExp
Constructor:
RegExp(String propertyNameOrExpression, String pattern)
Usage:
policy = new RegExp("some.property", "a.*z");
XML Element: <RegExp>
Nested elements:
<Property> : name of a node property or string expression, min = 1, max = 1
<Value> : regular expression pattern to match against, min = 1, max = 1
Usage:
<RegExp> <Property>some.property</Property> <Value>a*z</Value> </RegExp>
17 ScriptedPolicy
Executes a script which returns a boolean value.
Class name: ScriptedPolicy
Constructors:
ScriptedPolicy(String language, String script) ScriptedPolicy(String language, Reader scriptReader) ScriptedPolicy(String language, File scriptFile)
Usage:
policy = new ScriptedPolicy("javascript", "true"); policy = new ScriptedPolicy("javascript", new StringReader(myScript)); policy = new ScriptedPolicy("javascript", new File("myScript.js"));
XML Element: <Script>
Attribute: language
Usage:
<Script language=”javascript”>true</Script> <Script language=”javascript”><![CDATA[ function myFunction() { return true; } myFunction(); ]]></Script>
18 CustomRule
Performs a user-defined test that can be specified in an XML policy document.
Class name: subclass of CustomPolicy
Constructor:
MySubclassOfCustomPolicy(String...args)
Usage:
policy = new MySubclassOfCustomPolicy("arg 1", "arg 2", "arg 3");
XML Element: <CustomRule>
Attribute: class: fully qualified name of a policy class, required
Nested element: <Arg> : custom rule parameters, min = 0, max = unbounded
Usage:
<CustomRule class="my.sample.MySubclassOfCustomPolicy"> <Arg>arg 1</Arg> <Arg>arg 2</Arg> <Arg>arg 3</Arg> </CustomRule>
19 Preference
Evaluates a set of nested policies ordered by preference.
Class name: Preference
Constructors:
Preference(ExecutionPolicy...policies) Preference(List<ExecutionPolicy> policies)
Usage:
policy = new Preference(AtLeast("jppf.processing.threads", 4), new LessThan("jppf.processing.threads", 4).and(new AtLeast("maxMemory", 1_000_000)));
XML Element: <Preference>
Usage:
<Preference> <AtLeast> <Property>jppf.processing.thread</Property> <Value>4</Value> </AtLeast> <AND> <LessThan> <Property>jppf.processing.thread</Property> <Value>4</Value> </LessThan> <AtLeast> <Property>maxMemory</Property> <Value>1000000</Value> </AtLeast> </AND> </Preference>
20 IsInIPv4Subnet
Performs a test of type “ipv4.addresses has an address in at least one of s1, ... or sn subnets”
Each subnet can be expressed in either CIDR or IPv4AddressPattern format.
Class name: IsInIPv4Subnet
Constructors:
IsInIPv4Subnet(String...subnets) IsInIPv4Subnet(Collection<String> subnets)
Usage:
policy = new IsInIPv4Subnet(“192.168.1.0/24”, “192.168.1.0-255”, "${ip4.netmask}");
XML element: <IsInIPv4Subnet>
Nested element: <Subnet> : IPv4 subnet mask, min = 1, max = unbounded
Usage:
<IsInIPv4Subnet> <Subnet>192.168.1.0/24</Subnet> <Subnet>192.168.1.0-255</Subnet> <Subnet>${ip4.netmask}</Subnet> </IsInIPv4Subnet>
21 IsInIPv6Subnet
Performs a test of type “ipv6.addresses has an address in at least one of s1, ... or sn subnets”
Each subnet can be expressed in either CIDR or IPv6AddressPattern format.
Class name: IsInIPv6Subnet
Constructors:
IsInIPv6Subnet(String...subnets) IsInIPv6Subnet(Collection<String> subnets)
Usage:
policy = new IsInIPv6Subnet(“::1/80”, “1080::0:0:8:800:200C:417A/97”, "${ip6.netmask}");
XML element: <IsInIPv6Subnet>
Nested element: <Subnet> : IPv6 subnet mask, min = 1, max = unbounded
Usage:
<IsInIPv6Subnet> <Subnet>::1/80</Subnet> <Subnet><span style="color:#000000;">1080::0:0:8:800:200C:417A/97</span></Subnet> <Subnet>${ip6.netmask}</Subnet> </IsInIPv6Subnet>
22 NodesMatching
Counts the nodes matching a given execution policy and compares the resulting number with an expected number of nodes, using a specified comparison operator: expected_number compared_to (actual_number matching node_policy).
Class name: NodesMatching
Constructors:
NodesMatching(Operator operator, long expectedNodes, ExecutionPolicy nodePolicy) NodesMatching(Operator operator, long expectNodesExpression, ExecutionPolicy nodePolicy)
Usage:
new NodesMatching(Operator.AT_LEAST, 4, new MoreThan("availableProcessors", 2)); new NodesMatching(Operator.AT_LEAST, "$S{${idle.nodes} / 2}$", new MoreThan("availableProcessors", 2));
reads as: at least 4 nodes with more than 2 processors each
XML element: <NodesMatching>
Attributes:
operator: the comparison operator, one of EQUAL, NOT_EQUAL, AT_LEAST, MORE_THAN, AT_MOST, LESS_THAN.
expected: the number of expected nodes as an int literal or expression
Nested element: any other execution policy element
Usage:
<NodesMatching operator="AT_MOST" expected="4"> <MoreThan> <Property>availableProcessors</Property> <Value>2</Value> </MoreThan> </NodesMatching>
<NodesMatching operator="AT_MOST" expected="$S{${idle.nodes} / 2}$"> <MoreThan> <Property>availableProcessors</Property> <Value>2</Value> </MoreThan> </NodesMatching>
23 AcceptAll
An execution policy which accepts everything. Mostly useful when used within a more complex policy.
Class name: AcceptAll
Constructors:
AcceptAll() AcceptAll(ExecutionPolicy wrappedPolicy)
Usage:
ExecutionPolicy policy = new AcceptAll(); policy = new AcceptAll(new AtLeast("availableProcessors", 2));
reads as: accept whether the node has at least 2 CPUs or not
XML element: <AcceptAll>
Optional nested element: any other execution policy element
Usage:
<AcceptAll/>
<AcceptAll> <AtLeast> <Property>availableProcessors</Property> <Value>2</Value> </AtLeast> </AcceptAll>
24 RejectAll
An execution policy which rejects everything. Mostly useful when used within a more complex policy.
Class name: Class name: RejectAll
Constructors:
RejectAll() RejectAll(ExecutionPolicy wrappedPolicy)
Usage:
ExecutionPolicy policy = new RejectAll(); policy = new RejectAll(new AtLeast("availableProcessors", 2));
reads as: reject whether the node has at least 2 CPUs or not
XML element: <RejectAll>
Optional nested element: any other execution policy element
Usage:
<RejectAll/>
<RejectAll> <AtLeast> <Property>availableProcessors</Property> <Value>2</Value> </AtLeast> </RejectAll>
25 IsMasterNode
An execution policy which determines whether a node is a master node.
Class name: IsMasterNode
Constructors:
IsMasterNode()
Usage:
ExecutionPolicy policy = new IsMasterNode();
XML element: <IsMasterNode>
No nested element.
Usage:
<IsMasterNode/> <IsMasterNode></IsMasterNode>
26 IsSlaveNode
An execution policy which determines whether a node is a slave node.
Class name: IsSlaveNode
Constructors:
IsSlaveNode()
Usage:
ExecutionPolicy policy = new IsSlaveNode();
XML element: <IsSlaveNode>
No nested element.
Usage:
<IsSlaveNode/> <IsSlaveNode></IsSlaveNode>
27 IsLocalChannel
An execution policy which determines whether a connection endpoint is a local client executor (on the client side), or a local node (on the server sde).
Class name: IsLocalChannel
Constructors:
IsLocalChannel()
Usage:
ExecutionPolicy policy = new IsLocalChannel();
XML element: <IsLocalChannel>
No nested element.
Usage:
<IsLocalChannel/> <IsLocalChannel></IsLocalChannel>
28 IsPeerDriver
An execution policy which determines whether a node connection endpoint is actually a remote peer driver.
Class name: IsPeerDriver
Constructors:
IsPeerDriver()
Usage:
ExecutionPolicy policy = new IsPeerDriver();
XML element: <IsPeerDriver>
No nested element.
Usage:
<IsPeerDriver/> <IsPeerDriver></IsPeerDriver>
Main Page > Execution policy reference > Execution Policy Elements |