public Rete(InternalRuleBase ruleBase) { super( 0, RuleBasePartitionId.MAIN_PARTITION, ruleBase != null ? ruleBase.getConfiguration().isMultithreadEvaluation() : false ); this.entryPoints = Collections.synchronizedMap( new HashMap<EntryPoint, EntryPointNode>() ); this.ruleBase = ruleBase; }
public List getRuleBaseUpdateListeners() { if ( this.ruleBaseListeners == null || this.ruleBaseListeners == Collections.EMPTY_LIST ) { String listenerName = this.ruleBase.getConfiguration().getRuleBaseUpdateHandler(); if ( listenerName != null && listenerName.length() > 0 ) { RuleBaseUpdateListener listener = RuleBaseUpdateListenerFactory.createListener( listenerName, this ); this.ruleBaseListeners = Collections.singletonList( listener ); } else { this.ruleBaseListeners = Collections.EMPTY_LIST; } } return this.ruleBaseListeners; }
public BinaryHeapQueueAgendaGroup(final String name, final InternalRuleBase ruleBase) { this.name = name; this.queue = new BinaryHeapQueue( ruleBase.getConfiguration().getConflictResolver() ); }
/** * Construct a <code>Builder</code> against an existing <code>Rete</code> * network. */ ReteooBuilder( final InternalRuleBase ruleBase ) { this.ruleBase = ruleBase; this.rules = new HashMap<Rule, BaseNode[]>(); this.namedWindows = new HashMap<String, WindowNode>(); //Set to 1 as Rete node is set to 0 this.idGenerator = new IdGenerator( 1 ); this.ruleBuilder = ruleBase.getConfiguration().getComponentFactory().getRuleBuilderFactory().newRuleBuilder(); }
private void initManagementBeans() { if ( this.ruleBase.getConfiguration().isMBeansEnabled() ) { DroolsManagementAgent.getInstance().registerKnowledgeSession( this ); } }
public void setRuleBase( ReteooRuleBase reteooRuleBase ) { this.ruleBase = reteooRuleBase; this.ruleBuilder = ruleBase.getConfiguration().getComponentFactory().getRuleBuilderFactory().newRuleBuilder(); }
public ElseNode(final int id, final LeftTupleSource leftInput, final ObjectSource rightInput, final BetaConstraints binder, final BuildContext context) { super( id, context.getPartitionId(), context.getRuleBase().getConfiguration().isMultithreadEvaluation(), leftInput, rightInput, binder, context ); this.tupleMemoryEnabled = context.isTupleMemoryEnabled(); this.lrUnlinkingEnabled = context.getRuleBase().getConfiguration().isLRUnlinkingEnabled(); }
public EntryPointNode(final int id, final ObjectSource objectSource, final BuildContext context) { this( id, context.getPartitionId(), context.getRuleBase().getConfiguration().isMultithreadEvaluation(), objectSource, context.getCurrentEntryPoint() ); // irrelevant for this node, since it overrides sink management }
/** * Creates the actual partition managers and their tasks for multi-thread * processing */ private void initPartitionManagers() { if ( this.ruleBase.getConfiguration().isMultithreadEvaluation() ) { this.partitionManager = new PartitionManager( this ); for ( RuleBasePartitionId partitionId : this.ruleBase.getPartitionIds() ) { this.partitionManager.manage( partitionId ); } } }
public NamedEntryPoint(EntryPoint entryPoint, EntryPointNode entryPointNode, AbstractWorkingMemory wm, ReentrantLock lock) { this.entryPoint = entryPoint; this.entryPointNode = entryPointNode; this.wm = wm; this.ruleBase = (InternalRuleBase) this.wm.getRuleBase(); this.lock = lock; this.typeConfReg = new ObjectTypeConfigurationRegistry( this.ruleBase ); this.handleFactory = this.wm.getFactHandleFactory(); this.objectStore = new SingleThreadedObjectStore( this.ruleBase.getConfiguration(), this.lock ); }
public NotNode(final int id, final LeftTupleSource leftInput, final ObjectSource rightInput, final BetaConstraints joinNodeBinder, final BuildContext context) { super( id, context.getPartitionId(), context.getRuleBase().getConfiguration().isMultithreadEvaluation(), leftInput, rightInput, joinNodeBinder, context ); this.tupleMemoryEnabled = context.isTupleMemoryEnabled(); }
public ConditionalBranchNode( int id, LeftTupleSource tupleSource, ConditionalBranchEvaluator branchEvaluator, BuildContext context ) { super( id, context.getPartitionId(), context.getRuleBase().getConfiguration().isMultithreadEvaluation()); this.tupleSource = tupleSource; this.tupleMemoryEnabled = context.isTupleMemoryEnabled(); this.branchEvaluator = branchEvaluator; initMasks(context, tupleSource); }
public void init(BuildContext context, short betaNodeType) { RuleBaseConfiguration config = context.getRuleBase().getConfiguration(); if ( (disableIndex) || (!config.isIndexLeftBetaMemory() && !config.isIndexRightBetaMemory()) ) { this.indexed = false; } else { initIndexes(config.getCompositeKeyDepth(), betaNodeType); } }
public TraitObjectTypeNode( int id, EntryPointNode source, ObjectType objectType, BuildContext context ) { super( id, source, objectType, context ); typeMask = context.getRuleBase().getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy().getCode( ((ClassObjectType) objectType).getClassName() ); }
public void init(BuildContext context, short betaNodeType) { RuleBaseConfiguration config = context.getRuleBase().getConfiguration(); if ( disableIndexing || (!config.isIndexLeftBetaMemory() && !config.isIndexRightBetaMemory()) ) { indexed = 0; } else { int depth = config.getCompositeKeyDepth(); if ( !compositeAllowed( constraints, betaNodeType ) ) { // UnificationRestrictions cannot be allowed in composite indexes // We also ensure that if there is a mixture that standard restriction is first depth = 1; } initIndexes( depth, betaNodeType ); } }
public final void init(BuildContext context, short betaNodeType) { RuleBaseConfiguration config = context.getRuleBase().getConfiguration(); if ( disableIndexing || (!config.isIndexLeftBetaMemory() && !config.isIndexRightBetaMemory()) ) { indexed = new boolean[constraints.length]; } else { int depth = config.getCompositeKeyDepth(); if ( !compositeAllowed( constraints, betaNodeType ) ) { // UnificationRestrictions cannot be allowed in composite indexes // We also ensure that if there is a mixture that standard restriction is first depth = 1; } initIndexes( depth, betaNodeType ); } }
public void setWorkingMemory(final InternalWorkingMemory workingMemory) { this.workingMemory = workingMemory; RuleBaseConfiguration rbc = ((InternalRuleBase) this.workingMemory.getRuleBase()).getConfiguration(); if ( rbc.isSequential() ) { this.knowledgeHelper = rbc.getComponentFactory().getKnowledgeHelperFactory().newSequentialKnowledgeHelper( this.workingMemory ); } else { this.knowledgeHelper = rbc.getComponentFactory().getKnowledgeHelperFactory().newStatefulKnowledgeHelper( this.workingMemory ); } }
public void asyncExecute(final Object object) { InternalWorkingMemory wm = newWorkingMemory(); final AssertObject assertObject = new AssertObject( object ); ExecutorService executor = ExecutorServiceFactory.createExecutorService( this.ruleBase.getConfiguration().getExecutorService() ); executor.setCommandExecutor( new CommandExecutor( wm ) ); executor.submit( assertObject ); executor.submit( new FireAllRules( this.agendaFilter ) ); }
public void asyncExecute(final Collection collection) { InternalWorkingMemory wm = newWorkingMemory(); final AssertObjects assertObjects = new AssertObjects( collection ); ExecutorService executor = ExecutorServiceFactory.createExecutorService( this.ruleBase.getConfiguration().getExecutorService() ); executor.setCommandExecutor( new CommandExecutor( wm ) ); executor.submit( assertObjects ); executor.submit( new FireAllRules( this.agendaFilter ) ); }
public void asyncExecute(final Object[] array) { InternalWorkingMemory wm = newWorkingMemory(); final AssertObjects assertObjects = new AssertObjects( array ); ExecutorService executor = ExecutorServiceFactory.createExecutorService( this.ruleBase.getConfiguration().getExecutorService() ); executor.setCommandExecutor( new CommandExecutor( wm ) ); executor.submit( assertObjects ); executor.submit( new FireAllRules( this.agendaFilter ) ); }