[jboss-svn-commits] JBL Code SVN: r32611 - in labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main: resources/org/drools and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Apr 23 12:22:23 EDT 2010
Author: salaboy21
Date: 2010-04-23 12:22:22 -0400 (Fri, 23 Apr 2010)
New Revision: 32611
Modified:
labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/GridConnection.java
labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/StatefulKnowledgeSessionGridClient.java
labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/resources/org/drools/executionNodeService.groovy
Log:
JBRULES-2446: Drools Services API
- drools-grid-rio getGlobal and setGlobal impl
Modified: labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/GridConnection.java
===================================================================
--- labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/GridConnection.java 2010-04-23 15:20:11 UTC (rev 32610)
+++ labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/GridConnection.java 2010-04-23 16:22:22 UTC (rev 32611)
@@ -95,7 +95,18 @@
aMgr.setBackend(this);
aMgr.addAssociationDescriptors(descriptorExecutionNode, descriptorDirectoryNode);
+
+ Iterable<org.drools.grid.ExecutionNodeService> executionNodes = aMgr.getAssociations("ExecutionNodeService", null)[0];
+ for (ExecutionNodeService executionNodeService : executionNodes) {
+ addNodeConnector(executionNodeService);
+ }
+
+ Iterable<org.drools.grid.DirectoryNodeService> directoryNodes = aMgr.getAssociations("DirectoryNodeService", null)[0];
+ for (DirectoryNodeService directoryNodeService : directoryNodes) {
+ addDirectoryNode(directoryNodeService);
+ }
+
long waited = 0;
while (nodeConnectors.size() == 0 && waited < 30000) {
Thread.sleep(500);
Modified: labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/StatefulKnowledgeSessionGridClient.java
===================================================================
--- labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/StatefulKnowledgeSessionGridClient.java 2010-04-23 15:20:11 UTC (rev 32610)
+++ labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/java/org/drools/grid/distributed/StatefulKnowledgeSessionGridClient.java 2010-04-23 16:22:22 UTC (rev 32611)
@@ -7,7 +7,10 @@
import org.drools.KnowledgeBase;
import org.drools.command.Command;
import org.drools.command.ExecuteCommand;
+import org.drools.command.FinishedCommand;
import org.drools.command.KnowledgeContextResolveFromContextCommand;
+import org.drools.command.runtime.GetGlobalCommand;
+import org.drools.command.runtime.SetGlobalCommand;
import org.drools.command.runtime.rule.FireAllRulesCommand;
import org.drools.event.process.ProcessEventListener;
import org.drools.event.rule.AgendaEventListener;
@@ -151,8 +154,31 @@
}
public Object getGlobal(String identifier) {
- // TODO Auto-generated method stub
- return null;
+ String commandId = "ksession.execute" + messageSession.getNextId();
+ String kresultsId = "kresults_" + messageSession.getSessionId();
+
+ Message msg = new Message( messageSession.getSessionId(),
+ messageSession.counter.incrementAndGet(),
+ false,
+ new KnowledgeContextResolveFromContextCommand( new GetGlobalCommand( identifier ),
+ null,
+ null,
+ instanceId,
+ kresultsId ) );
+
+ try {
+ Object result = nodeConnection.write( msg ).getPayload();
+ if ( result == null ) {
+ throw new RuntimeException( "Response was not correctly received = null" );
+ }
+
+ return result;
+
+
+ } catch ( Exception e ) {
+ throw new RuntimeException( "Unable to execute message",
+ e );
+ }
}
public Globals getGlobals() {
@@ -178,8 +204,35 @@
public void setGlobal(String identifier,
Object object) {
- // TODO Auto-generated method stub
+ String commandId = "ksession.execute" + messageSession.getNextId();
+ String kresultsId = "kresults_" + messageSession.getSessionId();
+ Message msg = new Message( messageSession.getSessionId(),
+ messageSession.counter.incrementAndGet(),
+ false,
+ new KnowledgeContextResolveFromContextCommand( new SetGlobalCommand( identifier,
+ object ),
+ null,
+ null,
+ instanceId,
+ kresultsId ) );
+
+ try {
+ Object result = nodeConnection.write( msg ).getPayload();
+ if ( result == null ) {
+ throw new RuntimeException( "Response was not correctly received = null" );
+ }
+
+ if ( !(result instanceof FinishedCommand)) {
+ throw new RuntimeException( "Response was not correctly received" );
+ }
+
+
+ } catch ( Exception e ) {
+ throw new RuntimeException( "Unable to execute message",
+ e );
+ }
+
}
public void unregisterExitPoint(String name) {
Modified: labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/resources/org/drools/executionNodeService.groovy
===================================================================
--- labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/resources/org/drools/executionNodeService.groovy 2010-04-23 15:20:11 UTC (rev 32610)
+++ labs/jbossrules/trunk/drools-grid/drools-grid-rio/src/main/resources/org/drools/executionNodeService.groovy 2010-04-23 16:22:22 UTC (rev 32611)
@@ -5,10 +5,10 @@
deployment(name:'executionNodeService', debug: 'true') {
- logging {
- logger 'org.rioproject.resolver', Level.FINE
- logger 'org.rioproject.associsations' , Level.FINE
- }
+// logging {
+// logger 'org.rioproject.resolver', Level.FINE
+// logger 'org.rioproject.associsations' , Level.FINE
+// }
/* Configuration for the discovery group that the service should join.
* This first checks if the org.rioproject.groups property is set, if not
* the user name is used */
More information about the jboss-svn-commits
mailing list