From ca67bcda135939f42c38e131902a2b293a8c3614 Mon Sep 17 00:00:00 2001 From: mariofusco Date: Thu, 13 Jul 2023 15:46:10 +0200 Subject: [PATCH] wip --- .../drools/base/common/PartitionsManager.java | 33 ++++++ .../base/common/RuleBasePartitionId.java | 25 ++-- .../org/drools/core/common/AgendaFactory.java | 5 +- .../java/org/drools/core/common/BaseNode.java | 21 ++-- .../core/common/DefaultEventHandle.java | 2 +- .../drools/core/common/DefaultFactHandle.java | 23 ++-- .../core/common/InternalFactHandle.java | 2 +- .../drools/core/impl/InternalRuleBase.java | 30 ++--- .../drools/core/impl/KnowledgeBaseImpl.java | 109 ++++++++++-------- .../core/reteoo/AbstractTerminalNode.java | 26 ++--- .../org/drools/core/reteoo/AlphaNode.java | 19 ++- ...positePartitionAwareObjectSinkAdapter.java | 29 ++--- .../core/reteoo/EmptyObjectSinkAdapter.java | 16 +-- .../drools/core/reteoo/EntryPointNode.java | 17 +-- .../drools/core/reteoo/LeftTupleSource.java | 16 ++- .../org/drools/core/reteoo/ObjectSource.java | 26 ++--- .../drools/core/reteoo/ObjectTypeNode.java | 40 ++++--- .../drools/core/reteoo/QueryTerminalNode.java | 13 +-- .../java/org/drools/core/reteoo/Rete.java | 24 ++-- .../core/reteoo/RightInputAdapterNode.java | 20 ++-- .../drools/core/reteoo/RuleTerminalNode.java | 15 ++- .../org/drools/core/reteoo/WindowNode.java | 1 - .../core/reteoo/builder/NodeFactory.java | 33 +++--- .../reteoo/builder/PhreakNodeFactory.java | 38 +++--- .../org/drools/core/reteoo/BaseNodeTest.java | 2 +- .../drools/core/reteoo/MockObjectSource.java | 16 +-- .../agenda/CompositeDefaultAgenda.java | 18 +-- .../kiesession/agenda/DefaultAgenda.java | 30 ++--- .../agenda/DefaultAgendaFactory.java | 13 +-- .../rulebase/SessionsAwareKnowledgeBase.java | 54 +++++---- .../kiesession/ReteooWorkingMemoryTest.java | 1 - .../core/ReliableAgendaFactory.java | 4 - .../protobuf/FactHandleMarshallingTest.java | 24 ++-- .../drools/mvel/model/MockObjectSource.java | 16 +-- 34 files changed, 384 insertions(+), 377 deletions(-) create mode 100644 drools-base/src/main/java/org/drools/base/common/PartitionsManager.java diff --git a/drools-base/src/main/java/org/drools/base/common/PartitionsManager.java b/drools-base/src/main/java/org/drools/base/common/PartitionsManager.java new file mode 100644 index 00000000000..ef9e62353ca --- /dev/null +++ b/drools-base/src/main/java/org/drools/base/common/PartitionsManager.java @@ -0,0 +1,33 @@ +package org.drools.base.common; + +import java.util.concurrent.atomic.AtomicInteger; + +public class PartitionsManager { + + private static final int MIN_PARALLEL_THRESHOLD = Runtime.getRuntime().availableProcessors(); + private static final int MAX_PARALLEL_THRESHOLD = Runtime.getRuntime().availableProcessors(); + + private final AtomicInteger partitionCounter = new AtomicInteger( 0 ); + + private int parallelEvaluationSlotsCount = -1; + + public RuleBasePartitionId createNewPartitionId() { + return new RuleBasePartitionId(this, partitionCounter.incrementAndGet()); + } + + public int getPartitionsCount() { + return partitionCounter.get(); + } + + public boolean hasParallelEvaluation() { + return getPartitionsCount() >= MIN_PARALLEL_THRESHOLD; + } + + public int getParallelEvaluationSlotsCount() { + return parallelEvaluationSlotsCount; + } + + public void init() { + this.parallelEvaluationSlotsCount = Math.min(getPartitionsCount(), MAX_PARALLEL_THRESHOLD); + } +} diff --git a/drools-base/src/main/java/org/drools/base/common/RuleBasePartitionId.java b/drools-base/src/main/java/org/drools/base/common/RuleBasePartitionId.java index 7ecb704117b..b7b53f736b0 100644 --- a/drools-base/src/main/java/org/drools/base/common/RuleBasePartitionId.java +++ b/drools-base/src/main/java/org/drools/base/common/RuleBasePartitionId.java @@ -16,27 +16,19 @@ package org.drools.base.common; -import org.kie.api.concurrent.KieExecutors; - -import java.io.Serializable; -import java.util.concurrent.atomic.AtomicInteger; - /** * A class to identify RuleBase partitions */ -public final class RuleBasePartitionId implements Serializable { - - private static final long serialVersionUID = 510l; - - public static final int PARALLEL_PARTITIONS_NUMBER = KieExecutors.Pool.SIZE; +public final class RuleBasePartitionId { - public static final RuleBasePartitionId MAIN_PARTITION = new RuleBasePartitionId( 0 ); + public static final RuleBasePartitionId MAIN_PARTITION = new RuleBasePartitionId(null, 0); - private static final AtomicInteger PARTITION_COUNTER = new AtomicInteger( 1 ); + private final PartitionsManager partitionsManager; private final int id; - private RuleBasePartitionId( int id ) { + public RuleBasePartitionId(PartitionsManager partitionsManager, int id ) { + this.partitionsManager = partitionsManager; this.id = id; } @@ -45,7 +37,7 @@ public int getId() { } public int getParallelEvaluationSlot() { - return id % PARALLEL_PARTITIONS_NUMBER; + return id % partitionsManager.getParallelEvaluationSlotsCount(); } @Override @@ -58,11 +50,8 @@ public boolean equals(Object obj) { return this == obj || (obj instanceof RuleBasePartitionId && id == ((RuleBasePartitionId)obj).id); } + @Override public String toString() { return "Partition(" + (id == 0 ? "MAIN" : id) + ")"; } - - public static RuleBasePartitionId createPartition() { - return new RuleBasePartitionId( PARTITION_COUNTER.getAndIncrement() ); - } } diff --git a/drools-core/src/main/java/org/drools/core/common/AgendaFactory.java b/drools-core/src/main/java/org/drools/core/common/AgendaFactory.java index 9947cafd44b..b5b4ce136a5 100644 --- a/drools-core/src/main/java/org/drools/core/common/AgendaFactory.java +++ b/drools-core/src/main/java/org/drools/core/common/AgendaFactory.java @@ -23,6 +23,7 @@ public interface AgendaFactory { InternalAgenda createAgenda(InternalRuleBase kBase, boolean initMain); - InternalAgenda createAgenda(InternalRuleBase kBase); - + default InternalAgenda createAgenda(InternalRuleBase kBase) { + return createAgenda(kBase, true); + } } diff --git a/drools-core/src/main/java/org/drools/core/common/BaseNode.java b/drools-core/src/main/java/org/drools/core/common/BaseNode.java index 40f00fad204..bd7ec582b80 100644 --- a/drools-core/src/main/java/org/drools/core/common/BaseNode.java +++ b/drools-core/src/main/java/org/drools/core/common/BaseNode.java @@ -16,12 +16,6 @@ package org.drools.core.common; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import org.drools.base.common.NetworkNode; import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.BaseTerminalNode; @@ -36,6 +30,12 @@ import org.drools.core.reteoo.builder.BuildContext; import org.kie.api.definition.rule.Rule; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + /** * The base class for all Rete nodes. */ @@ -48,7 +48,6 @@ public abstract class BaseNode protected int memoryId = -1; protected RuleBasePartitionId partitionId; - protected boolean partitionsEnabled; protected Set associations; private Map associatedTerminals; @@ -68,12 +67,10 @@ public BaseNode() { * The unique id */ public BaseNode(final int id, - final RuleBasePartitionId partitionId, - final boolean partitionsEnabled) { + final RuleBasePartitionId partitionId) { super(); this.id = id; this.partitionId = partitionId; - this.partitionsEnabled = partitionsEnabled; this.associations = new HashSet<>(); this.associatedTerminals = new HashMap<>(); } @@ -171,10 +168,6 @@ public void setPartitionId(BuildContext context, RuleBasePartitionId partitionId this.partitionId = partitionId; } - public void setPartitionsEnabled( boolean partitionsEnabled ) { - this.partitionsEnabled = partitionsEnabled; - } - /** * Associates this node with the give rule */ diff --git a/drools-core/src/main/java/org/drools/core/common/DefaultEventHandle.java b/drools-core/src/main/java/org/drools/core/common/DefaultEventHandle.java index 4958f9b90e9..87700c4da0d 100644 --- a/drools-core/src/main/java/org/drools/core/common/DefaultEventHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/DefaultEventHandle.java @@ -268,7 +268,7 @@ private DefaultEventHandle cloneWithoutTuples() { clone.setOtnCount( getOtnCount() ); clone.setExpired( isExpired() ); clone.setEqualityKey( getEqualityKey() ); - clone.linkedTuples = this.linkedTuples.newInstance(); + clone.linkedTuples = this.linkedTuples.cloneEmpty(); clone.setObjectHashCode(getObjectHashCode()); clone.wmEntryPoint = this.wmEntryPoint; return clone; diff --git a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java index 93b5dd0a879..0559383b053 100644 --- a/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/DefaultFactHandle.java @@ -16,7 +16,6 @@ package org.drools.core.common; -import org.drools.base.common.RuleBasePartitionId; import org.drools.base.factmodel.traits.TraitTypeEnum; import org.drools.base.rule.EntryPointId; import org.drools.core.WorkingMemoryEntryPoint; @@ -353,9 +352,9 @@ public WorkingMemoryEntryPoint getEntryPoint(ReteEvaluator reteEvaluator) { return wmEntryPoint; } - protected void setLinkedTuples( InternalRuleBase kbase) { - linkedTuples = kbase != null && kbase.getRuleBaseConfiguration().isMultithreadEvaluation() ? - new CompositeLinkedTuples() : + protected void setLinkedTuples(InternalRuleBase kbase) { + linkedTuples = kbase != null && kbase.hasParallelEvaluation() ? + new CompositeLinkedTuples(kbase.getParallelEvaluationSlotsCount()) : new SingleLinkedTuples(); } @@ -467,7 +466,7 @@ public SingleLinkedTuples clone() { } @Override - public LinkedTuples newInstance() { + public LinkedTuples cloneEmpty() { return new SingleLinkedTuples(); } @@ -717,7 +716,11 @@ RightTuple getFirstRightTuple() { public static class CompositeLinkedTuples implements LinkedTuples { - private final LinkedTuples[] partitionedTuples = new LinkedTuples[RuleBasePartitionId.PARALLEL_PARTITIONS_NUMBER]; + private final LinkedTuples[] partitionedTuples; + + public CompositeLinkedTuples(int parallelEvaluationSlotsCount) { + this.partitionedTuples = new LinkedTuples[parallelEvaluationSlotsCount]; + } private LinkedTuples getPartitionedTuple(int partition) { LinkedTuples tuples = partitionedTuples[partition]; @@ -733,8 +736,8 @@ private LinkedTuples getOrCreatePartitionedTuple(int partition) { } @Override - public LinkedTuples newInstance() { - return new CompositeLinkedTuples(); + public LinkedTuples cloneEmpty() { + return new CompositeLinkedTuples(partitionedTuples.length); } @Override @@ -749,7 +752,7 @@ public boolean hasTuples() { @Override public LinkedTuples clone() { - CompositeLinkedTuples clone = new CompositeLinkedTuples(); + CompositeLinkedTuples clone = new CompositeLinkedTuples(partitionedTuples.length); for (int i = 0; i < partitionedTuples.length; i++) { clone.partitionedTuples[i] = partitionedTuples[i] == null ? null : partitionedTuples[i].clone(); } @@ -875,7 +878,7 @@ public LinkedTuples clone() { } @Override - public LinkedTuples newInstance() { + public LinkedTuples cloneEmpty() { throw new UnsupportedOperationException(); } diff --git a/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java b/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java index dbbf6025d8e..fa1eab11e1d 100644 --- a/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java +++ b/drools-core/src/main/java/org/drools/core/common/InternalFactHandle.java @@ -137,7 +137,7 @@ default boolean hasMatches() { interface LinkedTuples extends Serializable { LinkedTuples clone(); - LinkedTuples newInstance(); + LinkedTuples cloneEmpty(); boolean hasTuples(); diff --git a/drools-core/src/main/java/org/drools/core/impl/InternalRuleBase.java b/drools-core/src/main/java/org/drools/core/impl/InternalRuleBase.java index 9731fbb1ec1..83b2b803a35 100644 --- a/drools-core/src/main/java/org/drools/core/impl/InternalRuleBase.java +++ b/drools-core/src/main/java/org/drools/core/impl/InternalRuleBase.java @@ -16,23 +16,18 @@ package org.drools.core.impl; -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Future; - import org.drools.base.RuleBase; +import org.drools.base.common.RuleBasePartitionId; +import org.drools.base.definitions.InternalKnowledgePackage; +import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.rule.InvalidPatternException; +import org.drools.base.rule.TypeDeclaration; +import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.drools.core.KieBaseConfigurationImpl; import org.drools.core.RuleBaseConfiguration; import org.drools.core.base.ClassFieldAccessorCache; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; -import org.drools.base.definitions.InternalKnowledgePackage; -import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.reteoo.AsyncReceiveNode; import org.drools.core.reteoo.EntryPointNode; import org.drools.core.reteoo.LeftTupleNode; @@ -41,10 +36,7 @@ import org.drools.core.reteoo.ReteooBuilder; import org.drools.core.reteoo.SegmentMemory; import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; -import org.drools.base.rule.InvalidPatternException; -import org.drools.base.rule.TypeDeclaration; import org.drools.core.rule.accessor.FactHandleFactory; -import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.ReleaseId; import org.kie.api.definition.KiePackage; @@ -55,6 +47,14 @@ import org.kie.api.io.Resource; import org.kie.api.runtime.KieSessionConfiguration; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Future; + public interface InternalRuleBase extends RuleBase { Collection getKiePackages(); @@ -81,6 +81,8 @@ public interface InternalRuleBase extends RuleBase { String getId(); RuleBasePartitionId createNewPartitionId(); + boolean hasParallelEvaluation(); + int getParallelEvaluationSlotsCount(); RuleBaseConfiguration getRuleBaseConfiguration(); diff --git a/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseImpl.java b/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseImpl.java index bbeeeb37d81..7aee74e5bb3 100644 --- a/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseImpl.java +++ b/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseImpl.java @@ -16,35 +16,26 @@ package org.drools.core.impl; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Future; -import java.util.concurrent.locks.ReentrantReadWriteLock; - +import org.drools.base.base.ClassObjectType; +import org.drools.base.common.PartitionsManager; +import org.drools.base.common.RuleBasePartitionId; +import org.drools.base.definitions.InternalKnowledgePackage; +import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.factmodel.ClassDefinition; +import org.drools.base.rule.DialectRuntimeRegistry; +import org.drools.base.rule.EntryPointId; +import org.drools.base.rule.Function; +import org.drools.base.rule.ImportDeclaration; +import org.drools.base.rule.InvalidPatternException; +import org.drools.base.rule.TypeDeclaration; +import org.drools.base.rule.WindowDeclaration; +import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.drools.core.KieBaseConfigurationImpl; import org.drools.core.RuleBaseConfiguration; import org.drools.core.SessionConfiguration; import org.drools.core.base.ClassFieldAccessorCache; -import org.drools.base.base.ClassObjectType; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; -import org.drools.base.definitions.InternalKnowledgePackage; -import org.drools.base.definitions.rule.impl.RuleImpl; -import org.drools.base.factmodel.ClassDefinition; import org.drools.core.management.DroolsManagementAgent; import org.drools.core.phreak.BuildtimeSegmentUtilities; import org.drools.core.phreak.EagerPhreakBuilder.Add; @@ -65,16 +56,8 @@ import org.drools.core.reteoo.TerminalNode; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.reteoo.builder.NodeFactory; -import org.drools.base.rule.DialectRuntimeRegistry; -import org.drools.base.rule.EntryPointId; -import org.drools.base.rule.Function; -import org.drools.base.rule.ImportDeclaration; -import org.drools.base.rule.InvalidPatternException; import org.drools.core.rule.JavaDialectRuntimeData; -import org.drools.base.rule.TypeDeclaration; -import org.drools.base.rule.WindowDeclaration; import org.drools.core.rule.accessor.FactHandleFactory; -import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.drools.wiring.api.classloader.ProjectClassLoader; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.ReleaseId; @@ -94,13 +77,31 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Future; +import java.util.concurrent.locks.ReentrantReadWriteLock; + import static org.drools.core.phreak.PhreakBuilder.isEagerSegmentCreation; import static org.drools.util.BitMaskUtil.isSet; import static org.drools.util.ClassUtils.convertClassToResourcePath; public class KnowledgeBaseImpl implements InternalRuleBase { - protected static final transient Logger logger = LoggerFactory.getLogger(KnowledgeBaseImpl.class); + protected static final Logger logger = LoggerFactory.getLogger(KnowledgeBaseImpl.class); private Set addedEntryNodeCache; private Set removedEntryNodeCache; @@ -149,6 +150,8 @@ public class KnowledgeBaseImpl implements InternalRuleBase { private boolean hasMultipleAgendaGroups = false; + private final PartitionsManager partitionsManager = new PartitionsManager(); + public KnowledgeBaseImpl() { } public KnowledgeBaseImpl(final String id, @@ -447,9 +450,22 @@ public void kBaseInternal_addPackages(Collection clone ruleUnitDescriptionRegistry.add(newPkg.getRuleUnitDescriptionLoader()); } - if (ruleBaseConfig.isMultithreadEvaluation() && !hasMultiplePartitions()) { + if (ruleBaseConfig.isMultithreadEvaluation()) { + setupParallelEvaluation(); + } + } + + private void setupParallelEvaluation() { + if (!hasParallelEvaluation()) { disableMultithreadEvaluation("The rete network cannot be partitioned: disabling multithread evaluation"); } + partitionsManager.init(); + for (EntryPointNode epn : rete.getEntryPointNodes().values()) { + epn.setupParallelEvaluation(this); + for ( ObjectTypeNode otn : epn.getObjectTypeNodes().values() ) { + otn.setupParallelEvaluation(this); + } + } } public void processAllTypesDeclaration( Collection pkgs ) { @@ -490,18 +506,6 @@ private void checkMultithreadedEvaluation( RuleImpl rule ) { } } - private boolean hasMultiplePartitions() { - for (EntryPointNode entryPointNode : rete.getEntryPointNodes().values()) { - for ( ObjectTypeNode otn : entryPointNode.getObjectTypeNodes().values() ) { - ObjectSinkPropagator sink = otn.getObjectSinkPropagator(); - if (sink instanceof CompositePartitionAwareObjectSinkAdapter && ( (CompositePartitionAwareObjectSinkAdapter) sink ).getUsedPartitionsCount() > 1) { - return true; - } - } - } - return false; - } - public boolean hasMultipleAgendaGroups() { return hasMultipleAgendaGroups; } @@ -510,7 +514,6 @@ private void disableMultithreadEvaluation(String warningMessage) { ruleBaseConfig.enforceSingleThreadEvaluation(); logger.warn( warningMessage ); for (EntryPointNode entryPointNode : rete.getEntryPointNodes().values()) { - entryPointNode.setPartitionsEnabled( false ); for (ObjectTypeNode otn : entryPointNode.getObjectTypeNodes().values()) { ObjectSinkPropagator sink = otn.getObjectSinkPropagator(); if (sink instanceof CompositePartitionAwareObjectSinkAdapter) { @@ -840,7 +843,6 @@ protected void setupRete() { // always add the default entry point EntryPointNode epn = nodeFactory.buildEntryPointNode(this.reteooBuilder.getNodeIdsGenerator().getNextId(), RuleBasePartitionId.MAIN_PARTITION, - ruleBaseConfig.isMultithreadEvaluation(), this.rete, EntryPointId.DEFAULT); epn.attach(); @@ -1176,8 +1178,19 @@ private void addReloadDialectDatas( DialectRuntimeRegistry registry ) { this.reloadPackageCompilationData.offer( registry ); } + @Override public RuleBasePartitionId createNewPartitionId() { - return RuleBasePartitionId.createPartition(); + return partitionsManager.createNewPartitionId(); + } + + @Override + public boolean hasParallelEvaluation() { + return getRuleBaseConfiguration().isMultithreadEvaluation() && partitionsManager.hasParallelEvaluation(); + } + + @Override + public int getParallelEvaluationSlotsCount() { + return partitionsManager.getParallelEvaluationSlotsCount(); } public FactType getFactType(String packageName, String typeName) { diff --git a/drools-core/src/main/java/org/drools/core/reteoo/AbstractTerminalNode.java b/drools-core/src/main/java/org/drools/core/reteoo/AbstractTerminalNode.java index 3cfb9e96b02..41eca410c84 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/AbstractTerminalNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/AbstractTerminalNode.java @@ -15,27 +15,27 @@ package org.drools.core.reteoo; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import org.drools.core.RuleBaseConfiguration; import org.drools.base.base.ObjectType; -import org.drools.core.common.BaseNode; -import org.drools.core.common.ReteEvaluator; import org.drools.base.common.RuleBasePartitionId; -import org.drools.core.common.UpdateContext; import org.drools.base.definitions.rule.impl.RuleImpl; -import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; -import org.drools.core.reteoo.builder.BuildContext; import org.drools.base.rule.Declaration; import org.drools.base.rule.GroupElement; import org.drools.base.rule.Pattern; +import org.drools.core.RuleBaseConfiguration; +import org.drools.core.common.BaseNode; +import org.drools.core.common.ReteEvaluator; +import org.drools.core.common.UpdateContext; +import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; +import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.util.bitmask.AllSetBitMask; import org.drools.core.util.bitmask.BitMask; import org.drools.core.util.bitmask.EmptyBitMask; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + import static org.drools.base.reteoo.PropertySpecificUtil.isPropertyReactive; public abstract class AbstractTerminalNode extends BaseNode implements TerminalNode { @@ -77,10 +77,10 @@ public abstract class AbstractTerminalNode extends BaseNode implements TerminalN public AbstractTerminalNode() { } - public AbstractTerminalNode(int id, RuleBasePartitionId partitionId, boolean partitionsEnabled, LeftTupleSource source, + public AbstractTerminalNode(int id, RuleBasePartitionId partitionId, LeftTupleSource source, BuildContext context, RuleImpl rule, GroupElement subrule, int subruleIndex) { - super(id, partitionId, partitionsEnabled); + super(id, partitionId); this.tupleSource = source; this.rule = rule; this.subrule = subrule; diff --git a/drools-core/src/main/java/org/drools/core/reteoo/AlphaNode.java b/drools-core/src/main/java/org/drools/core/reteoo/AlphaNode.java index 972e03389da..102cbb59233 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/AlphaNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/AlphaNode.java @@ -16,22 +16,22 @@ package org.drools.core.reteoo; -import java.util.List; - import org.drools.base.base.ObjectType; +import org.drools.base.common.NetworkNode; +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.BaseTerminalNode; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; -import org.drools.base.common.NetworkNode; import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; import org.drools.core.util.bitmask.BitMask; import org.kie.api.definition.rule.Rule; +import java.util.List; + /** * AlphaNodes are nodes in the Rete network used * to apply FieldConstraint<.code>s on asserted fact @@ -73,11 +73,10 @@ public AlphaNode(final int id, final ObjectSource objectSource, final BuildContext context) { super(id, - context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), - objectSource, - context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeHashingThreshold(), - context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeRangeIndexThreshold()); + context.getPartitionId(), + objectSource, + context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeHashingThreshold(), + context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeRangeIndexThreshold()); this.constraint = constraint.cloneIfInUse(); this.constraint.registerEvaluationContext(context); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/CompositePartitionAwareObjectSinkAdapter.java b/drools-core/src/main/java/org/drools/core/reteoo/CompositePartitionAwareObjectSinkAdapter.java index 662f785aac7..6eb62799279 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/CompositePartitionAwareObjectSinkAdapter.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/CompositePartitionAwareObjectSinkAdapter.java @@ -16,36 +16,37 @@ package org.drools.core.reteoo; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.IndexableConstraint; +import org.drools.base.rule.accessor.ReadAccessor; import org.drools.core.common.ActivationsManager; import org.drools.core.common.BaseNode; import org.drools.core.common.InternalFactHandle; +import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.phreak.PropagationEntry; import org.drools.core.reteoo.CompositeObjectSinkAdapter.FieldIndex; -import org.drools.base.rule.IndexableConstraint; -import org.drools.base.rule.accessor.ReadAccessor; -import org.drools.core.common.PropagationContext; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; public class CompositePartitionAwareObjectSinkAdapter implements ObjectSinkPropagator { - private final ObjectSinkPropagator[] partitionedPropagators = new ObjectSinkPropagator[RuleBasePartitionId.PARALLEL_PARTITIONS_NUMBER]; + private final ObjectSinkPropagator[] partitionedPropagators; private boolean hashed = true; private CompositeObjectSinkAdapter.FieldIndex fieldIndex; private Map hashedSinkMap; - public CompositePartitionAwareObjectSinkAdapter() { + public CompositePartitionAwareObjectSinkAdapter(int parallelEvaluationSlotsCount) { + this.partitionedPropagators = new ObjectSinkPropagator[parallelEvaluationSlotsCount]; Arrays.fill(partitionedPropagators, EmptyObjectSinkAdapter.getInstance()); } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/EmptyObjectSinkAdapter.java b/drools-core/src/main/java/org/drools/core/reteoo/EmptyObjectSinkAdapter.java index 61a718068c9..bd6210f84e3 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/EmptyObjectSinkAdapter.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/EmptyObjectSinkAdapter.java @@ -16,14 +16,14 @@ package org.drools.core.reteoo; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; - import org.drools.core.common.BaseNode; import org.drools.core.common.InternalFactHandle; -import org.drools.core.common.ReteEvaluator; import org.drools.core.common.PropagationContext; +import org.drools.core.common.ReteEvaluator; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; public class EmptyObjectSinkAdapter implements ObjectSinkPropagator { @@ -58,12 +58,6 @@ public void propagateAssertObject(final InternalFactHandle factHandle, } - public void propagateRetractObject(final InternalFactHandle handle, - final PropagationContext context, - final ReteEvaluator reteEvaluator, - final boolean useHash) { - } - public void propagateModifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, diff --git a/drools-core/src/main/java/org/drools/core/reteoo/EntryPointNode.java b/drools-core/src/main/java/org/drools/core/reteoo/EntryPointNode.java index ac13db33216..3c0232ecd73 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/EntryPointNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/EntryPointNode.java @@ -29,6 +29,7 @@ import org.drools.core.common.ObjectTypeConfigurationRegistry; import org.drools.core.common.ReteEvaluator; import org.drools.core.common.PropagationContext; +import org.drools.core.impl.InternalRuleBase; import org.drools.core.phreak.PropagationEntry; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.util.bitmask.BitMask; @@ -74,6 +75,8 @@ public class EntryPointNode extends ObjectSource implements ObjectSink { private ObjectTypeConfigurationRegistry typeConfReg; + private boolean parallelEvaluation = false; + // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ @@ -86,19 +89,16 @@ public EntryPointNode(final int id, final BuildContext context) { this( id, context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), objectSource, context.getCurrentEntryPoint() ); // irrelevant for this node, since it overrides sink management } public EntryPointNode(final int id, final RuleBasePartitionId partitionId, - final boolean partitionsEnabled, final ObjectSource objectSource, final EntryPointId entryPoint) { super( id, partitionId, - partitionsEnabled, objectSource, 999, 999); // irrelevant for this node, since it overrides sink management @@ -113,6 +113,10 @@ public EntryPointNode(final int id, // Instance methods // ------------------------------------------------------------ + public void setupParallelEvaluation(InternalRuleBase kbase) { + parallelEvaluation = true; + } + public ObjectTypeConfigurationRegistry getTypeConfReg() { return typeConfReg; } @@ -127,9 +131,6 @@ public short getType() { public EntryPointId getEntryPoint() { return entryPoint; } - void setEntryPoint(EntryPointId entryPoint) { - this.entryPoint = entryPoint; - } public ObjectTypeNode getQueryNode() { if ( queryNode == null ) { @@ -189,9 +190,9 @@ public void assertObject(final InternalFactHandle handle, log.trace("Insert {}", handle.toString()); } - if ( partitionsEnabled || !reteEvaluator.isThreadSafe() ) { + if ( parallelEvaluation || !reteEvaluator.isThreadSafe() ) { // In case of multithreaded evaluation the CompositePartitionAwareObjectSinkAdapter - // used by the OTNs will take care of enqueueing this inseretion on the propagation queues + // used by the OTNs will take care of enqueueing this insertion on the propagation queues // of the different agendas PropagationEntry.Insert.execute( handle, context, reteEvaluator, objectTypeConf ); } else { diff --git a/drools-core/src/main/java/org/drools/core/reteoo/LeftTupleSource.java b/drools-core/src/main/java/org/drools/core/reteoo/LeftTupleSource.java index c814532a879..b48e4df0baf 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/LeftTupleSource.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/LeftTupleSource.java @@ -16,21 +16,21 @@ package org.drools.core.reteoo; -import java.util.Collection; -import java.util.List; - import org.drools.base.base.ClassObjectType; +import org.drools.base.base.ObjectType; +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.Pattern; import org.drools.core.common.BaseNode; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.phreak.BuildtimeSegmentUtilities; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.rule.Pattern; -import org.drools.base.base.ObjectType; import org.drools.core.util.bitmask.AllSetBitMask; import org.drools.core.util.bitmask.BitMask; import org.drools.core.util.bitmask.EmptyBitMask; +import java.util.Collection; +import java.util.List; + import static org.drools.base.reteoo.PropertySpecificUtil.calculateNegativeMask; import static org.drools.base.reteoo.PropertySpecificUtil.calculatePositiveMask; import static org.drools.base.reteoo.PropertySpecificUtil.getAccessibleProperties; @@ -80,9 +80,7 @@ public LeftTupleSource() { * @param id */ protected LeftTupleSource(int id, BuildContext context) { - super(id, - context != null ? context.getPartitionId() : RuleBasePartitionId.MAIN_PARTITION, - context != null && context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation()); + super(id, context != null ? context.getPartitionId() : RuleBasePartitionId.MAIN_PARTITION); this.sink = EmptyLeftTupleSinkAdapter.getInstance(); initMemoryId( context ); } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/ObjectSource.java b/drools-core/src/main/java/org/drools/core/reteoo/ObjectSource.java index 5c81ba89429..0acd415af66 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/ObjectSource.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/ObjectSource.java @@ -16,23 +16,23 @@ package org.drools.core.reteoo; -import java.util.List; - +import org.drools.base.base.ObjectType; +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.Pattern; import org.drools.core.common.BaseNode; import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.InternalWorkingMemory; -import org.drools.base.common.RuleBasePartitionId; +import org.drools.core.common.PropagationContext; import org.drools.core.common.UpdateContext; import org.drools.core.impl.InternalRuleBase; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.rule.Pattern; -import org.drools.base.base.ObjectType; -import org.drools.core.common.PropagationContext; import org.drools.core.util.bitmask.AllSetBitMask; import org.drools.core.util.bitmask.BitMask; import org.drools.core.util.bitmask.EmptyBitMask; +import java.util.List; + import static org.drools.base.reteoo.PropertySpecificUtil.getAccessibleProperties; import static org.drools.base.reteoo.PropertySpecificUtil.isPropertyReactive; @@ -72,15 +72,8 @@ public ObjectSource() { /** * Single parameter constructor that specifies the unique id of the node. */ - protected ObjectSource(final int id, - final RuleBasePartitionId partitionId, - final boolean partitionsEnabled) { - this( id, - partitionId, - partitionsEnabled, - null, - 3, - 3); + protected ObjectSource(int id, RuleBasePartitionId partitionId) { + this( id, partitionId, null, 3, 3); } /** @@ -88,11 +81,10 @@ protected ObjectSource(final int id, */ ObjectSource(final int id, final RuleBasePartitionId partitionId, - final boolean partitionsEnabled, final ObjectSource objectSource, final int alphaNodeHashingThreshold, final int alphaNodeRangeIndexThreshold) { - super(id, partitionId, partitionsEnabled); + super(id, partitionId); this.source = objectSource; this.alphaNodeHashingThreshold = alphaNodeHashingThreshold; this.alphaNodeRangeIndexThreshold = alphaNodeRangeIndexThreshold; diff --git a/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java b/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java index 7ad7bab2a52..fdc02df5c90 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java @@ -16,15 +16,6 @@ package org.drools.core.reteoo; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.Serializable; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - import org.drools.base.InitialFact; import org.drools.base.base.ClassObjectType; import org.drools.base.base.ObjectType; @@ -38,6 +29,7 @@ import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; import org.drools.core.common.UpdateContext; +import org.drools.core.impl.InternalRuleBase; import org.drools.core.impl.WorkingMemoryReteExpireAction; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.time.Job; @@ -46,6 +38,15 @@ import org.drools.core.util.bitmask.BitMask; import org.drools.core.util.bitmask.EmptyBitMask; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + import static org.drools.base.rule.TypeDeclaration.NEVER_EXPIRES; /** @@ -101,22 +102,25 @@ public ObjectTypeNode(final int id, final BuildContext context) { super(id, RuleBasePartitionId.MAIN_PARTITION, - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), source, context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeHashingThreshold(), context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeRangeIndexThreshold()); this.objectType = objectType; - idGenerator = new IdGenerator(id); - + this.idGenerator = new IdGenerator(id); this.dirty = true; + this.hashcode = calculateHashCode(); + initMemoryId( context ); + } - hashcode = calculateHashCode(); - - if (objectType != ClassObjectType.InitialFact_ObjectType && context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation()) { - this.sink = new CompositePartitionAwareObjectSinkAdapter(); + public void setupParallelEvaluation(InternalRuleBase kbase) { + if (objectType == ClassObjectType.InitialFact_ObjectType) { + return; } - - initMemoryId( context ); + CompositePartitionAwareObjectSinkAdapter partitionedSink = new CompositePartitionAwareObjectSinkAdapter(kbase.getParallelEvaluationSlotsCount()); + for ( ObjectSink objectSink : this.sink.getSinks()) { + partitionedSink.addObjectSink(objectSink, alphaNodeHashingThreshold, alphaNodeRangeIndexThreshold); + } + this.sink = partitionedSink; } private static class IdGenerator { diff --git a/drools-core/src/main/java/org/drools/core/reteoo/QueryTerminalNode.java b/drools-core/src/main/java/org/drools/core/reteoo/QueryTerminalNode.java index 3b334910d38..187d34207fd 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/QueryTerminalNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/QueryTerminalNode.java @@ -16,16 +16,16 @@ package org.drools.core.reteoo; -import java.util.Map; - -import org.drools.base.reteoo.NodeTypeEnums; -import org.drools.core.common.InternalFactHandle; +import org.drools.base.definitions.rule.impl.QueryImpl; import org.drools.base.definitions.rule.impl.RuleImpl; -import org.drools.core.reteoo.builder.BuildContext; +import org.drools.base.reteoo.NodeTypeEnums; import org.drools.base.rule.Declaration; import org.drools.base.rule.GroupElement; -import org.drools.base.definitions.rule.impl.QueryImpl; +import org.drools.core.common.InternalFactHandle; import org.drools.core.common.PropagationContext; +import org.drools.core.reteoo.builder.BuildContext; + +import java.util.Map; /** * Leaf Rete-OO node responsible for enacting Action s on a @@ -66,7 +66,6 @@ public QueryTerminalNode(final int id, final BuildContext context) { super( id, context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), source, context, rule, subrule, subruleIndex); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/Rete.java b/drools-core/src/main/java/org/drools/core/reteoo/Rete.java index 6196ae13407..96144324c4f 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/Rete.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/Rete.java @@ -16,25 +16,25 @@ package org.drools.core.reteoo; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import org.drools.base.base.ObjectType; +import org.drools.base.common.RuleBasePartitionId; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.EntryPointId; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; +import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.common.UpdateContext; import org.drools.core.impl.InternalRuleBase; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.rule.EntryPointId; -import org.drools.base.base.ObjectType; -import org.drools.core.common.PropagationContext; import org.drools.core.util.bitmask.BitMask; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * The Rete-OO network. * @@ -70,8 +70,8 @@ public Rete() { // ------------------------------------------------------------ public Rete(InternalRuleBase kBase) { - super( 0, RuleBasePartitionId.MAIN_PARTITION, kBase != null && kBase.getRuleBaseConfiguration().isMultithreadEvaluation() ); - this.entryPoints = Collections.synchronizedMap( new HashMap() ); + super( 0, RuleBasePartitionId.MAIN_PARTITION ); + this.entryPoints = Collections.synchronizedMap( new HashMap<>() ); this.kBase = kBase; hashcode = calculateHashCode(); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java b/drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java index 6c1e58ae46d..530b1c716a5 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java @@ -16,28 +16,28 @@ package org.drools.core.reteoo; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - +import org.drools.base.base.ObjectType; +import org.drools.base.common.NetworkNode; +import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.base.reteoo.NodeTypeEnums; import org.drools.core.RuleBaseConfiguration; -import org.drools.base.base.ObjectType; import org.drools.core.common.ActivationsManager; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.Memory; -import org.drools.base.common.NetworkNode; import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; import org.drools.core.common.UpdateContext; -import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.util.bitmask.BitMask; import org.kie.api.definition.rule.Rule; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + /** * When joining a subnetwork into the main network again, RightInputAdapterNode adapts the * subnetwork's tuple into a fact in order right join it with the tuple being propagated in @@ -90,9 +90,7 @@ public RightInputAdapterNode(final int id, final LeftTupleSource source, final LeftTupleSource startTupleSource, final BuildContext context) { - super( id, - context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation() ); + super( id, context.getPartitionId() ); this.tupleSource = source; this.tupleMemoryEnabled = context.isTupleMemoryEnabled(); this.startTupleSource = startTupleSource; diff --git a/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java b/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java index b2e624a9781..f4fbdb09a4e 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/RuleTerminalNode.java @@ -16,22 +16,22 @@ package org.drools.core.reteoo; -import java.util.Map; -import java.util.Objects; - import org.drools.base.base.SalienceInteger; +import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.base.reteoo.NodeTypeEnums; +import org.drools.base.rule.Declaration; +import org.drools.base.rule.GroupElement; import org.drools.core.common.InternalFactHandle; +import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; -import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.phreak.PhreakRuleTerminalNode; import org.drools.core.phreak.RuleExecutor; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.rule.Declaration; -import org.drools.base.rule.GroupElement; -import org.drools.core.common.PropagationContext; import org.drools.core.rule.consequence.InternalMatch; +import java.util.Map; +import java.util.Objects; + /** * Leaf Rete-OO node responsible for enacting Action s on a * matched Rule. @@ -64,7 +64,6 @@ public RuleTerminalNode(final int id, final BuildContext context) { super( id, context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), source, context, rule, subrule, subruleIndex); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java b/drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java index e4645393673..df48deb9ba8 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java @@ -83,7 +83,6 @@ public WindowNode(final int id, final BuildContext context) { super(id, context.getPartitionId(), - context.getRuleBase().getRuleBaseConfiguration().isMultithreadEvaluation(), objectSource, context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeHashingThreshold(), context.getRuleBase().getRuleBaseConfiguration().getAlphaNodeRangeIndexThreshold()); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/builder/NodeFactory.java b/drools-core/src/main/java/org/drools/core/reteoo/builder/NodeFactory.java index 2c4d70d2985..c7d72584558 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/builder/NodeFactory.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/builder/NodeFactory.java @@ -18,11 +18,22 @@ package org.drools.core.reteoo.builder; -import java.util.List; - -import org.drools.core.common.BetaConstraints; +import org.drools.base.base.ObjectType; import org.drools.base.common.RuleBasePartitionId; import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.rule.Accumulate; +import org.drools.base.rule.AsyncReceive; +import org.drools.base.rule.AsyncSend; +import org.drools.base.rule.Declaration; +import org.drools.base.rule.EntryPointId; +import org.drools.base.rule.EvalCondition; +import org.drools.base.rule.From; +import org.drools.base.rule.GroupElement; +import org.drools.base.rule.QueryElement; +import org.drools.base.rule.accessor.DataProvider; +import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; +import org.drools.base.time.impl.Timer; +import org.drools.core.common.BetaConstraints; import org.drools.core.reteoo.AccumulateNode; import org.drools.core.reteoo.AlphaNode; import org.drools.core.reteoo.AsyncReceiveNode; @@ -45,20 +56,9 @@ import org.drools.core.reteoo.TerminalNode; import org.drools.core.reteoo.TimerNode; import org.drools.core.reteoo.WindowNode; -import org.drools.base.rule.Accumulate; -import org.drools.base.rule.AsyncReceive; -import org.drools.base.rule.AsyncSend; import org.drools.core.rule.BehaviorRuntime; -import org.drools.base.rule.Declaration; -import org.drools.base.rule.EntryPointId; -import org.drools.base.rule.EvalCondition; -import org.drools.base.rule.From; -import org.drools.base.rule.GroupElement; -import org.drools.base.rule.QueryElement; -import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; -import org.drools.base.rule.accessor.DataProvider; -import org.drools.base.base.ObjectType; -import org.drools.base.time.impl.Timer; + +import java.util.List; public interface NodeFactory { @@ -68,7 +68,6 @@ EntryPointNode buildEntryPointNode( int id, EntryPointNode buildEntryPointNode( int id, RuleBasePartitionId partitionId, - boolean partitionsEnabled, ObjectSource objectSource, EntryPointId entryPoint); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/builder/PhreakNodeFactory.java b/drools-core/src/main/java/org/drools/core/reteoo/builder/PhreakNodeFactory.java index 8a93aaf3f1d..6d20d0da2d8 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/builder/PhreakNodeFactory.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/builder/PhreakNodeFactory.java @@ -17,12 +17,22 @@ package org.drools.core.reteoo.builder; -import java.io.Serializable; -import java.util.List; - -import org.drools.core.common.BetaConstraints; +import org.drools.base.base.ObjectType; import org.drools.base.common.RuleBasePartitionId; import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.rule.Accumulate; +import org.drools.base.rule.AsyncReceive; +import org.drools.base.rule.AsyncSend; +import org.drools.base.rule.Declaration; +import org.drools.base.rule.EntryPointId; +import org.drools.base.rule.EvalCondition; +import org.drools.base.rule.From; +import org.drools.base.rule.GroupElement; +import org.drools.base.rule.QueryElement; +import org.drools.base.rule.accessor.DataProvider; +import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; +import org.drools.base.time.impl.Timer; +import org.drools.core.common.BetaConstraints; import org.drools.core.reteoo.AccumulateNode; import org.drools.core.reteoo.AlphaNode; import org.drools.core.reteoo.AlphaTerminalNode; @@ -48,20 +58,10 @@ import org.drools.core.reteoo.TerminalNode; import org.drools.core.reteoo.TimerNode; import org.drools.core.reteoo.WindowNode; -import org.drools.base.rule.Accumulate; -import org.drools.base.rule.AsyncReceive; -import org.drools.base.rule.AsyncSend; import org.drools.core.rule.BehaviorRuntime; -import org.drools.base.rule.Declaration; -import org.drools.base.rule.EntryPointId; -import org.drools.base.rule.EvalCondition; -import org.drools.base.rule.From; -import org.drools.base.rule.GroupElement; -import org.drools.base.rule.QueryElement; -import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; -import org.drools.base.rule.accessor.DataProvider; -import org.drools.base.base.ObjectType; -import org.drools.base.time.impl.Timer; + +import java.io.Serializable; +import java.util.List; public class PhreakNodeFactory implements NodeFactory, Serializable { @@ -75,8 +75,8 @@ public EntryPointNode buildEntryPointNode(int id, ObjectSource objectSource, Bui return new EntryPointNode(id, objectSource, context); } - public EntryPointNode buildEntryPointNode(int id, RuleBasePartitionId partitionId, boolean partitionsEnabled, ObjectSource objectSource, EntryPointId entryPoint) { - return new EntryPointNode(id, partitionId, partitionsEnabled, objectSource, entryPoint); + public EntryPointNode buildEntryPointNode(int id, RuleBasePartitionId partitionId, ObjectSource objectSource, EntryPointId entryPoint) { + return new EntryPointNode(id, partitionId, objectSource, entryPoint); } diff --git a/drools-core/src/test/java/org/drools/core/reteoo/BaseNodeTest.java b/drools-core/src/test/java/org/drools/core/reteoo/BaseNodeTest.java index 187c64406ff..c1db5b53164 100644 --- a/drools-core/src/test/java/org/drools/core/reteoo/BaseNodeTest.java +++ b/drools-core/src/test/java/org/drools/core/reteoo/BaseNodeTest.java @@ -44,7 +44,7 @@ public MockBaseNode() { } public MockBaseNode(final int id) { - super( id, RuleBasePartitionId.MAIN_PARTITION, false ); + super( id, RuleBasePartitionId.MAIN_PARTITION ); } public void ruleAttached() { diff --git a/drools-core/src/test/java/org/drools/core/reteoo/MockObjectSource.java b/drools-core/src/test/java/org/drools/core/reteoo/MockObjectSource.java index d021d96e5f6..19956cc6f0c 100644 --- a/drools-core/src/test/java/org/drools/core/reteoo/MockObjectSource.java +++ b/drools-core/src/test/java/org/drools/core/reteoo/MockObjectSource.java @@ -16,18 +16,18 @@ package org.drools.core.reteoo; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - +import org.drools.base.base.ObjectType; +import org.drools.base.common.RuleBasePartitionId; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; -import org.drools.base.common.RuleBasePartitionId; -import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.base.ObjectType; import org.drools.core.common.PropagationContext; +import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.util.bitmask.BitMask; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + public class MockObjectSource extends ObjectSource { private static final long serialVersionUID = 510l; @@ -41,7 +41,7 @@ public MockObjectSource(int i, BuildContext context) { } public MockObjectSource(final int id) { - super( id, RuleBasePartitionId.MAIN_PARTITION, false); + super( id, RuleBasePartitionId.MAIN_PARTITION ); this.facts = new ArrayList(); } diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/CompositeDefaultAgenda.java b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/CompositeDefaultAgenda.java index b62242baa4b..7577c3e014a 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/CompositeDefaultAgenda.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/CompositeDefaultAgenda.java @@ -17,7 +17,6 @@ package org.drools.kiesession.agenda; import org.drools.base.common.NetworkNode; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.common.ActivationsFilter; import org.drools.core.common.AgendaGroupsManager; import org.drools.core.common.InternalActivationGroup; @@ -66,19 +65,16 @@ public class CompositeDefaultAgenda implements Externalizable, InternalAgenda { private static final AtomicBoolean FIRING_UNTIL_HALT_USING_EXECUTOR = new AtomicBoolean( false ); - private final DefaultAgenda[] agendas = new DefaultAgenda[RuleBasePartitionId.PARALLEL_PARTITIONS_NUMBER]; - private final DefaultAgenda.ExecutionStateMachine executionStateMachine = new DefaultAgenda.ConcurrentExecutionStateMachine(); + private DefaultAgenda[] agendas; + private PropagationList propagationList; public CompositeDefaultAgenda() { } - public CompositeDefaultAgenda(InternalRuleBase kBase) { - this( kBase, true ); - } - public CompositeDefaultAgenda(InternalRuleBase kBase, boolean initMain) { + this.agendas = new DefaultAgenda[kBase.getParallelEvaluationSlotsCount()]; for ( int i = 0; i < agendas.length; i++ ) { agendas[i] = new PartitionedDefaultAgenda(kBase, initMain, executionStateMachine, i); } @@ -86,16 +82,12 @@ public CompositeDefaultAgenda(InternalRuleBase kBase, boolean initMain) { @Override public void writeExternal( ObjectOutput out ) throws IOException { - for ( DefaultAgenda agenda : agendas ) { - out.writeObject( agenda ); - } + out.writeObject( agendas ); } @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { - for ( int i = 0; i < agendas.length; i++ ) { - agendas[i] = (DefaultAgenda) in.readObject(); - } + agendas = (DefaultAgenda[]) in.readObject(); } @Override diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java index df8599620f4..266b2d74784 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgenda.java @@ -16,17 +16,9 @@ package org.drools.kiesession.agenda; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - +import org.drools.base.definitions.rule.impl.QueryImpl; +import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.rule.consequence.ConsequenceException; import org.drools.core.common.ActivationGroupImpl; import org.drools.core.common.ActivationGroupNode; import org.drools.core.common.ActivationsFilter; @@ -44,8 +36,6 @@ import org.drools.core.common.RuleFlowGroup; import org.drools.core.concurrent.RuleEvaluator; import org.drools.core.concurrent.SequentialRuleEvaluator; -import org.drools.base.definitions.rule.impl.QueryImpl; -import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.event.AgendaEventSupport; import org.drools.core.impl.InternalRuleBase; import org.drools.core.phreak.ExecutableEntry; @@ -62,7 +52,6 @@ import org.drools.core.reteoo.RuleTerminalNodeLeftTuple; import org.drools.core.reteoo.TerminalNode; import org.drools.core.reteoo.Tuple; -import org.drools.base.rule.consequence.ConsequenceException; import org.drools.core.rule.consequence.ConsequenceExceptionHandler; import org.drools.core.rule.consequence.InternalMatch; import org.drools.core.rule.consequence.KnowledgeHelper; @@ -76,6 +65,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + /** * Rule-firing Agenda. * @@ -133,7 +133,7 @@ public class DefaultAgenda implements Externalizable, InternalAgenda { // ------------------------------------------------------------ public DefaultAgenda() { } - public DefaultAgenda(InternalRuleBase kBase) { + protected DefaultAgenda(InternalRuleBase kBase) { this( kBase, true ); } diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgendaFactory.java b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgendaFactory.java index 341c9442218..718b8ec5f21 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgendaFactory.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/agenda/DefaultAgendaFactory.java @@ -17,12 +17,12 @@ package org.drools.kiesession.agenda; -import java.io.Serializable; - import org.drools.core.common.AgendaFactory; import org.drools.core.common.InternalAgenda; import org.drools.core.impl.InternalRuleBase; +import java.io.Serializable; + public class DefaultAgendaFactory implements AgendaFactory, Serializable { private static final AgendaFactory INSTANCE = new DefaultAgendaFactory(); @@ -34,15 +34,8 @@ public static AgendaFactory getInstance() { private DefaultAgendaFactory() { } public InternalAgenda createAgenda(InternalRuleBase kBase, boolean initMain) { - return kBase.getRuleBaseConfiguration().isMultithreadEvaluation() ? + return kBase.hasParallelEvaluation() ? new CompositeDefaultAgenda( kBase, initMain ) : new DefaultAgenda( kBase, initMain ); } - - public InternalAgenda createAgenda(InternalRuleBase kBase) { - return kBase.getRuleBaseConfiguration().isMultithreadEvaluation() ? - new CompositeDefaultAgenda( kBase ) : - new DefaultAgenda( kBase ); - } - } diff --git a/drools-kiesession/src/main/java/org/drools/kiesession/rulebase/SessionsAwareKnowledgeBase.java b/drools-kiesession/src/main/java/org/drools/kiesession/rulebase/SessionsAwareKnowledgeBase.java index 220c7a49e57..d64f0987c50 100644 --- a/drools-kiesession/src/main/java/org/drools/kiesession/rulebase/SessionsAwareKnowledgeBase.java +++ b/drools-kiesession/src/main/java/org/drools/kiesession/rulebase/SessionsAwareKnowledgeBase.java @@ -16,31 +16,18 @@ package org.drools.kiesession.rulebase; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - +import org.drools.base.common.RuleBasePartitionId; +import org.drools.base.definitions.InternalKnowledgePackage; +import org.drools.base.definitions.rule.impl.RuleImpl; +import org.drools.base.rule.InvalidPatternException; +import org.drools.base.rule.TypeDeclaration; +import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.drools.core.KieBaseConfigurationImpl; import org.drools.core.RuleBaseConfiguration; import org.drools.core.SessionConfiguration; import org.drools.core.base.ClassFieldAccessorCache; import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.ReteEvaluator; -import org.drools.base.common.RuleBasePartitionId; -import org.drools.base.definitions.InternalKnowledgePackage; -import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.impl.EnvironmentFactory; import org.drools.core.impl.InternalKieContainer; import org.drools.core.impl.InternalRuleBase; @@ -57,10 +44,7 @@ import org.drools.core.reteoo.RuntimeComponentFactory; import org.drools.core.reteoo.SegmentMemory; import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; -import org.drools.base.rule.InvalidPatternException; -import org.drools.base.rule.TypeDeclaration; import org.drools.core.rule.accessor.FactHandleFactory; -import org.drools.base.ruleunit.RuleUnitDescriptionRegistry; import org.kie.api.KieBaseConfiguration; import org.kie.api.builder.ReleaseId; import org.kie.api.definition.KiePackage; @@ -76,6 +60,22 @@ import org.kie.api.runtime.KieSessionsPool; import org.kie.api.runtime.StatelessKieSession; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + public class SessionsAwareKnowledgeBase implements InternalKnowledgeBase { private final KnowledgeBaseImpl delegate; @@ -761,6 +761,16 @@ public RuleBasePartitionId createNewPartitionId() { return delegate.createNewPartitionId(); } + @Override + public boolean hasParallelEvaluation() { + return delegate.hasParallelEvaluation(); + } + + @Override + public int getParallelEvaluationSlotsCount() { + return delegate.getParallelEvaluationSlotsCount(); + } + @Override public FactType getFactType(String packageName, String typeName) { return delegate.getFactType(packageName, typeName); diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java index 189345d1f8a..77a01a6036a 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/ReteooWorkingMemoryTest.java @@ -167,7 +167,6 @@ public void testDifferentEntryPointsOnSameFact() { NodeFactory nFacotry = new PhreakNodeFactory(); EntryPointNode epn = nFacotry.buildEntryPointNode( kBase.getReteooBuilder().getNodeIdsGenerator().getNextId(), RuleBasePartitionId.MAIN_PARTITION, - kBase.getRuleBaseConfiguration().isMultithreadEvaluation(), rete, new EntryPointId( "xxx" ) ); diff --git a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableAgendaFactory.java b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableAgendaFactory.java index f332b59571e..57b4124ffc5 100644 --- a/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableAgendaFactory.java +++ b/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableAgendaFactory.java @@ -36,8 +36,4 @@ private ReliableAgendaFactory() { } public InternalAgenda createAgenda(InternalRuleBase kBase, boolean initMain) { return new ReliableAgenda( kBase, initMain ); } - - public InternalAgenda createAgenda(InternalRuleBase kBase) { - return new ReliableAgenda( kBase ); - } } diff --git a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java index 53ecec9e9f1..c974823d85e 100644 --- a/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java +++ b/drools-serialization-protobuf/src/test/java/org/drools/serialization/protobuf/FactHandleMarshallingTest.java @@ -14,21 +14,14 @@ package org.drools.serialization.protobuf; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.Date; - +import org.drools.base.common.RuleBasePartitionId; +import org.drools.base.rule.EntryPointId; import org.drools.core.SessionConfiguration; import org.drools.core.WorkingMemoryEntryPoint; -import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.DefaultEventHandle; +import org.drools.core.common.DefaultFactHandle; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.QueryElementFactHandle; -import org.drools.base.common.RuleBasePartitionId; import org.drools.core.impl.EnvironmentFactory; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.marshalling.MarshallerReaderContext; @@ -37,7 +30,6 @@ import org.drools.core.reteoo.ObjectTypeConf; import org.drools.core.reteoo.Rete; import org.drools.core.reteoo.builder.NodeFactory; -import org.drools.base.rule.EntryPointId; import org.drools.kiesession.entrypoints.NamedEntryPoint; import org.drools.kiesession.rulebase.InternalKnowledgeBase; import org.drools.kiesession.rulebase.KnowledgeBaseFactory; @@ -55,6 +47,14 @@ import org.kie.api.runtime.rule.RuleRuntime; import org.kie.internal.marshalling.MarshallerFactory; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.Date; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -73,7 +73,7 @@ private InternalFactHandle createEventFactHandle(StatefulKnowledgeSessionImpl wm NodeFactory nFacotry = CoreComponentFactory.get().getNodeFactoryService(); RuleBasePartitionId partionId = RuleBasePartitionId.MAIN_PARTITION; - EntryPointNode entryPointNode = nFacotry.buildEntryPointNode(1, partionId, false, rete , EntryPointId.DEFAULT); + EntryPointNode entryPointNode = nFacotry.buildEntryPointNode(1, partionId, rete , EntryPointId.DEFAULT); WorkingMemoryEntryPoint wmEntryPoint = new NamedEntryPoint( EntryPointId.DEFAULT, entryPointNode, wm); DefaultEventHandle factHandle = new DefaultEventHandle(1, new Person(), 0, (new Date()).getTime(), 0, wmEntryPoint); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/model/MockObjectSource.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/model/MockObjectSource.java index fa3fcf2cdfe..e70e38474de 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/model/MockObjectSource.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/model/MockObjectSource.java @@ -16,20 +16,20 @@ package org.drools.mvel.model; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - +import org.drools.base.base.ObjectType; +import org.drools.base.common.RuleBasePartitionId; import org.drools.core.common.InternalFactHandle; import org.drools.core.common.InternalWorkingMemory; -import org.drools.base.common.RuleBasePartitionId; +import org.drools.core.common.PropagationContext; import org.drools.core.reteoo.ObjectSink; import org.drools.core.reteoo.ObjectSource; import org.drools.core.reteoo.builder.BuildContext; -import org.drools.base.base.ObjectType; -import org.drools.core.common.PropagationContext; import org.drools.core.util.bitmask.BitMask; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + public class MockObjectSource extends ObjectSource { private static final long serialVersionUID = 510l; @@ -43,7 +43,7 @@ public MockObjectSource() { } public MockObjectSource( final int id) { - super( id, RuleBasePartitionId.MAIN_PARTITION, false); + super( id, RuleBasePartitionId.MAIN_PARTITION ); this.facts = new ArrayList(); }