You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/10/02 14:38:33 UTC

[2/5] airavata-php-gateway git commit: Set the gateway level maximum values for walltime, node and CPU counts

Set the gateway level maximum values for walltime, node and CPU counts


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/d3900b9a
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/d3900b9a
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/d3900b9a

Branch: refs/heads/develop
Commit: d3900b9ab94a9fb5c68d686480429ae003d9a21e
Parents: e189880
Author: Sneha Tilak <ti...@149-160-247-119.dhcp-bl.indiana.edu>
Authored: Fri Sep 29 18:15:38 2017 -0400
Committer: Sneha Tilak <ti...@149-160-247-119.dhcp-bl.indiana.edu>
Committed: Fri Sep 29 18:15:38 2017 -0400

----------------------------------------------------------------------
 app/config/pga_config.php.template       | 15 ++++++++++
 app/controllers/ExperimentController.php | 40 +++++++++++++++++++++++++--
 app/libraries/ExperimentUtilities.php    | 20 +++++++++++++-
 3 files changed, 71 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d3900b9a/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 654a1ed..495c98c 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -180,6 +180,21 @@ return array(
         'wall-time-limit' => '30',
 
         /**
+         * Max node count
+         */
+        'max-node-count' => '4',
+
+        /**
+         * Max total core count
+         */
+        'max-total-cpu-count' => '96',
+
+        /**
+         * Max wall time limit
+         */
+        'max-wall-time-limit' => '120',
+
+        /**
          * Enable app-catalog cache
          */
         'enable-app-catalog-cache' => true,

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d3900b9a/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 131fa1d..5660a36 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -55,7 +55,6 @@ class ExperimentController extends BaseController
                 "wallTimeLimit" => $wallTimeLimit
             );
 
-
             $experimentInputs = array(
                 "disabled" => ' disabled',
                 "experimentName" => $_POST['experiment-name'],
@@ -94,7 +93,17 @@ class ExperimentController extends BaseController
 
         } else if (isset($_POST['save']) || isset($_POST['launch'])) {
             try {
-                $expId = ExperimentUtilities::create_experiment();
+                $computeResourceId = Input::get("crId");
+                //Validate entered queue details
+                $queueValues = array("queueName" => Input::get("queue-name"),
+                    "nodeCount" => Input::get("nodeCount"),
+                    "cpuCount" => Input::get("cpuCount"),
+                    "wallTimeLimit" => Input::get("wallTimeLimit")
+                );
+                if($this->validateQueueData($computeResourceId, $queueValues))
+                    $expId = ExperimentUtilities::create_experiment();
+                else
+                    Redirect::to("experiment/create")->with("error-message", "Validate the number f nodes, CPUs and the wall time limit");
             } catch (Exception $ex) {
                 Log::error("Failed to create experiment!");
                 Log::error($ex);
@@ -396,7 +405,17 @@ class ExperimentController extends BaseController
     {
         $experiment = ExperimentUtilities::get_experiment(Input::get('expId')); // update local experiment variable
         try {
-            $updatedExperiment = ExperimentUtilities::apply_changes_to_experiment($experiment, Input::all());
+            $computeResourceId = Input::get("crId");
+            //Validate entered queue details
+            $queueValues = array("queueName" => Input::get("queue-name"),
+                "nodeCount" => Input::get("nodeCount"),
+                "cpuCount" => Input::get("cpuCount"),
+                "wallTimeLimit" => Input::get("wallTimeLimit")
+            );
+            if($this->validateQueueData($computeResourceId, $queueValues))
+                $updatedExperiment = ExperimentUtilities::apply_changes_to_experiment($experiment, Input::all());
+            else
+                Redirect::to("experiment/create")->with("error-message", "Validate the number of nodes, CPUs and the wall time limit");
         } catch (Exception $ex) {
             $errMessage = "Failed to update experiment: " . $ex->getMessage();
             Log::error($errMessage);
@@ -590,6 +609,21 @@ class ExperimentController extends BaseController
         }
         return $allowedFileSize;
     }
+
+    private function validateQueueData($computeResourceId, $queue)
+    {
+        $queues = ExperimentUtilities::getQueueDatafromResourceId($computeResourceId);
+        $queueName = $queue['queueName'];
+
+        foreach($queues as $aQueue){
+            if($aQueue->queueName == $queueName) {
+                if($queue['validateQueueData'] <= $aQueue->maxNodes && $queue['maxCPUCount'] <= $aQueue->maxProcessors && $queue['wallTimeLimit'] <= $aQueue->maxRunTime)
+                    return true;
+            }
+        }
+
+        return false;
+    }
 }
 
 ?>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d3900b9a/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 9424893..f3c96ce 100755
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -1422,7 +1422,25 @@ class ExperimentUtilities
     public static function getQueueDatafromResourceId($crId)
     {
         $resourceObject = Airavata::getComputeResource(Session::get('authz-token'), $crId);
-        return $resourceObject->batchQueues;
+        $queues =  $resourceObject->batchQueues;
+
+        //Defining maximum allowed value for queue resources
+        $maxNodeCount = Config::get('pga_config.airavata')["max-node-count"];
+        $maxCPUCount = Config::get('pga_config.airavata')["max-total-cpu-count"];
+        $maxWallTimeLimit = Config::get('pga_config.airavata')["max-wall-time-limit"];
+
+        foreach($queues as $aQueue){
+            if($aQueue->maxNodes > $maxNodeCount){
+                $aQueue->maxNodes = $maxNodeCount;
+            }
+            if($aQueue->maxProcessors > $maxCPUCount){
+                $aQueue->maxProcessors = $maxCPUCount;
+            }
+            if($aQueue->maxRunTime > $maxWallTimeLimit){
+                $aQueue->maxRunTime = $maxWallTimeLimit;
+            }
+        }
+        return $queues;
     }
 
     /**