NodeGroupEvaluator (Quartz Parent POM 2.0.1 API)

Quartz Java



org.quartz.locality.constraint.evaluator Class NodeGroupEvaluator

java.lang.Object
  extended by org.quartz.locality.constraint.evaluator.NodeGroupEvaluator
All Implemented Interfaces:
Evaluator<NodeGroupConstraint>

public class NodeGroupEvaluator
extends Object
implements Evaluator<NodeGroupConstraint>

Evaluator that matches job execution to particular nodes based on the Trigger and JobDetail groups they are in.

The rules for matching is loaded from quartzLocality.properties where:

 # Example of node groups
 org.quartz.locality.nodeGroup.group0 = node0
 org.quartz.locality.nodeGroup.group1 = node1,node2

 # Automagic dispatching based on trigger group
 org.quartz.locality.nodeGroup.group0.triggerGroups = blueTriggers
 org.quartz.locality.nodeGroup.group1.jobGroups = redJobs
 
Which, in this example, defines two groups: group0 and group1. Automatically dispatching jobs being executed by Triggers of group blueTriggers to group0 (and hence node0). While JobDetails of group redJobs will be dispatched to group1 (either node1 or node2)

Author:
Alex Snaps

Constructor Summary
NodeGroupEvaluator()
          Constructor initializing all the local data structures
 
Method Summary
 String getNodeGroupForJobGroup(String jobGroup)
          Retrieves the node group for a particular trigger group
 String getNodeGroupForTriggerGroup(String triggerGroup)
          Retrieves the node group for a particular trigger group
 boolean isNodeInGroup(String nodeName, String group)
          Checks whether a node is part of a group
 boolean matches(NodeGroupConstraint constraint)
          Evaluates the constraint against local node.
 List<String> suitedNodes(NodeGroupConstraint constraint)
          Returns a list of best suited node (instanceId) based on the constraint
 void verify(NodeGroupConstraint constraint)
          Verifies that the node group actually exists in the current configuration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeGroupEvaluator

public NodeGroupEvaluator()
Constructor initializing all the local data structures

Method Detail

matches

public boolean matches(NodeGroupConstraint constraint)
Evaluates the constraint against local node.

Specified by:
matches in interface Evaluator<NodeGroupConstraint>
Parameters:
constraint - The constraint to evaluate
Returns:
true if local node is a match
See Also:
Constraint#matches(Object)

suitedNodes

public List<String> suitedNodes(NodeGroupConstraint constraint)
Returns a list of best suited node (instanceId) based on the constraint

Specified by:
suitedNodes in interface Evaluator<NodeGroupConstraint>
Parameters:
constraint - To find best suited nodes for
Returns:
List of best suited Quartz instanceId

verify

public void verify(NodeGroupConstraint constraint)
            throws LocalityException
Verifies that the node group actually exists in the current configuration

Specified by:
verify in interface Evaluator<NodeGroupConstraint>
Parameters:
constraint - The constraint to validate
Throws:
LocalityException - if node group is unknown

getNodeGroupForTriggerGroup

public String getNodeGroupForTriggerGroup(String triggerGroup)
Retrieves the node group for a particular trigger group

Parameters:
triggerGroup - the TriggerKey's group
Returns:
the matching node group, null if null

getNodeGroupForJobGroup

public String getNodeGroupForJobGroup(String jobGroup)
Retrieves the node group for a particular trigger group

Parameters:
jobGroup - the JobKey's group
Returns:
the matching node group, null if null

isNodeInGroup

public boolean isNodeInGroup(String nodeName,
                             String group)
Checks whether a node is part of a group

Parameters:
nodeName - the instanceId of the node
group - the group of the node
Returns:
true is node is part of group, false otherwise


Copyright 2001-2011, Terracotta, Inc.