Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Limit the proliferation of Grids to avoid more leaks

  • Loading branch information...
commit 06fb39ad869eeb3a3aa4ced2a89ea1a8bcaa1f5e 1 parent 658a5b2
@sotty sotty authored
Showing with 199 additions and 120 deletions.
  1. +8 −0 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgent.java
  2. +10 −7 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgentFactory.java
  3. +9 −2 drools-mas-core/src/main/java/org/drools/mas/core/SessionManager.java
  4. +2 −2 drools-mas-core/src/main/resources/org/drools/mas/acl_common.drl
  5. +0 −1  drools-mas-core/src/main/resources/org/drools/mas/acl_content_based_routing.drl
  6. +6 −4 drools-mas-core/src/main/resources/org/drools/mas/acl_internal.drl
  7. +10 −6 drools-mas-core/src/test/java/org/drools/mas/core/tests/GridTests.java
  8. +0 −2  drools-mas-core/src/test/java/org/drools/mas/core/tests/SpringAgentTest.java
  9. +30 −17 drools-mas-core/src/test/java/org/drools/mas/core/tests/TestAgent.java
  10. +3 −3 drools-mas-core/src/test/resources/session2.drl
  11. +64 −57 drools-mas-generic-client/pom.xml
  12. +10 −3 drools-mas-generic-client/src/main/java/org/drools/mas/helpers/SyncDialogueHelper.java
  13. +11 −11 drools-mas-util/src/main/java/org/drools/mas/util/helper/ResponseContent.java
  14. +8 −0 examples/drools-mas-emergency-agent-client/pom.xml
  15. +1 −4 examples/drools-mas-emergency-agent-client/src/test/java/org/drools/mas/EmergencyAgentServiceRemoteTest.java
  16. +13 −0 examples/drools-mas-emergency-agent-model/pom.xml
  17. +1 −1  examples/drools-mas-emergency-agent/src/main/resources/knowledge/agent-brain_hello-module.drl
  18. +13 −0 pom.xml
