Project

General

Profile

« Previous | Next » 

Revision 33689

Added by Eri Katsari almost 10 years ago

finalized migrate option

View differences:

refreshNums.php
13 13
		global $redis_host;
14 14
		global $redis_port;
15 15
		global $redis_scheme;
16
		global $host;
16
		global $db_name;
17
         	GLOBAL $username;
18
		global $password;
19
        	global $host;
17 20

  
18
                $this->log = Logger::getLogger(__CLASS__);
19
                  Logger::configure('./js/log4php/log4php.xml');
20
              if(class_exists("Predis\Client")){
21
		$this->log = Logger::getLogger(__CLASS__);
22
                Logger::configure('./js/log4php/log4php.xml');
23
              
24
if(class_exists("Predis\Client")){
21 25

  
22 26
                        try {
23 27
//todo changed timeout from 0 to -1 
......
29 33
                        }
30 34
                }
31 35
        else{
32
            $this->log->info("cache does not exist"); //predis
33
                        exit;
36
              $this->log->info("cache does not exist"); //predis
37
               exit;
34 38
        }
35 39
//NOW GET DB
36 40
		try {
37
	         $str = 'pgsql:host='.$host.';port=5432;dbname=stats;user=sqoop;password=sqoop';
38
      	$this->db = new PDO($str);
39
		} catch(Exception $e){
41
	        $str = 'pgsql:host='.$host.";port=5432;dbname=".$db_name.";user=".$username.";password=".$password;
42
      	   
43
 $this->db = new PDO($str);
44

  
45
//TODO set search path here
46
                   } catch(Exception $e){
40 47
			$this->log->error('Could not connect to database: ' . $e->getMessage());
41 48
			exit;
42 49
		}
......
56 63
	}
57 64
//TODO  here store Queries in cache
58 65
private function storeQuery($key, $query) {
59
		global $redis_host;
60
		global $redis_port;
61
		global $redis_scheme;
62

  
63 66
$res=$this->doQuery($query);
64 67

  
65
$this->cache = new Predis\Client(array("scheme" => $redis_scheme, "host" => $redis_host, "port" => $redis_port));
68
//$this->cache = new Predis\Client(array("scheme" => $redis_scheme, "host" => $redis_host, "port" => $redis_port));
66 69
$this->cache->connect(); //predis
67 70
$this->cache->hset('SHADOW_STATS_NUMBERS',$key,$res);
68

  
69

  
70
//TODO  hset name is STATS_NUMBERS; field name = each key; query=field value
71

  
72 71
$this->log->info("Stored query : ".$key."  ".$this->cache->hget('SHADOW_STATS_NUMBERS',$key));
73 72
$this->cache->quit();
73

  
74 74
}
75 75

  
76 76
function computeStats() {
77 77
		
78 78
 global $redis_host;
79
                global $redis_port;
80
                global $redis_scheme;
81
/*OVERALL*/
82

  
79
                /*OVERALL*/
80
				
83 81
		/*1*/ 
84 82
		$qpubs = "SELECT count(*) FROM result where type='publication'";
85 83

  

Also available in: Unified diff