You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/06 10:40:09 UTC

[2/5] airavata-php-gateway git commit: Caching App Catalog Data improve PGA performance

Caching App Catalog Data improve PGA performance


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/f3d7e2b4
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f3d7e2b4
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f3d7e2b4

Branch: refs/heads/airavata-php-gateway-0.15-release
Commit: f3d7e2b45e7936babbb35ace919e4c0e5a3c2905
Parents: d5b1ebb
Author: Supun Nakandala <sc...@apache.org>
Authored: Sat Jun 6 00:34:01 2015 +0530
Committer: Supun Nakandala <sc...@apache.org>
Committed: Sat Jun 6 00:34:01 2015 +0530

----------------------------------------------------------------------
 app/config/cache.php                     | 24 +++++++++++-----------
 app/config/pga_config.php                |  7 ++++++-
 app/controllers/ExperimentController.php |  8 ++++++--
 app/libraries/AppUtilities.php           | 11 +++++++---
 app/libraries/CRUtilities.php            | 10 ++++++---
 app/libraries/ExperimentUtilities.php    | 29 ++++++++++++++++++---------
 6 files changed, 58 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/config/cache.php
----------------------------------------------------------------------
diff --git a/app/config/cache.php b/app/config/cache.php
index 34e5bf0..2733233 100755
--- a/app/config/cache.php
+++ b/app/config/cache.php
@@ -15,18 +15,18 @@ return array(
 	|
 	*/
 
-	'driver' => 'apc',
-
-	/*
-	|--------------------------------------------------------------------------
-	| File Cache Location
-	|--------------------------------------------------------------------------
-	|
-	| When using the "file" cache driver, we need a location where the cache
-	| files may be stored. A sensible default has been specified, but you
-	| are free to change it to any other place on disk that you desire.
-	|
-	*/
+    'driver' => 'file',
+
+    /*
+    |--------------------------------------------------------------------------
+    | File Cache Location
+    |--------------------------------------------------------------------------
+    |
+    | When using the "file" cache driver, we need a location where the cache
+    | files may be stored. A sensible default has been specified, but you
+    | are free to change it to any other place on disk that you desire.
+    |
+    */
 
 	'path' => storage_path().'/cache',
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/config/pga_config.php
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php b/app/config/pga_config.php
index 56f5fcb..27ec861 100644
--- a/app/config/pga_config.php
+++ b/app/config/pga_config.php
@@ -124,7 +124,12 @@ return array(
         /**
          * Default wall time limit
          */
-        'wall-time-limit' => '30'
+        'wall-time-limit' => '30',
+
+        /**
+         * Life time of app catalog data cache in minutes
+         */
+        'app-catalog-cache-duration' => 5
     ]
 
 );
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 60561de..e5f0baa 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -7,7 +7,7 @@ class ExperimentController extends BaseController
      * Limit used in fetching paginated results
      * @var int
      */
