[jboss-svn-commits] JBL Code SVN: r25924 - in labs/jbossrules/trunk: drools-api/src/main/java/org/drools/conf and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Apr 2 15:06:52 EDT 2009


Author: tirelli
Date: 2009-04-02 15:06:52 -0400 (Thu, 02 Apr 2009)
New Revision: 25924

Added:
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MaxThreadsOption.java
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MultithreadEvaluationOption.java
Modified:
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/KnowledgeBaseConfiguration.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-Features.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_ExplicitExpirationPolicy.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_InferredExpirationPolicy.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_HowToConfigurePartitioning.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_MultithreadingManagement.xml
   labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_WhenPartitioningIsUseful.xml
Log:
Adding docs

Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/KnowledgeBaseConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/KnowledgeBaseConfiguration.java	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/KnowledgeBaseConfiguration.java	2009-04-02 19:06:52 UTC (rev 25924)
@@ -41,6 +41,8 @@
  * <li>drools.indexLeftBetaMemory = &lt;true/false&gt;</li>
  * <li>drools.indexRightBetaMemory = &lt;true/false&gt;</li>
  * <li>drools.consequenceExceptionHandler = &lt;qualified class name&gt;</li>
+ * <li>drools.maxThreads = &lt;-1|1..n&gt;</li>
+ * <li>drools.multithreadEvaluation = &lt;true|false&gt;</li>
  * </ul>
  * </p>
  * 

Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MaxThreadsOption.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MaxThreadsOption.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MaxThreadsOption.java	2009-04-02 19:06:52 UTC (rev 25924)
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+
+/**
+ * A class for the max threads configuration.
+ * 
+ * @author etirelli
+ */
+public class MaxThreadsOption implements SingleValueKnowledgeBaseOption {
+
+    private static final long serialVersionUID = -8461267995706982981L;
+
+    /**
+     * The property name for the max threads
+     */
+    public static final String PROPERTY_NAME = "drools.maxThreads";
+    
+    /**
+     * max threads
+     */
+    private final int maxThreads;
+    
+    /**
+     * Private constructor to enforce the use of the factory method
+     * @param maxThreads
+     */
+    private MaxThreadsOption( int maxThreads ) {
+        this.maxThreads = maxThreads;
+    }
+    
+    /**
+     * This is a factory method for this Max Threads configuration.
+     * The factory method is a best practice for the case where the 
+     * actual object construction is changed in the future.
+     * 
+     * @param maxThreads the maximum number of threads for partition evaluation
+     * 
+     * @return the actual type safe max threads configuration.
+     */
+    public static MaxThreadsOption get( int threshold ) {
+        return new MaxThreadsOption( threshold );
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String getPropertyName() {
+        return PROPERTY_NAME;
+    }
+    
+    /**
+     * Returns the maximum number of threads for partition evaluation
+     * 
+     * @return
+     */
+    public int getMaxThreads() {
+        return maxThreads;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + maxThreads;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( getClass() != obj.getClass() ) return false;
+        MaxThreadsOption other = (MaxThreadsOption) obj;
+        if ( maxThreads != other.maxThreads ) return false;
+        return true;
+    }
+    
+}


Property changes on: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MaxThreadsOption.java
___________________________________________________________________
Name: svn:executable
   + *

Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MultithreadEvaluationOption.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MultithreadEvaluationOption.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MultithreadEvaluationOption.java	2009-04-02 19:06:52 UTC (rev 25924)
@@ -0,0 +1,56 @@
+/*
+ * 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 multithread evaluation option.
+ * 
+ * drools.multithreadEvaluation = &lt;true|false&gt; 
+ * 
+ * DEFAULT = false
+ * 
+ * @author etirelli
+ */
+public enum MultithreadEvaluationOption implements SingleValueKnowledgeBaseOption {
+    
+    YES(true),
+    NO(false);
+
+    /**
+     * The property name for the multithread evaluation option
+     */
+    public static final String PROPERTY_NAME = "drools.multithreadEvaluation";
+    
+    private boolean value;
+    
+    MultithreadEvaluationOption( final boolean value ) {
+        this.value = value;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String getPropertyName() {
+        return PROPERTY_NAME;
+    }
+    
+    public boolean isMultithreadEvaluation() {
+        return this.value;
+    }
+
+}


Property changes on: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/conf/MultithreadEvaluationOption.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-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java	2009-04-02 19:06:52 UTC (rev 25924)
@@ -362,7 +362,53 @@
                       config.getProperty( EventProcessingOption.PROPERTY_NAME ) );
     }
     
