Author: mattmann
Date: Sun Jun  5 04:58:20 2011
New Revision: 1131693

URL: http://svn.apache.org/viewvc?rev=1131693&view=rev
Log:
- patch for OODT-182 Add ability to change node capacity during execution 
contributed by Gabe Resneck

Modified:
    oodt/trunk/CHANGES.txt
    
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java
    
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java

Modified: oodt/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1131693&r1=1131692&r2=1131693&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sun Jun  5 04:58:20 2011
@@ -4,6 +4,8 @@ Apache OODT Change Log
 Release 0.3-SNAPSHOT (in progress)
 --------------------------------------------
 
+* OODT-182 Add ability to change node capacity during execution (Gabe Resneck 
via mattmann)
+
 * OODT-162 Parametric Data Model File Manager Catalog (mattmann, ahart, 
cgoodale)
 
 * OODT-195 XMLValidationLayer: Elements Map and ProductType to Element 

Modified: 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java?rev=1131693&r1=1131692&r2=1131693&view=diff
==============================================================================
--- 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java
 (original)
+++ 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java
 Sun Jun  5 04:58:20 2011
@@ -337,6 +337,17 @@ public class XmlRpcResourceManager {
             } catch (InterruptedException ignore) {
             }
     }
+    
+    public boolean setNodeCapacity(String nodeId, int capacity){
+       try{
+               
this.scheduler.getMonitor().getNodeById(nodeId).setCapacity(capacity);
+       }catch (MonitorException e){
+               LOG.log(Level.WARNING, "Exception setting capacity on node "
+                               + nodeId + ": " + e.getMessage());
+               return false;
+       }
+       return true;
+    }
 
     private String genericHandleJob(Hashtable jobHash, Object jobIn)
             throws SchedulerException {

Modified: 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java?rev=1131693&r1=1131692&r2=1131693&view=diff
==============================================================================
--- 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java
 (original)
+++ 
oodt/trunk/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java
 Sun Jun  5 04:58:20 2011
@@ -120,6 +120,7 @@ public class XmlRpcResourceManagerClient
         String getQueuesOperation = "--getQueues\n";
         String addNodeOperation = "--addNode --nodeId <node id> --ipAddr <url> 
--capacity <max load>\n";
         String removeNodeOperation = "--removeNode --nodeId <node id>\n";
+        String setNodeCapacityOperation = "--setNodeCapacity --nodeId <node 
id> --capacity <max load>\n";
         String addQueueOperation = "--addQueue --queueName <queue name>\n";
         String removeQueueOperation = "--removeQueue --queueName <queue 
name>\n";
         String addNodeToQueueOperation = "--addNodeToQueue --nodeId <node id> 
--queueName <queue name>\n";
@@ -230,6 +231,26 @@ public class XmlRpcResourceManagerClient
             client.removeNode(nodeId);
             System.out.println("Successfully removed node!");
             
+        }else if (operation.equals("--setNodeCapacity")){
+            String nodeId = null;
+            String capacity = null;
+            
+            for (int i = 4; i < args.length; i++) {
+                if (args[i].equals("--nodeId")) {
+                    nodeId = args[++i];
+                }else if (args[i].equals("--capacity")) {
+                    capacity = args[++i];
+                }
+            }
+            
+            if (nodeId == null || capacity == null) {
+                System.err.println(setNodeCapacityOperation);
+                System.exit(1);
+            }
+            
+            client.setNodeCapacity(nodeId, Integer.parseInt(capacity));
+            System.out.println("Successfully set node capacity!");
+               
         }else if (operation.equals("--addQueue")) {
             String queueName = null;
             
@@ -694,6 +715,17 @@ public class XmlRpcResourceManagerClient
         }
     }
     
+    public void setNodeCapacity(String nodeId, int capacity) throws 
MonitorException{
+       try{
+               Vector<Object> argList = new Vector<Object>();
+            argList.add(nodeId);
+            argList.add(new Integer(capacity));
+            client.execute("resourcemgr.setNodeCapacity", argList);
+       }catch (Exception e){
+               throw new MonitorException(e.getMessage(), e);
+       }
+    }
+    
     /**
      * Addes the node with given id to the queue with the given name
      * @param nodeId The id of the node to be added to the given queueName


Reply via email to