-    var $limit = 10;
+    var $limit = 20;
 
     /**
      *    Instantiate a new ExperimentController Instance
@@ -82,6 +82,7 @@ class ExperimentController extends BaseController
         if ($experiment != null) {
             $project = ProjectUtilities::get_project($experiment->projectID);
             $expVal = ExperimentUtilities::get_experiment_values($experiment, $project);
+            $expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
             $jobDetails = ExperimentUtilities::get_job_details($experiment->experimentID);
             $transferDetails = ExperimentUtilities::get_transfer_details($experiment->experimentID);
             //var_dump( $jobDetails); exit;
@@ -133,6 +134,7 @@ class ExperimentController extends BaseController
         $project = ProjectUtilities::get_project($experiment->projectID);
 
         $expVal = ExperimentUtilities::get_experiment_values($experiment, $project);
+        $expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
         /*if (isset($_POST['save']))
         {
             $updatedExperiment = Utilities::apply_changes_to_experiment($experiment);
@@ -148,6 +150,7 @@ class ExperimentController extends BaseController
             $project = ProjectUtilities::get_project($experiment->projectID);
 
             $expVal = ExperimentUtilities::get_experiment_values($experiment, $project);
+            $expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
 
             return Redirect::to('experiment/edit?expId=' . $experiment->experimentID);
 
@@ -170,6 +173,7 @@ class ExperimentController extends BaseController
         $project = ProjectUtilities::get_project($experiment->projectID);
 
         $expVal = ExperimentUtilities::get_experiment_values($experiment, $project);
+        $expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
         //var_dump( $expVal); exit;
         $computeResources = CRUtilities::create_compute_resources_select($experiment->applicationId, $expVal['scheduling']->resourceHostId);
 
@@ -243,7 +247,7 @@ class ExperimentController extends BaseController
         $expContainer = ExperimentUtilities::get_expsearch_results_with_pagination(Input::all(), $this->limit,
             ($pageNo - 1) * $this->limit);
 
-        $experimentStates = CommonUtilities::getExpStates();
+        $experimentStates = ExperimentUtilities::getExpStates();
         return View::make('experiment/search', array(
             'input' => Input::all(),
             'pageNo' => $pageNo,

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/libraries/AppUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AppUtilities.php b/app/libraries/AppUtilities.php
index 5ceb44a..0eb9e2a 100644
--- a/app/libraries/AppUtilities.php
+++ b/app/libraries/AppUtilities.php
@@ -248,7 +248,14 @@ class AppUtilities
         $applicationInterface = null;
 
         try {
-            $applicationInterface = Airavata::getApplicationInterface($id);
+            if (Cache::has('APP-' . $id)) {
+                return Cache::get('APP-' . $id);
+            } else {
+                $applicationInterface = Airavata::getApplicationInterface($id);
+                Cache::put('APP-' . $id, $applicationInterface, Config::get('pga_config.airavata')['app-catalog-cache-duration']);
+                return $applicationInterface;
+            }
+
         } catch (InvalidRequestException $ire) {
             CommonUtilities::print_error_message('<p>There was a problem getting the application interface.
             Please try again later or submit a bug report using the link in the Help menu.</p>' .
@@ -262,8 +269,6 @@ class AppUtilities
             Please try again later or submit a bug report using the link in the Help menu.</p>' .
                 '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
         }
-
-        return $applicationInterface;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 688c1de..9e3069d 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -420,7 +420,13 @@ class CRUtilities
         $computeResource = null;
 
         try {
-            $computeResource = Airavata::getComputeResource($id);
+            if (Cache::has('CR-' . $id)) {
+                return Cache::get('CR-' . $id);
+            } else {
+                $computeResource = Airavata::getComputeResource($id);
+                Cache::put('CR-' . $id, $computeResource, Config::get('pga_config.airavata')['app-catalog-cache-duration']);
+                return $computeResource;
+            }
         } catch (InvalidRequestException $ire) {
             CommonUtilities::print_error_message('<p>There was a problem getting the compute resource.
             Please try again later or submit a bug report using the link in the Help menu.</p>' .
@@ -434,8 +440,6 @@ class CRUtilities
             Please try again later or submit a bug report using the link in the Help menu.</p>' .
                 '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>');
         }
-
-        return $computeResource;
     }
 
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f3d7e2b4/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 6a5f0b4..9f6c6b9 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -620,16 +620,6 @@ class ExperimentUtilities
             $expVal["experimentTimeOfStateChange"] = $experimentStatus->timeOfStateChange / 1000; // divide by 1000 since timeOfStateChange is in ms
             $expVal["experimentCreationTime"] = $experiment->creationTime / 1000; // divide by 1000 since creationTime is in ms
         }
-        $jobStatus = Airavata::getJobStatuses($experiment->experimentID);
-
-        if ($jobStatus) {
-            $jobName = array_keys($jobStatus);
-            $jobState = JobState::$__names[$jobStatus[$jobName[0]]->jobState];
-        } else {
-            $jobState = null;
-        }
-
-        $expVal["jobState"] = $jobState;
 
         if (!$forSearch) {
             $userConfigData = $experiment->userConfigurationData;
@@ -670,6 +660,25 @@ class ExperimentUtilities
 
     }
 
+    /**
+     * Method to get the job status of an experiment
+     * @param $experiment
+     * @return null
+     */
+    public static function get_job_status($experiment)
+    {
+        $jobStatus = Airavata::getJobStatuses($experiment->experimentID);
+
+        if ($jobStatus) {
+            $jobName = array_keys($jobStatus);
+            $jobState = JobState::$__names[$jobStatus[$jobName[0]]->jobState];
+        } else {
+            $jobState = null;
+        }
+
+        return $jobState;
+    }
+
 
     /**
      * Create options for the search key select input