1
|
<?php
|
2
|
require_once('./js/log4php/Logger.php');
|
3
|
include_once('./refreshNums.php');
|
4
|
include_once('./refreshCharts.php');
|
5
|
include_once('./promoteNums.php');
|
6
|
include_once('./promoteCharts.php');
|
7
|
include_once('./backupCache.php');
|
8
|
include_once('./restoreCache.php');
|
9
|
include_once('./migrateCache.php');
|
10
|
|
11
|
class CacheController
|
12
|
{
|
13
|
public function __construct($action){
|
14
|
$this->log = Logger::getLogger(__CLASS__);
|
15
|
$this->log->info("Calling scripts to modify Cache....");
|
16
|
$this->log->info("Script Mode:".$action);
|
17
|
|
18
|
if ($action=='refreshNums')
|
19
|
{$this->refreshNums();}
|
20
|
else if ($action=='refreshCharts')
|
21
|
{$this->refreshCharts();}
|
22
|
else if ($action=='refreshAll')
|
23
|
{ $this->refreshAll(); }
|
24
|
else if ($action=='promoteNums')
|
25
|
{$this->promoteNums();}
|
26
|
else if ($action=='promoteCharts')
|
27
|
{$this->promoteCharts();}
|
28
|
else if ($action=='promoteAll')
|
29
|
{ $this->promoteAll(); }
|
30
|
else if ($action=='restore')
|
31
|
{ $this->restore(); }
|
32
|
else if ($action=='backup')
|
33
|
{ $this->backup(); }
|
34
|
else if ($action=='migrate')
|
35
|
{$this->migrate(); }
|
36
|
else if ($action=='help')
|
37
|
{$this->printHelp();}
|
38
|
|
39
|
else
|
40
|
{$this->log->info("Wrong argument given");
|
41
|
$this->printHelp();}
|
42
|
|
43
|
}
|
44
|
|
45
|
private function printHelp()
|
46
|
{
|
47
|
$this->log->info("Availiable options for refresh : refreshNums-> Refreshes Stats Numbers Only; refreshCharts -> Refresh Chart Queries ; refreshAll-> Refresh every entry in the cache.");
|
48
|
$this->log->info("Availiable options for promote : promoteNums-> Promotes Stats Numbers Only; promoteCharts -> Promote Chart Queries ; promoteAll->Promote every entry in the cache.");
|
49
|
$this->log->info("Availiable options for backup : backup-> ; restore -> ; migrate-> ");
|
50
|
}
|
51
|
|
52
|
public function refreshNums(){
|
53
|
$this->log->info("Refreshing Numbers...");
|
54
|
$csn = new ComputeStatsNumbers();
|
55
|
$csn->computeStats();
|
56
|
$this->log->info("Done!");
|
57
|
}
|
58
|
|
59
|
public function refreshCharts()
|
60
|
{
|
61
|
$this->log->info("Refreshing Charts...");
|
62
|
$csn = new RefreshCharts();$csn->refresh();
|
63
|
$this->log->info("Done!");
|
64
|
}
|
65
|
|
66
|
public function refreshAll()
|
67
|
{
|
68
|
$this->refreshNums();
|
69
|
$this->refreshCharts();
|
70
|
}
|
71
|
|
72
|
public function promoteNums(){
|
73
|
$this->log->info(" Promoting Numbers...");
|
74
|
$csn = new PromoteShadowNums();
|
75
|
$csn->replace();
|
76
|
$this->log->info("Done!");
|
77
|
}
|
78
|
|
79
|
public function promoteCharts()
|
80
|
{
|
81
|
$this->log->info("Promoting Charts...");
|
82
|
$csn = new PromoteCharts();$csn->replace();
|
83
|
$this->log->info("Done!");
|
84
|
}
|
85
|
|
86
|
public function migrate()
|
87
|
{
|
88
|
$this->log->info("Migrating Cache...");
|
89
|
$csn = new MigrateCache();
|
90
|
$csn->migrate();
|
91
|
$this->log->info("Done!");
|
92
|
}
|
93
|
|
94
|
public function backup()
|
95
|
{
|
96
|
$this->log->info("Backing Up Cache...");
|
97
|
$csn = new BackupCache();$csn->backup();
|
98
|
$this->log->info("Done!");
|
99
|
}
|
100
|
|
101
|
public function restore()
|
102
|
{
|
103
|
$this->log->info("Restoring Cache...");
|
104
|
$csn = new RestoreCache();$csn->restore();
|
105
|
$this->log->info("Done!");
|
106
|
}
|
107
|
|
108
|
|
109
|
public function promoteAll()
|
110
|
{ $this->promoteNums();
|
111
|
$this->promoteCharts();
|
112
|
}
|
113
|
|
114
|
|
115
|
|
116
|
}
|
117
|
|
118
|
|
119
|
if ($_GET) {
|
120
|
$argument1 = $_GET['action'];
|
121
|
} else {
|
122
|
$argument1 = $argv[1];
|
123
|
}
|
124
|
$rc = new CacheController($argument1);
|
125
|
|
126
|
?>
|