+    public void testMaxThreadsConfiguration() {
+        // setting the option using the type safe method
+        config.setOption( MaxThreadsOption.get(5) );
+
+        // checking the type safe getOption() method
+        assertEquals( MaxThreadsOption.get(5),
+                      config.getOption( MaxThreadsOption.class ) );
+        // checking the string based getProperty() method
+        assertEquals( "5",
+                      config.getProperty( MaxThreadsOption.PROPERTY_NAME ) );
+
+        // setting the options using the string based setProperty() method
+        config.setProperty( MaxThreadsOption.PROPERTY_NAME,
+                            "8" );
+        
+        // checking the type safe getOption() method
+        assertEquals( MaxThreadsOption.get(8),
+                      config.getOption( MaxThreadsOption.class ) );
+        // checking the string based getProperty() method
+        assertEquals( "8",
+                      config.getProperty( MaxThreadsOption.PROPERTY_NAME ) );
+    }
     
+    public void testMultithreadEvaluationConfiguration() {
+        // setting the option using the type safe method
+        config.setOption( MultithreadEvaluationOption.YES );
+
+        // checking the type safe getOption() method
+        assertEquals( MultithreadEvaluationOption.YES,
+                      config.getOption( MultithreadEvaluationOption.class ) );
+        // checking the string based getProperty() method
+        assertEquals( "true",
+                      config.getProperty( MultithreadEvaluationOption.PROPERTY_NAME ) );
+
+        // setting the options using the string based setProperty() method
+        config.setProperty( MultithreadEvaluationOption.PROPERTY_NAME,
+                            "false" );
+        
+        // checking the type safe getOption() method
+        assertEquals( MultithreadEvaluationOption.NO,
+                      config.getOption( MultithreadEvaluationOption.class ) );
+        // checking the string based getProperty() method
+        assertEquals( "false",
+                      config.getProperty( MultithreadEvaluationOption.PROPERTY_NAME ) );
+    }
     
+    
+    
 
 }

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-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java	2009-04-02 19:06:52 UTC (rev 25924)
@@ -43,7 +43,9 @@
 import org.drools.conf.KnowledgeBaseOption;
 import org.drools.conf.LogicalOverrideOption;
 import org.drools.conf.MaintainTMSOption;
+import org.drools.conf.MaxThreadsOption;
 import org.drools.conf.MultiValueKnowledgeBaseOption;
+import org.drools.conf.MultithreadEvaluationOption;
 import org.drools.conf.RemoveIdentitiesOption;
 import org.drools.conf.SequentialAgendaOption;
 import org.drools.conf.SequentialOption;
@@ -106,6 +108,8 @@
  * drools.consequenceExceptionHandler = <qualified class name>
  * drools.ruleBaseUpdateHandler = <qualified class name>
  * drools.sessionClock = <qualified class name>
+ * drools.maxThreads = <-1|1..n>
+ * drools.multithreadEvaluation = <true|false>
  * 
  */
 public class RuleBaseConfiguration
@@ -288,10 +292,10 @@
             setConflictResolver( RuleBaseConfiguration.determineConflictResolver( StringUtils.isEmpty( value ) ? DepthConflictResolver.class.getName() : value ) );
         } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) {
             setAdvancedProcessRuleIntegration( StringUtils.isEmpty( value ) ? false : Boolean.valueOf( value ) );
-        } else if ( name.equals( "drools.multithreadEvaluation" ) ) {
+        } else if ( name.equals( MultithreadEvaluationOption.PROPERTY_NAME ) ) {
             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( MaxThreadsOption.PROPERTY_NAME ) ) {
+            setMaxThreads( StringUtils.isEmpty( value ) ? 3 : Integer.parseInt( value ) );
         } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) {
             setEventProcessingMode( EventProcessingOption.determineEventProcessingMode( StringUtils.isEmpty( value ) ? "cloud" : value ) );
         }
