[jboss-svn-commits] JBL Code SVN: r34432 - in labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid: drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl and 12 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Aug 1 20:00:38 EDT 2010


Author: salaboy21
Date: 2010-08-01 20:00:34 -0400 (Sun, 01 Aug 2010)
New Revision: 34432

Added:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DistributedRioNodeConnector.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DirectoryNodeServiceGridClient.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedRioDirectoryConnector.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/configuration/RioProvider.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/manager-config.groovy
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/start-monitor.groovy
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/test-config.groovy
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/java/org/drools/services/ITGridExecutionTest.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/resources/org/drools/executionNodeServiceTest.groovy
Removed:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DirectoryNodeServiceGridClient.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioDirectoryConnector.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioNodeConnector.java
Modified:
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBaseProviderGridClient.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBuilderProviderGridClient.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedConnectionDirectory.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/test/java/org/drools/distributed/directory/ITGridExecutionTest.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-rio/src/test/java/org/drools/grid/distributed/ITGridExecutionTest.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-remote-dir-mina/src/main/java/org/drools/grid/remote/directory/RemoteMinaConnectionDirectory.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/pom.xml
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/GridTopology.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/DirectoryInstanceFactory.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/ExecutionEnvironmentFactory.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerBuilder.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerFactoryHelper.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/TaskServerInstanceFactory.java
   labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/strategies/ExecutionEnvByPrioritySelectionStrategy.java
