[jboss-svn-commits] JBL Code SVN: r25891 - in labs/jbossrules/trunk: drools-compiler/src/test/java/org/drools/conf and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Mar 30 12:12:33 EDT 2009
Author: tirelli
Date: 2009-03-30 12:12:33 -0400 (Mon, 30 Mar 2009)
New Revision: 25891
Added:
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/EventProcessingOption.java
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java
labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes.xml
labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_CloudMode.xml
labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_StreamMode.xml
Log:
Adding docs and the EventProcessingOption configuration
Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/EventProcessingOption.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/EventProcessingOption.java (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/EventProcessingOption.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Red Hat
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.drools.conf;
+
+/**
+ * An Enum for Event Processing option.
+ *
+ * drools.eventProcessingMode = <identity|equality>
+ *
+ * When the rulebase is compiled in the CLOUD (default) event processing mode,
+ * it behaves just like a regular rulebase.
+ *
+ * When the rulebase is compiled in the STREAM event processing mode, additional
+ * assumptions are made. These assumptions allow the engine to perform a few optimisations
+ * like:
+ *
+ * <li> reasoning over absence of events (NOT CE), automatically adds an appropriate duration attribute
+ * to the rule in order to avoid early rule firing. </li>
+ * <li> memory management techniques may be employed when an event no longer can match other events
+ * due to session clock continuous increment. </li>
+ *
+ * @author etirelli
+ *
+ */
+public enum EventProcessingOption
+ implements SingleValueKnowledgeBaseOption {
+
+ CLOUD("cloud"),
+ STREAM("stream");
+
+ /**
+ * The property name for the sequential mode option
+ */
+ public static final String PROPERTY_NAME = "drools.eventProcessingMode";
+
+ private String string;
+
+ EventProcessingOption(String mode) {
+ this.string = mode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPropertyName() {
+ return PROPERTY_NAME;
+ }
+
+ public String getMode() {
+ return string;
+ }
+
+ public String toString() {
+ return "EventProcessingOption( "+string+ " )";
+ }
+
+ public String toExternalForm() {
+ return this.string;
+ }
+
+ public static EventProcessingOption determineEventProcessingMode(String mode) {
+ if ( STREAM.getMode().equalsIgnoreCase( mode ) ) {
+ return STREAM;
+ } else if ( CLOUD.getMode().equalsIgnoreCase( mode ) ) {
+ return CLOUD;
+ }
+ throw new IllegalArgumentException( "Illegal enum value '" + mode + "' for EventProcessingMode" );
+ }
+}
Property changes on: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/EventProcessingOption.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -339,7 +339,30 @@
config.getProperty( ConsequenceExceptionHandlerOption.PROPERTY_NAME ) );
}
+ public void testEventProcessingConfiguration() {
+ // setting the option using the type safe method
+ config.setOption( EventProcessingOption.STREAM );
+
+ // checking the type safe getOption() method
+ assertEquals( EventProcessingOption.STREAM,
+ config.getOption( EventProcessingOption.class ) );
+ // checking the string based getProperty() method
+ assertEquals( "stream",
+ config.getProperty( EventProcessingOption.PROPERTY_NAME ) );
+
+ // setting the options using the string based setProperty() method
+ config.setProperty( EventProcessingOption.PROPERTY_NAME,
+ "cloud" );
+
+ // checking the type safe getOption() method
+ assertEquals( EventProcessingOption.CLOUD,
+ config.getOption( EventProcessingOption.class ) );
+ // checking the string based getProperty() method
+ assertEquals( "cloud",
+ config.getProperty( EventProcessingOption.PROPERTY_NAME ) );
+ }
+
}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -20,7 +20,6 @@
import org.drools.SessionConfiguration;
import org.drools.StatefulSession;
import org.drools.StockTick;
-import org.drools.RuleBaseConfiguration.EventProcessingMode;
import org.drools.base.evaluators.TimeIntervalParser;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
@@ -31,6 +30,7 @@
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
+import org.drools.conf.EventProcessingOption;
import org.drools.io.ResourceFactory;
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.Package;
@@ -38,7 +38,6 @@
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.conf.ClockTypeOption;
-import org.drools.time.SessionClock;
import org.drools.time.SessionPseudoClock;
import org.drools.time.impl.PseudoClockScheduler;
@@ -314,7 +313,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_TimeRelationalOperators.drl" ) );
final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
- rbconf.setEventProcessingMode( EventProcessingMode.STREAM );
+ rbconf.setEventProcessingMode( EventProcessingOption.STREAM );
final RuleBase ruleBase = loadRuleBase( reader,
rbconf );
@@ -676,7 +675,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_SimpleTimeWindow.drl" ) );
final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
- rbconf.setEventProcessingMode( EventProcessingMode.STREAM );
+ rbconf.setEventProcessingMode( EventProcessingOption.STREAM );
final RuleBase ruleBase = loadRuleBase( reader,
rbconf );
@@ -809,7 +808,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_SimpleLengthWindow.drl" ) );
final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
- rbconf.setEventProcessingMode( EventProcessingMode.STREAM );
+ rbconf.setEventProcessingMode( EventProcessingOption.STREAM );
final RuleBase ruleBase = loadRuleBase( reader,
rbconf );
@@ -894,7 +893,7 @@
// read in the source
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_DelayingNot.drl" ) );
final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
- rbconf.setEventProcessingMode( EventProcessingMode.STREAM );
+ rbconf.setEventProcessingMode( EventProcessingOption.STREAM );
final RuleBase ruleBase = loadRuleBase( reader,
rbconf );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -37,6 +37,7 @@
import org.drools.conf.AssertBehaviorOption;
import org.drools.conf.CompositeKeyDepthOption;
import org.drools.conf.ConsequenceExceptionHandlerOption;
+import org.drools.conf.EventProcessingOption;
import org.drools.conf.IndexLeftBetaMemoryOption;
import org.drools.conf.IndexRightBetaMemoryOption;
import org.drools.conf.KnowledgeBaseOption;
@@ -134,7 +135,7 @@
private String consequenceExceptionHandler;
private String ruleBaseUpdateHandler;
- private EventProcessingMode eventProcessingMode;
+ private EventProcessingOption eventProcessingMode;
// if "true", rulebase builder will try to split
// the rulebase into multiple partitions that can be evaluated
@@ -203,7 +204,7 @@
advancedProcessRuleIntegration = in.readBoolean();
multithread = in.readBoolean();
maxThreads = in.readInt();
- eventProcessingMode = (EventProcessingMode) in.readObject();
+ eventProcessingMode = (EventProcessingOption) in.readObject();
}
/**
@@ -291,8 +292,8 @@
setMultithreadEvaluation( StringUtils.isEmpty( value ) ? false : Boolean.valueOf( value ) );
} else if ( name.equals( "drools.maxThreads" ) ) {
setMaxThreads( StringUtils.isEmpty( value ) ? -1 : Integer.parseInt( value ) );
- } else if ( name.equals( "drools.eventProcessingMode" ) ) {
- setEventProcessingMode( EventProcessingMode.determineAssertBehaviour( StringUtils.isEmpty( value ) ? "cloud" : value ) );
+ } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) {
+ setEventProcessingMode( EventProcessingOption.determineEventProcessingMode( StringUtils.isEmpty( value ) ? "cloud" : value ) );
}
}
@@ -340,8 +341,8 @@
Boolean.toString( isMultithreadEvaluation() );
} else if ( name.equals( "drools.maxThreads" ) ) {
return Integer.toString( getMaxThreads() );
- } else if ( name.equals( "drools.eventProcessingMode" ) ) {
- return getEventProcessingMode().toExternalForm();
+ } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) {
+ return getEventProcessingMode().getMode();
}
return null;
@@ -433,7 +434,7 @@
setMaxThreads( Integer.parseInt( this.chainedProperties.getProperty( "drools.maxThreads",
"-1" ) ) );
- setEventProcessingMode( EventProcessingMode.determineAssertBehaviour( this.chainedProperties.getProperty( "drools.eventProcessingMode",
+ setEventProcessingMode( EventProcessingOption.determineEventProcessingMode( this.chainedProperties.getProperty( EventProcessingOption.PROPERTY_NAME,
"cloud" ) ) );
}
@@ -522,11 +523,11 @@
this.assertBehaviour = assertBehaviour;
}
- public EventProcessingMode getEventProcessingMode() {
+ public EventProcessingOption getEventProcessingMode() {
return this.eventProcessingMode;
}
- public void setEventProcessingMode(final EventProcessingMode mode) {
+ public void setEventProcessingMode(final EventProcessingOption mode) {
checkCanChange(); // throws an exception if a change isn't possible;
this.eventProcessingMode = mode;
}
@@ -1144,58 +1145,6 @@
}
}
- /**
- * An enum for the valid event processing modes.
- *
- * When the rulebase is compiled in the CLOUD (default) event processing mode,
- * it behaves just like a regular rulebase.
- *
- * When the rulebase is compiled in the STREAM event processing mode, additional
- * assumptions are made. These assumptions allow the engine to perform a few optimisations
- * like:
- *
- * <li> reasoning over absence of events (NOT CE), automatically adds an appropriate duration attribute
- * to the rule in order to avoid early rule firing. </li>
- * <li> memory management techniques may be employed when an event no longer can match other events
- * due to session clock continuous increment. </li>
- *
- * @author etirelli
- *
- */
- public static enum EventProcessingMode {
-
- CLOUD(
- "cloud"), STREAM(
- "stream");
-
- private String string;
-
- EventProcessingMode(String mode) {
- this.string = mode;
- }
-
- public String getId() {
- return string;
- }
-
- public String toString() {
- return string;
- }
-
- public String toExternalForm() {
- return this.string;
- }
-
- public static EventProcessingMode determineAssertBehaviour(String mode) {
- if ( STREAM.getId().equalsIgnoreCase( mode ) ) {
- return STREAM;
- } else if ( CLOUD.getId().equalsIgnoreCase( mode ) ) {
- return CLOUD;
- }
- throw new IllegalArgumentException( "Illegal enum value '" + mode + "' for EventProcessingMode" );
- }
- }
-
@SuppressWarnings("unchecked")
public <T extends SingleValueKnowledgeBaseOption> T getOption(Class<T> option) {
if ( MaintainTMSOption.class.equals( option ) ) {
@@ -1230,6 +1179,8 @@
throw new RuntimeDroolsException("Unable to resolve ConsequenceExceptionHandler class: "+consequenceExceptionHandler, e);
}
return (T) ConsequenceExceptionHandlerOption.get( handler );
+ } else if ( EventProcessingOption.class.equals( option ) ) {
+ return (T) getEventProcessingMode();
}
return null;
@@ -1262,6 +1213,8 @@
setCompositeKeyDepth( ((CompositeKeyDepthOption) option).getDepth() );
} else if ( option instanceof ConsequenceExceptionHandlerOption) {
setConsequenceExceptionHandler( ((ConsequenceExceptionHandlerOption) option).getHandler().getName() );
+ } else if ( option instanceof EventProcessingOption ) {
+ setEventProcessingMode( (EventProcessingOption) option );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/PatternBuilder.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -22,11 +22,11 @@
import java.util.ListIterator;
import org.drools.RuntimeDroolsException;
-import org.drools.RuleBaseConfiguration.EventProcessingMode;
import org.drools.base.ClassObjectType;
import org.drools.base.DroolsQuery;
import org.drools.common.InstanceNotEqualsConstraint;
import org.drools.common.InternalWorkingMemory;
+import org.drools.conf.EventProcessingOption;
import org.drools.reteoo.AlphaNode;
import org.drools.reteoo.EntryPointNode;
import org.drools.reteoo.ObjectSource;
@@ -164,7 +164,7 @@
} else if ( constraint.getType().equals( Constraint.ConstraintType.BETA ) ) {
betaConstraints.add( constraint );
if( isNegative &&
- context.getRuleBase().getConfiguration().getEventProcessingMode() == EventProcessingMode.STREAM &&
+ context.getRuleBase().getConfiguration().getEventProcessingMode() == EventProcessingOption.STREAM &&
pattern.getObjectType().isEvent() &&
constraint.isTemporal() ) {
checkDelaying( context, constraint );
@@ -271,7 +271,7 @@
(EntryPointNode) context.getObjectSource(),
objectType,
context );
- if( objectType.isEvent() && EventProcessingMode.STREAM.equals( context.getRuleBase().getConfiguration().getEventProcessingMode() ) ) {
+ if( objectType.isEvent() && EventProcessingOption.STREAM.equals( context.getRuleBase().getConfiguration().getEventProcessingMode() ) ) {
long expirationOffset = 0;
for( TypeDeclaration type : context.getRuleBase().getTypeDeclarations() ) {
if( type.getObjectType().isAssignableFrom( objectType ) ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/builder/ReteooRuleBuilder.java 2009-03-30 16:12:33 UTC (rev 25891)
@@ -21,10 +21,10 @@
import org.drools.InitialFact;
import org.drools.RuleIntegrationException;
-import org.drools.RuleBaseConfiguration.EventProcessingMode;
import org.drools.base.ClassObjectType;
import org.drools.common.BaseNode;
import org.drools.common.InternalRuleBase;
+import org.drools.conf.EventProcessingOption;
import org.drools.reteoo.QueryTerminalNode;
import org.drools.reteoo.ReteooBuilder;
import org.drools.reteoo.RuleTerminalNode;
@@ -105,7 +105,7 @@
context.setRule( rule );
// if running in STREAM mode, calculate temporal distance for events
- if( EventProcessingMode.STREAM.equals( rulebase.getConfiguration().getEventProcessingMode() ) ) {
+ if( EventProcessingOption.STREAM.equals( rulebase.getConfiguration().getEventProcessingMode() ) ) {
TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] );
context.setTemporalDistance( temporal );
}
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes.xml 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes.xml 2009-03-30 16:12:33 UTC (rev 25891)
@@ -1,15 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" xmlns="http://docbook.org/ns/docbook"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:m="http://www.w3.org/1998/Math/MathML"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:db="http://docbook.org/ns/docbook">
- <title>Event Processing Modes</title>
-
- <xi:include href="Section-EventProcessingModes_CloudMode.xml" />
-
- <xi:include href="Section-EventProcessingModes_StreamMode.xml" />
-
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:db="http://docbook.org/ns/docbook">
+ <title>Event Processing Modes</title>
+
+ <para>Rules engines in general have a well known way of processing data and
+ rules and provide the application with the results. Also, there is not many
+ requirements on how facts should be presented to the rules engine, specially
+ because in general, the processing itself is time independent. That is a
+ good assumption for most scenarios, but not for all of them. When the
+ requirements include the processing of real time or near real time events,
+ time becomes and important variable of the reasoning process.</para>
+
+ <para>The following sections will explain the impact of time on rules
+ reasoning and the two modes provided by Drools for the reasoning process.
+ </para>
+
+ <xi:include href="Section-EventProcessingModes_CloudMode.xml" />
+
+ <xi:include href="Section-EventProcessingModes_StreamMode.xml" />
</section>
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_CloudMode.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_CloudMode.xml 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_CloudMode.xml 2009-03-30 16:12:33 UTC (rev 25891)
@@ -1,11 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" xmlns="http://docbook.org/ns/docbook"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:m="http://www.w3.org/1998/Math/MathML"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:db="http://docbook.org/ns/docbook">
- <title>Cloud Mode</title>
-
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:db="http://docbook.org/ns/docbook">
+ <title>Cloud Mode</title>
+
+ <para>The CLOUD processing mode is the default processing mode. Users of
+ rules engine are familiar with this mode because it behaves in exactly the
+ same way as any pure forward chaining rules engine, including previous
+ versions of Drools.</para>
+
+ <para>When running in CLOUD mode, the engine sees all facts in the working
+ memory, does not matter if they are regular facts or events, as a whole.
+ There is no notion of flow of time, although events have a timestamp as
+ usual. In other words, although the engine knows that a given event was
+ created, for instance, on January 1st 2009, at 09:35:40.767, it is not
+ possible for the engine to determine how "old" the event is, because there
+ is no concept of "now".</para>
+
+ <para>In this mode, the engine will apply its usual many-to-many pattern
+ matching algorithm, using the rules constraints to find the matching tuples,
+ activate and fire rules as usual.</para>
+
+ <para>This mode does not impose any kind of additional requirements on
+ facts. So for instance:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>There is no notion of time. No requirements clock synchronization.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>There is no requirement on event ordering. The engine looks at the
+ events as an unnordered cloud against which the engine tries to match
+ rules.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>On the other hand, since there is no requirements, some benefits are
+ not available either. For instance, in CLOUD mode, it is not possible to use
+ sliding windows, because sliding windows are based on the concept of "now"
+ and there is no concept of "now" in CLOUD mode. </para>
+
+ <para>Since there is no ordering requirement on events, it is not possible
+ for the engine to determine when events can no longer match and as so, there
+ is no automatic life-cycle management for events. I.e., the application must
+ explicitly retract events when they are no longer necessary, in the same way
+ the application does with regular facts.</para>
+
+ <para>Cloud mode is the default execution mode for Drools, but in any case,
+ as any other configuration in Drools, it is possible to change this behavior
+ either by setting a system property, using configuration property files or
+ using the API. The corresponding property is:</para>
+
+ <programlisting>KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+config.setOption( EventProcessingOption.CLOUD );</programlisting>
+
+ <para>The equivalent property is:</para>
+
+ <programlisting>drools.eventProcessingMode = cloud</programlisting>
+
+ <para></para>
</section>
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_StreamMode.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_StreamMode.xml 2009-03-30 12:41:18 UTC (rev 25890)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-EventProcessingModes/Section-EventProcessingModes_StreamMode.xml 2009-03-30 16:12:33 UTC (rev 25891)
@@ -1,19 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" xmlns="http://docbook.org/ns/docbook"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:m="http://www.w3.org/1998/Math/MathML"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:db="http://docbook.org/ns/docbook">
- <title>Stream Mode</title>
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:db="http://docbook.org/ns/docbook">
+ <title>Stream Mode</title>
+ <para>The STREAM processing mode is the mode of choice when the application
+ needs to process streams of events. It adds a few common requirements to the
+ regular processing, but enables a whole lot of features that make stream
+ event processing a lot simpler.</para>
- <section>
- <title>Role of Session Clock in Stream mode</title>
- </section>
- <section>
- <title>Negative Patterns in Stream Mode</title>
- </section>
+ <para>The main requirements to use STREAM mode are:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Events in each stream must be time-ordered. I.e., inside a given
+ stream, events that happened first must be inserted first into the
+ engine.</para>
+ </listitem>
+
+ <listitem>
+ <para>The engine will force synchronization between streams through the
+ use of the session clock, so, although the application does not need to
+ enforce time ordering between streams, the use of non-time-synchronized
+ streams may result in some unexpected results.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Given that the above requirements are met, the application may enable
+ the STREAM mode using the following API:</para>
+
+ <programlisting>KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+config.setOption( EventProcessingOption.STREAM );</programlisting>
+
+ <para>Or, the equivalent property:</para>
+
+ <programlisting>drools.eventProcessingMode = stream</programlisting>
+
+ <para>When using the STREAM, the engine knows the concept of flow of time
+ and the concept of "now", i.e., the engine understands how old events are
+ based on the current timestamp read from the Session Clock. This
+ characteristic allows the engine to provide the following additional
+ features to the application:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Sliding Window support</para>
+ </listitem>
+
+ <listitem>
+ <para>Automatic Event Lifecycle Management</para>
+ </listitem>
+
+ <listitem>
+ <para>Automatic Rule Delaying when using Negative Patterns</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>All these features are explained in the following sections.</para>
+
+ <section>
+ <title>Role of Session Clock in Stream mode</title>
+ </section>
+
+ <section>
+ <title>Negative Patterns in Stream Mode</title>
+ </section>
</section>
More information about the jboss-svn-commits
mailing list