@@ -337,9 +341,9 @@
             return getConflictResolver().getClass().getName();
         } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) {
             return Boolean.toString( isAdvancedProcessRuleIntegration() );
-        } else if ( name.equals( "drools.multithreadEvaluation" ) ) {
-            Boolean.toString( isMultithreadEvaluation() );
-        } else if ( name.equals( "drools.maxThreads" ) ) {
+        } else if ( name.equals( MultithreadEvaluationOption.PROPERTY_NAME ) ) {
+            return Boolean.toString( isMultithreadEvaluation() );
+        } else if ( name.equals( MaxThreadsOption.PROPERTY_NAME ) ) {
             return Integer.toString( getMaxThreads() );
         } else if ( name.equals( EventProcessingOption.PROPERTY_NAME ) ) {
             return getEventProcessingMode().getMode();
@@ -429,11 +433,11 @@
         setAdvancedProcessRuleIntegration( Boolean.valueOf( this.chainedProperties.getProperty( "drools.advancedProcessRuleIntegration",
                                                                                                 "false" ) ).booleanValue() );
 
-        setMultithreadEvaluation( Boolean.valueOf( this.chainedProperties.getProperty( "drools.multithreadEvaluation",
+        setMultithreadEvaluation( Boolean.valueOf( this.chainedProperties.getProperty( MultithreadEvaluationOption.PROPERTY_NAME,
                                                                                        "false" ) ).booleanValue() );
 
-        setMaxThreads( Integer.parseInt( this.chainedProperties.getProperty( "drools.maxThreads",
-                                                                             "-1" ) ) );
+        setMaxThreads( Integer.parseInt( this.chainedProperties.getProperty( MaxThreadsOption.PROPERTY_NAME,
+                                                                             "3" ) ) );
         setEventProcessingMode( EventProcessingOption.determineEventProcessingMode( this.chainedProperties.getProperty( EventProcessingOption.PROPERTY_NAME,
                                                                                                                   "cloud" ) ) );
     }
@@ -1181,6 +1185,10 @@
             return (T) ConsequenceExceptionHandlerOption.get( handler );
         } else if ( EventProcessingOption.class.equals( option ) ) {
             return (T) getEventProcessingMode();
+        } else if ( MaxThreadsOption.class.equals( option ) ) {
+            return (T) MaxThreadsOption.get( getMaxThreads() );
+        } else if ( MultithreadEvaluationOption.class.equals( option ) ) {
+            return (T) (this.multithread ? MultithreadEvaluationOption.YES : MultithreadEvaluationOption.NO);
         }
         return null;
         
@@ -1215,6 +1223,10 @@
             setConsequenceExceptionHandler( ((ConsequenceExceptionHandlerOption) option).getHandler().getName() );
         } else if ( option instanceof EventProcessingOption ) {
             setEventProcessingMode( (EventProcessingOption) option );
+        } else if ( option instanceof MaxThreadsOption ) {
+            setMaxThreads( ((MaxThreadsOption) option).getMaxThreads() );
+        } else if ( option instanceof MultithreadEvaluationOption ) {
+            setMultithreadEvaluation( ((MultithreadEvaluationOption) option).isMultithreadEvaluation() );
         } 
 
     }

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-Features.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-Features.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-Features.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,25 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <chapter 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>Drools Fusion Features</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>Drools Fusion Features</title>
 
-    <xi:include href="Chapter-Events/Section-Events.xml" />
+  <xi:include href="Chapter-Events/Section-Events.xml" />
 
-	<xi:include href="Chapter-SessionClock/Section-SessionClock.xml" />
+  <xi:include href="Chapter-SessionClock/Section-SessionClock.xml" />
 
-	<xi:include href="Chapter-StreamsSupport/Section-StreamsSupport.xml" />
+  <xi:include href="Chapter-StreamsSupport/Section-StreamsSupport.xml" />
 
-	<xi:include href="Chapter-TemporalReasoning/Section-TemporalReasoning.xml" />
+  <xi:include href="Chapter-TemporalReasoning/Section-TemporalReasoning.xml" />
 
-	<xi:include href="Chapter-EventProcessingModes/Section-EventProcessingModes.xml" />
+  <xi:include href="Chapter-EventProcessingModes/Section-EventProcessingModes.xml" />
 
-	<xi:include href="Chapter-SlidingWindows/Section-SlidingWindows.xml" />
+  <xi:include href="Chapter-SlidingWindows/Section-SlidingWindows.xml" />
 
-	<xi:include href="Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml" />
+  <xi:include href="Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml" />
 
-	<xi:include href="Chapter-MemoryManagement/Section-MemoryManagement.xml" />
-
-	<xi:include href="Chapter-Examples/Section-Examples.xml" /> 
-</chapter>
\ No newline at end of file
+  <xi:include href="Chapter-MemoryManagement/Section-MemoryManagement.xml" />
+</chapter>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,17 +1,41 @@
 <?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>Memory Management</title>	
