[jboss-svn-commits] JBL Code SVN: r37073 - in labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586: drools-compiler/src/test/java/org/drools/core and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 7 12:31:46 EDT 2011
Author: tsurdilovic
Date: 2011-06-07 12:31:45 -0400 (Tue, 07 Jun 2011)
New Revision: 37073
Added:
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/reteoo/
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/reteoo/BinaryHeapQueueTest.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/resources/org/drools/integrationtests/test_Exists_JBRULES_2810.drl
Removed:
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java
Modified:
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/debug/SessionInspector.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/CompositeLeftTupleSinkAdapter.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/SingleLeftTupleSinkAdapter.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/guvnor-importer/.classpath
labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/sample-model/.classpath
Log:
BRMS-599: Request a hotfix for BRMS-519 and BRMS-586
Added: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/reteoo/BinaryHeapQueueTest.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/reteoo/BinaryHeapQueueTest.java (rev 0)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/core/reteoo/BinaryHeapQueueTest.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -0,0 +1,412 @@
+package org.drools.core.reteoo;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import junit.framework.TestCase;
+
+import org.drools.common.ActivationGroupNode;
+import org.drools.common.ActivationNode;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.LogicalDependency;
+import org.drools.core.util.BinaryHeapQueue;
+import org.drools.core.util.LinkedList;
+import org.drools.core.util.Queueable;
+import org.drools.reteoo.LeftTuple;
+import org.drools.rule.GroupElement;
+import org.drools.rule.Rule;
+import org.drools.runtime.rule.FactHandle;
+import org.drools.spi.Activation;
+import org.drools.spi.AgendaGroup;
+import org.drools.spi.ConflictResolver;
+import org.drools.spi.PropagationContext;
+
+/**
+ * Thes test class uses auxiliary test classes in org.drools.util:
+ * Group and Item as a mock-up for the corresponding Agenda classes.
+ *
+ * The test testShuffled uses a sequence of shuffled Item arrays, inserts
+ * them in the "random" order, retracts and reinserts the Items at an even
+ * position. Finally, Items are retrieved and the order is checked.
+ *
+ * Experience has shown that at least 6 Items are required to demonstrate
+ * a certain bug, so don't reduce the max parameter.
+ *
+ */
+public class BinaryHeapQueueTest extends TestCase {
+
+ private List<Integer[]> perms = new ArrayList<Integer[]>();
+ private final static int max = 6;
+
+ // NOT really permutations, just some shuffling
+ private void shuffle(Integer[] a,
+ int lim) {
+ if ( lim == 0 ) {
+ Integer[] p = a.clone();
+ perms.add( p );
+ } else {
+ shuffle( a,
+ lim - 1 );
+ Integer h = a[lim];
+ a[lim] = a[lim - 1];
+ a[lim - 1] = h;
+ shuffle( a,
+ lim - 1 );
+ }
+ }
+
+ public void setUp() throws Exception {
+ System.out.println( "Running setup" );
+ Integer[] a = new Integer[max];
+ for ( int i = 0; i < max; i++ ) {
+ a[i] = i;
+ }
+ shuffle( a,
+ max - 1 );
+ // System.out.println( "The size is " + perms.size() );
+ }
+
+ public void testShuffled() {
+
+ for ( Integer[] perm : perms ) {
+ Group group = new Group( "group" );
+
+ for ( Integer i : perm ) {
+ Item item = new Item( group,
+ i );
+ group.add( item );
+ }
+
+ Queueable[] elems = group.getQueue();
+ for ( Queueable elem : elems ) {
+ Item item = (Item) elem;
+ // System.out.print( " " + item.getSalience() + "/" + item.getActivationNumber() + "/" + item.getIndex() );
+ if ( item.getIndex() % 2 == 0 ) {
+ group.remove( item );
+ group.add( item );
+ }
+ }
+ boolean ok = true;
+ StringBuilder sb = new StringBuilder( "queue:" );
+ for ( int i = max - 1; i >= 0; i-- ) {
+ int sal = group.getNext().getSalience();
+ sb.append( " " ).append( sal );
+ if ( sal != i ) ok = false;
+ }
+ assertTrue( "incorrect order in " + sb.toString(),
+ ok );
+ // System.out.println( sb.toString() );
+ }
+ }
+
+ public static class Group {
+
+ private static final long serialVersionUID = 510l;
+
+ private String name;
+
+ /** Items in the agenda. */
+ private BinaryHeapQueue queue;
+
+ /**
+ * Construct an <code>AgendaGroup</code> with the given name.
+ *
+ * @param name
+ * The <AgendaGroup> name.
+ */
+ public Group() {
+ }
+
+ public Group(final String name) {
+ this.name = name;
+ this.queue = new BinaryHeapQueue( ItemConflictResolver.INSTANCE );
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void clear() {
+ this.queue.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.spi.AgendaGroup#size()
+ */
+ public int size() {
+ return this.queue.size();
+ }
+
+ public void add(final Item item) {
+ this.queue.enqueue( (Queueable) item );
+ }
+
+ public Item getNext() {
+ return (Item) this.queue.dequeue();
+ }
+
+ /**
+ * Iterates a PriorityQueue removing empty entries until it finds a populated entry and return true,
+ * otherwise it returns false;
+ *
+ * @param priorityQueue
+ * @return
+ */
+ public boolean isEmpty() {
+ return this.queue.isEmpty();
+ }
+
+ public String toString() {
+ return "AgendaGroup '" + this.name + "'";
+ }
+
+ public boolean equal(final Object object) {
+ if ( (object == null) || !(object instanceof Group) ) {
+ return false;
+ }
+
+ if ( ((Group) object).name.equals( this.name ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public int hashCode() {
+ return this.name.hashCode();
+ }
+
+ public void remove(Item agendaItem) {
+ this.queue.dequeue( agendaItem.getIndex() );
+ }
+
+ public Queueable[] getQueue() {
+ return (Queueable[]) this.queue.toArray( new Queueable[size()] );
+ }
+ }
+
+ public static class IsTuple extends BaseMatcher<List<InternalFactHandle>> {
+ private final InternalFactHandle[] expected;
+
+ public IsTuple(List<InternalFactHandle> tupleAsList) {
+ expected = tupleAsList.toArray( new InternalFactHandle[tupleAsList.size()] );
+ }
+
+ public IsTuple(InternalFactHandle[] tuple) {
+ expected = tuple;
+ }
+
+ public boolean matches(Object arg) {
+ if ( arg == null || !(arg.getClass().isArray() && InternalFactHandle.class.isAssignableFrom( arg.getClass().getComponentType() )) ) {
+ return false;
+ }
+ InternalFactHandle[] actual = (InternalFactHandle[]) arg;
+ return Arrays.equals( expected,
+ actual );
+ }
+
+ public void describeTo(Description description) {
+ description.appendValue( expected );
+ }
+
+ /**
+ * Is the value equal to another value, as tested by the
+ * {@link java.lang.Object#equals} invokedMethod?
+ */
+ @Factory
+ public static Matcher<List<InternalFactHandle>> isTuple(List<InternalFactHandle> operand) {
+ return new IsTuple( operand );
+ }
+
+ public static Matcher< ? super List<InternalFactHandle>> isTuple(InternalFactHandle... operands) {
+ return new IsTuple( operands );
+ }
+ }
+
+ public static class Item
+ implements
+ Queueable,
+ Activation {
+
+ private static int actNo = 1;
+
+ private int index;
+ private long activationNumber;
+ private Group group;
+ private int salience;
+
+ public Item(Group group,
+ int salience) {
+ this.group = group;
+ this.salience = salience;
+ this.activationNumber = actNo++;
+ }
+
+ public void dequeue() {
+ if ( this.group != null ) {
+ this.group.remove( this );
+ }
+ this.index = -1;
+ }
+
+ public void enqueued(int index) {
+ this.index = index;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public int getSalience() {
+ return salience;
+ }
+
+ public long getActivationNumber() {
+ return activationNumber;
+ }
+
+ public void addLogicalDependency(LogicalDependency arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ActivationGroupNode getActivationGroupNode() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ActivationNode getActivationNode() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public AgendaGroup getAgendaGroup() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public LinkedList getLogicalDependencies() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PropagationContext getPropagationContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Rule getRule() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public GroupElement getSubRule() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public LeftTuple getTuple() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isActivated() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void remove() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setActivated(boolean arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setActivationGroupNode(ActivationGroupNode arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setActivationNode(ActivationNode arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLogicalDependencies(LinkedList arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public List<String> getDeclarationIDs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getDeclarationValue(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List< ? extends FactHandle> getFactHandles() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Object> getObjects() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ }
+
+ public static class ItemConflictResolver
+ implements
+ ConflictResolver {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final ItemConflictResolver INSTANCE = new ItemConflictResolver();
+
+ public static ItemConflictResolver getInstance() {
+ return ItemConflictResolver.INSTANCE;
+ }
+
+ /**
+ * @see ConflictResolver
+ */
+ public final int compare(final Object existing,
+ final Object adding) {
+ return compare( (Item) existing,
+ (Item) adding );
+ }
+
+ public final int compare(final Item existing,
+ final Item adding) {
+ final int s1 = existing.getSalience();
+ final int s2 = adding.getSalience();
+
+ if ( s1 != s2 ) {
+ return s1 - s2;
+ }
+
+ // we know that no two activations will have the same number
+ return (int) (existing.getActivationNumber() - adding.getActivationNumber());
+ }
+
+ public int compare(Activation arg0,
+ Activation arg1) {
+ return 0;
+ }
+
+ }
+}
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -1,5 +1,10 @@
package org.drools.integrationtests;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -33,6 +38,7 @@
import org.drools.StatefulSession;
import org.drools.StockTick;
import org.drools.WorkingMemory;
+import org.drools.audit.WorkingMemoryConsoleLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
@@ -49,7 +55,6 @@
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.conf.ClockTypeOption;
import org.drools.time.SessionPseudoClock;
-import static org.mockito.Mockito.*;
public class FirstOrderLogicTest extends TestCase {
protected RuleBase getRuleBase() throws Exception {
@@ -447,6 +452,23 @@
list.size() );
}
+ public void testExists3() throws Exception {
+ final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_Exists_JBRULES_2810.drl",
+ FirstOrderLogicTest.class ),
+ ResourceType.DRL );
+
+ assertFalse( kbuilder.getErrors().toString(), kbuilder.hasErrors() );
+
+ final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ WorkingMemoryConsoleLogger logger = new WorkingMemoryConsoleLogger( ksession );
+ ksession.fireAllRules();
+ ksession.dispose();
+ }
+
public void testForall() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Forall.drl" ) ) );
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -429,6 +429,6 @@
ksession.fireAllRules();
assertThat( ksession.getObjects().size(),
- equalTo( 0 ) );
+ equalTo( 2 ) );
}
}
Added: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/resources/org/drools/integrationtests/test_Exists_JBRULES_2810.drl
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/resources/org/drools/integrationtests/test_Exists_JBRULES_2810.drl (rev 0)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-compiler/src/test/resources/org/drools/integrationtests/test_Exists_JBRULES_2810.drl 2011-06-07 16:31:45 UTC (rev 37073)
@@ -0,0 +1,48 @@
+package org.drools;
+
+declare A
+ id : int
+end
+
+declare B
+ id : int
+end
+
+declare C
+ id : int
+end
+
+rule "Setup"
+ salience 100
+then
+ insert( new A(1) );
+ insert( new A(1) );
+ insert( new B(1) );
+ insert( new C(1) );
+ insert( new B(2) );
+ insert( new C(4) );
+end
+
+rule "Trigger"
+ salience 50
+ no-loop
+when
+ $a : A()
+ $c1 : C( id == 1 )
+ $c4 : C( id == 4 )
+then
+ modify( $a ) {}
+ modify( $c1 ) { }
+ modify( $c4 ) { setId( 5 ) }
+end
+
+rule "Offending"
+when
+ A( $id : id )
+ B( )
+ C( id == $id )
+ exists( B( ) and
+ C( id == 4 ) )
+then
+ // do something
+end
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/ArrayAgendaGroup.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -24,6 +24,7 @@
import org.drools.core.util.Iterator;
import org.drools.core.util.LinkedList;
import org.drools.core.util.LinkedListEntry;
+import org.drools.core.util.Queueable;
import org.drools.spi.Activation;
/**
@@ -119,6 +120,12 @@
public int size() {
return this.size;
}
+
+ public Activation[] getAndClear() {
+ Activation[] queue = getActivations();
+ clear();
+ return queue;
+ }
public void add(final Activation activation) {
AgendaItem item = (AgendaItem) activation;
@@ -196,10 +203,6 @@
return activations;
}
- public Activation[] getQueue() {
- return getActivations();
- }
-
public String toString() {
return "AgendaGroup '" + this.name + "'";
}
@@ -228,3 +231,5 @@
throw new UnsupportedOperationException();
}
}
+
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/BinaryHeapQueueAgendaGroup.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -89,6 +89,10 @@
public void clear() {
this.queue.clear();
}
+
+ public Activation[] getAndClear() {
+ return this.queue.getAndClear();
+ }
/* (non-Javadoc)
* @see org.drools.spi.AgendaGroup#size()
@@ -128,10 +132,6 @@
return (Activation[]) this.queue.toArray( new AgendaItem[this.queue.size()] );
}
- public Activation[] getQueue() {
- return this.queue.getQueueable();
- }
-
public String toString() {
return "AgendaGroup '" + this.name + "'";
}
@@ -160,3 +160,5 @@
this.queue.dequeue( agendaItem.getIndex() );
}
}
+
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -722,7 +722,9 @@
public void clearAndCancelAgendaGroup(final AgendaGroup agendaGroup) {
final EventSupport eventsupport = (EventSupport) this.workingMemory;
- final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getQueue();
+ // this is thread safe for BinaryHeapQueue
+ // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear()
+ final Activation[] queueable = ((InternalAgendaGroup) agendaGroup).getAndClear();
for ( int i = 0, length = queueable.length; i < length; i++ ) {
final AgendaItem item = (AgendaItem) queueable[i];
if ( item == null ) {
@@ -747,7 +749,6 @@
this.workingMemory,
ActivationCancelledCause.CLEAR );
}
- ((InternalAgendaGroup) agendaGroup).clear();
}
/*
@@ -1104,3 +1105,5 @@
return this.legacyConsequenceExceptionHandler;
}
}
+
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/InternalAgendaGroup.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -16,6 +16,7 @@
package org.drools.common;
+import org.drools.core.util.Queueable;
import org.drools.spi.Activation;
import org.drools.spi.AgendaGroup;
@@ -26,7 +27,7 @@
public void setActive(boolean activate);
- public Activation[] getQueue();
+ public Activation[] getAndClear();
public void clear();
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/PropagationContextImpl.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -188,5 +188,11 @@
public void setOriginOffset(int originOffset) {
this.originOffset = originOffset;
}
+
+ @Override
+ public String toString() {
+ return "PropagationContextImpl [activeActivations=" + activeActivations + ", dormantActivations=" + dormantActivations + ", entryPoint=" + entryPoint + ", factHandle=" + factHandle + ", leftTuple=" + leftTuple + ", originOffset="
+ + originOffset + ", propagationNumber=" + propagationNumber + ", rule=" + rule + ", type=" + type + "]";
+ }
}
Deleted: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/common/SimpleAgendaGroup.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -1,277 +0,0 @@
-/**
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.drools.common;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.PriorityQueue;
-
-import org.drools.core.util.AbstractBaseLinkedListNode;
-import org.drools.core.util.BinaryHeapQueue;
-import org.drools.core.util.LinkedList;
-import org.drools.core.util.Queueable;
-import org.drools.spi.Activation;
-
-/**
- * <code>AgendaGroup</code> implementation that uses a
- * <code>ActivationQueue</code>s. The <code>AgendaGroup</code> also maintains a
- * <code>Map</code> of <code>ActivationQueues</code> for requested salience
- * values.
- *
- * @see PriorityQueue
- * @see ActivationQueue
- *
- * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
- * @author <a href="mailto:bob at werken.com">Bob McWhirter</a>
- *
- */
-public class SimpleAgendaGroup
- implements
- InternalAgendaGroup {
-
- private static final long serialVersionUID = 510l;
-
- private String name;
-
- /** Items in the agenda. */
- private LinkedList salienceGroups;
-
- private int size;
-
- private boolean active;
-
- public static class SalienceGroup extends AbstractBaseLinkedListNode {
- private int salience;
- private LinkedList list;
-
- public SalienceGroup(int salience) {
- this.salience = salience;
- this.list = new LinkedList();
- }
-
- public int getSalience() {
- return salience;
- }
-
- public LinkedList getList() {
- return this.list;
- }
- }
-
- /**
- * Construct an <code>AgendaGroup</code> with the given name.
- *
- * @param name
- * The <AgendaGroup> name.
- */
- public SimpleAgendaGroup() {
-
- }
-
- public SimpleAgendaGroup(final String name,
- final InternalRuleBase ruleBase) {
- this.name = name;
- this.salienceGroups = new LinkedList();
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- name = (String) in.readObject();
- //queue = (BinaryHeapQueue) in.readObject();
- active = in.readBoolean();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject( name );
- //out.writeObject(queue);
- out.writeBoolean( active );
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.drools.spi.AgendaGroup#getName()
- */
- public String getName() {
- return this.name;
- }
-
- public void clear() {
- this.salienceGroups.clear();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.drools.spi.AgendaGroup#size()
- */
- public int size() {
- return this.size;
- }
-
- public void add(final Activation activation) {
- int salience = activation.getSalience();
- SalienceGroup group = null;
-
- if ( !this.salienceGroups.isEmpty() ) {
- SalienceGroup lastGroup = (SalienceGroup) this.salienceGroups.getLast();
-
- // optimisation to find out it's the lowest, and thus add get or add it.
- if ( salience <= lastGroup.getSalience() ) {
- if ( salience == lastGroup.getSalience() ) {
- // get
- group = (SalienceGroup) lastGroup;
- } else {
- // create and add
- SalienceGroup newGroup = new SalienceGroup( salience );
- this.salienceGroups.insertAfter( lastGroup, newGroup );
- group = newGroup;
- }
- //add or get to end
- }
-
-
- if ( group == null ) {
- // we know this won't iterate to the end returning null, as we checked the end already.
- for ( group = (SalienceGroup) this.salienceGroups.getFirst(); group != null && salience < group.getSalience(); group = (SalienceGroup) group.getNext() ) {
- }
-
- if ( salience == group.getSalience() ) {
- // get
- group = (SalienceGroup) group;
- } else {
- // create and add before, as must be larger
- SalienceGroup newGroup = new SalienceGroup( salience );
- this.salienceGroups.insertAfter( group.getPrevious(), newGroup );
- group = newGroup;
- }
- }
-
- } else {
- //no groups so add
- SalienceGroup newGroup = new SalienceGroup( salience );
- this.salienceGroups.add( newGroup );
- group = newGroup;
- }
-
- group.getList().add( new ActivationNode( activation,
- this ) );
-
- }
-
- public void remove(AgendaItem agendaItem) {
- int salience = agendaItem.getSalience();
-
- SalienceGroup group = null;
-
- SalienceGroup lastGroup = (SalienceGroup) this.salienceGroups.getLast();
-
- // optimisation to find out it's the lowest, and thus add get or add it.
- if ( salience == lastGroup.getSalience() ) {
- group = lastGroup;
- } else {
- // don't check for !
- for ( group = (SalienceGroup) this.salienceGroups.getFirst(); group != null && group.getSalience() != salience; group = (SalienceGroup) group.getNext() ) {
- }
- }
-
- if ( group == null ) {
- throw new RuntimeException( "SalienceGroup does not exist, This should not be possible." );
- }
-
- group.getList().remove( agendaItem.getActivationNode() );
- }
-
- public Activation getNext() {
- SalienceGroup group = (SalienceGroup) this.salienceGroups.getFirst();
-
- while ( !this.salienceGroups.isEmpty() && ( group == null || ( group != null && group.getList().isEmpty() ) ) ) {
- this.salienceGroups.removeFirst();
- group = (SalienceGroup) this.salienceGroups.getFirst();
- }
-
- if ( group != null ) {
- ActivationNode node = (ActivationNode) group.getList().removeFirst();
- if ( group.getList().isEmpty() ) {
- this.salienceGroups.removeFirst();
- }
-
- return node.getActivation();
-
- }
-
- return null;
- }
-
- public boolean isActive() {
- return this.active;
- }
-
- public void setActive(final boolean activate) {
- this.active = activate;
- }
-
- /**
- * Iterates a PriorityQueue removing empty entries until it finds a
- * populated entry and return true, otherwise it returns false;
- *
- * @param priorityQueue
- * @return
- */
- public boolean isEmpty() {
- return this.salienceGroups.isEmpty();
- }
-
- public Activation[] getActivations() {
- return null;
- // return (Activation[]) this.queue.toArray(new AgendaItem[this.queue
- // .size()]);
- }
-
- public Activation[] getQueue() {
- return null;
- //return this.queue.getQueueable();
- }
-
- public String toString() {
- return "AgendaGroup '" + this.name + "'";
- }
-
- public boolean equal(final Object object) {
- if ( (object == null) || !(object instanceof SimpleAgendaGroup) ) {
- return false;
- }
-
- if ( ((SimpleAgendaGroup) object).name.equals( this.name ) ) {
- return true;
- }
-
- return false;
- }
-
- public int hashCode() {
- return this.name.hashCode();
- }
-
- public void setFocus() {
- throw new UnsupportedOperationException();
- }
-
-}
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2005 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,13 +16,34 @@
package org.drools.core.util;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Comparator;
import java.util.NoSuchElementException;
+import java.util.concurrent.locks.ReentrantLock;
+import org.drools.spi.Activation;
+
public class BinaryHeapQueue
implements
Queue,
@@ -38,6 +59,8 @@
/** The elements in this heap. */
private Queueable[] elements;
+
+ private ReentrantLock lock;
public BinaryHeapQueue() {
@@ -71,6 +94,7 @@
//+1 as 0 is noop
this.elements = new Queueable[capacity + 1];
this.comparator = comparator;
+ this.lock = new ReentrantLock();
}
//-----------------------------------------------------------------------
@@ -90,9 +114,26 @@
* Clears all elements from queue.
*/
public void clear() {
- this.elements = new Queueable[this.elements.length]; // for gc
- this.size = 0;
+ try {
+ this.lock.lock();
+ this.elements = new Queueable[this.elements.length]; // for gc
+ this.size = 0;
+ } finally {
+ this.lock.unlock();
+ }
}
+
+ public Activation[] getAndClear() {
+ try {
+ this.lock.lock();
+ Activation[] queue = ( Activation[] )this.elements;
+ this.elements = new Queueable[this.elements.length]; // for gc
+ this.size = 0;
+ return queue;
+ } finally {
+ this.lock.unlock();
+ }
+ }
/**
* Tests if queue is empty.
@@ -129,12 +170,17 @@
*
* @param element the Queueable to be inserted
*/
- public synchronized void enqueue(final Queueable element) {
- if ( isFull() ) {
- grow();
+ public void enqueue(final Queueable element) {
+ try {
+ this.lock.lock();
+ if ( isFull() ) {
+ grow();
+ }
+
+ percolateUpMaxHeap( element );
+ } finally {
+ this.lock.unlock();
}
-
- percolateUpMaxHeap( element );
}
/**
@@ -143,56 +189,56 @@
* @return the Queueable at top of heap
* @throws NoSuchElementException if <code>isEmpty() == true</code>
*/
- public synchronized Queueable dequeue() throws NoSuchElementException {
- if ( isEmpty() ) {
- return null;
- }
-
- final Queueable result = this.elements[1];
- result.dequeue();
-
- // Code bellow was removed because it is already executed
- // inside result.dequeue()
- //
- // setElement(1, this.elements[this.size--]);
- // this.elements[this.size + 1] = null;
- //
- // if (this.size != 0) {
- // percolateDownMinHeap(1);
- // }
-
- return result;
+ public Queueable dequeue() throws NoSuchElementException {
+ try {
+ this.lock.lock();
+ if ( isEmpty() ) {
+ return null;
+ }
+
+ final Queueable result = this.elements[1];
+ result.dequeue();
+
+ return result;
+ } finally {
+ this.lock.unlock();
+ }
}
/**
*
* @param index
*/
- public synchronized Queueable dequeue(final int index) {
- if ( index < 1 || index > this.size ) {
- //throw new NoSuchElementException();
- return null;
- }
-
- final Queueable result = this.elements[index];
- setElement( index,
- this.elements[this.size] );
- this.elements[this.size] = null;
- this.size--;
- if ( this.size != 0 && index <= this.size ) {
- int compareToParent = 0;
- if ( index > 1 ) {
- compareToParent = compare( this.elements[index],
- this.elements[index / 2] );
+ public Queueable dequeue(final int index) {
+ try {
+ this.lock.lock();
+ if ( index < 1 || index > this.size ) {
+ //throw new NoSuchElementException();
+ return null;
}
- if ( index > 1 && compareToParent < 0 ) {
- percolateUpMaxHeap( index );
- } else {
- percolateDownMaxHeap( index );
+
+ final Queueable result = this.elements[index];
+ setElement( index,
+ this.elements[this.size] );
+ this.elements[this.size] = null;
+ this.size--;
+ if ( this.size != 0 && index <= this.size ) {
+ int compareToParent = 0;
+ if ( index > 1 ) {
+ compareToParent = compare( this.elements[index],
+ this.elements[index / 2] );
+ }
+ if ( index > 1 && compareToParent > 0 ) {
+ percolateUpMaxHeap( index );
+ } else {
+ percolateDownMaxHeap( index );
+ }
}
- }
-
- return result;
+
+ return result;
+ } finally {
+ this.lock.unlock();
+ }
}
// /**
@@ -373,36 +419,30 @@
element.enqueued( index );
}
- public Queueable[] getQueueable() {
- return this.elements;
- }
-
- public Object[] toArray() {
- final Object[] result = new Object[this.size];
- System.arraycopy( this.elements,
- 1,
- result,
- 0,
- this.size );
- return result;
- }
-
public Object[] toArray(Object a[]) {
- if ( a.length < this.size ) {
- a = (Object[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(),
- this.size );
+ try {
+ this.lock.lock();
+
+ if ( a.length < this.size ) {
+ a = (Object[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(),
+ this.size );
+ }
+
+ System.arraycopy( this.elements,
+ 1,
+ a,
+ 0,
+ this.size );
+
+ if ( a.length > this.size ) {
+ a[this.size] = null;
+ }
+
+ return a;
+ } finally {
+ this.lock.unlock();
}
+ }
+}
- System.arraycopy( this.elements,
- 1,
- a,
- 0,
- this.size );
- if ( a.length > this.size ) {
- a[this.size] = null;
- }
-
- return a;
- }
-}
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/debug/SessionInspector.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/debug/SessionInspector.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/core/util/debug/SessionInspector.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -29,6 +29,7 @@
import org.drools.reteoo.EntryPointNode;
import org.drools.reteoo.EvalConditionNode;
import org.drools.reteoo.ExistsNode;
+import org.drools.reteoo.ForallNotNode;
import org.drools.reteoo.FromNode;
import org.drools.reteoo.JoinNode;
import org.drools.reteoo.LeftInputAdapterNode;
@@ -88,6 +89,8 @@
BetaNodeVisitor.INSTANCE );
this.visitors.put( NotNode.class,
BetaNodeVisitor.INSTANCE );
+ this.visitors.put( ForallNotNode.class,
+ BetaNodeVisitor.INSTANCE );
this.visitors.put( ExistsNode.class,
BetaNodeVisitor.INSTANCE );
this.visitors.put( AccumulateNode.class,
@@ -133,7 +136,7 @@
nodeStack,
info );
} else {
- throw new RuntimeException( "No visitor found for node: " + parent );
+ throw new RuntimeException( "No visitor found for node class: " + parent.getClass()+" node: "+parent );
}
visitChildren( parent,
nodeStack,
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/CompositeLeftTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/CompositeLeftTupleSinkAdapter.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/CompositeLeftTupleSinkAdapter.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -276,11 +276,15 @@
// iterate to find all child tuples for the shared node
while ( childLeftTuple != null && childLeftTuple.getRightParent() == parentRightTuple ) {
// this will iterate for each child node when the
- // the current node is shared
+ // the current node is shared
+
+ // preserve the current LeftTuple, as we need to iterate to the next before re-adding
+ LeftTuple temp = childLeftTuple;
childLeftTuple.getLeftTupleSink().modifyLeftTuple( childLeftTuple,
context,
workingMemory );
childLeftTuple = childLeftTuple.getLeftParentNext();
+ temp.reAddRight();
}
return childLeftTuple;
}
@@ -293,11 +297,15 @@
// iterate to find all child tuples for the shared node
while ( childLeftTuple != null && childLeftTuple.getLeftParent() == parentLeftTuple ) {
// this will iterate for each child node when the
- // the current node is shared
+ // the current node is shared
+
+ // preserve the current LeftTuple, as we need to iterate to the next before re-adding
+ LeftTuple temp = childLeftTuple;
childLeftTuple.getLeftTupleSink().modifyLeftTuple( childLeftTuple,
context,
workingMemory );
childLeftTuple = childLeftTuple.getRightParentNext();
+ temp.reAddLeft();
}
return childLeftTuple;
}
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -241,15 +241,11 @@
workingMemory,
true );
} else {
- // preserve the current LeftTuple, as we need to iterate to the next before re-adding
- LeftTuple temp = childLeftTuple;
childLeftTuple = this.sink.propagateModifyChildLeftTuple( childLeftTuple,
leftTuple,
context,
workingMemory,
true );
- // we must re-add this to ensure deterministic iteration
- temp.reAddLeft();
}
} else if ( childLeftTuple != null && childLeftTuple.getLeftParent() == leftTuple ) {
childLeftTuple = this.sink.propagateRetractChildLeftTuple( childLeftTuple,
@@ -329,15 +325,11 @@
workingMemory,
true );
} else {
- // preserve the current LeftTuple, as we need to iterate to the next before re-adding
- LeftTuple temp = childLeftTuple;
childLeftTuple = this.sink.propagateModifyChildLeftTuple( childLeftTuple,
rightTuple,
context,
workingMemory,
true );
- // we must re-add this to ensure deterministic iteration
- temp.reAddRight();
}
} else if ( childLeftTuple != null && childLeftTuple.getRightParent() == rightTuple ) {
childLeftTuple = this.sink.propagateRetractChildLeftTuple( childLeftTuple,
@@ -399,3 +391,4 @@
return "[JoinNode(" + this.getId() + ") - " + ((ObjectTypeNode) source).getObjectType() + "]";
}
}
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/RightInputAdapterNode.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -117,7 +117,6 @@
public void assertLeftTuple(final LeftTuple tuple,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
-
// creating a dummy fact handle to wrap the tuple
final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( tuple,
workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( context.getEntryPoint(),
@@ -147,7 +146,6 @@
final InternalWorkingMemory workingMemory) {
final ObjectHashMap memory = (ObjectHashMap) workingMemory.getNodeMemory( this );
-
// retrieve handle from memory
final InternalFactHandle factHandle = (InternalFactHandle) memory.remove( tuple );
@@ -332,4 +330,10 @@
return this.tupleMemoryEnabled == other.tupleMemoryEnabled && this.tupleSource.equals( other.tupleSource );
}
+ @Override
+ public String toString() {
+ return "RightInputAdapterNode(" + id + ")[ tupleMemoryEnabled=" + tupleMemoryEnabled + ", tupleSource=" + tupleSource + ", source="
+ + source + ", associations=" + associations.keySet() + ", partitionId=" + partitionId + "]";
+ }
}
+
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/SingleLeftTupleSinkAdapter.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/SingleLeftTupleSinkAdapter.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/reteoo/SingleLeftTupleSinkAdapter.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -239,6 +239,8 @@
childLeftTuple.getLeftTupleSink().modifyLeftTuple( childLeftTuple,
context,
workingMemory );
+ // re-order right to keep order consistency
+ childLeftTuple.reAddRight();
return childLeftTuple.getLeftParentNext();
}
@@ -250,6 +252,8 @@
childLeftTuple.getLeftTupleSink().modifyLeftTuple( childLeftTuple,
context,
workingMemory );
+ // re-order right to keep order consistency
+ childLeftTuple.reAddLeft();
return childLeftTuple.getRightParentNext();
}
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-core/src/main/java/org/drools/runtime/rule/impl/AgendaGroupImpl.java 2011-06-07 16:31:45 UTC (rev 37073)
@@ -20,8 +20,11 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.util.Arrays;
+import java.util.Collection;
import org.drools.common.InternalAgenda;
+import org.drools.runtime.rule.Activation;
import org.drools.runtime.rule.AgendaGroup;
public class AgendaGroupImpl implements AgendaGroup, Externalizable {
@@ -59,5 +62,10 @@
public void setFocus() {
this.agenda.setFocus( this.name );
}
+
+// public Collection<Activation> getActivations() {
+// return this.agenda.getAgendaGroup( this.name ).getActivations();
+//}
+
}
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/guvnor-importer/.classpath
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/guvnor-importer/.classpath 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/guvnor-importer/.classpath 2011-06-07 16:31:45 UTC (rev 37073)
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/sample-model/.classpath
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/sample-model/.classpath 2011-06-07 13:28:25 UTC (rev 37072)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_BRMS-519_BRMS-586/drools-guvnor/bulk-importer-util/sample-model/.classpath 2011-06-07 16:31:45 UTC (rev 37073)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
More information about the jboss-svn-commits
mailing list