[jboss-svn-commits] JBL Code SVN: r32253 - in labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src: main/java/org/drools/services/grid/impl and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Mar 27 11:03:22 EDT 2010
Author: salaboy21
Date: 2010-03-27 11:03:22 -0400 (Sat, 27 Mar 2010)
New Revision: 32253
Added:
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionNodeService.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridConnection.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/ExecutionNodeServiceImpl.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioServiceConnector.java
Removed:
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionGridConnection.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridNodeExecutionService.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/GridNodeExecutionServiceImpl.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioConnector.java
Modified:
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryLookupProviderGridClient.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryService.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GenericMessageGridHandlerImpl.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridExecutionNodeConnection.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridSelectionStrategy.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseGridClient.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseProviderGridClient.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBuilderProviderGridClient.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/StatefulKnowledgeSessionGridClient.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/DirectoryServiceImpl.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/strategies/StaticIncrementalSelectionStrategy.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ExecutionNodeBaseTest.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ITGridExecutionTest.java
labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/resources/org/drools/executionNodeService.groovy
Log:
JBRULES-2446: Drools Services API
- drools-services-grid refactoring names, cleaning code
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryLookupProviderGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryLookupProviderGridClient.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryLookupProviderGridClient.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -37,13 +37,13 @@
*/
public class DirectoryLookupProviderGridClient implements DirectoryLookupFactoryService {
- private ExecutionGridConnection gridClient;
- private GridNodeExecutionService currentService;
+ private GridConnection gridClient;
+ private ExecutionNodeService currentService;
private MessageSession messageSession;
- public DirectoryLookupProviderGridClient(GridNodeExecutionService currentService, ExecutionGridConnection gridClient) {
+ public DirectoryLookupProviderGridClient(ExecutionNodeService currentService, GridConnection gridClient) {
this.currentService = currentService;
this.gridClient = gridClient;
this.messageSession = new MessageSession();
@@ -102,7 +102,7 @@
kresultsId ) );
System.out.println("Looking up the session with identifier = "+identifier);
try {
- //First I need to get the correct client GridNodeExecutionService with the identifier
+ //First I need to get the correct client ExecutionNodeService with the identifier
DirectoryService directory = (DirectoryService) gridClient.getDirectories().iterator().next();
if(directory != null){
System.out.println("Setting session for identifier = "+identifier +" - client ="+currentService);
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryService.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryService.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/DirectoryService.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -16,7 +16,7 @@
public interface DirectoryService {
public void register(String executorId, String sessionServiceId) throws RemoteException;
- public GridNodeExecutionService lookup(String executorId) throws RemoteException;
+ public ExecutionNodeService lookup(String executorId) throws RemoteException;
public void registerKBase(String kbaseId, String sessionServiceId) throws RemoteException;
public KnowledgeBase lookupKBase(String kbaseId) throws RemoteException;
}
Deleted: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionGridConnection.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionGridConnection.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionGridConnection.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -1,118 +0,0 @@
-/*
- * Copyright 2010 salaboy.
- *
- * 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.
- * under the License.
- */
-package org.drools.services.grid;
-
-import org.drools.builder.DirectoryLookupFactoryService;
-import java.util.ArrayList;
-import java.util.List;
-import org.drools.KnowledgeBaseFactoryService;
-import org.drools.builder.KnowledgeBuilderFactoryService;
-import org.drools.services.ExecutionNode;
-import org.drools.services.grid.strategies.StaticIncrementalSelectionStrategy;
-
-/**
- *
- * @author salaboy
- */
-//Should I rename this class to something like GridClient?
-public class ExecutionGridConnection {
-
- //Cached Services
- private List<GridNodeExecutionService> services;
-
-
- //Cached Directories
- private List<DirectoryService> directories;
-
- //Clients
- //private List<>
-
-
- public ExecutionGridConnection() {
- this.services = new ArrayList<GridNodeExecutionService>();
- this.directories = new ArrayList<DirectoryService>();
- }
-
-
-
- public void addService(GridNodeExecutionService service) {
-
- this.services.add(service);
-
- }
-
- public void addDirectory(DirectoryService directory) {
- this.directories.add(directory);
- }
-
-
-
-
- //This will use the default/random strategy
- public ExecutionNode getExecutionNode() {
- GridNodeExecutionService currentService = getBestService(
- new StaticIncrementalSelectionStrategy(this));
- ExecutionNode node = new ExecutionNode();
- node.set(KnowledgeBuilderFactoryService.class,
- new KnowledgeBuilderProviderGridClient( currentService, this ));
-
- node.set(KnowledgeBaseFactoryService.class,
- new KnowledgeBaseProviderGridClient( currentService, this ));
-
-
- node.set(DirectoryLookupFactoryService.class, new DirectoryLookupProviderGridClient(currentService,this));
-
-// new GridExecutionNodeConnection
-// ((GridNodeExecutionService)currentService).getId(),
-//
-//
-// new RioConnector("client1",SystemEventListenerFactory.getSystemEventListener(),
-// (GridNodeExecutionService)currentService)
-// ,env)
-
- return node;
- }
-
- //This will use the strategy to return a new Execution Node
- public ExecutionNode getExecutionNode(GridSelectionStrategy strategy){
- return new ExecutionNode();
- }
-
- private GridNodeExecutionService getBestService(GridSelectionStrategy gridSelectionStrategy) {
- return gridSelectionStrategy.getBestNode();
- }
-
-
-
- public List<DirectoryService> getDirectories() {
- return directories;
- }
-
- public void setDirectories(List<DirectoryService> directories) {
- this.directories = directories;
- }
-
- public List<GridNodeExecutionService> getServices() {
- return services;
- }
-
- public void setServices(List<GridNodeExecutionService> services) {
- this.services = services;
- }
-
-
-}
Copied: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionNodeService.java (from rev 32004, labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridNodeExecutionService.java)
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionNodeService.java (rev 0)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionNodeService.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -0,0 +1,20 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.drools.services.grid;
+
+import java.rmi.RemoteException;
+import org.drools.services.generic.GenericIoWriter;
+import org.drools.services.generic.Message;
+
+
+/**
+ *
+ * @author salaboy
+ */
+public interface ExecutionNodeService extends GenericIoWriter {
+ public String getId() throws RemoteException;
+ public Message write(Message msg) throws RemoteException;
+
+}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GenericMessageGridHandlerImpl.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GenericMessageGridHandlerImpl.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GenericMessageGridHandlerImpl.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -17,7 +17,7 @@
import org.drools.command.impl.ContextImpl;
import org.drools.command.impl.GenericCommand;
import org.drools.runtime.impl.ExecutionResultImpl;
-import org.drools.services.generic.ExecutionNodeData;
+import org.drools.services.generic.NodeData;
import org.drools.services.generic.GenericIoWriter;
import org.drools.services.generic.GenericMessageHandler;
import org.drools.services.generic.Message;
@@ -26,10 +26,10 @@
public class GenericMessageGridHandlerImpl implements GenericMessageHandler {
private SystemEventListener systemEventListener;
- private ExecutionNodeData data;
+ private NodeData data;
private DirectoryService registry;
- public GenericMessageGridHandlerImpl(ExecutionNodeData data,
+ public GenericMessageGridHandlerImpl(NodeData data,
SystemEventListener systemEventListener) {
this.systemEventListener = systemEventListener;
this.data = data;
Copied: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridConnection.java (from rev 32165, labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/ExecutionGridConnection.java)
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridConnection.java (rev 0)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridConnection.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2010 salaboy.
+ *
+ * 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.
+ * under the License.
+ */
+package org.drools.services.grid;
+
+import org.drools.builder.DirectoryLookupFactoryService;
+import java.util.ArrayList;
+import java.util.List;
+import org.drools.KnowledgeBaseFactoryService;
+import org.drools.builder.KnowledgeBuilderFactoryService;
+import org.drools.services.ExecutionNode;
+import org.drools.services.grid.strategies.StaticIncrementalSelectionStrategy;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+/**
+ *
+ * @author salaboy
+ */
+public class GridConnection {
+
+ //Cached Services
+ private List<ExecutionNodeService> services;
+ //Cached Directories
+ private List<DirectoryService> directories;
+
+ public GridConnection() {
+ this.services = new ArrayList<ExecutionNodeService>();
+ this.directories = new ArrayList<DirectoryService>();
+ }
+
+ public void addService(ExecutionNodeService service) {
+
+ this.services.add(service);
+
+ }
+
+ public void addDirectory(DirectoryService directory) {
+ this.directories.add(directory);
+ }
+
+ // In real scenarios this method will be in charge of populating
+ // all the ExecutionNodeService and DirectoryServices
+ public void connect() {
+ throw new NotImplementedException();
+ }
+
+
+ public ExecutionNode getExecutionNode(GridSelectionStrategy strategy) {
+ ExecutionNode node = null;
+ ExecutionNodeService currentService = null;
+ //if the strategy is null use the default one
+ if(strategy == null){
+ currentService = getBestService(
+ new StaticIncrementalSelectionStrategy(this));
+ }
+
+ node = new ExecutionNode();
+ node.set(KnowledgeBuilderFactoryService.class,
+ new KnowledgeBuilderProviderGridClient(currentService, this));
+
+ node.set(KnowledgeBaseFactoryService.class,
+ new KnowledgeBaseProviderGridClient(currentService, this));
+ node.set(DirectoryLookupFactoryService.class, new DirectoryLookupProviderGridClient(currentService, this));
+ return node;
+ }
+
+
+
+ private ExecutionNodeService getBestService(GridSelectionStrategy gridSelectionStrategy) {
+ return gridSelectionStrategy.getBestNode();
+ }
+
+ public List<DirectoryService> getDirectories() {
+ return directories;
+ }
+
+ public void setDirectories(List<DirectoryService> directories) {
+ this.directories = directories;
+ }
+
+ public List<ExecutionNodeService> getServices() {
+ return services;
+ }
+
+ public void setServices(List<ExecutionNodeService> services) {
+ this.services = services;
+ }
+}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridExecutionNodeConnection.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridExecutionNodeConnection.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridExecutionNodeConnection.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -21,7 +21,7 @@
import org.drools.runtime.ExecutionResults;
import org.drools.services.ServiceManager;
import org.drools.services.command.ExecutionNodeClientConnectCommand;
-import org.drools.services.generic.GenericConnector;
+import org.drools.services.generic.GenericServiceConnector;
import org.drools.services.generic.Message;
import org.drools.services.generic.MessageSession;
@@ -36,11 +36,11 @@
- public GenericConnector client;
- private ExecutionGridConnection gridClient;
+ public GenericServiceConnector client;
+ private GridConnection gridClient;
- public GridExecutionNodeConnection(GenericConnector client, MessageSession messageSession, ExecutionGridConnection gridClient) {
+ public GridExecutionNodeConnection(GenericServiceConnector client, MessageSession messageSession, GridConnection gridClient) {
this.client = client;
this.messageSession = messageSession;
@@ -86,7 +86,7 @@
}
// Connecting with services
// if (this.services != null) {
-// for (GenericConnector connector : services){
+// for (GenericServiceConnector connector : services){
// boolean serviceConnected = connector.connect();
// if ( serviceConnected ){
// System.out.println("Service Connected");
@@ -100,7 +100,7 @@
public void disconnect() {
this.client.disconnect();
// if (this.services != null){
-// for (GenericConnector connector : this.services){
+// for (GenericServiceConnector connector : this.services){
// connector.disconnect();
// }
// }
@@ -226,7 +226,7 @@
return null;
}
-// public List<GenericConnector> getServices() {
+// public List<GenericServiceConnector> getServices() {
// return services;
// }
//
@@ -242,7 +242,7 @@
// this.directoryService = registryService;
// }
- public void setCurrentSessionService(GridNodeExecutionService sessionService){
+ public void setCurrentSessionService(ExecutionNodeService sessionService){
this.client.setSession(sessionService);
}
@@ -254,11 +254,11 @@
this.messageSession = messageSession;
}
-// public List<GridNodeExecutionService> getSessionServices(){
-//// List<GridNodeExecutionService> sessionServices =
+// public List<ExecutionNodeService> getSessionServices(){
+//// List<ExecutionNodeService> sessionServices =
//// ((RioConnector)this.client).getSessionServices();
//// List<String> ids = new ArrayList<String>();
-//// for(GridNodeExecutionService ss : sessionServices){
+//// for(ExecutionNodeService ss : sessionServices){
//// try {
//// ids.add(ss.getId());
//// } catch (RemoteException ex) {
Deleted: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridNodeExecutionService.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridNodeExecutionService.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridNodeExecutionService.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -1,20 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.drools.services.grid;
-
-import java.rmi.RemoteException;
-import org.drools.services.generic.GenericIoWriter;
-import org.drools.services.generic.Message;
-
-
-/**
- *
- * @author salaboy
- */
-public interface GridNodeExecutionService extends GenericIoWriter {
- public String getId() throws RemoteException;
- public Message write(Message msg) throws RemoteException;
-
-}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridSelectionStrategy.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridSelectionStrategy.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/GridSelectionStrategy.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -23,7 +23,7 @@
*/
public interface GridSelectionStrategy {
- public GridNodeExecutionService getBestNode();
+ public ExecutionNodeService getBestNode();
}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseGridClient.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseGridClient.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -24,7 +24,7 @@
import org.drools.services.generic.CollectionClient;
import org.drools.services.generic.Message;
import org.drools.services.grid.command.NewStatefulKnowledgeSessionGridCommand;
-import org.drools.services.grid.rio.RioConnector;
+import org.drools.services.grid.rio.RioServiceConnector;
public class KnowledgeBaseGridClient
@@ -33,10 +33,10 @@
private GridExecutionNodeConnection nodeConnection;
private String instanceId;
- private ExecutionGridConnection gridClient;
+ private GridConnection gridClient;
public KnowledgeBaseGridClient(String instanceId,
- GridExecutionNodeConnection nodeConnection, ExecutionGridConnection gridClient) {
+ GridExecutionNodeConnection nodeConnection, GridConnection gridClient) {
this.instanceId = instanceId;
this.nodeConnection = nodeConnection;
this.gridClient = gridClient;
@@ -140,7 +140,7 @@
}
return new StatefulKnowledgeSessionGridClient( localId,
- ((RioConnector)nodeConnection.client).getCurrentNodeService(),nodeConnection.getMessageSession() );
+ ((RioServiceConnector)nodeConnection.client).getCurrentNodeService(),nodeConnection.getMessageSession() );
}
public StatelessKnowledgeSession newStatelessKnowledgeSession(KnowledgeSessionConfiguration conf) {
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseProviderGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseProviderGridClient.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBaseProviderGridClient.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -16,26 +16,26 @@
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.services.generic.Message;
import org.drools.services.generic.MessageSession;
-import org.drools.services.grid.rio.RioConnector;
+import org.drools.services.grid.rio.RioServiceConnector;
public class KnowledgeBaseProviderGridClient
implements
KnowledgeBaseFactoryService {
- private ExecutionGridConnection gridClient;
+ private GridConnection gridClient;
private String localId = "";
private GridExecutionNodeConnection nodeConnection;
private MessageSession messageSession;
- public KnowledgeBaseProviderGridClient(GridNodeExecutionService currentService, ExecutionGridConnection gridClient) {
+ public KnowledgeBaseProviderGridClient(ExecutionNodeService currentService, GridConnection gridClient) {
this.gridClient = gridClient;
this.messageSession = new MessageSession();
this.nodeConnection = new GridExecutionNodeConnection(
//I need to specialize this class for include the RIO Connector, and solve the name problem
- new RioConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (GridNodeExecutionService) currentService),
+ new RioServiceConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (ExecutionNodeService) currentService),
this.messageSession,
gridClient
);
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBuilderProviderGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBuilderProviderGridClient.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/KnowledgeBuilderProviderGridClient.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -23,7 +23,7 @@
import org.drools.runtime.Environment;
import org.drools.services.generic.Message;
import org.drools.services.generic.MessageSession;
-import org.drools.services.grid.rio.RioConnector;
+import org.drools.services.grid.rio.RioServiceConnector;
public class KnowledgeBuilderProviderGridClient
@@ -38,12 +38,12 @@
// this.env = env;
// }
- public KnowledgeBuilderProviderGridClient(GridNodeExecutionService currentService, ExecutionGridConnection gridClient) {
+ public KnowledgeBuilderProviderGridClient(ExecutionNodeService currentService, GridConnection gridClient) {
this.messageSession = new MessageSession();
this.nodeConnection = new GridExecutionNodeConnection(
//I need to specialize this class for include the RIO Connector, and solve the name problem
- new RioConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (GridNodeExecutionService) currentService),
+ new RioServiceConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (ExecutionNodeService) currentService),
this.messageSession,
gridClient
);
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/StatefulKnowledgeSessionGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/StatefulKnowledgeSessionGridClient.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/StatefulKnowledgeSessionGridClient.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -29,7 +29,7 @@
import org.drools.services.command.GetWorkItemManagerCommand;
import org.drools.services.command.RegisterRemoteWorkItemHandlerCommand;
import org.drools.services.command.StartProcessRemoteCommand;
-import org.drools.services.generic.GenericConnector;
+import org.drools.services.generic.GenericServiceConnector;
import org.drools.services.generic.Message;
import org.drools.services.generic.MessageSession;
import org.drools.time.SessionClock;
@@ -39,7 +39,7 @@
implements
StatefulKnowledgeSession {
- private GridNodeExecutionService nodeConnection;
+ private ExecutionNodeService nodeConnection;
private String instanceId;
private MessageSession messageSession;
@@ -48,7 +48,7 @@
- StatefulKnowledgeSessionGridClient(String instanceId, GridNodeExecutionService currentService, MessageSession messageSession) {
+ StatefulKnowledgeSessionGridClient(String instanceId, ExecutionNodeService currentService, MessageSession messageSession) {
this.instanceId = instanceId;
this.nodeConnection = currentService;
this.messageSession = messageSession;
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/DirectoryServiceImpl.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/DirectoryServiceImpl.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/DirectoryServiceImpl.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -13,7 +13,7 @@
import org.drools.command.KnowledgeContextResolveFromContextCommand;
import org.drools.command.runtime.GetKnowledgeBaseCommand;
import org.drools.services.generic.Message;
-import org.drools.services.grid.GridNodeExecutionService;
+import org.drools.services.grid.ExecutionNodeService;
import org.drools.services.grid.DirectoryService;
@@ -29,10 +29,10 @@
private Map<String, String> kbaseregistry = new HashMap<String, String>();
- private Iterable<GridNodeExecutionService> nodeServices;
+ private Iterable<ExecutionNodeService> nodeServices;
public DirectoryServiceImpl() {
- nodeServices = new ArrayList<GridNodeExecutionService>();
+ nodeServices = new ArrayList<ExecutionNodeService>();
}
@@ -44,12 +44,12 @@
}
@Override
- public GridNodeExecutionService lookup(String sessionId) throws RemoteException {
- GridNodeExecutionService sessionService = null;
+ public ExecutionNodeService lookup(String sessionId) throws RemoteException {
+ ExecutionNodeService sessionService = null;
String sessionServiceId = (String)registry.get(sessionId);
System.out.println("Registry = "+ registry.toString());
System.out.println("Nodes Services = "+nodeServices);
- for(GridNodeExecutionService ss : nodeServices){
+ for(ExecutionNodeService ss : nodeServices){
System.out.println("Session Service id = "+ss.getId() + "needs to match with ="+sessionServiceId);
if(ss.getId().equals(sessionServiceId)){
sessionService = ss;
@@ -60,7 +60,7 @@
}
- public void setNodeServices(Iterable<GridNodeExecutionService> nodeServices) {
+ public void setNodeServices(Iterable<ExecutionNodeService> nodeServices) {
this.nodeServices = nodeServices;
}
@@ -72,11 +72,11 @@
@Override
public KnowledgeBase lookupKBase(String kbaseId) throws RemoteException{
- GridNodeExecutionService nodeService = null;
+ ExecutionNodeService nodeService = null;
String nodeServiceId = (String)kbaseregistry.get(kbaseId);
System.out.println("Kbase Registry = "+ kbaseregistry.toString());
System.out.println("Session Services = "+nodeService);
- for(GridNodeExecutionService ns : nodeServices){
+ for(ExecutionNodeService ns : nodeServices){
System.out.println("Node Service id = "+ns.getId() + "needs to match with ="+nodeServiceId);
if(ns.getId().equals(nodeServiceId)){
nodeService = ns;
Copied: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/ExecutionNodeServiceImpl.java (from rev 32004, labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/GridNodeExecutionServiceImpl.java)
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/ExecutionNodeServiceImpl.java (rev 0)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/ExecutionNodeServiceImpl.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2009 salaboy.
+ *
+ * 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.
+ * under the License.
+ */
+package org.drools.services.grid.impl;
+
+import java.rmi.RemoteException;
+import java.util.UUID;
+
+import org.drools.SystemEventListener;
+import org.drools.SystemEventListenerFactory;
+import org.drools.services.generic.BlockingGenericIoWriter;
+import org.drools.services.generic.GenericMessageHandler;
+import org.drools.services.generic.Message;
+import org.drools.services.generic.MessageResponseHandler;
+import org.drools.services.generic.NodeData;
+import org.drools.services.grid.GenericMessageGridHandlerImpl;
+import org.drools.services.grid.ExecutionNodeService;
+import org.drools.services.grid.util.IDEntry;
+
+import org.rioproject.core.jsb.ServiceBeanContext;
+
+/**
+ *
+ * @author salaboy
+ */
+public class ExecutionNodeServiceImpl implements ExecutionNodeService {
+
+ private GenericMessageHandler handler;
+ private String id;
+
+
+ public ExecutionNodeServiceImpl() {
+ this.id = UUID.randomUUID().toString();
+ handler = new GenericMessageGridHandlerImpl(new NodeData(), SystemEventListenerFactory.getSystemEventListener());
+ }
+
+ public ExecutionNodeServiceImpl(NodeData data,
+ SystemEventListener systemEventListener) {
+ handler = new GenericMessageGridHandlerImpl(data, systemEventListener);
+ }
+
+ public Message write(Message msg) throws RemoteException {
+ BlockingGenericIoWriter blockingWriter = new BlockingGenericIoWriter();
+ try {
+ handler.messageReceived(blockingWriter, msg);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getMessage());
+ }
+
+ return blockingWriter.getMessage();
+ }
+
+ public GenericMessageHandler getGenericMessageHandler() {
+ return this.handler;
+ }
+
+ public void write(Message msg,
+ MessageResponseHandler responseHandler) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setServiceBeanContext(ServiceBeanContext context) {
+ context.addAttribute(new IDEntry(this.id));
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+
+}
Deleted: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/GridNodeExecutionServiceImpl.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/GridNodeExecutionServiceImpl.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/impl/GridNodeExecutionServiceImpl.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -1,90 +0,0 @@
-/*
- * Copyright 2009 salaboy.
- *
- * 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.
- * under the License.
- */
-package org.drools.services.grid.impl;
-
-import java.rmi.RemoteException;
-import java.util.UUID;
-
-import org.drools.SystemEventListener;
-import org.drools.SystemEventListenerFactory;
-import org.drools.services.generic.BlockingGenericIoWriter;
-import org.drools.services.generic.GenericMessageHandler;
-import org.drools.services.generic.Message;
-import org.drools.services.generic.MessageResponseHandler;
-import org.drools.services.generic.ExecutionNodeData;
-import org.drools.services.grid.GenericMessageGridHandlerImpl;
-import org.drools.services.grid.GridNodeExecutionService;
-import org.drools.services.grid.util.IDEntry;
-
-import org.rioproject.core.jsb.ServiceBeanContext;
-
-/**
- *
- * @author salaboy
- */
-public class GridNodeExecutionServiceImpl implements GridNodeExecutionService {
-
- private GenericMessageHandler handler;
- private String id;
-
-
- public GridNodeExecutionServiceImpl() {
- this.id = UUID.randomUUID().toString();
- handler = new GenericMessageGridHandlerImpl(new ExecutionNodeData(), SystemEventListenerFactory.getSystemEventListener());
- }
-
- public GridNodeExecutionServiceImpl(ExecutionNodeData data,
- SystemEventListener systemEventListener) {
- handler = new GenericMessageGridHandlerImpl(data, systemEventListener);
- }
-
- public Message write(Message msg) throws RemoteException {
- BlockingGenericIoWriter blockingWriter = new BlockingGenericIoWriter();
- try {
- handler.messageReceived(blockingWriter, msg);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RemoteException(e.getMessage());
- }
-
- return blockingWriter.getMessage();
- }
-
- public GenericMessageHandler getGenericMessageHandler() {
- return this.handler;
- }
-
- public void write(Message msg,
- MessageResponseHandler responseHandler) {
- throw new UnsupportedOperationException();
- }
-
- public void setServiceBeanContext(ServiceBeanContext context) {
- context.addAttribute(new IDEntry(this.id));
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
-
-
-}
Deleted: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioConnector.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioConnector.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioConnector.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -1,130 +0,0 @@
-package org.drools.services.grid.rio;
-
-
-import java.rmi.RemoteException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.net.SocketAddress;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.drools.SystemEventListener;
-import org.drools.services.generic.GenericConnector;
-import org.drools.services.generic.Message;
-import org.drools.services.generic.MessageResponseHandler;
-import org.drools.services.grid.GridNodeExecutionService;
-
-
-public class RioConnector
- implements
- GenericConnector {
-
- protected final String name;
- protected AtomicInteger counter;
- protected GridNodeExecutionService nodeService;
- //protected List<GridNodeExecutionService> nodeServices;
- protected SocketAddress address;
- protected SystemEventListener eventListener;
-
- public RioConnector(String name,
- SystemEventListener eventListener
- ) {
- if ( name == null ) {
- throw new IllegalArgumentException( "Name can not be null" );
- }
- this.name = name;
- this.counter = new AtomicInteger();
- this.eventListener = eventListener;
-
- }
-
- public RioConnector(String name,
- SystemEventListener eventListener,
- GridNodeExecutionService nodeService
- ) {
- if ( name == null ) {
- throw new IllegalArgumentException( "Name can not be null" );
- }
- this.name = name;
- this.counter = new AtomicInteger();
- this.eventListener = eventListener;
- this.nodeService = nodeService;
- // this.nodeServices = sessionServices;
-
- }
-
- /* (non-Javadoc)
- * @see org.drools.vsm.mina.Messenger#connect()
- */
- public boolean connect() {
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.drools.vsm.mina.Messenger#disconnect()
- */
- public void disconnect() {
- //I don't need to be disconected
- }
-
- public Message write(Message msg) {
- if ( nodeService != null ) {
- try {
-
- Message returnMessage = this.nodeService.write( msg );
- return returnMessage;
- // ioHandler.messageReceived( sessionService ,
- // returnMessage );
-
- } catch ( RemoteException ex ) {
- Logger.getLogger( RioConnector.class.getName() ).log( Level.SEVERE,
- null,
- ex );
- } catch ( Exception ex ) {
- Logger.getLogger( RioConnector.class.getName() ).log( Level.SEVERE,
- null,
- ex );
- }
- }
- throw new IllegalStateException( "sessionService should not be null" );
- }
-
- public void write(Message msg,
- MessageResponseHandler responseHandler) {
- throw new UnsupportedOperationException();
- }
-
-
- public String getId() {
- try {
- return nodeService.getId();
- } catch (RemoteException ex) {
- Logger.getLogger(RioConnector.class.getName()).log(Level.SEVERE, null, ex);
- }
- return null;
- }
-
- public GridNodeExecutionService getCurrentNodeService() {
- return nodeService;
- }
-
-// public List<GridNodeExecutionService> getNodeServices() {
-// return nodeServices;
-// }
-
-
-
-
- public void setSession(Object object) {
- this.nodeService = (GridNodeExecutionService) object;
- try {
- System.out.println("Setting Node Service = " + nodeService.getId());
- } catch (RemoteException ex) {
- Logger.getLogger(RioConnector.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
-
-
-}
Copied: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioServiceConnector.java (from rev 32095, labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioConnector.java)
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioServiceConnector.java (rev 0)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/rio/RioServiceConnector.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -0,0 +1,130 @@
+package org.drools.services.grid.rio;
+
+
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.net.SocketAddress;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.drools.SystemEventListener;
+import org.drools.services.generic.GenericServiceConnector;
+import org.drools.services.generic.Message;
+import org.drools.services.generic.MessageResponseHandler;
+import org.drools.services.grid.ExecutionNodeService;
+
+
+public class RioServiceConnector
+ implements
+ GenericServiceConnector {
+
+ protected final String name;
+ protected AtomicInteger counter;
+ protected ExecutionNodeService nodeService;
+ //protected List<ExecutionNodeService> nodeServices;
+ protected SocketAddress address;
+ protected SystemEventListener eventListener;
+
+ public RioServiceConnector(String name,
+ SystemEventListener eventListener
+ ) {
+ if ( name == null ) {
+ throw new IllegalArgumentException( "Name can not be null" );
+ }
+ this.name = name;
+ this.counter = new AtomicInteger();
+ this.eventListener = eventListener;
+
+ }
+
+ public RioServiceConnector(String name,
+ SystemEventListener eventListener,
+ ExecutionNodeService nodeService
+ ) {
+ if ( name == null ) {
+ throw new IllegalArgumentException( "Name can not be null" );
+ }
+ this.name = name;
+ this.counter = new AtomicInteger();
+ this.eventListener = eventListener;
+ this.nodeService = nodeService;
+ // this.nodeServices = sessionServices;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.vsm.mina.Messenger#connect()
+ */
+ public boolean connect() {
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.vsm.mina.Messenger#disconnect()
+ */
+ public void disconnect() {
+ //I don't need to be disconected
+ }
+
+ public Message write(Message msg) {
+ if ( nodeService != null ) {
+ try {
+
+ Message returnMessage = this.nodeService.write( msg );
+ return returnMessage;
+ // ioHandler.messageReceived( sessionService ,
+ // returnMessage );
+
+ } catch ( RemoteException ex ) {
+ Logger.getLogger( RioServiceConnector.class.getName() ).log( Level.SEVERE,
+ null,
+ ex );
+ } catch ( Exception ex ) {
+ Logger.getLogger( RioServiceConnector.class.getName() ).log( Level.SEVERE,
+ null,
+ ex );
+ }
+ }
+ throw new IllegalStateException( "sessionService should not be null" );
+ }
+
+ public void write(Message msg,
+ MessageResponseHandler responseHandler) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public String getId() {
+ try {
+ return nodeService.getId();
+ } catch (RemoteException ex) {
+ Logger.getLogger(RioServiceConnector.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return null;
+ }
+
+ public ExecutionNodeService getCurrentNodeService() {
+ return nodeService;
+ }
+
+// public List<ExecutionNodeService> getNodeServices() {
+// return nodeServices;
+// }
+
+
+
+
+ public void setSession(Object object) {
+ this.nodeService = (ExecutionNodeService) object;
+ try {
+ System.out.println("Setting Node Service = " + nodeService.getId());
+ } catch (RemoteException ex) {
+ Logger.getLogger(RioServiceConnector.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+
+
+}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/strategies/StaticIncrementalSelectionStrategy.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/strategies/StaticIncrementalSelectionStrategy.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/main/java/org/drools/services/grid/strategies/StaticIncrementalSelectionStrategy.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -17,8 +17,8 @@
package org.drools.services.grid.strategies;
-import org.drools.services.grid.ExecutionGridConnection;
-import org.drools.services.grid.GridNodeExecutionService;
+import org.drools.services.grid.GridConnection;
+import org.drools.services.grid.ExecutionNodeService;
import org.drools.services.grid.GridSelectionStrategy;
/**
@@ -27,16 +27,16 @@
*/
public class StaticIncrementalSelectionStrategy implements GridSelectionStrategy{
public static int counter = 0;
- private ExecutionGridConnection connection;
- public StaticIncrementalSelectionStrategy(ExecutionGridConnection connection) {
+ private GridConnection connection;
+ public StaticIncrementalSelectionStrategy(GridConnection connection) {
this.connection = connection;
}
@Override
- public GridNodeExecutionService getBestNode() {
+ public ExecutionNodeService getBestNode() {
System.out.println("!!!!!GET BEST NODE = "+counter);
- GridNodeExecutionService service = this.connection.getServices().get(counter);
+ ExecutionNodeService service = this.connection.getServices().get(counter);
StaticIncrementalSelectionStrategy.counter = counter +1;
return service;
}
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ExecutionNodeBaseTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ExecutionNodeBaseTest.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ExecutionNodeBaseTest.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -28,8 +28,7 @@
import org.drools.runtime.ExecutionResults;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.builder.DirectoryLookupFactoryService;
-import org.drools.services.grid.ExecutionGridConnection;
-import org.drools.services.grid.KnowledgeBaseProviderGridClient;
+import org.drools.services.grid.GridConnection;
import org.drools.services.grid.strategies.StaticIncrementalSelectionStrategy;
import org.junit.Assert;
import org.junit.Test;
@@ -41,7 +40,7 @@
public abstract class ExecutionNodeBaseTest {
protected ExecutionNode node;
- protected ExecutionGridConnection connection = new ExecutionGridConnection();
+ protected GridConnection connection = new GridConnection();
public ExecutionNodeBaseTest() {
}
@@ -68,22 +67,28 @@
Assert.assertNotNull(node);
- KnowledgeBuilder kbuilder = node.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder();
+ KnowledgeBuilder kbuilder =
+ node.get(KnowledgeBuilderFactoryService.class)
+ .newKnowledgeBuilder();
Assert.assertNotNull(kbuilder);
- kbuilder.add( ResourceFactory.newByteArrayResource( str.getBytes() ),
+ kbuilder.add( ResourceFactory
+ .newByteArrayResource( str.getBytes() ),
ResourceType.DRL );
if ( kbuilder.hasErrors() ) {
System.out.println( "Errors: " + kbuilder.getErrors() );
}
- KnowledgeBase kbase = node.get(KnowledgeBaseFactoryService.class).newKnowledgeBase();
+ KnowledgeBase kbase =
+ node.get(KnowledgeBaseFactoryService.class)
+ .newKnowledgeBase();
Assert.assertNotNull(kbase);
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
- StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ StatefulKnowledgeSession ksession =
+ kbase.newStatefulKnowledgeSession();
Assert.assertNotNull(ksession);
int fired = ksession.fireAllRules();
@@ -265,11 +270,9 @@
node.get(DirectoryLookupFactoryService.class).register( "ksession1", ksession1 );
System.out.println("Let's go for the Second ksession");
+ //Switching to another node
+ node = connection.getExecutionNode(null);
- //((ServiceManagerGridClient)this.client).setCurrentSessionService((SessionService)((ServiceManagerGridClient)this.client).getSessionServices().get(1));
- //If I do this here.. and I don't create a new Kbase. the context got nothing and cannot find the kbase in the new session service.. of course
- node = connection.getExecutionNode();
-
KnowledgeBuilder kbuilder2 = node.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder();
Assert.assertNotNull(kbuilder2);
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ITGridExecutionTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ITGridExecutionTest.java 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/java/org/drools/services/ITGridExecutionTest.java 2010-03-27 15:03:22 UTC (rev 32253)
@@ -8,14 +8,14 @@
import org.drools.builder.KnowledgeBuilderFactoryService;
import org.drools.impl.EnvironmentImpl;
import org.drools.runtime.Environment;
-import org.drools.services.generic.ExecutionNodeData;
-import org.drools.services.grid.ExecutionGridConnection;
+import org.drools.services.generic.NodeData;
+import org.drools.services.grid.GridConnection;
import org.drools.services.grid.GridExecutionNodeConnection;
-import org.drools.services.grid.GridNodeExecutionService;
+import org.drools.services.grid.ExecutionNodeService;
import org.drools.services.grid.KnowledgeBaseProviderGridClient;
import org.drools.services.grid.KnowledgeBuilderProviderGridClient;
import org.drools.services.grid.DirectoryService;
-import org.drools.services.grid.rio.RioConnector;
+import org.drools.services.grid.rio.RioServiceConnector;
@@ -34,59 +34,26 @@
@Before
public void setUp() throws Exception {
- ExecutionNodeData nodeData = new ExecutionNodeData();
+
Assert.assertNotNull(testManager);
- //setup Server
- GridNodeExecutionService nodeService = (GridNodeExecutionService) testManager.waitForService(GridNodeExecutionService.class);
- ServiceItem[] nodeServiceItems = testManager.getServiceItems(GridNodeExecutionService.class);
- //List<GridNodeExecutionService> nodeServices = new ArrayList<GridNodeExecutionService>();
+ //setup all the services using the Rio Test Framework
+ //In real scenarios all this code will happen inside the connection.connect() method
+ ExecutionNodeService nodeService = (ExecutionNodeService) testManager.waitForService(ExecutionNodeService.class);
+ ServiceItem[] nodeServiceItems = testManager.getServiceItems(ExecutionNodeService.class);
System.out.println("Node Service Items =" + nodeServiceItems.length);
-
DirectoryService directoryService = (DirectoryService) testManager.waitForService(DirectoryService.class);
Assert.assertNotNull(directoryService);
connection.addDirectory(directoryService);
-// Environment env = new EnvironmentImpl();
-// env.set("DIRECTORY_SERVICE", directoryService);
-
for (int i = 0; i < nodeServiceItems.length; i++) {
- if (nodeServiceItems[i].service instanceof GridNodeExecutionService) {
-
-
-// System.out.println("Service Item = "+nodeServiceItems[i].service);
-// ExecutionNode node = new ExecutionNode();
-// node.set(KnowledgeBuilderFactoryService.class,
-// new KnowledgeBuilderProviderGridClient(
-// new GridExecutionNodeConnection(
-// ((GridNodeExecutionService)nodeServiceItems[i].service).getId(),
-// new RioConnector("client1",SystemEventListenerFactory.getSystemEventListener(),
-// (GridNodeExecutionService)nodeServiceItems[i].service)
-// ,env),
-// env
-// ));
-// node.set(KnowledgeBaseFactoryService.class,
-// new KnowledgeBaseProviderGridClient(
-// new GridExecutionNodeConnection(
-// ((GridNodeExecutionService)nodeServiceItems[i].service).getId(),
-// new RioConnector("client2",SystemEventListenerFactory.getSystemEventListener(),
-// (GridNodeExecutionService)nodeServiceItems[i].service),
-// env),
-// env
-// ));
-// connection.addNode(node);
-
- connection.addService((GridNodeExecutionService) nodeServiceItems[i].service);
+ if (nodeServiceItems[i].service instanceof ExecutionNodeService) {
+ connection.addService((ExecutionNodeService) nodeServiceItems[i].service);
}
}
-
- // Assert.assertNotNull(nodeServices);
-
-// connection.setDirectory(directoryService);
-
-
- node = connection.getExecutionNode();
+ //Get an execution node using the default/round robin strategy
+ node = connection.getExecutionNode(null);
System.out.println("Node = "+ node);
Modified: labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/resources/org/drools/executionNodeService.groovy
===================================================================
--- labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/resources/org/drools/executionNodeService.groovy 2010-03-27 15:01:57 UTC (rev 32252)
+++ labs/jbossrules/branches/salaboy_ServiceAPIs/drools-services-grid/src/test/resources/org/drools/executionNodeService.groovy 2010-03-27 15:03:22 UTC (rev 32253)
@@ -22,12 +22,12 @@
* Declare the service to be deployed. The number of instances deployed
* defaults to 1. If you require > 1 instances change as needed
*/
- service(name: 'GridNodeExecutionService') {
+ service(name: 'ExecutionNodeService') {
interfaces {
- classes 'org.drools.services.grid.GridNodeExecutionService'
+ classes 'org.drools.services.grid.ExecutionNodeService'
artifact ref:'service-dl'
}
- implementation(class:'org.drools.services.grid.impl.GridNodeExecutionServiceImpl') {
+ implementation(class:'org.drools.services.grid.impl.ExecutionNodeServiceImpl') {
artifact ref:'service'
}
//association (name:'RegistryService', type:'uses', property:'registryService')
@@ -42,7 +42,7 @@
artifact ref:'service'
}
- association (name:'GridNodeExecutionService', type:'uses', property:'nodeServices')
+ association (name:'ExecutionNodeService', type:'uses', property:'nodeServices')
maintain 1
}
More information about the jboss-svn-commits
mailing list