-	
-	<xi:include href="Section-MemoryManagement_ExplicitExpirationPolicy.xml" />
-	
-	<xi:include href="Section-MemoryManagement_InferredExpirationPolicy.xml" />
-	
-	<xi:include href="Section-MemoryManagement_HowImplemented.xml" />
-				
-</section>
\ No newline at end of file
+         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>Memory Management for Events</title>
+
+  <important>
+    <para>The automatic memory management for events is only performed when
+    running the engine in STREAM mode. Check the Event Processing Mode section
+    for details on how the STREAM mode works.</para>
+  </important>
+
+  <para>One of the benefits of running the engine in STREAM mode is that the
+  engine can detect when an event can no longer match any rule due to its
+  temporal constraints. When that happens, the engine can safely retract the
+  event from the session without side effects and release any resources used
+  by that event.</para>
+
+  <para>There are basically 2 ways for the engine to calculate the matching
+  window for a given event:</para>
+
+  <itemizedlist>
+    <listitem>
+      <para>explicitly, using the expiration policy</para>
+    </listitem>
+
+    <listitem>
+      <para>implicitly, analyzing the temporal constraints on events</para>
+    </listitem>
+  </itemizedlist>
+
+  <para></para>
+
+  <xi:include href="Section-MemoryManagement_ExplicitExpirationPolicy.xml" />
+
+  <xi:include href="Section-MemoryManagement_InferredExpirationPolicy.xml" />
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_ExplicitExpirationPolicy.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_ExplicitExpirationPolicy.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_ExplicitExpirationPolicy.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,12 +1,28 @@
 <?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>Explicit expiration policy</title>	
-	
-	
-</section>
\ No newline at end of file
+         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>Explicit expiration offset</title>
+
+  <para>The first way of allowing the engine to calculate the window of
+  interest for a given event type is by explicitly setting it. To do that,
+  just use the declare statement and define an expiration for the fact
+  type:</para>
+
+  <para><example>
+      <title>explicitly defining an expiration offset of 30 minutes for
+      StockTick events</title>
+
+      <programlisting>declare StockTick
+    @expires( 30m )
+end
+</programlisting>
+    </example>The above example declares an expiration offset of 30 minutes
+  for StockTick events. After that time, assuming no rule still needs the
+  event, the engine will expire and remove the event from the session
+  automatically.</para>
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_InferredExpirationPolicy.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_InferredExpirationPolicy.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-MemoryManagement/Section-MemoryManagement_InferredExpirationPolicy.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,11 +1,37 @@
 <?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>Inferred expiration policy</title>	
-		
-</section>
\ No newline at end of file
+         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>Inferred expiration offset</title>
+
+  <para>Another way for the engine to calculate the expiration offset for a
+  given event is implicitly, by analyzing the temporal constraints in the
+  rules. For instance, given the following rule:</para>
+
+  <para><example>
+      <title>example rule with temporal constraints</title>
+
+      <programlisting>rule "correlate orders"
+when
+    $bo : BuyOrderEvent( $id : id ) 
+    $ae : AckEvent( id == $id, this after[0,10s] $bo )
+then
+    // do something
+end
+</programlisting>
+    </example>Analyzing the above rule, the engine automatically calculates
+  that whenever a BuyOrderEvent matches, it needs to store it for up to 10
+  seconds to wait for matching AckEvent's. So, the implicit expiration offset
+  for BuyOrderEvent will be 10 seconds. AckEvent, on the other hand, can only
+  match existing BuyOrderEvent's, and so its expiration offset will be zero
+  seconds.</para>
+
+  <para>The engine will make this analysis for the whole rulebase and find the
+  offset for every event type. Whenever an implicit expiration offset clashes
+  with the explicit expiration offset, then engine will use the greater of the
+  two.</para>
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,17 +1,42 @@
 <?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>Rulebase Partitioning</title>	
