use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method getActivationParameters.
public Map getActivationParameters(Activation activation) {
if (activation instanceof RuleAgendaItem) {
RuleAgendaItem ruleAgendaItem = (RuleAgendaItem) activation;
TupleList tupleList = ruleAgendaItem.getRuleExecutor().getLeftTupleList();
Map result = new TreeMap();
int i = 0;
for (Tuple tuple = tupleList.getFirst(); tuple != null; tuple = tuple.getNext()) {
Map params = getActivationParameters(tuple);
result.put("Parameters set [" + i++ + "]", (Map.Entry[]) params.entrySet().toArray(new Map.Entry[params.size()]));
}
return result;
} else {
return getActivationParameters(activation.getTuple());
}
}
use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class ParallelRuleEvaluator method evaluateAndFire.
@Override
public int evaluateAndFire(AgendaFilter filter, int fireCount, int fireLimit, InternalAgendaGroup group) {
this.filter = filter;
this.fireCount = fireCount;
this.fireLimit = fireLimit;
Activation[] activations = group.getActivations();
for (Activation activation : activations) {
RuleAgendaItem item = (RuleAgendaItem) activation;
int index = item.getPartition().getParallelEvaluationSlot();
RuleEvaluatorCallable evaluator = evaluators[index];
evaluator.enqueue(item);
if (!evaluator.running) {
evaluator.running = true;
results[index] = Completion.service.submit(evaluator);
}
}
int localFireCount = 0;
for (int i = 0; i < evaluatorsNr; i++) {
if (results[i] != null) {
try {
evaluators[i].enqueue(POISON_PILL);
localFireCount += results[i].get();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
results[i] = null;
}
}
}
return localFireCount;
}
use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class DefaultAgenda method sizeOfRuleFlowGroup.
public int sizeOfRuleFlowGroup(String name) {
InternalAgendaGroup group = agendaGroups.get(name);
if (group == null) {
return 0;
}
int count = 0;
for (Activation item : group.getActivations()) {
if (!((RuleAgendaItem) item).getRuleExecutor().getLeftTupleList().isEmpty()) {
count = count + ((RuleAgendaItem) item).getRuleExecutor().getLeftTupleList().size();
}
}
return count;
}
use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class DefaultAgenda method isRuleInstanceAgendaItem.
public boolean isRuleInstanceAgendaItem(String ruleflowGroupName, String ruleName, long processInstanceId) {
propagationList.flush();
RuleFlowGroup systemRuleFlowGroup = this.getRuleFlowGroup(ruleflowGroupName);
Match[] matches = ((InternalAgendaGroup) systemRuleFlowGroup).getActivations();
for (Match match : matches) {
Activation act = (Activation) match;
if (act.isRuleAgendaItem()) {
// The lazy RuleAgendaItem must be fully evaluated, to see if there is a rule match
RuleExecutor ruleExecutor = ((RuleAgendaItem) act).getRuleExecutor();
ruleExecutor.evaluateNetwork(this);
TupleList list = ruleExecutor.getLeftTupleList();
for (RuleTerminalNodeLeftTuple lt = (RuleTerminalNodeLeftTuple) list.getFirst(); lt != null; lt = (RuleTerminalNodeLeftTuple) lt.getNext()) {
if (ruleName.equals(lt.getRule().getName())) {
if (checkProcessInstance(lt, processInstanceId)) {
return true;
}
}
}
} else {
if (ruleName.equals(act.getRule().getName())) {
if (checkProcessInstance(act, processInstanceId)) {
return true;
}
}
}
}
return false;
}
use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class DefaultAgenda method evaluateEagerList.
public void evaluateEagerList() {
while (!eager.isEmpty()) {
RuleAgendaItem item = eager.removeFirst();
if (item.isRuleInUse()) {
// this rule could have been removed by an incremental compilation
evaluateQueriesForRule(item);
RuleExecutor ruleExecutor = item.getRuleExecutor();
ruleExecutor.evaluateNetwork(this);
}
}
}
Aggregations