Log:
adding RioProvider and all the necessary impl for Rio in drools-grid-services

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DirectoryNodeServiceGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DirectoryNodeServiceGridClient.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DirectoryNodeServiceGridClient.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -1,138 +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.grid.distributed;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.drools.KnowledgeBase;
-import org.drools.SystemEventListenerFactory;
-import org.drools.grid.ConnectorException;
-import org.drools.grid.ConnectorType;
-import org.drools.grid.DirectoryNodeService;
-import org.drools.grid.GenericConnection;
-import org.drools.grid.GenericNodeConnector;
-import org.drools.grid.NodeConnectionType;
-import org.drools.grid.internal.Message;
-import org.drools.grid.internal.MessageResponseHandler;
-
-/**
- *
- * @author salaboy
- */
-public class DirectoryNodeServiceGridClient implements DirectoryNodeService {
-    private RioDirectoryConnector client;
-    
-    public DirectoryNodeServiceGridClient(GenericNodeConnector connector, GenericConnection connection) {
-        
-        this.client = new RioDirectoryConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (DirectoryNodeService) connector);
-    }
-
-
-
-    public void register(String executorId, String resourceId) throws ConnectorException, RemoteException {
-        
-        client.register(executorId, resourceId);
-    }
-
-    public void register(String executorId, GenericNodeConnector resourceConnector) throws ConnectorException, RemoteException {
-        
-        client.register(executorId, resourceConnector);
-    }
-
-    public void unregister(String executorId) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public GenericNodeConnector lookup(String resourceId) throws ConnectorException, RemoteException {
-        return client.lookup(resourceId);
-    }
-
-    public String lookupId(String resourceId) throws ConnectorException, RemoteException {
-        return client.lookupId(resourceId);
-    }
-
-    public void registerKBase(String kbaseId, String resourceId) throws ConnectorException, RemoteException {
-        client.registerKBase(kbaseId, resourceId);
-    }
-
-    public void registerKBase(String kbaseId, KnowledgeBase kbase) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public void unregisterKBase(String kbaseId) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public KnowledgeBase lookupKBase(String kbaseId) throws ConnectorException, RemoteException {
-        return client.lookupKBase(kbaseId);
-    }
-
-    public Map<String, String> getExecutorsMap() throws ConnectorException, RemoteException {
-        return client.getExecutorsMap();
-    }
-
-    public Map<String, String> getKBasesMap() throws ConnectorException, RemoteException {
-        return client.getKBasesMap();
-    }
-
-    public void dispose() throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public void connect() throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public void disconnect() throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public Message write(Message msg) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public String getId() throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public GenericConnection getConnection() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public NodeConnectionType getNodeConnectionType() throws ConnectorException, RemoteException {
-        return client.getNodeConnectionType();
-    }
-
-    public ConnectorType getConnectorType() {
-        return client.getConnectorType();
-    }
-
-    public int getSessionId() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public AtomicInteger getCounter() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public void write(Message msg, MessageResponseHandler responseHandler) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-}

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DistributedRioNodeConnector.java (from rev 33963, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioNodeConnector.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DistributedRioNodeConnector.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DistributedRioNodeConnector.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,120 @@
+package org.drools.grid.distributed;
+
+import java.net.SocketAddress;
+import java.rmi.RemoteException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.drools.SystemEventListener;
+import org.drools.grid.ConnectorException;
+import org.drools.grid.ConnectorType;
+import org.drools.grid.GenericConnection;
+import org.drools.grid.NodeConnectionType;
+import org.drools.grid.internal.Message;
+import org.drools.grid.internal.MessageResponseHandler;
+import org.drools.grid.ExecutionNodeService;
+import org.drools.grid.GenericNodeConnector;
+import org.drools.grid.GridConnection;
+
+public class DistributedRioNodeConnector
+        implements GenericNodeConnector {
+
+    protected final String name;
+    protected AtomicInteger counter;
+    protected ExecutionNodeService executionNodeService;
+    protected SocketAddress address;
+    protected SystemEventListener eventListener;
+    protected GenericConnection connection;
+
+    public DistributedRioNodeConnector(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;
+        this.connection = new GridConnection();
+        
+    }
+
+    public DistributedRioNodeConnector(String name,
+            SystemEventListener eventListener,
+            ExecutionNodeService executionNodeService) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name can not be null");
+        }
+        this.name = name;
+        this.counter = new AtomicInteger();
+        this.eventListener = eventListener;
+        this.executionNodeService = executionNodeService;
+        this.connection = new GridConnection();
+
+    }
+
+    
+    public Message write(Message msg) throws ConnectorException, RemoteException {
+        if (executionNodeService != null) {
+
+
+            Message returnMessage = this.executionNodeService.write(msg);
+            return returnMessage;
+
+
+        }
+        throw new IllegalStateException("executionNode should not be null");
+    }
+
+    public void write(Message msg,
+            MessageResponseHandler responseHandler) {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getId() throws ConnectorException, RemoteException {
+
+        return executionNodeService.getId();
+
+
+    }
+
+    public void setExecutionNodeService(ExecutionNodeService executionNode) {
+        this.executionNodeService = executionNode;
+
+
+    }
+
+    public ExecutionNodeService getExecutionNodeService() {
+        return executionNodeService;
+    }
+
+    
+
+    public void connect() throws ConnectorException {
+        //do nothing, here we use auto discover
+    }
+
+    public void disconnect() throws ConnectorException {
+        //I don't need to be disconected
+    }
+
+    public GenericConnection getConnection() {
+        return this.connection;
+    }
+
+    public NodeConnectionType getNodeConnectionType() throws ConnectorException {
+        return new DistributedConnectionNode();
+    }
+
+    public ConnectorType getConnectorType() {
+        return ConnectorType.DISTRIBUTED;
+    }
+
+    public int getSessionId() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public AtomicInteger getCounter() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBaseProviderGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBaseProviderGridClient.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBaseProviderGridClient.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -35,7 +35,8 @@
         
         this.connection = connection;
         this.messageSession = new MessageSession();
-        this.connector = new RioNodeConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (ExecutionNodeService) connector);
+        this.connector = new DistributedRioNodeConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), 
+                                            ((DistributedRioNodeConnector)connector).getExecutionNodeService());
 
     }
 

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBuilderProviderGridClient.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBuilderProviderGridClient.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/KnowledgeBuilderProviderGridClient.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -34,7 +34,8 @@
 
     public KnowledgeBuilderProviderGridClient(GenericNodeConnector connector, GenericConnection connection) {
             this.messageSession = new MessageSession();
-            client = new RioNodeConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), (ExecutionNodeService) connector);
+            client = new DistributedRioNodeConnector("client 1", SystemEventListenerFactory.getSystemEventListener(),
+                                                    ((DistributedRioNodeConnector)connector).getExecutionNodeService());
         
     }
 

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioDirectoryConnector.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioDirectoryConnector.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioDirectoryConnector.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -1,159 +0,0 @@
-package org.drools.grid.distributed;
-
-import java.net.SocketAddress;
-import java.rmi.RemoteException;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.drools.KnowledgeBase;
-
-import org.drools.SystemEventListener;
-import org.drools.grid.ConnectorException;
-import org.drools.grid.ConnectorType;
-import org.drools.grid.DirectoryNodeService;
-import org.drools.grid.GenericConnection;
-import org.drools.grid.NodeConnectionType;
-import org.drools.grid.internal.Message;
-import org.drools.grid.internal.MessageResponseHandler;
-import org.drools.grid.GenericNodeConnector;
-import org.drools.grid.GridConnection;
-
-public class RioDirectoryConnector
-        implements GenericNodeConnector, DirectoryNodeService {
-
-    protected final String name;
-    protected AtomicInteger counter;
-    protected DirectoryNodeService directoryNode;
-    protected SocketAddress address;
-    protected SystemEventListener eventListener;
-
-    public RioDirectoryConnector(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 RioDirectoryConnector(String name,
-            SystemEventListener eventListener,
-            DirectoryNodeService directoryNode) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name can not be null");
-        }
-        this.name = name;
-        this.counter = new AtomicInteger();
-        this.eventListener = eventListener;
-        this.directoryNode = directoryNode;
-
-
-    }
-
-    public Message write(Message msg) throws ConnectorException, RemoteException {
-        if (directoryNode != null) {
-
-
-            Message returnMessage = this.directoryNode.write(msg);
-            return returnMessage;
-
-
-        }
-        throw new IllegalStateException("sessionService should not be null");
-    }
-
-    public void write(Message msg,
-            MessageResponseHandler responseHandler) {
-        throw new UnsupportedOperationException();
-    }
-
-    public String getId() throws ConnectorException, RemoteException {
-
-        return directoryNode.getId();
-
-
-    }
-
-    public void setNodeService(Object object) {
-        this.directoryNode = (DirectoryNodeService) object;
-
-
-    }
-
-    public void connect() throws ConnectorException {
-        //do nothing, here we use auto discover
-    }
-
-    public void disconnect() throws ConnectorException {
-        //I don't need to be disconected
-    }
-
-    public GenericConnection getConnection() {
-        return new GridConnection();
-    }
-
-    public NodeConnectionType getNodeConnectionType() throws ConnectorException {
-        return new DistributedConnectionNode();
-    }
-
-    public ConnectorType getConnectorType() {
-        return ConnectorType.DISTRIBUTED;
-    }
-
-    public int getSessionId() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public AtomicInteger getCounter() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public void register(String executorId, String resourceId) throws ConnectorException, RemoteException {
-        this.directoryNode.register(executorId, resourceId);
-    }
-
-    public void register(String executorId, GenericNodeConnector resourceConnector) throws ConnectorException, RemoteException {
-        this.directoryNode.register(executorId, resourceConnector);
-    }
-
-    public void unregister(String executorId) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public GenericNodeConnector lookup(String resourceId) throws ConnectorException, RemoteException {
-        return this.directoryNode.lookup(resourceId);
-    }
-
-    public String lookupId(String resourceId) throws ConnectorException, RemoteException {
-        return this.directoryNode.lookupId(resourceId);
-    }
-
-    public void registerKBase(String kbaseId, String resourceId) throws ConnectorException, RemoteException {
-        this.directoryNode.registerKBase(kbaseId, resourceId);
-    }
-
-    public void registerKBase(String kbaseId, KnowledgeBase kbase) throws ConnectorException, RemoteException {
-        this.directoryNode.registerKBase(kbaseId, kbase);
-    }
-
-    public void unregisterKBase(String kbaseId) throws ConnectorException, RemoteException {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public KnowledgeBase lookupKBase(String kbaseId) throws ConnectorException, RemoteException {
-        return this.directoryNode.lookupKBase(kbaseId);
-    }
-
-    public Map<String, String> getExecutorsMap() throws ConnectorException, RemoteException {
-        return this.directoryNode.getExecutorsMap();
-    }
-
-    public Map<String, String> getKBasesMap() throws ConnectorException, RemoteException {
-        return this.directoryNode.getKBasesMap();
-    }
-
-    public void dispose() throws ConnectorException, RemoteException {
-        this.directoryNode.dispose();
-    }
-}

