public void fireRNEAs(final InternalWorkingMemory wm) { RuleAgendaItem rnea = null; while ((rnea = rneaToFire.poll()) != null) { rnea.remove(); rnea.setQueued(false); rnea.getRuleExecutor().evaluateNetworkAndFire(wm, null, 0, -1); } }
@Override public void removeEagerRuleAgendaItem(RuleAgendaItem item) { if (!item.isInList()) { return; } if (log.isTraceEnabled()) { log.trace("Removed {} from eager evaluation list.", item.getRule().getName()); } eager.remove(item); }
@Override public void addEagerRuleAgendaItem(RuleAgendaItem item) { if (item.isInList()) { return; } if (log.isTraceEnabled()) { log.trace("Added {} to eager evaluation list.", item.getRule().getName()); } eager.add(item); }
private static void evaluateRuleActivations(StatefulKnowledgeSessionImpl wm) { // ET: NOTE: initially we were only resolving partially evaluated rules // but some tests fail because of that. Have to resolve all rule agenda items // in order to fix the tests // find all partially evaluated rule activations // ActivationIterator it = ActivationIterator.iterator( wm ); // Set<String> evaluated = new HashSet<String>(); // for ( org.drools.core.spi.Activation item = (org.drools.core.spi.Activation) // it.next(); item != null; item = (org.drools.core.spi.Activation) it.next() ) { // if ( !item.isRuleAgendaItem() ) { // evaluated.add( item.getRule().getPackageName()+"."+item.getRule().getName() ); // } // } // need to evaluate all lazy partially evaluated activations before serializing boolean dirty = true; while (dirty) { for (Activation activation : ((InternalAgenda) wm.getAgenda()).getActivations()) { if (activation .isRuleAgendaItem() /*&& evaluated.contains( activation.getRule().getPackageName()+"."+activation.getRule().getName() )*/) { // evaluate it ((RuleAgendaItem) activation).getRuleExecutor().reEvaluateNetwork(wm, null, false); ((RuleAgendaItem) activation).getRuleExecutor().removeRuleAgendaItemWhenEmpty(wm); } } dirty = false; if (wm.getKnowledgeBase().getConfiguration().isPhreakEnabled()) { // network evaluation with phreak and TMS may make previous processed rules dirty again, so // need to reprocess until all is flushed. for (Activation activation : ((InternalAgenda) wm.getAgenda()).getActivations()) { if (activation.isRuleAgendaItem() && ((RuleAgendaItem) activation).getRuleExecutor().isDirty()) { dirty = true; break; } } } } }
public void evaluateEagerList() { while (!eager.isEmpty()) { RuleAgendaItem item = eager.removeFirst(); item.getRuleExecutor().evaluateNetwork(this.workingMemory); } }