[jboss-cvs] JBossAS SVN: r67216 - in trunk: cluster/src/main/org/jboss/ha/framework/server and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 16 21:40:13 EST 2007


Author: scottmarlownovell
Date: 2007-11-16 21:40:13 -0500 (Fri, 16 Nov 2007)
New Revision: 67216

Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java
   trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockHAPartition.java
Log:
JBAS-4984 Add HAPartition methods for calling a specific cluster targetNode.

Modified: trunk/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java	2007-11-17 02:27:06 UTC (rev 67215)
+++ trunk/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java	2007-11-17 02:40:13 UTC (rev 67216)
@@ -161,10 +161,39 @@
     * @throws Exception Throws if a communication exception occurs
     * @return an array of responses from remote nodes
     */
-      public ArrayList callMethodOnCoordinatorNode(String serviceName, String methodName,
+   public ArrayList callMethodOnCoordinatorNode(String serviceName, String methodName,
              Object[] args, Class[] types, boolean excludeSelf) throws Exception;
 
+    /**
+     * Calls method synchrounously on target node only.
+     * @param serviceName Name of the target service name on which calls are de-multiplexed
+     * @param methodName name of the Java method to be called on remote services
+     * @param args array of Java Object representing the set of parameters to be
+     * given to the remote method
+     * @param types The types of the parameters
+     * node of the partition or only on remote nodes
+     * @param targetNode is the target of the call
+     * @return the value returned by the target method
+     * @throws Exception Throws if a communication exception occurs
+     */
+   public Object callMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable;
 
+   /**
+     * Calls method on target node only.
+     * @param serviceName Name of the target service name on which calls are de-multiplexed
+     * @param methodName name of the Java method to be called on remote services
+     * @param args array of Java Object representing the set of parameters to be
+     * given to the remote method
+     * @param types The types of the parameters
+     * node of the partition or only on remote nodes
+     * @param targetNode is the target of the call
+     * @return none
+     * @throws Exception Throws if a communication exception occurs
+     */
+   public void callAsyncMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable;
+
    // *************************
    // *************************
    // State transfer management

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java	2007-11-17 02:27:06 UTC (rev 67215)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java	2007-11-17 02:40:13 UTC (rev 67216)
@@ -932,7 +932,92 @@
 
       return processResponseList(rsp, trace);
    }
-   
+
+    /**
+     * Calls method synchrounously on target node only.
+     * @param serviceName Name of the target service name on which calls are de-multiplexed
+     * @param methodName name of the Java method to be called on remote services
+     * @param args array of Java Object representing the set of parameters to be
+     * given to the remote method
+     * @param types The types of the parameters
+     * node of the partition or only on remote nodes
+     * @param targetNode is the target of the call
+     * @return the value returned by the target method
+     * @throws Exception Throws if a communication exception occurs
+     */
+   public Object callMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable
+    {
+       MethodCall m;
+       boolean trace = log.isTraceEnabled();
+       if(types != null)
+          m=new MethodCall(serviceName + "." + methodName, args, types);
+       else
+          m=new MethodCall(serviceName + "." + methodName, args);
+       if( trace )
+       {
+          log.trace("callMethodOnNode( objName="+serviceName
+             +", methodName="+methodName);
+       }
+       Object rc = dispatcher.callRemoteMethod(targetNode.getOriginalJGAddress(), m, GroupRequest.GET_FIRST, methodTimeout);
+       if (rc != null)
+       {
+          Object item = rc;
+          if (item instanceof Rsp)
+          {
+             Rsp response = (Rsp) item;
+             // Only include received responses
+             boolean wasReceived = response.wasReceived();
+             if( wasReceived == true )
+             {
+                item = response.getValue();
+                if (!(item instanceof NoHandlerForRPC))
+                   rc = item;
+                }
+                else if( trace )
+                   log.trace("Ignoring non-received response: "+response);
+             }
+             else
+             {
+                if (!(item instanceof NoHandlerForRPC))
+                   rc = item;
+                else if( trace )
+                   log.trace("Ignoring NoHandlerForRPC");
+             }
+          }
+       return rc;
+     }
+
+
+   /**
+     * Calls method on target node only.
+     * @param serviceName Name of the target service name on which calls are de-multiplexed
+     * @param methodName name of the Java method to be called on remote services
+     * @param args array of Java Object representing the set of parameters to be
+     * given to the remote method
+     * @param types The types of the parameters
+     * node of the partition or only on remote nodes
+     * @param targetNode is the target of the call
+     * @return none
+     * @throws Exception Throws if a communication exception occurs
+     */
+   public void callAsyncMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable
+   {
+       MethodCall m;
+       boolean trace = log.isTraceEnabled();
+       if(types != null)
+          m=new MethodCall(serviceName + "." + methodName, args, types);
+       else
+          m=new MethodCall(serviceName + "." + methodName, args);
+       if( trace )
+       {
+          log.trace("callAsyncMethodOnNode( objName="+serviceName
+             +", methodName="+methodName);
+       }
+       dispatcher.callRemoteMethod(targetNode.getOriginalJGAddress(), m, GroupRequest.GET_NONE, methodTimeout);
+   }
+
    private ArrayList processResponseList(RspList rsp, boolean trace)
    {
       ArrayList rtn = new ArrayList();

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockHAPartition.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockHAPartition.java	2007-11-17 02:27:06 UTC (rev 67215)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/MockHAPartition.java	2007-11-17 02:40:13 UTC (rev 67216)
@@ -145,6 +145,20 @@
       throw new UnsupportedOperationException("not implemented");
    }
 
+   public Object callMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable
+   {
+      throw new UnsupportedOperationException("not implemented");
+   }
+
+
+   public void callAsyncMethodOnNode(String serviceName, String methodName,
+           Object[] args, Class[] types, long methodTimeout, ClusterNode targetNode) throws Throwable
+   {
+      throw new UnsupportedOperationException("not implemented");
+   }
+   
+
    public void subscribeToStateTransferEvents(String serviceName, HAPartitionStateTransfer subscriber)
    {
       // no-op. at this point the test fixture directly passes state




More information about the jboss-cvs-commits mailing list