Project

General

Profile

1
<html>
2
<head>
3
<title>...</title>
4
<style type=”text/css”>
5
table {
6
margin: 8px;
7
}
8
h1 {
9
    text-align: center;
10
    text-transform: uppercase;
11
    color: #A7C942;
12
}
13

    
14
 
15

    
16
p {
17
    text-indent: 50px;
18
    text-align:justify;
19
    letter-spacing:3px;
20
font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
21

    
22
}
23
a {
24
    text-decoration:none;
25

    
26
}
27

    
28

    
29

    
30

    
31
</style>
32
</head>
33
<body>
34

    
35

    
36
<?php
37
require_once('./js/log4php/Logger.php');
38
include_once('./refreshNums.php');
39
include_once('./refreshCharts.php');
40
include_once('./promoteNums.php');
41
include_once('./promoteCharts.php');
42
include_once('./backupCache.php');
43
include_once('./restoreCache.php');
44
include_once('./migrateCache.php');
45

    
46
class CacheController
47
	{
48
             public function __construct($action){
49
	     $this->log = Logger::getLogger(__CLASS__);
50
             $this->log->info("Calling scripts to modify Cache...."); 
51
	     $this->log->info("Script Mode:".$action);
52

    
53

    
54
if(!$action=='help'){
55
echo ("Performing Action :  ".$action."<br><br>"); }
56

    
57

    
58
if ($action=='refreshNums') 
59
{$this->refreshNums();}
60
else if ($action=='refreshCharts') 
61
{$this->refreshCharts();}
62
else if ($action=='refreshAll')
63
{ $this->refreshAll(); }
64
else if ($action=='promoteNums') 
65
{$this->promoteNums();}
66
else if ($action=='promoteCharts') 
67
{$this->promoteCharts();}
68
else if ($action=='promoteAll')
69
{ $this->promoteAll(); }
70
else if ($action=='restore')
71
{ $this->restore(); }
72
else if ($action=='backup')
73
{
74
$this->backup(); }
75
else if ($action=='migrate')
76
{$this->migrate(); }
77
else if ($action=='help')
78
{$this->printHelp();}
79
else
80
{$this->log->info("Wrong argument given");
81
 $this->printHelp();}
82

    
83
if(!$action=='help'){
84
echo("<br>Done<br>!");
85
}
86

    
87
}
88

    
89
private function printHelp()
90
{
91
$msg="<h1>Cache Controls <br><br> </h1> Availiable options for <b> refresh :</b> <br><br> <a href=\"https://beta.openaire.eu/stats/cacheController?action=refreshNums\"> refreshNums </a> -> Refresh Stats Numbers Only <br>  <a href=\"https://beta.openaire.eu/stats/cacheController?action=refreshCharts\"> refreshCharts</a> -> Refresh Chart Queries  <br> <a href=\"https://beta.openaire.eu/stats/cacheController?action=refreshAll\"> refreshAll</a > -> Refresh every entry in the cache.<br> <br>Availiable options for <b>promote</b> :<br> <br>  <a href=\"https://beta.openaire.eu/stats/cacheController?action=promoteNums\">  promoteNums </a> -> Promotes Stats Numbers Only; <br>  <a href=\"https://beta.openaire.eu/stats/cacheController?action=promoteCharts\"> promoteCharts </a> -> Promote Chart Queries ; <br> <a href=\"https://beta.openaire.eu/stats/cacheController?action=promoteAll\"> promoteAll</a> ->Promote every entry in the cache. <br> <br>Availiable options for <b>backup</b> : <br><br> <a href=\"https://beta.openaire.eu/stats/cacheController?action=backup\"> backup </a> <br>  <a href=\"https://beta.openaire.eu/stats/cacheController?action=restore\"> restore </a> <br> <a href=\"https://beta.openaire.eu/stats/cacheController?action=migrate\"> migrate </a> <br>"; $this->log->info($msg); echo($msg);
92
}
93

    
94
public  function refreshNums(){
95
$this->log->info("Refreshing Numbers..."); 
96
$csn = new ComputeStatsNumbers();
97
$csn->computeStats();
98
$this->log->info("Done!");
99
}
100

    
101
public function refreshCharts()
102
{
103
$this->log->info("Refreshing Charts...");
104
$csn = new RefreshCharts();$csn->refresh();
105
$this->log->info("Done!");
106
}
107

    
108
public function refreshAll()
109
{ 
110
 $this->refreshNums();
111
 $this->refreshCharts();
112
}
113

    
114
public function promoteNums(){
115
$this->log->info(" Promoting Numbers..."); 
116
$csn = new PromoteShadowNums();
117
$csn->replace();
118
$this->log->info("Done!");
119
}
120

    
121
public function promoteCharts()
122
{
123
$this->log->info("Promoting Charts...");
124
$csn = new PromoteCharts();$csn->replace();
125
$this->log->info("Done!");
126
}
127

    
128
public function migrate()
129
{ 
130
$this->log->info("Cache Migration not yet implemented");
131
//$csn = new MigrateCache();
132
//$csn->migrate();
133
//$this->log->info("Done!");
134
echo("Cache Migration not yet implemented <br>");
135
}
136

    
137
public function backup()
138
{  
139
$this->log->info("Backing Up Cache...");
140
$csn = new BackupCache();$csn->backup();
141
$this->log->info("Done!");
142
}
143

    
144
public function restore()
145
{  
146
$this->log->info("Restoring Cache...");
147
$csn = new RestoreCache();$csn->restore();
148
$this->log->info("Done!");
149
}
150

    
151

    
152
public  function promoteAll()
153
{  $this->promoteNums();
154
   $this->promoteCharts();
155
}
156

    
157

    
158

    
159
}
160

    
161
//if(!empty($_SERVER['argv'][0]) {
162
  //$action = $_SERVER['argv'][1];
163
 
164
//} else {
165
 // $action = $_GET['action'];
166
 //}
167

    
168

    
169
if ($_GET) {
170
$action = $_GET['action'];
171
} else {
172
$action = $argv[1];
173
}
174
$rc = new CacheController($action);
175

    
176
?>
177

    
178

    
179

    
180
</body>
181
</html>
(4-4/29)