-	
-	<xi:include href="Section-RulebasePartitioning_MultithreadingManagement.xml" />
-	
-	<xi:include href="Section-RulebasePartitioning_WhenPartitioningIsUseful.xml" />
-	
-	<xi:include href="Section-RulebasePartitioning_HowToConfigurePartitioning.xml" />
-			
-</section>
\ No newline at end of file
+         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>Knowledgebase Partitioning</title>
+
+  <warning>
+    <para>This is an experimental feature, subject to changes in the
+    future.</para>
+  </warning>
+
+  <para>The classic Rete algorithm is usually executed using a single thread.
+  Although, as confirmed in several opportunities by Dr. Forgy, the algorithm
+  itself is parallelizable. Drools implementation of the ReteOO algorithm
+  supports coarse grained parallelization through rulebase
+  partitioning.</para>
+
+  <para>When this option is enabled, the rulebase will be partitioned in
+  several independent partitions and a pool of worker threads will be used to
+  propagate facts through the partitions. The implementation guarantees that
+  at most one worker thread will be executing tasks for a given partition, but
+  multiple partitions may be "active" at a single point in time.</para>
+
+  <para>Everything should be transparent to the user, except that all working
+  memory actions (insert/retract/modify) are executed assynchronously.</para>
+
+  <important>
+    <para>This feature enables parallel LHS evaluation, but does not change
+    the behavior of rule firing. I.e., rules will continue to fire
+    sequentially, according to the conflict resolution strategy.</para>
+  </important>
+
+  <xi:include href="Section-RulebasePartitioning_WhenPartitioningIsUseful.xml" />
+
+  <xi:include href="Section-RulebasePartitioning_HowToConfigurePartitioning.xml" />
+
+  <xi:include href="Section-RulebasePartitioning_MultithreadingManagement.xml" />
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_HowToConfigurePartitioning.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_HowToConfigurePartitioning.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_HowToConfigurePartitioning.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,14 +1,27 @@
 <?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>How to configure partitioning</title>	
-		
-	<section>
-		<title>How to configure partitioning</title> 						
-	</section>		
-</section>
\ No newline at end of file
+         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>How to configure partitioning</title>
+
+   <para>To enable knowledge base partitioning, set the following
+    option:</para>
+
+    <example>
+      <title>enabling multithread evaluation (partitioning)</title>
+
+      <programlisting>KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+config.setOption( MultithreadEvaluationOption.YES );
+</programlisting>
+    </example>
+
+    <para>The equivalent property is:</para>
+
+    <programlisting>drools.multithreadEvaluation = &lt;true|false&gt;</programlisting>
+
+    <para>The default value for this option is "false" (disabled).</para>
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_MultithreadingManagement.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_MultithreadingManagement.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_MultithreadingManagement.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,16 +1,38 @@
 <?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>Multithreading management</title>	
-	
-	
-	<section>
-		<title>Multithreading management</title> 	
-	</section>
-			
-</section>
\ No newline at end of file
+         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>Multithreading management</title>
+
+    <para>Drools offers a simple configuration option for users to control the
+    size of the worker thread's pool.</para>
+
+    <para>To define the maximum size for the thread pool, the user may use the
+    following configuration option:</para>
+
+    <para><example>
+        <title>setting the maximum number of threads for rule evaluation to
+        5</title>
+
+        <programlisting>KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+config.setOption( MaxThreadsOption.get(5) );
+</programlisting>
+      </example></para>
+
+    <para>The equivalent property is:</para>
+
+    <programlisting>drools.maxThreads = &lt;-1|1..n&gt;</programlisting>
+
+    <para>The default value for this configuration is 3 and a negative number
+    means the engine will try to spawn as many threads as there are partitions
+    in the rulebase.</para>
+
+    <warning>
+      <para>It is usually dangerous to set this option with a negative number.
+      Always set it with a sensible positive number of threads.</para>
+    </warning>
+</section>

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_WhenPartitioningIsUseful.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_WhenPartitioningIsUseful.xml	2009-04-02 19:05:58 UTC (rev 25923)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-fusion/src/main/docbook/en-US/Chapter-Features/Chapter-RulebasePartitioning/Section-RulebasePartitioning_WhenPartitioningIsUseful.xml	2009-04-02 19:06:52 UTC (rev 25924)
@@ -1,16 +1,39 @@
 <?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>When partitioning is useful</title>	
-	
-	
-	<section>
-		<title>When partitioning is useful</title> 						
-	</section>
-			
-</section>
\ No newline at end of file
+         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>When partitioning is useful</title>
+
+    <para>Knowledge base partitioning is a very powerful feature for specific
+    scenarios, but it is not a general case solution. To understand if this
+    feature would be useful for a given scenario, the user may follow the
+    checklist bellow:</para>
+
+    <orderedlist>
+      <listitem>
+        <para>Does your hardware contains multiple processors?</para>
+      </listitem>
+
+      <listitem>
+        <para>Does your knowledge session process a high volume of
+        facts?</para>
+      </listitem>
+
+      <listitem>
+        <para>Are the LHS of your rules expensive to evaluate? (ex: use
+        expensive "from" expressions)</para>
+      </listitem>
+
+      <listitem>
+        <para>Does your knowledge base contains hundreds or more rules?</para>
+      </listitem>
+    </orderedlist>
+
+    <para>If the answer to all the questions above is "yes", then this feature
+    will probably increase the overall performance of your rulebase
+    evaluation. </para>
+</section>




More information about the jboss-svn-commits mailing list