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);
   }
 }
Beispiel #2
0
  @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);
  }
Beispiel #3
0
  @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;
          }
        }
      }
    }
  }
Beispiel #5
0
 public void evaluateEagerList() {
   while (!eager.isEmpty()) {
     RuleAgendaItem item = eager.removeFirst();
     item.getRuleExecutor().evaluateNetwork(this.workingMemory);
   }
 }