[Fusionforge-commits] r10568 - trunk/plugins/coclico/hudson/include

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Mon Sep 20 22:43:32 CEST 2010


Author: aljeux
Date: 2010-09-20 22:43:32 +0200 (Mon, 20 Sep 2010)
New Revision: 10568

Modified:
   trunk/plugins/coclico/hudson/include/HudsonJob.class.php
Log:
Performance improvments on hudson plugin.
Try to delay loading xml config file.
Use APC cache if available.

Modified: trunk/plugins/coclico/hudson/include/HudsonJob.class.php
===================================================================
--- trunk/plugins/coclico/hudson/include/HudsonJob.class.php	2010-09-20 20:43:27 UTC (rev 10567)
+++ trunk/plugins/coclico/hudson/include/HudsonJob.class.php	2010-09-20 20:43:32 UTC (rev 10568)
@@ -26,7 +26,9 @@
 
     protected $hudson_job_url;
     protected $hudson_dobuild_url;
+    protected $hudson_config_job_url;
     protected $dom_job;
+    protected $config_job;
     private $icons_path;
     
     private $context;
@@ -43,6 +45,7 @@
                 
         $this->hudson_job_url = $hudson_job_url . "/api/xml";
         $this->hudson_dobuild_url = $hudson_job_url . "/build";
+        $this->hudson_config_job_url = $hudson_job_url . "/config.xml";
         
         $controler = $this->getHudsonControler(); 
         $this->icons_path = $controler->getIconsPath();
@@ -50,6 +53,7 @@
         $this->_setStreamContext();
         
         $this->buildJobObject();
+        $this->configJobObject();
         
     }
     function getHudsonControler() {
@@ -60,8 +64,23 @@
         $this->dom_job = $this->_getXMLObject($this->hudson_job_url);
     }
     
+	public function configJobObject() {
+        $this->config_job = $this->_getXMLObject($this->hudson_config_job_url);
+    }
+    
     protected function _getXMLObject($hudson_job_url) {
-        $xmlstr = @file_get_contents($hudson_job_url, false, $this->context);
+
+        // If enabled, use APC cache (1sec) to reduce RSS fetching that may cause big delays.
+        if (function_exists('apc_fetch')) {
+            $xmlstr = apc_fetch($hudson_job_url);
+            if ($xmlstr === false) {
+        		$xmlstr = @file_get_contents($hudson_job_url, false, $this->context);
+                apc_store($hudson_job_url, $xmlstr, 1);
+            }
+        } else {
+            $xmlstr = @file_get_contents($hudson_job_url, false, $this->context);
+        }
+
         if ($xmlstr !== false) {
             $xmlobj = simplexml_load_string($xmlstr);
             if ($xmlobj !== false) {
@@ -270,6 +289,10 @@
         }
     }
     
+	function getSvnLocation() {
+        return $this->config_job->scm->locations->{'hudson.scm.SubversionSCM_-ModuleLocation'}->remote;
+    }
+    
     /**
      * Launch a Build for this job on the Continuous Integration server.
      * 
@@ -301,4 +324,4 @@
     
 }
 
-?>
\ No newline at end of file
+?>




More information about the Fusionforge-commits mailing list