Deleted: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioNodeConnector.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioNodeConnector.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioNodeConnector.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -1,110 +0,0 @@
-package org.drools.grid.distributed;
-
-import java.net.SocketAddress;
-import java.rmi.RemoteException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.drools.SystemEventListener;
-import org.drools.grid.ConnectorException;
-import org.drools.grid.ConnectorType;
-import org.drools.grid.GenericConnection;
-import org.drools.grid.NodeConnectionType;
-import org.drools.grid.internal.Message;
-import org.drools.grid.internal.MessageResponseHandler;
-import org.drools.grid.ExecutionNodeService;
-import org.drools.grid.GenericNodeConnector;
-import org.drools.grid.GridConnection;
-
-public class RioNodeConnector
-        implements GenericNodeConnector {
-
-    protected final String name;
-    protected AtomicInteger counter;
-    protected ExecutionNodeService executionNode;
-    protected SocketAddress address;
-    protected SystemEventListener eventListener;
-
-    public RioNodeConnector(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 RioNodeConnector(String name,
-            SystemEventListener eventListener,
-            ExecutionNodeService executionNode) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name can not be null");
-        }
-        this.name = name;
-        this.counter = new AtomicInteger();
-        this.eventListener = eventListener;
-        this.executionNode = executionNode;
-
-
-    }
-
-    
-    public Message write(Message msg) throws ConnectorException, RemoteException {
-        if (executionNode != null) {
-
-
-            Message returnMessage = this.executionNode.write(msg);
-            return returnMessage;
-
-
-        }
-        throw new IllegalStateException("executionNode should not be null");
-    }
-
-    public void write(Message msg,
-            MessageResponseHandler responseHandler) {
-        throw new UnsupportedOperationException();
-    }
-
-    public String getId() throws ConnectorException, RemoteException {
-
-        return executionNode.getId();
-
-
-    }
-
-    public void setNodeService(Object object) {
-        this.executionNode = (ExecutionNodeService) object;
-
-
-    }
-
-    public void connect() throws ConnectorException {
-        //do nothing, here we use auto discover
-    }
-
-    public void disconnect() throws ConnectorException {
-        //I don't need to be disconected
-    }
-
-    public GenericConnection getConnection() {
-        return new GridConnection();
-    }
-
-    public NodeConnectionType getNodeConnectionType() throws ConnectorException {
-        return new DistributedConnectionNode();
-    }
-
-    public ConnectorType getConnectorType() {
-        return ConnectorType.DISTRIBUTED;
-    }
-
-    public int getSessionId() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public AtomicInteger getCounter() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-}

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DirectoryNodeServiceGridClient.java (from rev 34430, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/DirectoryNodeServiceGridClient.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DirectoryNodeServiceGridClient.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DirectoryNodeServiceGridClient.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,139 @@
+/*
+ *  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.distributed.directory.impl;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.drools.KnowledgeBase;
+import org.drools.SystemEventListenerFactory;
+import org.drools.grid.ConnectorException;
+import org.drools.grid.ConnectorType;
+import org.drools.grid.DirectoryNodeService;
+import org.drools.grid.GenericConnection;
+import org.drools.grid.GenericNodeConnector;
+import org.drools.grid.NodeConnectionType;
+import org.drools.grid.internal.Message;
+import org.drools.grid.internal.MessageResponseHandler;
+
+/**
+ *
+ * @author salaboy
+ */
+public class DirectoryNodeServiceGridClient implements DirectoryNodeService {
+    private DistributedRioDirectoryConnector client;
+    
+    public DirectoryNodeServiceGridClient(GenericNodeConnector connector, GenericConnection connection) {
+        
+        this.client = new DistributedRioDirectoryConnector("client 1", SystemEventListenerFactory.getSystemEventListener(), 
+                                ((DistributedRioDirectoryConnector) connector).getDirectoryNodeService());
+    }
+
+
+
+    public void register(String executorId, String resourceId) throws ConnectorException, RemoteException {
+        
+        client.register(executorId, resourceId);
+    }
+
+    public void register(String executorId, GenericNodeConnector resourceConnector) throws ConnectorException, RemoteException {
+        
+        client.register(executorId, resourceConnector);
+    }
+
+    public void unregister(String executorId) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public GenericNodeConnector lookup(String resourceId) throws ConnectorException, RemoteException {
+        return client.lookup(resourceId);
+    }
+
+    public String lookupId(String resourceId) throws ConnectorException, RemoteException {
+        return client.lookupId(resourceId);
+    }
+
+    public void registerKBase(String kbaseId, String resourceId) throws ConnectorException, RemoteException {
+        client.registerKBase(kbaseId, resourceId);
+    }
+
+    public void registerKBase(String kbaseId, KnowledgeBase kbase) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public void unregisterKBase(String kbaseId) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public KnowledgeBase lookupKBase(String kbaseId) throws ConnectorException, RemoteException {
+        return client.lookupKBase(kbaseId);
+    }
+
+    public Map<String, String> getExecutorsMap() throws ConnectorException, RemoteException {
+        return client.getExecutorsMap();
+    }
+
+    public Map<String, String> getKBasesMap() throws ConnectorException, RemoteException {
+        return client.getKBasesMap();
+    }
+
+    public void dispose() throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public void connect() throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public void disconnect() throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public Message write(Message msg) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public String getId() throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public GenericConnection getConnection() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public NodeConnectionType getNodeConnectionType() throws ConnectorException, RemoteException {
+        return client.getNodeConnectionType();
+    }
+
+    public ConnectorType getConnectorType() {
+        return client.getConnectorType();
+    }
+
+    public int getSessionId() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public AtomicInteger getCounter() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public void write(Message msg, MessageResponseHandler responseHandler) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedConnectionDirectory.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedConnectionDirectory.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedConnectionDirectory.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -29,7 +29,6 @@
 import org.drools.grid.GenericConnection;
 import org.drools.grid.GenericNodeConnector;
 import org.drools.grid.NodeConnectionType;
-import org.drools.grid.distributed.DirectoryNodeServiceGridClient;
 
 /**
  *
@@ -55,13 +54,9 @@
     
 
     public void init() {
-        try {
+       
             services.put(DirectoryNodeService.class, new DirectoryNodeServiceGridClient(connector, connection));
-        } catch (ConnectorException ex) {
-            Logger.getLogger(DistributedConnectionDirectory.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (RemoteException ex) {
-            Logger.getLogger(DistributedConnectionDirectory.class.getName()).log(Level.SEVERE, null, ex);
-        }
+       
     }
 
     public Set<Class<?>> getServicesKeys() {

Copied: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedRioDirectoryConnector.java (from rev 34142, labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-api/src/main/java/org/drools/grid/distributed/RioDirectoryConnector.java)
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedRioDirectoryConnector.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/main/java/org/drools/distributed/directory/impl/DistributedRioDirectoryConnector.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,166 @@
+package org.drools.distributed.directory.impl;
+
+import java.net.SocketAddress;
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.drools.KnowledgeBase;
+
+import org.drools.SystemEventListener;
+import org.drools.grid.ConnectorException;
+import org.drools.grid.ConnectorType;
+import org.drools.grid.DirectoryNodeService;
+import org.drools.grid.GenericConnection;
+import org.drools.grid.NodeConnectionType;
+import org.drools.grid.internal.Message;
+import org.drools.grid.internal.MessageResponseHandler;
+import org.drools.grid.GenericNodeConnector;
+import org.drools.grid.GridConnection;
+
+public class DistributedRioDirectoryConnector
+        implements GenericNodeConnector, DirectoryNodeService {
+
+    protected final String name;
+    protected AtomicInteger counter;
+    protected DirectoryNodeService directoryNodeService;
+    protected SocketAddress address;
+    protected SystemEventListener eventListener;
+    protected GenericConnection connection;
+    public DistributedRioDirectoryConnector(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;
+        this.connection = new GridConnection();
+
+    }
+
+    public DistributedRioDirectoryConnector(String name,
+            SystemEventListener eventListener,
+            DirectoryNodeService directoryNode) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name can not be null");
+        }
+        this.name = name;
+        this.counter = new AtomicInteger();
+        this.eventListener = eventListener;
+        this.directoryNodeService = directoryNode;
+        this.connection = new GridConnection(); 
+
+    }
+
+    public Message write(Message msg) throws ConnectorException, RemoteException {
+        if (directoryNodeService != null) {
+
+
+            Message returnMessage = this.directoryNodeService.write(msg);
+            return returnMessage;
+
+
+        }
+        throw new IllegalStateException("sessionService should not be null");
+    }
+
+    public void write(Message msg,
+            MessageResponseHandler responseHandler) {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getId() throws ConnectorException, RemoteException {
+
+        return directoryNodeService.getId();
+
+
+    }
+
+    public void setDirectoryNodeService(DirectoryNodeService directoryNodeService) {
+        this.directoryNodeService = directoryNodeService;
+
+
+    }
+
+    public DirectoryNodeService getDirectoryNodeService() {
+        return directoryNodeService;
+    }
+
+    
+
+    public void connect() throws ConnectorException {
+        //do nothing, here we use auto discover
+    }
+
+    public void disconnect() throws ConnectorException {
+        //I don't need to be disconected
+    }
+
+    public GenericConnection getConnection() {
+        return this.connection;
+    }
+
+    public NodeConnectionType getNodeConnectionType() throws ConnectorException {
+        return new DistributedConnectionDirectory();
+    }
+
+    public ConnectorType getConnectorType() {
+        return ConnectorType.DISTRIBUTED;
+    }
+
+    public int getSessionId() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public AtomicInteger getCounter() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public void register(String executorId, String resourceId) throws ConnectorException, RemoteException {
+        this.directoryNodeService.register(executorId, resourceId);
+    }
+
+    public void register(String executorId, GenericNodeConnector resourceConnector) throws ConnectorException, RemoteException {
+        this.directoryNodeService.register(executorId, resourceConnector);
+    }
+
+    public void unregister(String executorId) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public GenericNodeConnector lookup(String resourceId) throws ConnectorException, RemoteException {
+        return this.directoryNodeService.lookup(resourceId);
+    }
+
+    public String lookupId(String resourceId) throws ConnectorException, RemoteException {
+        return this.directoryNodeService.lookupId(resourceId);
+    }
+
+    public void registerKBase(String kbaseId, String resourceId) throws ConnectorException, RemoteException {
+        this.directoryNodeService.registerKBase(kbaseId, resourceId);
+    }
+
+    public void registerKBase(String kbaseId, KnowledgeBase kbase) throws ConnectorException, RemoteException {
+        this.directoryNodeService.registerKBase(kbaseId, kbase);
+    }
+
+    public void unregisterKBase(String kbaseId) throws ConnectorException, RemoteException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public KnowledgeBase lookupKBase(String kbaseId) throws ConnectorException, RemoteException {
+        return this.directoryNodeService.lookupKBase(kbaseId);
+    }
+
+    public Map<String, String> getExecutorsMap() throws ConnectorException, RemoteException {
+        return this.directoryNodeService.getExecutorsMap();
+    }
+
+    public Map<String, String> getKBasesMap() throws ConnectorException, RemoteException {
+        return this.directoryNodeService.getKBasesMap();
+    }
+
+    public void dispose() throws ConnectorException, RemoteException {
+        this.directoryNodeService.dispose();
+    }
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/test/java/org/drools/distributed/directory/ITGridExecutionTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/test/java/org/drools/distributed/directory/ITGridExecutionTest.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-dir-rio/src/test/java/org/drools/distributed/directory/ITGridExecutionTest.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -4,9 +4,12 @@
 import org.drools.grid.AcceptorService;
 import junit.framework.Assert;
 import net.jini.core.lookup.ServiceItem;
+import org.drools.SystemEventListenerFactory;
+import org.drools.distributed.directory.impl.DistributedRioDirectoryConnector;
 
 import org.drools.grid.DirectoryNodeService;
 import org.drools.grid.ExecutionNodeService;
+import org.drools.grid.distributed.DistributedRioNodeConnector;
 import org.junit.After;
 
 
@@ -35,7 +38,9 @@
         Assert.assertNotNull(directoryService);
 
 
-        connection.addDirectoryNode(directoryService);
+        connection.addDirectoryNode(new DistributedRioDirectoryConnector("directory1",
+                                SystemEventListenerFactory.getSystemEventListener(), 
+                                directoryService));
 
         ExecutionNodeService executionNode = (ExecutionNodeService) testManager.waitForService(ExecutionNodeService.class);
         ServiceItem[] nodeServiceItems = testManager.getServiceItems(ExecutionNodeService.class);
@@ -43,7 +48,9 @@
 
         for (int i = 0; i < nodeServiceItems.length; i++) {
             if (nodeServiceItems[i].service instanceof ExecutionNodeService) {
-                connection.addExecutionNode((ExecutionNodeService) nodeServiceItems[i].service);
+                connection.addExecutionNode(new DistributedRioNodeConnector("node"+i, 
+                            SystemEventListenerFactory.getSystemEventListener(),
+                            (ExecutionNodeService) nodeServiceItems[i].service));
             }
         }
 

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-rio/src/test/java/org/drools/grid/distributed/ITGridExecutionTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-rio/src/test/java/org/drools/grid/distributed/ITGridExecutionTest.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-distributed-rio/src/test/java/org/drools/grid/distributed/ITGridExecutionTest.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -8,6 +8,8 @@
 import junit.framework.Assert;
 
 import net.jini.core.lookup.ServiceItem;
+import org.drools.SystemEventListenerFactory;
+import org.drools.distributed.directory.impl.DistributedRioDirectoryConnector;
 import org.drools.grid.DirectoryNodeService;
 import org.junit.After;
 
@@ -41,7 +43,9 @@
 //
         waitForRule(gnostic, "SLAKsessions");
         
-        connection.addDirectoryNode(directoryService);
+        connection.addDirectoryNode(new DistributedRioDirectoryConnector("directory1", 
+                                        SystemEventListenerFactory.getSystemEventListener(),
+                                        directoryService));
 
         ExecutionNodeService executionNode = (ExecutionNodeService) testManager.waitForService(ExecutionNodeService.class);
         ServiceItem[] nodeServiceItems = testManager.getServiceItems(ExecutionNodeService.class);
@@ -49,7 +53,9 @@
 
         for (int i = 0; i < nodeServiceItems.length; i++) {
             if (nodeServiceItems[i].service instanceof ExecutionNodeService) {
-                connection.addExecutionNode((ExecutionNodeService) nodeServiceItems[i].service);
+                connection.addExecutionNode(new DistributedRioNodeConnector("node"+i,
+                                SystemEventListenerFactory.getSystemEventListener(),
+                                (ExecutionNodeService) nodeServiceItems[i].service));
             }
         }
 

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-remote-dir-mina/src/main/java/org/drools/grid/remote/directory/RemoteMinaConnectionDirectory.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-remote-dir-mina/src/main/java/org/drools/grid/remote/directory/RemoteMinaConnectionDirectory.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-remote-dir-mina/src/main/java/org/drools/grid/remote/directory/RemoteMinaConnectionDirectory.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -29,7 +29,7 @@
  *
  * @author salaboy
  */
-class RemoteMinaConnectionDirectory implements NodeConnectionType {
+public class RemoteMinaConnectionDirectory implements NodeConnectionType {
 
     private final Map<Class<?>, Object> services = new ConcurrentHashMap<Class<?>, Object>();
     private GenericNodeConnector connector;

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/pom.xml
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/pom.xml	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/pom.xml	2010-08-02 00:00:34 UTC (rev 34432)
@@ -40,7 +40,7 @@
             <type>jar</type>
         </dependency>
 
-         <dependency>
+        <dependency>
             <groupId>org.drools</groupId>
             <artifactId>drools-grid-remote-dir-mina</artifactId>
             <version>5.1.0.SNAPSHOT</version>
@@ -53,6 +53,27 @@
             <version>5.1.0.SNAPSHOT</version>
             <type>jar</type>
         </dependency>
+
+
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-grid-distributed-api</artifactId>
+            <version>5.1.0.SNAPSHOT</version>
+            <type>jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-grid-distributed-rio</artifactId>
+            <version>5.1.0.SNAPSHOT</version>
+            <type>jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-grid-distributed-dir-rio</artifactId>
+            <version>5.1.0.SNAPSHOT</version>
+            <type>jar</type>
+        </dependency>
         
         <!-- Test deps -->
         <dependency>
@@ -61,6 +82,13 @@
             <version>4.8.1</version>
             <scope>test</scope>
         </dependency>
+         <!-- RIO Test framework -->
+        <dependency>
+            <groupId>org.rioproject</groupId>
+            <artifactId>rio-test</artifactId>
+            <version>4.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
        
     </dependencies>
 

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/GridTopology.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/GridTopology.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/GridTopology.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -32,6 +32,7 @@
     private Map<String, String> executionEnvironmentsByConnectorId = new HashMap<String, String>();
     private Map<String, DirectoryInstance> directories = new HashMap<String, DirectoryInstance>();
     private Map<String, TaskServerInstance> taskServerInstance = new HashMap<String, TaskServerInstance>();
+
     private final ExecutionEnvironmentSelectionStrategy DEFAULT_EXECTUTION_STRATEGY = new ExecutionEnvByPrioritySelectionStrategy();
     private final DirectoryInstanceSelectionStrategy DEFAULT_DIRECTORY_STRATEGY = new DirectoryInstanceByPrioritySelectionStrategy();
     private final TaskServerInstanceSelectionStrategy DEFAULT_TASK_STRATEGY = new TaskServerInstanceByPrioritySelectionStrategy();
@@ -60,10 +61,14 @@
         //We need to add all the other exec envs connectors inside this connection
         for (ExecutionEnvironment e : executionEnvironments.values()) {
             connection.addExecutionNode(e.getConnector());
+            //I need to add this execution node to all the other EE
+            e.getConnector().getConnection().addExecutionNode(connector);
         }
         //We need to add all the other directory connectors inside this connection
         for (DirectoryInstance d : directories.values()) {
             connection.addDirectoryNode(d.getConnector());
+            //I need to add this execution node to all the other DI
+            d.getConnector().getConnection().addExecutionNode(connector);
         }
         //Adding the env to the local cache
         executionEnvironments.put(name, environment);
@@ -126,9 +131,13 @@
 
         for (ExecutionEnvironment e : executionEnvironments.values()) {
             connection.addExecutionNode(e.getConnector());
+            //I need to add this directory instance to all the other EE
+            e.getConnector().getConnection().addDirectoryNode(connector);
         }
         for (DirectoryInstance d : directories.values()) {
             connection.addDirectoryNode(d.getConnector());
+            //I need to add this directory Instance to all the other DI
+            d.getConnector().getConnection().addDirectoryNode(connector);
         }
 
         

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/configuration/RioProvider.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/configuration/RioProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/configuration/RioProvider.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,117 @@
+/*
+ *  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.grid.services.configuration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.discovery.LookupDiscoveryManager;
+import net.jini.lease.LeaseRenewalManager;
+import net.jini.lookup.ServiceDiscoveryManager;
+import org.drools.grid.DirectoryNodeService;
+import org.drools.grid.ExecutionNodeService;
+
+/**
+ *
+ * @author salaboy
+ */
+public class RioProvider extends GenericProvider {
+
+    private List<ExecutionNodeService> executionNodes;
+    private List<DirectoryNodeService> directoryNodes;
+
+    public RioProvider(List<ExecutionNodeService> executionNodes, List<DirectoryNodeService> directoryNodes) {
+        this.executionNodes = executionNodes;
+        this.directoryNodes = directoryNodes;
+    }
+
+    public RioProvider() {
+        this.executionNodes = new ArrayList<ExecutionNodeService>();
+        this.directoryNodes = new ArrayList<DirectoryNodeService>();
+    }
+
+    @Override
+    public String getId() {
+        return "RioProvider:";
+    }
+
+    @Override
+    public ProviderType getProviderType() {
+        return ProviderType.DistributedRio;
+    }
+
+    public ExecutionNodeService getExecutionNode() {
+        return executionNodes.get(0);
+    }
+
+    public DirectoryNodeService getDirectoryNode() {
+        return directoryNodes.get(0);
+    }
+
+    public List<ExecutionNodeService> getExecutionNodes() {
+        return executionNodes;
+    }
+
+    public List<DirectoryNodeService> getDirectoryNodes() {
+        return directoryNodes;
+    }
+
+    public void lookupExecutionNodeServices() throws IOException, InterruptedException {
+        Class[] classes = new Class[]{ExecutionNodeService.class};
+        ServiceTemplate tmpl = new ServiceTemplate(null, classes, null);
+        LookupDiscoveryManager ldm =
+                new LookupDiscoveryManager(LookupDiscoveryManager.ALL_GROUPS,
+                null,
+                null);
+        System.out.println("Discovering ExecutionNodeService  services ...");
+        ServiceDiscoveryManager sdm =
+                new ServiceDiscoveryManager(ldm, new LeaseRenewalManager());
+        /* Wait no more then 10 seconds to discover the service */
+        ServiceItem[] items = sdm.lookup(tmpl, 1,100, null, 30000);
+        System.out.println("Service  items.lenght"+items.length);
+
+        for (int i = 0; i < items.length; i++) {
+            if (items[i].service instanceof ExecutionNodeService) {
+                executionNodes.add((ExecutionNodeService) items[i].service);
+            }
+        }
+    }
+
+    public void lookupDirectoryNodeServices() throws IOException, InterruptedException {
+        Class[] classes = new Class[]{DirectoryNodeService.class};
+        ServiceTemplate tmpl = new ServiceTemplate(null, classes, null);
+        LookupDiscoveryManager ldm =
+                new LookupDiscoveryManager(LookupDiscoveryManager.ALL_GROUPS,
+                null,
+                null);
+        System.out.println("Discovering DirectoryNodeService services ...");
+        ServiceDiscoveryManager sdm =
+                new ServiceDiscoveryManager(ldm, new LeaseRenewalManager());
+        /* Wait no more then 10 seconds to discover the service */
+        ServiceItem[] items = sdm.lookup(tmpl, 1,100, null, 30000);
+        System.out.println("Service  items.lenght"+items.length);
+
+        for (int i = 0; i < items.length; i++) {
+            
+            if (items[i].service instanceof DirectoryNodeService) {
+                directoryNodes.add((DirectoryNodeService) items[i].service);
+            }
+        }
+    }
+}

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/DirectoryInstanceFactory.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/DirectoryInstanceFactory.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/DirectoryInstanceFactory.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -16,14 +16,18 @@
  */
 package org.drools.grid.services.factory;
 
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.drools.SystemEventListenerFactory;
-import org.drools.grid.DirectoryNodeLocalImpl;
+import org.drools.distributed.directory.impl.DistributedRioDirectoryConnector;
 import org.drools.grid.local.LocalDirectoryConnector;
 import org.drools.grid.remote.directory.RemoteMinaDirectoryConnector;
 
 import org.drools.grid.services.DirectoryInstance;
 import org.drools.grid.services.configuration.GenericProvider;
 import org.drools.grid.services.configuration.MinaProvider;
+import org.drools.grid.services.configuration.RioProvider;
 
 public class DirectoryInstanceFactory {
 
@@ -57,9 +61,19 @@
         }
 
         @Override
-        public DirectoryInstance onRioProvider() {
-//          return new DirectoryInstance(name, new DistributedRioDirectoryConnector(name);
-            return null;
+        public DirectoryInstance onRioProvider(RioProvider rioProvider) {
+            try {
+                rioProvider.lookupDirectoryNodeServices();
+            } catch (IOException ex) {
+                Logger.getLogger(ExecutionEnvironmentFactory.class.getName()).log(Level.SEVERE, null, ex);
+            } catch (InterruptedException ex) {
+                Logger.getLogger(ExecutionEnvironmentFactory.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            return new DirectoryInstance(name,
+                    new DistributedRioDirectoryConnector(name,
+                            SystemEventListenerFactory.getSystemEventListener(),
+                            rioProvider.getDirectoryNode()));
+            
         }
 
         @Override

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/ExecutionEnvironmentFactory.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/ExecutionEnvironmentFactory.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/ExecutionEnvironmentFactory.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -16,12 +16,17 @@
  */
 package org.drools.grid.services.factory;
 
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.drools.SystemEventListenerFactory;
+import org.drools.grid.distributed.DistributedRioNodeConnector;
 import org.drools.grid.local.LocalNodeConnector;
 import org.drools.grid.remote.mina.RemoteMinaNodeConnector;
 import org.drools.grid.services.ExecutionEnvironment;
 import org.drools.grid.services.configuration.GenericProvider;
 import org.drools.grid.services.configuration.MinaProvider;
+import org.drools.grid.services.configuration.RioProvider;
 
 public class ExecutionEnvironmentFactory {
 
@@ -49,14 +54,24 @@
         public ExecutionEnvironment onMinaProvider(MinaProvider provider) {
             return new ExecutionEnvironment(name,
                     new RemoteMinaNodeConnector(name,
-                    ((MinaProvider) provider).getProviderAddress(),
-                    ((MinaProvider) provider).getProviderPort(),
+                     provider.getProviderAddress(),
+                     provider.getProviderPort(),
                     SystemEventListenerFactory.getSystemEventListener()));
         }
 
         @Override
-        public ExecutionEnvironment onRioProvider() {
-            return null;
+        public ExecutionEnvironment onRioProvider(RioProvider rioProvider) {
+            try {
+                rioProvider.lookupExecutionNodeServices();
+            } catch (IOException ex) {
+                Logger.getLogger(ExecutionEnvironmentFactory.class.getName()).log(Level.SEVERE, null, ex);
+            } catch (InterruptedException ex) {
+                Logger.getLogger(ExecutionEnvironmentFactory.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            return new ExecutionEnvironment(name, 
+                    new DistributedRioNodeConnector(name,
+                        SystemEventListenerFactory.getSystemEventListener(),
+                        rioProvider.getExecutionNode()));
         }
 
         @Override

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerBuilder.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerBuilder.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerBuilder.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -1,6 +1,7 @@
 package org.drools.grid.services.factory;
 
 import org.drools.grid.services.configuration.MinaProvider;
+import org.drools.grid.services.configuration.RioProvider;
 
 public interface GenericProviderContainerBuilder<T> {
 
@@ -10,6 +11,6 @@
 
 	T onHornetQProvider();
 
-	T onRioProvider();
+	T onRioProvider(RioProvider provider);
 
 }

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerFactoryHelper.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerFactoryHelper.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/GenericProviderContainerFactoryHelper.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -2,6 +2,7 @@
 
 import org.drools.grid.services.configuration.GenericProvider;
 import org.drools.grid.services.configuration.MinaProvider;
+import org.drools.grid.services.configuration.RioProvider;
 
 public class GenericProviderContainerFactoryHelper {
 
@@ -17,7 +18,7 @@
             	return builder.onHornetQProvider();
             }
             case DistributedRio: {
-            	return builder.onRioProvider();
+            	return builder.onRioProvider((RioProvider)provider);
             }
         }
         throw new IllegalArgumentException("Unmatcheable provider " + provider.getProviderType().name());

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/TaskServerInstanceFactory.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/TaskServerInstanceFactory.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/factory/TaskServerInstanceFactory.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -21,6 +21,7 @@
 import org.drools.grid.services.TaskServerInstance;
 import org.drools.grid.services.configuration.GenericProvider;
 import org.drools.grid.services.configuration.MinaProvider;
+import org.drools.grid.services.configuration.RioProvider;
 import org.drools.grid.task.RemoteMinaHumanTaskConnector;
 
 public class TaskServerInstanceFactory {
@@ -56,7 +57,7 @@
 		}
 
 		@Override
-		public TaskServerInstance onRioProvider() {
+		public TaskServerInstance onRioProvider(RioProvider rioProvider) {
             throw new UnsupportedOperationException("We don't have a Distributed Rio implementation for the Task Service. Yet!");
 		}
     	

Modified: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/strategies/ExecutionEnvByPrioritySelectionStrategy.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/strategies/ExecutionEnvByPrioritySelectionStrategy.java	2010-08-01 05:57:46 UTC (rev 34431)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/main/java/org/drools/grid/services/strategies/ExecutionEnvByPrioritySelectionStrategy.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -40,7 +40,7 @@
 
                 {
                     put(ConnectorType.LOCAL, 1);
-                    // put("RioEnvironmentProvider", 2);
+                    put(ConnectorType.DISTRIBUTED, 2);
                     // put("HornetQEnvironmentProvider", 3);
                     put(ConnectorType.REMOTE, 4);
                 }

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/manager-config.groovy
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/manager-config.groovy	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/manager-config.groovy	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,53 @@
+/*
+ * Copyright to the original author or authors.
+ *
+ * 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.
+ */
+
+import org.rioproject.config.Constants
+
+/*
+* Configuration properties for the Gnostic
+*/
+manager {
+    execClassPath =
+        '${RIO_HOME}${/}lib${/}boot.jar${:}${RIO_HOME}${/}lib/${/}start.jar${:}${JAVA_HOME}${/}lib${/}tools.jar${:}${RIO_HOME}${/}lib${/}groovy-all.jar'
+
+    inheritOptions = true
+
+    jvmOptions = '''
+        -XX:+UseConcMarkSweepGC -XX:+AggressiveOpts
+        -Djava.security.policy=${RIO_HOME}${/}policy${/}policy.all
+        -DRIO_HOME=${RIO_HOME} -Dorg.rioproject.groups=${org.rioproject.groups}'''
+
+    mainClass = 'com.sun.jini.start.ServiceStarter'
+
+    /* The ${service} token will be replaced by the name of the starter file.
+     * For start-reggie the service name will be reggie, for start-monitor the
+     * service name will be monitor, etc ... */
+    String logExt = System.getProperty(Constants.GROUPS_PROPERTY_NAME,
+                                       System.getProperty('user.name'))
+    String logDir = '/tmp/logs/rio/'
+    String opSys = System.getProperty('os.name')
+    if(opSys.startsWith("Windows"))
+        logDir = '${java.io.tmpdir}/logs/rio/'
+    log = logDir + logExt + '/${service}.log'
+
+    /*
+    * Remove any previously created service log files
+    */
+    cleanLogs = true
+
+    monitorStarter = '${user.dir}${/}src${/}test${/}conf${/}start-monitor.groovy'
+    cybernodeStarter = '${RIO_HOME}/config/start-cybernode.groovy'
+}
\ No newline at end of file

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/start-monitor.groovy
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/start-monitor.groovy	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/start-monitor.groovy	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,38 @@
+/*
+ * This configuration is used by the com.sun.jini.start utility to start a
+ * ProvisionMonitor, including an embedded Webster
+ */
+
+import org.rioproject.config.Component
+
+import org.rioproject.boot.ServiceDescriptorUtil;
+import com.sun.jini.start.ServiceDescriptor;
+
+ at Component('com.sun.jini.start')
+class StartMonitorConfig {
+
+    ServiceDescriptor[] getServiceDescriptors() {
+        String m2Home = "${System.getProperty("user.home")}/.m2"
+        String rioHome = System.getProperty('RIO_HOME')
+        String cwd = System.getProperty('user.dir')
+        println "\n********\n$cwd\n********"
+        
+        def websterRoots = [rioHome+'/lib-dl', ';',
+                            rioHome+'/lib',     ';',
+                            m2Home+'/repository', ';',
+                            cwd+'/target/']
+
+        String policyFile = rioHome+'/policy/policy.all'
+        String monitorConfig = rioHome+'/config/monitor.groovy'
+        String reggieConfig = rioHome+'/config/reggie.groovy'
+
+        def serviceDescriptors = [
+            ServiceDescriptorUtil.getWebster(policyFile, '0', (String[])websterRoots),
+            ServiceDescriptorUtil.getLookup(policyFile, reggieConfig),
+            ServiceDescriptorUtil.getMonitor(policyFile, monitorConfig)
+        ]
+
+        return (ServiceDescriptor[])serviceDescriptors
+    }
+
+}

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/test-config.groovy
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/test-config.groovy	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/conf/test-config.groovy	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,13 @@
+/*
+ * Configuration file for integration test cases
+ */
+ITGridExecutionTest {
+    groups = "ITGridExecutionTest"
+    numCybernodes = 1
+    numMonitors = 1
+    //numLookups = 1
+    opstring = 'src/test/resources/org/drools/executionNodeServiceTest.groovy'
+    autoDeploy = true
+    //harvest = true
+}
+

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/java/org/drools/services/ITGridExecutionTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/java/org/drools/services/ITGridExecutionTest.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/java/org/drools/services/ITGridExecutionTest.java	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,220 @@
+/*
+ *  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;
+
+import java.io.IOException;
+import org.junit.Assert;
+import org.drools.grid.services.configuration.GenericProvider;
+
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+import net.jini.core.lookup.ServiceItem;
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactoryService;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactoryService;
+import org.drools.builder.ResourceType;
+import org.drools.grid.AcceptorService;
+import org.drools.grid.ConnectorException;
+import org.drools.grid.DirectoryNodeService;
+import org.drools.grid.ExecutionNode;
+import org.drools.grid.ExecutionNodeService;
+import org.drools.grid.services.ExecutionEnvironment;
+import org.drools.grid.services.GridTopology;
+import org.drools.grid.services.configuration.LocalProvider;
+import org.drools.grid.services.configuration.RioProvider;
+import org.drools.grid.services.strategies.ExecutionEnvByPrioritySelectionStrategy;
+import org.drools.io.ResourceFactory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.rioproject.gnostic.Gnostic;
+import org.rioproject.sla.RuleMap;
+import org.rioproject.test.RioTestRunner;
+import org.rioproject.test.SetTestManager;
+import org.rioproject.test.TestManager;
+
+/**
+ *
+ * @author salaboy
+ */
+ at RunWith(RioTestRunner.class)
+public class ITGridExecutionTest {
+
+    AcceptorService server;
+    @SetTestManager
+    static TestManager testManager;
+    private GridTopology grid;
+    private List<ExecutionNodeService> executionNodes = new ArrayList<ExecutionNodeService>();
+    private List<DirectoryNodeService> directoryNodes = new ArrayList<DirectoryNodeService>();
+    
+    public ITGridExecutionTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws IOException {
+        Assert.assertNotNull(testManager);
+//        //setup all the services using the Rio Test Framework
+//        //In real scenarios all this code will happen inside the connection.connect() method
+//
+        DirectoryNodeService directoryService = (DirectoryNodeService) testManager.waitForService(DirectoryNodeService.class);
+        Assert.assertNotNull(directoryService);
+        directoryNodes.add(directoryService);
+        Gnostic gnostic = (Gnostic)testManager.waitForService(Gnostic.class);
+//
+        waitForRule(gnostic, "SLAKsessions");
+
+       // connection.addDirectoryNode(directoryService);
+
+        ExecutionNodeService executionNode = (ExecutionNodeService) testManager.waitForService(ExecutionNodeService.class);
+        Assert.assertNotNull(executionNode);
+        ServiceItem[] nodeServiceItems = testManager.getServiceItems(ExecutionNodeService.class);
+        System.out.println("ExecutionNodes Items =" + nodeServiceItems.length);
+
+        for (int i = 0; i < nodeServiceItems.length; i++) {
+            if (nodeServiceItems[i].service instanceof ExecutionNodeService) {
+                executionNodes.add((ExecutionNodeService) nodeServiceItems[i].service);
+            }
+        }
+
+    }
+
+    @After
+    public void tearDown() throws ConnectorException, RemoteException {
+        System.out.println("Disconecting all clients");
+        grid.dispose();
+        
+        
+    }
+
+    
+     @Test
+     public void rioProviderTest() throws ConnectorException, RemoteException {
+        grid = new GridTopology("MyBusinessUnit");
+       
+        
+        GenericProvider rioProvider = new RioProvider();
+        GenericProvider rioDirProvider = new RioProvider();
+        
+
+        grid.registerExecutionEnvironment("MyRioEnv", rioProvider);
+        grid.registerDirectoryInstance("MyRioDir", rioDirProvider);
+
+       
+
+        ExecutionEnvironment ee = grid.getBestExecutionEnvironment(new ExecutionEnvByPrioritySelectionStrategy());
+        Assert.assertNotNull(ee);
+        System.out.println("EE Name = "+ee.getName());
+        System.out.println("Connector Id = "+ee.getConnector().getId());
+
+        ExecutionNode node = ee.getExecutionNode();
+        Assert.assertNotNull(node);
+
+         // Do a basic Runtime Test that register a ksession and fire some rules.
+        String str = "";
+        str += "package org.drools \n";
+        str += "global java.util.List list \n";
+        str += "rule rule1 \n";
+        str += "    dialect \"java\" \n";
+        str += "when \n";
+        str += "then \n";
+        str += "    System.out.println( \"hello1!!!\" ); \n";
+        str += "end \n";
+        str += "rule rule2 \n";
+        str += "    dialect \"java\" \n";
+        str += "when \n";
+        str += "then \n";
+        str += "    System.out.println( \"hello2!!!\" ); \n";
+        str += "end \n";
+
+
+        KnowledgeBuilder kbuilder =
+                node.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder();
+        kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()),
+                ResourceType.DRL);
+
+        if (kbuilder.hasErrors()) {
+            System.out.println("Errors: " + kbuilder.getErrors());
+        }
+
+        KnowledgeBase kbase =
+                node.get(KnowledgeBaseFactoryService.class).newKnowledgeBase();
+        Assert.assertNotNull(kbase);
+
+        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+        Assert.assertNotNull(ksession);
+
+        int fired = ksession.fireAllRules();
+        Assert.assertEquals(2, fired);
+
+
+
+
+
+     }
+
+      private void waitForRule(Gnostic g, String rule) {
+        Throwable thrown = null;
+        long t0 = System.currentTimeMillis();
+        try {
+            while (!hasRule(g.get(), rule)) {
+                sleep(500);
+            }
+        } catch (RemoteException e) {
+            e.printStackTrace();
+            thrown = e;
+        }
+        Assert.assertNull(thrown);
+        System.out.println("Rule loaded in " + (System.currentTimeMillis() - t0) + " millis");
+    }
+
+     private boolean hasRule(List<RuleMap> ruleMaps, String rule) {
+        boolean hasRule = false;
+        for (RuleMap ruleMap : ruleMaps) {
+            System.out.println("===> rule: " + ruleMap.getRuleDefinition().getResource());
+            if (ruleMap.getRuleDefinition().getResource().indexOf(rule) != -1) {
+                hasRule = true;
+                break;
+            }
+        }
+        return hasRule;
+    }
+    public static void sleep(long l) {
+        try {
+            Thread.sleep(l);
+        } catch (InterruptedException e) {
+
+        }
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/resources/org/drools/executionNodeServiceTest.groovy
===================================================================
--- labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/resources/org/drools/executionNodeServiceTest.groovy	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_drools_grid_api_separation/drools-grid/drools-grid-services/src/test/resources/org/drools/executionNodeServiceTest.groovy	2010-08-02 00:00:34 UTC (rev 34432)
@@ -0,0 +1,68 @@
+import org.rioproject.config.Constants
+import java.util.logging.Level
+
+import org.rioproject.resources.servicecore.Service
+import org.rioproject.system.SystemWatchID
+
+deployment(name:'executionNodeService',  debug: 'true') {
+
+    //logging {
+        //logger 'org.rioproject.resolver', Level.FINEST
+        //logger 'org.rioproject.associations' , Level.FINEST
+        //logger 'org.rioproject.gnostic', Level.FINEST
+    //}
+    /* 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 */
+    groups System.getProperty(Constants.GROUPS_PROPERTY_NAME,
+                              System.getProperty('user.name'))
+
+    /* Declares the artifacts required for deployment. Note the 'dl'
+     * classifier used for the 'download' jar */
+    artifact id:'service-dir', 'org.drools:drools-grid-distributed-dir-rio:5.1.0.SNAPSHOT'
+    artifact id:'service-dir-dl', 'org.drools:drools-grid-distributed-dir-rio:dl:5.1.0.SNAPSHOT'
+    artifact id:'service', 'org.drools:drools-grid-distributed-rio:5.1.0.SNAPSHOT'
+    artifact id:'service-dl', 'org.drools:drools-grid-distributed-rio:dl:5.1.0.SNAPSHOT'
+
+    /*
+     * Declare the service to be deployed. The number of instances deployed
+     * defaults to 1. If you require > 1 instances change as needed
+     */
+    service(name: 'ExecutionNodeService', fork: 'yes') { //fork yes, works only in unix machines
+        interfaces {
+            classes 'org.drools.grid.ExecutionNodeService'
+            artifact ref:'service-dl'
+        }
+        implementation(class:'org.drools.grid.distributed.impl.ExecutionNodeServiceImpl') {
+            artifact ref:'service'
+        }
+
+        maintain 2
+    }
+    service(name: 'DirectoryNodeService') {
+        interfaces {
+            classes 'org.drools.grid.DirectoryNodeService'
+            artifact ref:'service-dir-dl'
+        }
+        implementation(class:'org.drools.distributed.directory.impl.DirectoryNodeServiceImpl') {
+            artifact ref:'service-dir'
+        }
+
+        association (name:'ExecutionNodeService', type:'uses', property:'executionNodes')
+
+        maintain 1
+    }
+
+    rules {
+        rule{
+            resource 'SLAKsessions'
+            ruleClassPath 'org.drools:drools-grid-distributed-rio:5.1.0.SNAPSHOT'
+            serviceFeed(name: "ExecutionNodeService") {
+                watches "ksessionCounter"
+                //, ${SystemWatchID.SYSTEM_CPU}, ${SystemWatchID.JVM_MEMORY}"
+            }
+        }
+    }
+
+
+}
\ No newline at end of file



More information about the jboss-svn-commits mailing list