Search in sources :

Example 1 with EntryPointNode

use of org.drools.core.reteoo.EntryPointNode in project drools by kiegroup.

the class SegmentUtilities method getQueryOtn.

private static ObjectTypeNode getQueryOtn(LeftTupleSource lts) {
    while (!(lts instanceof LeftInputAdapterNode)) {
        lts = lts.getLeftTupleSource();
    }
    LeftInputAdapterNode liaNode = (LeftInputAdapterNode) lts;
    ObjectSource os = liaNode.getObjectSource();
    while (!(os instanceof EntryPointNode)) {
        os = os.getParentObjectSource();
    }
    return ((EntryPointNode) os).getQueryNode();
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) ObjectSource(org.drools.core.reteoo.ObjectSource) LeftInputAdapterNode(org.drools.core.reteoo.LeftInputAdapterNode)

Example 2 with EntryPointNode

use of org.drools.core.reteoo.EntryPointNode in project drools by kiegroup.

the class KnowledgeBaseMonitoring method startInternalMBeans.

public void startInternalMBeans() {
    for (EntryPointNode epn : kbase.getRete().getEntryPointNodes().values()) {
        for (ObjectTypeNode otn : epn.getObjectTypeNodes().values()) {
            ObjectTypeNodeMonitor otnm = new ObjectTypeNodeMonitor(otn);
            try {
                final StandardMBean adapter = new StandardMBean(otnm, ObjectTypeNodeMonitorMBean.class);
                ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=EntryPoints,EntryPoint=" + otnm.getNameSufix() + ",ObjectType=" + ((ClassObjectType) otn.getObjectType()).getClassName());
                DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
            } catch (NotCompliantMBeanException e) {
                logger.error("Unable to register ObjectTypeNodeMonitor mbean for OTN " + otn.getObjectType() + " into the platform MBean Server", e);
            }
        }
    }
    final KieBaseConfigurationMonitor kbcm = new KieBaseConfigurationMonitor(kbase.getConfiguration());
    try {
        final StandardMBean adapter = new StandardMBean(kbcm, KieBaseConfigurationMonitorMBean.class);
        ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=Configuration");
        DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
    } catch (NotCompliantMBeanException e) {
        logger.error("Unable to register KBaseConfigurationMonitor mbean into the platform MBean Server", e);
    }
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) ClassObjectType(org.drools.core.base.ClassObjectType) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) ObjectName(javax.management.ObjectName)

Example 3 with EntryPointNode

use of org.drools.core.reteoo.EntryPointNode in project drools by kiegroup.

the class KnowledgeBaseImpl method disableMultithreadEvaluation.

private void disableMultithreadEvaluation(String warningMessage) {
    config.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) {
                otn.setObjectSinkPropagator(((CompositePartitionAwareObjectSinkAdapter) sink).asNonPartitionedSinkPropagator(config.getAlphaNodeHashingThreshold()));
            }
        }
    }
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) CompositePartitionAwareObjectSinkAdapter(org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter) ObjectSinkPropagator(org.drools.core.reteoo.ObjectSinkPropagator) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode)

Example 4 with EntryPointNode

use of org.drools.core.reteoo.EntryPointNode in project drools by kiegroup.

the class KnowledgeBaseImpl method setupRete.

protected void setupRete() {
    this.rete = new Rete(this);
    this.reteooBuilder = new ReteooBuilder(this);
    NodeFactory nodeFactory = kieComponentFactory.getNodeFactoryService();
    // always add the default entry point
    EntryPointNode epn = nodeFactory.buildEntryPointNode(this.reteooBuilder.getIdGenerator().getNextId(), RuleBasePartitionId.MAIN_PARTITION, this.getConfiguration().isMultithreadEvaluation(), this.rete, EntryPointId.DEFAULT);
    epn.attach();
    BuildContext context = new BuildContext(this);
    context.setCurrentEntryPoint(epn.getEntryPoint());
    context.setTupleMemoryEnabled(true);
    context.setObjectTypeNodeMemoryEnabled(true);
    context.setPartitionId(RuleBasePartitionId.MAIN_PARTITION);
    ObjectTypeNode otn = nodeFactory.buildObjectTypeNode(this.reteooBuilder.getIdGenerator().getNextId(), epn, ClassObjectType.InitialFact_ObjectType, context);
    otn.attach(context);
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) Rete(org.drools.core.reteoo.Rete) ReteooBuilder(org.drools.core.reteoo.ReteooBuilder) NodeFactory(org.drools.core.reteoo.builder.NodeFactory) BuildContext(org.drools.core.reteoo.builder.BuildContext) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode)

Example 5 with EntryPointNode

use of org.drools.core.reteoo.EntryPointNode in project drools by kiegroup.

the class IncrementalCompilationTest method testRemoveRuleWithRia.

@Test
public void testRemoveRuleWithRia() throws Exception {
    // DROOLS-954
    String drl1 = "import " + List.class.getCanonicalName() + "\n" + "rule R when\n" + "    $list : List()\n" + "    exists Integer( this == 1 ) from $list\n" + "    exists Integer( this == 2 ) from $list\n" + "then \n" + "end\n";
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.1");
    KieModule km = createAndDeployJar(ks, releaseId1, drl1);
    KieContainer kc = ks.newKieContainer(km.getReleaseId());
    KieSession ksession = kc.newKieSession();
    ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.2");
    km = createAndDeployJar(ks, releaseId2);
    kc.updateToVersion(releaseId2);
    Rete rete = ((InternalKnowledgeBase) (InternalKnowledgeBase) ksession.getKieBase()).getRete();
    EntryPointNode entryPointNode = rete.getEntryPointNodes().values().iterator().next();
    for (ObjectTypeNode otns : entryPointNode.getObjectTypeNodes().values()) {
        assertEquals(0, otns.getObjectSinkPropagator().getSinks().length);
    }
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) Rete(org.drools.core.reteoo.Rete) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) KieServices(org.kie.api.KieServices) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) KieModule(org.kie.api.builder.KieModule) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Aggregations

EntryPointNode (org.drools.core.reteoo.EntryPointNode)23 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)16 ClassObjectType (org.drools.core.base.ClassObjectType)8 Test (org.junit.Test)8 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)7 KieSession (org.kie.api.runtime.KieSession)6 KieHelper (org.kie.internal.utils.KieHelper)6 LeftInputAdapterNode (org.drools.core.reteoo.LeftInputAdapterNode)5 ObjectSource (org.drools.core.reteoo.ObjectSource)5 KieBase (org.kie.api.KieBase)5 Rete (org.drools.core.reteoo.Rete)4 ArrayList (java.util.ArrayList)3 LeftTupleSink (org.drools.core.reteoo.LeftTupleSink)3 LeftTupleSource (org.drools.core.reteoo.LeftTupleSource)3 NodeFactory (org.drools.core.reteoo.builder.NodeFactory)3 WorkingMemoryEntryPoint (org.drools.core.WorkingMemoryEntryPoint)2 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)2 InternalWorkingMemoryEntryPoint (org.drools.core.common.InternalWorkingMemoryEntryPoint)2 NamedEntryPoint (org.drools.core.common.NamedEntryPoint)2 RuleBasePartitionId (org.drools.core.common.RuleBasePartitionId)2