public class RuleRegistrySet extends Object
RuleRegistry
instances that should be
applied via the FlowPlanner
to the given assembly.
The current RuleRegistrySet can be reached via FlowConnector.getRuleRegistrySet()
, or set with
the appropriate FlowConnector
constructor sub-class.
RuleRegistrySet configuration is mutable to address different situations.
During planner execution, all RuleRegistry instances are applied simultaneously within individual threads.
If the planner duration exceeds getPlannerTimeoutSec()
(with default
RuleSetExec.DEFAULT_TIMEOUT
) any incomplete planner executions
will be cancelled.
If no planner executions complete successfully within the timeout period, an exception will be thrown.
If there are multiple successful completions, the default cost comparator,
RuleSetExec.DEFAULT_PLAN_COMPARATOR
, will be applied to find the lower
cost plan. Use setPlanComparator(java.util.Comparator)
to override.
If all plans have equivalent costs, the plan corresponding to the first most RuleRegistry, as given to the
RuleRegistrySet, will be selected.
If setSelect(cascading.flow.planner.rule.RuleRegistrySet.Select)
is set to
RuleRegistrySet.Select.FIRST
, the first RuleRegistry to complete will be used
regardless of cost ordering provided by the plan Comparator. All remaining running planner executions will be
cancelled.
If isIgnoreFailed()
is false
, if any planner execution is times out or fails, an exception will be
thrown.Modifier and Type | Class and Description |
---|---|
static class |
RuleRegistrySet.Select |
Constructor and Description |
---|
RuleRegistrySet(Collection<RuleRegistry> ruleRegistries)
Instantiates a new Rule Registry Set.
|
RuleRegistrySet(RuleRegistry... ruleRegistries)
Instantiates a new Rule Registry Set.
|
Modifier and Type | Method and Description |
---|---|
RuleRegistry |
findRegistryWith(String ruleName) |
Comparator<RuleResult> |
getPlanComparator()
Returns planner comparator.
|
int |
getPlannerTimeoutSec()
Gets planner timeout, in seconds.
|
RuleRegistrySet.Select |
getSelect()
Returns the result selection type.
|
protected int |
indexOf(RuleRegistry ruleRegistry) |
boolean |
isIgnoreFailed()
When true, failures during planning will be ignored unless no registries are successful.
|
void |
setIgnoreFailed(boolean ignoreFailed)
Sets ignore failed setting.
|
void |
setPlanComparator(Comparator<RuleResult> planComparator)
Sets planner result comparator, used only if
getSelect() is RuleRegistrySet.Select.COMPARED . |
void |
setPlannerTimeoutSec(int plannerTimeoutSec)
Sets planner timeout, in seconds.
|
void |
setSelect(RuleRegistrySet.Select select)
Sets the result selection type.
|
int |
size() |
public RuleRegistrySet(RuleRegistry... ruleRegistries)
ruleRegistries
- the rule registriespublic RuleRegistrySet(Collection<RuleRegistry> ruleRegistries)
ruleRegistries
- the rule registriespublic int getPlannerTimeoutSec()
public void setPlannerTimeoutSec(int plannerTimeoutSec)
plannerTimeoutSec
- the planner timeout secpublic boolean isIgnoreFailed()
public void setIgnoreFailed(boolean ignoreFailed)
true
.
When true
, failures during planning will be ignored unless no registries are successful. When false
,
any failure will cause the planner to fail.ignoreFailed
- true
if any failures should be ignored, the defaultpublic RuleRegistrySet.Select getSelect()
public void setSelect(RuleRegistrySet.Select select)
select
- the selection typepublic Comparator<RuleResult> getPlanComparator()
public void setPlanComparator(Comparator<RuleResult> planComparator)
getSelect()
is RuleRegistrySet.Select.COMPARED
.planComparator
- the plan comparatorpublic int size()
public RuleRegistry findRegistryWith(String ruleName)
protected int indexOf(RuleRegistry ruleRegistry)
Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.