Search in sources :

Example 1 with CompositePartitionAwareObjectSinkAdapter

use of org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter 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(), config.getAlphaNodeRangeIndexThreshold()));
            }
        }
    }
}
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 2 with CompositePartitionAwareObjectSinkAdapter

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

the class ObjectTypeNodeParser method traversePropagator.

private void traversePropagator(ObjectSinkPropagator propagator, NetworkHandler handler) {
    if (propagator instanceof SingleObjectSinkAdapter) {
        // we know there is only a single child sink for this propagator
        ObjectSink sink = propagator.getSinks()[0];
        traverseSink(sink, handler);
    } else if (propagator instanceof CompositeObjectSinkAdapter) {
        CompositeObjectSinkAdapter composite = (CompositeObjectSinkAdapter) propagator;
        if (traverseHashedAlphaNodes) {
            traverseSinkList(composite.getRangeIndexableSinks(), handler);
            traverseSinkList(composite.getHashableSinks(), handler);
            traverseSinkList(composite.getOthers(), handler);
            traverseRangeIndexedAlphaNodes(composite.getRangeIndexMap(), handler);
            traverseHashedAlphaNodes(composite.getHashedSinkMap(), handler);
        } else {
            traverseSinkList(composite.getSinks(), handler);
        }
    } else if (propagator instanceof CompositePartitionAwareObjectSinkAdapter) {
        CompositePartitionAwareObjectSinkAdapter composite = (CompositePartitionAwareObjectSinkAdapter) propagator;
        traverseSinkList(composite.getSinks(), handler);
    }
}
Also used : CompositePartitionAwareObjectSinkAdapter(org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter) ObjectSink(org.drools.core.reteoo.ObjectSink) CompositeObjectSinkAdapter(org.drools.core.reteoo.CompositeObjectSinkAdapter) SingleObjectSinkAdapter(org.drools.core.reteoo.SingleObjectSinkAdapter)

Example 3 with CompositePartitionAwareObjectSinkAdapter

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

the class NodesPartitioningTest method checkPartitionedSinks.

private void checkPartitionedSinks(ObjectTypeNode otn) {
    if (InitialFact.class.isAssignableFrom(((ClassObjectType) otn.getObjectType()).getClassType())) {
        return;
    }
    ObjectSinkPropagator sinkPropagator = otn.getObjectSinkPropagator();
    ObjectSinkPropagator[] propagators = sinkPropagator instanceof CompositePartitionAwareObjectSinkAdapter ? ((CompositePartitionAwareObjectSinkAdapter) sinkPropagator).getPartitionedPropagators() : new ObjectSinkPropagator[] { sinkPropagator };
    for (int i = 0; i < propagators.length; i++) {
        for (ObjectSink sink : propagators[i].getSinks()) {
            assertEquals(sink + " on " + sink.getPartitionId() + " is expcted to be on propagator " + i, i, sink.getPartitionId().getId() % propagators.length);
        }
    }
}
Also used : CompositePartitionAwareObjectSinkAdapter(org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter) ObjectSinkPropagator(org.drools.core.reteoo.ObjectSinkPropagator) ObjectSink(org.drools.core.reteoo.ObjectSink)

Example 4 with CompositePartitionAwareObjectSinkAdapter

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

the class NodesPartitioningTest method checkPartitionedSinks.

private void checkPartitionedSinks(ObjectTypeNode otn) {
    if (InitialFact.class.isAssignableFrom(((ClassObjectType) otn.getObjectType()).getClassType())) {
        return;
    }
    ObjectSinkPropagator sinkPropagator = otn.getObjectSinkPropagator();
    ObjectSinkPropagator[] propagators = sinkPropagator instanceof CompositePartitionAwareObjectSinkAdapter ? ((CompositePartitionAwareObjectSinkAdapter) sinkPropagator).getPartitionedPropagators() : new ObjectSinkPropagator[] { sinkPropagator };
    for (int i = 0; i < propagators.length; i++) {
        for (ObjectSink sink : propagators[i].getSinks()) {
            assertEquals(sink + " on " + sink.getPartitionId() + " is expcted to be on propagator " + i, i, sink.getPartitionId().getId() % propagators.length);
        }
    }
}
Also used : CompositePartitionAwareObjectSinkAdapter(org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter) ObjectSinkPropagator(org.drools.core.reteoo.ObjectSinkPropagator) ObjectSink(org.drools.core.reteoo.ObjectSink)

Aggregations

CompositePartitionAwareObjectSinkAdapter (org.drools.core.reteoo.CompositePartitionAwareObjectSinkAdapter)4 ObjectSink (org.drools.core.reteoo.ObjectSink)3 ObjectSinkPropagator (org.drools.core.reteoo.ObjectSinkPropagator)3 CompositeObjectSinkAdapter (org.drools.core.reteoo.CompositeObjectSinkAdapter)1 EntryPointNode (org.drools.core.reteoo.EntryPointNode)1 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)1 SingleObjectSinkAdapter (org.drools.core.reteoo.SingleObjectSinkAdapter)1