View
8 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgent.java
@@ -21,6 +21,8 @@
import java.util.List;
import java.util.Set;
import org.drools.grid.*;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.management.DroolsManagementAgent;
import org.drools.mas.util.MessageContentEncoder;
import org.drools.runtime.StatefulKnowledgeSession;
@@ -103,6 +105,9 @@ public void tell( ACLMessage msg ) {
* Destructor
*/
public void dispose() {
+ DroolsManagementAgent kmanagement = DroolsManagementAgent.getInstance();
+ kmanagement.unregisterKnowledgeSession( ( (StatefulKnowledgeSessionImpl ) mind).getInternalWorkingMemory() );
+
//TODO : what if another agent is using this grid's nodes?
try {
if ( logger.isInfoEnabled() ) {
@@ -144,6 +149,9 @@ public void dispose() {
} finally {
grid.dispose();
}
+ // Should have already been disposed...
+ mind.dispose();
+
}
View
17 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgentFactory.java
@@ -15,6 +15,7 @@
*/
package org.drools.mas.core;
+import org.drools.grid.helper.GridHelper;
import org.drools.grid.remote.StatefulKnowledgeSessionRemoteClient;
import org.drools.mas.util.helper.NodeLocator;
import org.drools.runtime.StatefulKnowledgeSession;
@@ -62,7 +63,7 @@
private static DroolsAgentFactory singleton;
public static DroolsAgentFactory getInstance() {
- if (singleton == null) {
+ if ( singleton == null ) {
singleton = new DroolsAgentFactory();
}
return singleton;
@@ -76,15 +77,20 @@ public DroolsAgent spawn( DroolsAgentConfiguration config ) {
configureGrid( grid, config.getPort() );
AgentID aid = new AgentID();
- aid.setName( config.getAgentId() );
- aid.setLocalName( config.getAgentId() );
+ aid.setName( config.getAgentId() );
+ aid.setLocalName( config.getAgentId() );
+
if ( logger.isInfoEnabled() ) {
logger.info( " >>> Spawning Agent => Name: " + aid.getName() );
}
+
try {
+
if ( logger.isDebugEnabled() ) {
logger.debug(" ### Creating Agent Mind: " + config.getAgentId() + "- CS: " + config.getChangeset() +" - mind location: " +config.getMindNodeLocation() );
}
+
+
SessionManager manager = SessionManager.create( config, null, grid, false );
if ( manager == null ) {
logger.error( "SOMETHING BAD HAPPENED WHILE TRYING TO CREATE AN AGENT, could not create sessionManager" );
@@ -94,9 +100,6 @@ public DroolsAgent spawn( DroolsAgentConfiguration config ) {
StatefulKnowledgeSession mind = manager.getStatefulKnowledgeSession();
DroolsManagementAgent kmanagement = DroolsManagementAgent.getInstance();
-
- //kmanagement.registerKnowledgeBase((ReteooRuleBase) ((KnowledgeBaseImpl) mind.get).getRuleBase());
-
kmanagement.registerKnowledgeSession( ( (StatefulKnowledgeSessionImpl) mind ).getInternalWorkingMemory() );
if ( logger.isDebugEnabled() ) {
@@ -150,7 +153,7 @@ public DroolsAgent spawn( DroolsAgentConfiguration config ) {
return new DroolsAgent( grid, aid, mind );
} catch ( Throwable t ) {
- if (t.getCause() != null){
+ if ( t.getCause() != null ){
logger.error( "SOMETHING BAD HAPPENED WHILE TRYING TO CREATE AN AGENT " + t.getMessage() + ", due to " + t.getCause().getMessage() );
}else{
logger.error( "SOMETHING BAD HAPPENED WHILE TRYING TO CREATE AN AGENT " + t.getMessage());
View
11 drools-mas-core/src/main/java/org/drools/mas/core/SessionManager.java
@@ -26,8 +26,10 @@
import org.drools.grid.*;
import org.drools.grid.api.ResourceDescriptor;
import org.drools.grid.service.directory.Address;
+import org.drools.impl.EnvironmentImpl;
import org.drools.io.Resource;
import org.drools.io.impl.ByteArrayResource;
+import org.drools.runtime.Environment;
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.conf.ClockTypeOption;
@@ -193,9 +195,11 @@ protected SessionManager( String id, KnowledgeBase kbase, GridNode node ) {
}
conf.setProperty( ClockTypeOption.PROPERTY_NAME, ClockType.REALTIME_CLOCK.toExternalForm() );
+ Environment env = new EnvironmentImpl();
+ env.set( "sessionId", id );
// this.kSession = kAgent.getKnowledgeBase().newStatefulKnowledgeSession(conf, null);
- this.kSession = kbase.newStatefulKnowledgeSession( conf, null );
+ this.kSession = kbase.newStatefulKnowledgeSession( conf, env );
if ( ! node.isRemote() ) {
addKnowledgeAgent( id, kbase, node );
}
@@ -205,6 +209,9 @@ protected SessionManager( String id, KnowledgeBase kbase, GridNode node ) {
logger.info( " ### SessionManager : Registering session " + id + " in node: " + node.getId() );
}
node.set( id, this.kSession );
+ if ( ! node.isRemote() ) {
+ kSession.setGlobal( "grid", node.getGrid() );
+ }
}
@@ -344,7 +351,7 @@ public static void addResource( Grid grid, String nodeId, String sessionId, Stri
KnowledgeAgent kAgent;
GridNode node = grid.getGridNode( nodeId );
if ( node == null || node.isRemote() ) {
- kAgent = GridHelper.getKnowledgeAgentRemoteClient( grid, nodeId, sessionId );
+ kAgent = GridHelper.getInstance().getKnowledgeAgentRemoteClient( grid, nodeId, sessionId );
} else {
kAgent = node.get( sessionId + "_kAgent", KnowledgeAgent.class );
}
View
4 drools-mas-core/src/main/resources/org/drools/mas/acl_common.drl
@@ -82,9 +82,9 @@ rule "Init Grid"
salience 999
when
then
- // need to initialize Grid in remote nodes
if ( kcontext.getKnowledgeRuntime().getGlobal( "grid" ) == null ) {
- kcontext.getKnowledgeRuntime().setGlobal( "grid", GridHelper.createGrid() );
+ LoggerHelper.error( "Fatal error, global object GRID is not set" );
+// kcontext.getKnowledgeRuntime().setGlobal( "grid", GridHelper.getInstance().createGrid() );
}
end
View
1  drools-mas-core/src/main/resources/org/drools/mas/acl_content_based_routing.drl
@@ -30,7 +30,6 @@ import org.drools.mas.util.LoggerHelper;
import org.drools.mas.core.DroolsAgentConfiguration;
import org.drools.mas.util.helper.SessionLocator;
import org.drools.mas.util.helper.NodeLocator;
-import org.drools.grid.helper.GridHelper;
import org.drools.mas.util.helper.NoHandlerFault;
View
10 drools-mas-core/src/main/resources/org/drools/mas/acl_internal.drl
@@ -28,12 +28,14 @@ import org.drools.command.CommandFactory;
import org.drools.command.BatchExecutionCommand;
import org.drools.grid.remote.command.AsyncBatchExecutionCommandImpl;
import org.drools.runtime.rule.QueryResults;
+import org.drools.grid.helper.GridHelper;
import org.drools.mas.Act;
import org.drools.mas.body.content.*;
import org.drools.mas.body.acts.*;
import org.drools.mas.util.MessageContentHelper;
import org.drools.mas.util.MessageContentFactory;
import org.drools.command.runtime.rule.QueryCommand;
+import org.drools.grid.helper.GridHelper;
import java.util.List;
import java.util.ArrayList;
@@ -67,7 +69,7 @@ then
retract( $cmd );
- StatefulKnowledgeSession kSession = GridHelper.getStatefulKnowledgeSession( grid, $nodeId, $sessionId, true );
+ StatefulKnowledgeSession kSession = GridHelper.getInstance().getStatefulKnowledgeSession( grid, $nodeId, $sessionId, true );
if ( LoggerHelper.isDebugEnabled() ) {
LoggerHelper.debug( " ### INTERNAL RULES: Trying to execute in = " + kSession );
}
@@ -119,7 +121,7 @@ then
retract( $cmd );
- StatefulKnowledgeSession kSession = GridHelper.getStatefulKnowledgeSession( grid, $nodeId, $sessionId, true );
+ StatefulKnowledgeSession kSession = GridHelper.getInstance().getStatefulKnowledgeSession( grid, $nodeId, $sessionId, true );
kSession.execute( $act );
kSession.execute( CommandFactory.newFireAllRules() );
end
@@ -214,7 +216,7 @@ then
LoggerHelper.debug(" ### INTERNAL: FIXING QUERYIF RESULTS " + $sessionId );
}
if( $data instanceof QueryResultsDescriptor ) {
- $data = GridHelper.getQueryResultRemoteClient( grid, $nodeId, $sessionId,
+ $data = GridHelper.getInstance().getQueryResultRemoteClient( grid, $nodeId, $sessionId,
( (QueryResultsDescriptor) $data ).getQueryName(), ( (QueryResultsDescriptor) $data ).getQueryId() );
}
modify ( $cont ) {
@@ -259,7 +261,7 @@ then
LoggerHelper.debug(" ### INTERNAL: FIXING RESULTS FOR QUERYREF " + $data);
}
if( $data instanceof QueryResultsDescriptor ) {
- $data = GridHelper.getQueryResultRemoteClient( grid, $nodeId, $sessionId,
+ $data = GridHelper.getInstance().getQueryResultRemoteClient( grid, $nodeId, $sessionId,
( (QueryResultsDescriptor) $data ).getQueryName(), ( (QueryResultsDescriptor) $data ).getQueryId() );
}
View
16 drools-mas-core/src/test/java/org/drools/mas/core/tests/GridTests.java
@@ -68,7 +68,9 @@ public static void setUpClass() throws Exception {
}
System.out.println("DB for white pages started! ");
- GridHelper.reset();
+// WhitePages wps = new JpaWhitePages( Persistence.createEntityManagerFactory("org.drools.grid") );
+//
+// GridHelper.getInstance().reinitialize( wps );
}
@AfterClass
@@ -83,7 +85,8 @@ public static void tearDownClass() {
private Map<String, GridServiceDescription> coreServicesMap;
protected Grid grid1;
-
+ protected Grid grid2;
+
protected GridNode remoteN1;
private static Server server;
@@ -107,7 +110,7 @@ private void createRemoteNode(){
8000,
new JpaWhitePages( Persistence.createEntityManagerFactory( "org.drools.grid" ) ) );
- Grid grid2 = new GridImpl("peer2", new HashMap<String, Object>() );
+ grid2 = new GridImpl("peer2", new HashMap<String, Object>() );
configureGrid1( grid2,
-1,
grid1.get( WhitePages.class ) );
@@ -183,7 +186,8 @@ protected StatefulKnowledgeSession createSession(){
String rule = "package test\n"
+ "import mock.MockFact;\n"
- + "global MockFact myGlobalObj;\n"
+ + "global MockFact myGlobalObj;\n" +
+ " global org.drools.grid.Grid grid; \n"
+ "query getMyObjects(String n)\n"
+ " $mo: MockFact(name == n)\n"
+ "end\n"
@@ -229,7 +233,7 @@ protected StatefulKnowledgeSession createSession(){
@Test
public void remoteKAgentResourceLoadTest() throws InterruptedException {
StatefulKnowledgeSession ksession = createSession();
- ksession.setGlobal("myGlobalObj", new MockFact("myglobalObj",10));
+ ksession.setGlobal( "myGlobalObj", new MockFact( "myglobalObj", 10 ) );
int fired = ksession.fireAllRules();
Assert.assertEquals(0, fired);
@@ -244,7 +248,7 @@ public void remoteKAgentResourceLoadTest() throws InterruptedException {
((InternalResource) changeSetRes).setResourceType( ResourceType.CHANGE_SET );
- KnowledgeAgent kAgent = GridHelper.getKnowledgeAgentRemoteClient( GridHelper.createGrid(), remoteN1.getId(), "ksession-rules" );
+ KnowledgeAgent kAgent = GridHelper.getInstance().getKnowledgeAgentRemoteClient( grid2, remoteN1.getId(), "ksession-rules" );
kAgent.applyChangeSet( changeSetRes );
Thread.sleep( 5000 );
View
2  drools-mas-core/src/test/java/org/drools/mas/core/tests/SpringAgentTest.java
@@ -60,8 +60,6 @@ public static void setUpClass() throws Exception {
}
logger.info("DB for white pages started! ");
- GridHelper.reset();
-
logger.info( "----------------------------------------------------------------------------------------------" );
logger.info( "PRE-Setup Complete \n\n\n\n\n" );
}
View
47 drools-mas-core/src/test/java/org/drools/mas/core/tests/TestAgent.java
@@ -18,6 +18,8 @@
import java.sql.SQLException;
import org.drools.grid.helper.GridHelper;
+import org.drools.grid.service.directory.WhitePages;
+import org.drools.grid.service.directory.impl.JpaWhitePages;
import org.drools.mas.body.acts.Failure;
import org.drools.mas.body.content.Query;
import org.drools.mas.body.acts.InformIf;
@@ -49,6 +51,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.persistence.Persistence;
+
public class TestAgent {
private static DroolsAgent mainAgent;
@@ -68,9 +72,18 @@ public static void setupDB() {
logger.error( ex.getMessage() );
}
logger.info("DB for white pages started! ");
+ }
- // force DB initialization
- GridHelper.reset();
+ @Test
+ @Ignore( "Manual use only, test for memory leaks" )
+ public void stressTest() throws InterruptedException {
+ for ( int j = 0; j < 100; j++ ) {
+ if ( j > 0 ) {
+ createAgents();
+ }
+ testRequest();
+ mainAgent.dispose();
+ }
}
@Before
@@ -586,7 +599,7 @@ public void testQueryRefFailure() throws InterruptedException {
assertEquals( Act.FAILURE, ans.get(1).getPerformative() );
}
-
+
@Test
public void testDynamicResourceAddition() throws Exception{
@@ -595,34 +608,34 @@ public void testDynamicResourceAddition() throws Exception{
for (Object o : target.getObjects()) {
System.err.println("\t Assets BEFORE the inform : " + o);
}
-
+
Assert.assertFalse(target.getObjects().contains("--------@@ It's alive!! @@--------------"));
-
+
Assert.assertNull(target.getKnowledgeBase().getRule("org.drools.mas.test", "Test this"));
-
+
ClasspathURLResourceLocator uRLResourceLocator = new ClasspathURLResourceLocator(
- "classpath:newResource.drl",
- ResourceType.DRL
+ "classpath:newResource.drl",
+ ResourceType.DRL
);
uRLResourceLocator.setName("patient1");
-
+
ACLMessageFactory factory = new ACLMessageFactory(Encodings.XML);
ACLMessage info = factory.newInformMessage("me", "you", uRLResourceLocator);
mainAgent.tell(info);
-
+
waitForAnswers( info.getId(), 0, 1000, 50 );
-
+
for (Object o : target.getObjects()) {
System.err.println("\t Assets AFTER the inform : " + o);
}
-
+
//This string comes from newResource.drl
Assert.assertTrue( target.getObjects().contains("--------@@ It's alive!! @@--------------") );
Assert.assertNotNull( target.getKnowledgeBase().getRule( "org.drools.mas.test", "Test this") );
-
-
-
+
+
+
}
-
-
+
+
}
View
6 drools-mas-core/src/test/resources/session2.drl
@@ -90,7 +90,7 @@ rule "Action_Request : squareRoot - Result "
then
retract($a);
- ResponseContent.deliverResponse( $nodeId, $sessionId, $msgId, $return, null );
+ ResponseContent.deliverResponse( grid, $nodeId, $sessionId, $msgId, $return, null );
end
rule "Action_Request : no logic to deal with this kind request"
@@ -101,7 +101,7 @@ when
then
retract( $a );
Fault fault = new NoHandlerFault( $msgId, "No known way to process a request " + $actName );
- ResponseContent.deliverResponse( $nodeId, $sessionId, $msgId, null, fault );
+ ResponseContent.deliverResponse( grid, $nodeId, $sessionId, $msgId, null, fault );
end
@@ -113,7 +113,7 @@ when
then
retract( $a );
Fault fault = new ExecutionFault( $msgId,"can't extract the square root of " + $x );
- ResponseContent.deliverResponse( $nodeId, $sessionId, $msgId, null, fault );
+ ResponseContent.deliverResponse( grid, $nodeId, $sessionId, $msgId, null, fault );
end
View
121 drools-mas-generic-client/pom.xml
@@ -17,61 +17,68 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.drools.mas</groupId>
- <artifactId>drools-mas-generic-client</artifactId>
- <version>1.0.Final</version>
-
- <name>Drools MAS :: Generic Agent Client</name>
- <url>http://maven.apache.org</url>
- <build>
- <plugins>
-
- </plugins>
- </build>
- <repositories>
- <repository>
- <url>http://download.java.net/maven/2</url>
- <id>metro</id>
- <layout>default</layout>
- <name>Repository for library[metro]</name>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <name>java.net</name>
- <id>java.net</id>
- <url>http://download.java.net/maven/2/</url>
- </pluginRepository>
- </pluginRepositories>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
-
- <dependency>
- <groupId>org.drools.mas</groupId>
- <artifactId>drools-mas-util</artifactId>
- <version>1.0.Final</version>
- </dependency>
- <dependency>
- <groupId>javax.xml</groupId>
- <artifactId>webservices-api</artifactId>
- <version>1.4</version>
- </dependency>
-
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>webservices-rt</artifactId>
- <version>1.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.drools.mas</groupId>
+ <artifactId>drools-mas-generic-client</artifactId>
+ <version>1.0.Final</version>
+
+ <name>Drools MAS :: Generic Agent Client</name>
+ <url>http://maven.apache.org</url>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <url>http://download.java.net/maven/2</url>
+ <id>metro</id>
+ <layout>default</layout>
+ <name>Repository for library[metro]</name>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <name>java.net</name>
+ <id>java.net</id>
+ <url>http://download.java.net/maven/2/</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.drools.mas</groupId>
+ <artifactId>drools-mas-util</artifactId>
+ <version>1.0.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>webservices-api</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>webservices-rt</artifactId>
+ <version>1.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
View
13 drools-mas-generic-client/src/main/java/org/drools/mas/helpers/SyncDialogueHelper.java
@@ -234,16 +234,23 @@ public String invokeDisconfirm( String sender, String receiver, Object propositi
long waitTime = minWaitTime;
do {
try {
- logger.debug( " >>> Waiting for answers (" + waitTime + ") for: Message -> " + msgRef );
+ logger.debug( " >>> [" + msgid + "] Waiting for " + numExpectedMessages + " answers (" + waitTime + ") for: Message -> " + msgRef + " , now I have " + answers.size() );
+ logger.debug( answers.toString() );
Thread.sleep( waitTime );
} catch ( InterruptedException ex ) {
logger.error( ex.getMessage() );
}
- List<ACLMessage> incomingAnswers = asyncServicePort.getResponses(msgid);
+ logger.debug( " >>> [" + msgid + "] Wake up with " + answers );
+ List<ACLMessage> incomingAnswers = asyncServicePort.getResponses( msgid );
+ logger.debug( " >>> [" + msgid + "] Incoming new " + incomingAnswers );
answers.addAll( incomingAnswers );
+ logger.debug( " >>> [" + msgid + "] After adding new " + answers );
waitTime *= 2;
- } while ( answers.size() != numExpectedMessages && waitTime < maxTimeout );
+ } while ( answers.size() < numExpectedMessages && waitTime < maxTimeout );
+ if ( answers.size() < numExpectedMessages ) {
+ logger.equals( " >>> [" + msgid + "] Expecting " + numExpectedMessages + " but got " + answers.size() );
+ }
return answers;
}
View
22 drools-mas-util/src/main/java/org/drools/mas/util/helper/ResponseContent.java
@@ -26,19 +26,19 @@
private static Logger logger = LoggerFactory.getLogger( ResponseContent.class );
- public static void deliverResponse( String nodeId, String sessionId, String msgId, Object ret, Fault fault ) {
- deliverResponse( nodeId, sessionId, msgId, ret, fault, false );
- }
+// public static void deliverResponse( String nodeId, String sessionId, String msgId, Object ret, Fault fault ) {
+// deliverResponse( nodeId, sessionId, msgId, ret, fault, false );
+// }
public static void deliverResponse( Grid grid, String nodeId, String sessionId, String msgId, Object ret, Fault fault ) {
- deliverResponse( grid, nodeId, sessionId, msgId, ret, fault, false );
- }
-
- public static void deliverResponse( String nodeId, String sessionId, String msgId, Object ret, Fault fault, boolean needEncoding ) {
- Grid grid = GridHelper.createGrid();
- deliverResponse( grid, nodeId, sessionId, msgId, ret, fault, needEncoding );
+ deliverResponse( grid, nodeId, sessionId, msgId, ret, fault, false );
}
-
+
+// public static void deliverResponse( String nodeId, String sessionId, String msgId, Object ret, Fault fault, boolean needEncoding ) {
+// Grid grid = GridHelper.getInstance().createGrid();
+// deliverResponse( grid, nodeId, sessionId, msgId, ret, fault, needEncoding );
+// }
+
public static void deliverResponse( Grid grid, String nodeId, String sessionId, String msgId, Object ret, Fault fault, boolean needEncoding ) {
try {
if ( logger.isDebugEnabled() ) {
@@ -67,7 +67,7 @@ public static void deliverResponse( Grid grid, String nodeId, String sessionId,
logger.debug( "(" + Thread.currentThread().getId() + ")" + Thread.currentThread().getName() + "Content helper fault is expected to be null " + fault );
}
- StatefulKnowledgeSession kSession = GridHelper.getStatefulKnowledgeSession( grid, nodeId, sessionId, true );
+ StatefulKnowledgeSession kSession = GridHelper.getInstance().getStatefulKnowledgeSession( grid, nodeId, sessionId, true );
if ( logger.isDebugEnabled() ) {
logger.debug( "(" + Thread.currentThread().getId() + ")"+Thread.currentThread().getName() +"Content helper ksession found!" );
View
8 examples/drools-mas-emergency-agent-client/pom.xml
@@ -161,6 +161,14 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
</plugins>
</build>
View
5 ...ples/drools-mas-emergency-agent-client/src/test/java/org/drools/mas/EmergencyAgentServiceRemoteTest.java
@@ -58,15 +58,12 @@ public void tearDown() {
@Test
public void testSimpleInformWithHelper() {
- DialogueHelper agentHelper = new DialogueHelper( endpoint );
+ SyncDialogueHelper agentHelper = new SyncDialogueHelper( endpoint );
MockFact fact = new MockFact( "patient1", 18 );
String iid = agentHelper.invokeInform( "me", "you", fact );
- List<ACLMessage> result = agentHelper.getAgentAnswers( iid );
-
- assertEquals( 0, result.size() );
}
@Test
View
13 examples/drools-mas-emergency-agent-model/pom.xml
@@ -14,6 +14,19 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
View
2  examples/drools-mas-emergency-agent/src/main/resources/knowledge/agent-brain_hello-module.drl
@@ -44,7 +44,7 @@ when
coordinateEmergency( $return; )
then
retract( $action );
- ResponseContent.deliverResponse( $nodeId, $sessionId, $msgId, $return, null );
+ ResponseContent.deliverResponse( grid, $nodeId, $sessionId, $msgId, $return, null );
end
View
13 pom.xml
@@ -166,4 +166,17 @@
</dependencies>
</dependencyManagement>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
Please sign in to comment.
Something went wrong with that request. Please try again.