Some more performance improvements and caching

This commit is contained in:
Deon George 2012-12-06 14:50:06 +11:00
parent 74b3bfb408
commit 528a83a4fd
38 changed files with 303 additions and 103 deletions

View File

@ -98,7 +98,7 @@ Kohana::init(array(
/**
* Attach the file write to logging. Multiple writers are supported.
*/
Kohana::$log->attach(new Log_File(APPPATH.'logs'));
Kohana::$log->attach(new Log_File(APPPATH.'logs'),LOG::INFO);
/**
* Attach a file reader to config. Multiple readers are supported.
@ -146,7 +146,7 @@ Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-]+'))
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-=]+'))
->defaults(array(
'controller' => 'welcome',
'action' => 'index',

View File

@ -56,6 +56,12 @@ abstract class Controller_TemplateDefault_View extends Controller_TemplateDefaul
HTTP::redirect(strtolower($this->request->controller()));
}
// For some tables, are ID is base_64 encoded.
switch ($this->orm) {
case 'VOLUME': $object_name = base64_decode($object_name);
break;
}
$o = ORM::factory($this->orm,$object_name);
if (! $o->loaded()) {

View File

@ -14,5 +14,12 @@ abstract class Database extends Kohana_Database {
// Enable TSM SHOW commands
const SHOW = 5;
const SET = 6;
// We need to set our default database so that any internal calls to Database::instance() use the right database.
public static function instance($name = NULL, array $config = NULL) {
Database::$default = Kohana::$config->load('config')->client_type;
return parent::instance($name,$config);
}
}
?>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_ACTLOG extends TSM_ORM {
class Model_ACTLOG extends ORM_TSM {
protected $_table_name = 'ACTLOG';
protected $_primary_key = 'DATE_TIME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_ASSOCIATION extends TSM_ORM {
class Model_ASSOCIATION extends ORM_TSM {
protected $_table_name = 'ASSOCIATIONS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_CLIENTOPT extends TSM_ORM {
class Model_CLIENTOPT extends ORM_TSM {
protected $_table_name = 'CLIENTOPTS';
protected $_primary_key = 'OPTIONSET_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_COPYGROUP_AR extends TSM_ORM {
class Model_COPYGROUP_AR extends ORM_TSM {
protected $_table_name = 'AR_COPYGROUPS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_COPYGROUP_BU extends TSM_ORM {
class Model_COPYGROUP_BU extends ORM_TSM {
protected $_table_name = 'BU_COPYGROUPS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
@ -17,5 +17,9 @@ class Model_COPYGROUP_BU extends TSM_ORM {
'SET_NAME'=>'ASC',
'CLASS_NAME'=>'ASC',
);
protected $_has_one = array(
'STGPOOL'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'DESTINATION'),
);
}
?>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DB extends TSM_ORM {
class Model_DB extends ORM_TSM {
protected $_table_name = 'DB';
protected $_primary_key = 'DATABASE_NAME';
protected $_sorting = array(
@ -24,10 +24,10 @@ class Model_DB extends TSM_ORM {
array('number_format',array(':value',0)),
),
'LAST_REORG'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
'LAST_BACKUP_DATE'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
'TOTAL_BUFF_REQ'=>array(
array('number_format',array(':value',0)),

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DBSPACE extends TSM_ORM {
class Model_DBSPACE extends ORM_TSM {
protected $_table_name = 'DBSPACE';
protected $_primary_key = 'LOCATION';
protected $_sorting = array(

View File

@ -10,7 +10,7 @@
* @license http://phptsmadmin.sf.net/license.html
* @note This is model is using the plural name, as storage pools have an attribute with the singular name
*/
class Model_DEVCLASSES extends TSM_ORM {
class Model_DEVCLASSES extends ORM_TSM {
protected $_table_name = 'DEVCLASSES';
protected $_primary_key = 'DEVCLASS_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DOMAIN extends TSM_ORM {
class Model_DOMAIN extends ORM_TSM {
protected $_table_name = 'DOMAINS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DRIVE extends TSM_ORM {
class Model_DRIVE extends ORM_TSM {
protected $_table_name = 'DRIVES';
protected $_primary_key = 'DRIVE_NAME';
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_EVENT extends TSM_ORM {
class Model_EVENT extends ORM_TSM {
protected $_table_name = 'EVENTS';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
@ -19,13 +19,13 @@ class Model_EVENT extends TSM_ORM {
protected $_display_filters = array(
'SCHEDULED_START'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
'ACTUAL_START'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
'COMPLETED'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
);
}

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_FILESPACE extends TSM_ORM {
class Model_FILESPACE extends ORM_TSM {
protected $_table_name = 'FILESPACES';
protected $_primary_key = 'FILESPACE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
@ -41,45 +41,176 @@ class Model_FILESPACE extends TSM_ORM {
protected $_display_filters = array(
'BACKUP_END'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
);
/**
* Get all the OCCUPANCY for this FILESYSTEM on this NODE
*/
private function _occupancy() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$this->FILESPACE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
foreach ($this->NODE->occupancy() as $oo)
if ($oo->FILESPACE_NAME == $this->FILESPACE_NAME)
array_push($result,$oo);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Get all the VOLUEMUSAGE for this FILESYSTEM on this NODE
*/
private function _volumeusage() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$this->FILESPACE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
foreach ($this->NODE->volumeusage() as $vuo)
if ($vuo->FILESPACE_NAME == $this->FILESPACE_NAME)
array_push($result,$vuo);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the data that this FILESYSTEM has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
* @param $metric is metric of the storpage pool, eg: NUM_FILES
*/
private function data_bypool($pool,$metric) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$this->FILESPACE_NAME,$pool,$metric);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = 0;
foreach ($this->_occupancy() as $oo)
if ($oo->STGPOOL_NAME == $pool)
$result += $oo->{$metric};
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the data that this FILESYSTEM has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
* @param $metric is metric of the storpage pool, eg: NUM_FILES
* @param $type is Bkup/Arch/SpMg
*/
private function data_bypoolbybtype($pool,$metric,$type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$this->FILESPACE_NAME,$pool,$metric,$type);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = 0;
foreach ($this->_occupancy() as $oo)
if ($oo->STGPOOL_NAME == $pool AND $oo->TYPE == $type)
$result += $oo->{$metric};
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the LOGICAL_MB that this FILESYSTEM has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
*/
public function logmb_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->data_bypool($pool,'LOGICAL_MB');
}
/**
* Return the LOGICAL_MB that this FILESYSTEM has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
* @param $type is Bkup/Arch/SpMg
*/
public function logmb_bypoolbybtype($pool,$type) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->data_bypoolbybtype($pool,'LOGICAL_MB',$type);
}
public function utilsation() {
return $this->CAPACITY*($this->PCT_UTIL/100);
}
// $dtype must be Bkup or Arch
public function storagepools($dtype) {
$pool = array();
foreach ($this->NODE->OCC
->select('STGPOOL_NAME')
->where('TYPE','=',$dtype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $oo)
array_push($pool,$oo->STGPOOL);
return $pool;
}
public function pool_logical_util($pool,$btype) {
return $this->NODE->OCC
->where('STGPOOL_NAME','=',$pool)
->and_where('TYPE','=',$btype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->find()->LOGICAL_MB;
/**
* Return the VOLUMES that this FILESYSTEM uses for this NODE
* @param $pool is STORAGE POOL NAME
*/
public function vols_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$this->FILESPACE_NAME,$pool);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
foreach ($this->_volumeusage() as $vuo)
if ($vuo->STGPOOL_NAME == $pool AND ! in_array($vuo->VOLUME_NAME,$x)) {
array_push($result,$vuo);
array_push($x,$vuo->VOLUME_NAME);
}
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
public function pool_numvols($pool,$ctype) {
return $this->NODE->VOLUMEUSAGE
->where('STGPOOL_NAME','=',$pool)
->and_where('COPY_TYPE','=',$ctype)
->and_where('FILESPACE_NAME','=',$this->FILESPACE_NAME)
->find_all()->count();
/**
* Return the VOLUMES that this FILESYSTEM uses for this NODE by POOL and BACKUP TYPE
* @param $pool is STORAGE POOL NAME
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
*/
public function vols_bypoolbybtype($pool,$type) {
$x = $result = array();
foreach ($this->vols_bypool($pool) as $vuo)
if ($vuo->COPY_TYPE == $type AND ! in_array($vuo->VOLUME_NAME,$x)) {
array_push($result,$vuo);
array_push($x,$vuo->VOLUME_NAME);
}
return $result;
}
}
?>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBRARY extends TSM_ORM {
class Model_LIBRARY extends ORM_TSM {
protected $_table_name = 'LIBRARIES';
protected $_primary_key = 'LIBRARY_NAME';
protected $_sorting = array(
@ -28,7 +28,7 @@ class Model_LIBRARY extends TSM_ORM {
#zz
public function slots() {
return $this->slots ? $this->slots : $this->slots = DB::query(Database::SHOW,'SHOW SLOTS '.$this)->execute(Kohana::$config->load('config')->client_type);
return $this->slots ? $this->slots : $this->slots = DB::query(Database::SHOW,'SHOW SLOTS '.$this)->execute();
}
// Return a list of scratch volumes

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBVOLUME extends TSM_ORM {
class Model_LIBVOLUME extends ORM_TSM {
protected $_table_name = 'LIBVOLUMES';
protected $_primary_key = 'HOME_ELEMENT';
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_MEDIA extends TSM_ORM {
class Model_MEDIA extends ORM_TSM {
protected $_table_name = 'MEDIA';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_MGMTCLASS extends TSM_ORM {
class Model_MGMTCLASS extends ORM_TSM {
protected $_table_name = 'MGMTCLASSES';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_NODE extends TSM_ORM {
class Model_NODE extends ORM_TSM {
protected $_table_name = 'NODES';
protected $_primary_key = 'NODE_NAME';
protected $_sorting = array(
@ -86,13 +86,13 @@ class Model_NODE extends TSM_ORM {
protected $_display_filters = array(
'REG_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'PWSET_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'LASTACC_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'LASTSESS_SENT'=>array(
array('number_format',array(':value',0)),
@ -275,11 +275,13 @@ class Model_NODE extends TSM_ORM {
}
/**
* Return the data that this NODE has in a STORAGE POOL
* Return the data that this NODE has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
* @param $metric is metric of the storpage pool, eg: NUM_FILES
*/
private function data_bypool($pool,$metric) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool,$metric);
$c = Kohana::$config->load('config')->cache;
@ -294,14 +296,16 @@ class Model_NODE extends TSM_ORM {
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the FILES that this NODE has in a STORAGE POOL
* Return the FILES that this NODE has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
*/
public function file_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->data_bypool($pool,'NUM_FILES');
}
@ -310,19 +314,23 @@ class Model_NODE extends TSM_ORM {
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function file_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = 0;
foreach ($this->stgpools_byptype($type) as $spo)
$result += $this->file_bypool($spo);
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the LOGICAL_MB that this NODE has in a STORAGE POOL
* Return the LOGICAL_MB that this NODE has in a STORAGE POOL
* @param $pool is STORAGE POOL NAME
*/
public function logmb_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__));
return $this->data_bypool($pool,'LOGICAL_MB');
}
@ -331,18 +339,27 @@ class Model_NODE extends TSM_ORM {
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function logmb_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = 0;
foreach ($this->stgpools_byptype($type) as $spo)
$result += $this->logmb_bypool($spo);
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
public function occupancy() {
return $this->_occupancy();
}
/**
* Return the STORAGE POOLS this NODE has data in
*/
public function stgpools() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
@ -355,11 +372,11 @@ class Model_NODE extends TSM_ORM {
array_push($x,$vuo->STGPOOL_NAME);
}
Sort::MASort($result,'STGPOOL_NAME');
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -369,6 +386,8 @@ class Model_NODE extends TSM_ORM {
* @todo This should be sorted by PRIMARY/ACTIVE/COPY
*/
public function stgpooltypes() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
@ -383,6 +402,7 @@ class Model_NODE extends TSM_ORM {
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -391,6 +411,8 @@ class Model_NODE extends TSM_ORM {
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
*/
public function stgpools_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
@ -403,11 +425,11 @@ class Model_NODE extends TSM_ORM {
array_push($x,$vuo->STGPOOL_NAME);
}
Sort::MASort($result,'STGPOOL_NAME');
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -416,6 +438,8 @@ class Model_NODE extends TSM_ORM {
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function stgpools_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
@ -430,6 +454,7 @@ class Model_NODE extends TSM_ORM {
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -438,6 +463,8 @@ class Model_NODE extends TSM_ORM {
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
*/
public function vols_bybtype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type);
$c = Kohana::$config->load('config')->cache;
@ -455,6 +482,7 @@ class Model_NODE extends TSM_ORM {
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -463,14 +491,16 @@ class Model_NODE extends TSM_ORM {
* @param $pool is STORAGE POOL NAME
*/
public function vols_bypool($pool) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
foreach ($this->_volumeusage() as $vuo) {
if ($vuo->STGPOOL_NAME == $pool AND ! in_array($vuo->VOLUME_NAME,$x))
foreach ($this->_volumeusage() as $vuo)
if ($vuo->STGPOOL_NAME == $pool AND ! in_array($vuo->VOLUME_NAME,$x)) {
array_push($result,$vuo);
array_push($x,$vuo->VOLUME_NAME);
}
@ -480,6 +510,7 @@ class Model_NODE extends TSM_ORM {
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
@ -488,20 +519,25 @@ class Model_NODE extends TSM_ORM {
* @param $type is ACTIVEDATA/PRIMARY/COPY
*/
public function vols_byptype($type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$result = array();
foreach ($this->stgpools_byptype($type) as $spo)
$result = array_merge($result,$this->vols_bypool($spo));
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the VOLUMES that this NODE uses by pool and BACKUP TYPE
* Return the VOLUMES that this NODE uses by POOL and BACKUP TYPE
* @param $pool is STORAGE POOL NAME
* @param $type is BACKUP/ARCHIVE/SPACE MANAGED
*/
public function vols_bypoolbybtype($pool,$type) {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$x = $result = array();
foreach ($this->vols_bypool($pool) as $vuo)
@ -510,7 +546,12 @@ class Model_NODE extends TSM_ORM {
array_push($x,$vuo->VOLUME_NAME);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
public function volumeusage() {
return $this->_volumeusage();
}
}
?>

View File

@ -10,7 +10,7 @@
* @license http://phptsmadmin.sf.net/license.html
* @node This has been renamed to OCC from OCCUPANCY, as DB2/FILESPACES has an OCCUPANCY column
*/
class Model_OCC extends TSM_ORM {
class Model_OCC extends ORM_TSM {
protected $_table_name = 'OCCUPANCY';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_PATH extends TSM_ORM {
class Model_PATH extends ORM_TSM {
protected $_table_name = 'PATHS';
protected $_primary_key = 'DEVICE';
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_SCHEDULE_CLIENT extends TSM_ORM {
class Model_SCHEDULE_CLIENT extends ORM_TSM {
protected $_table_name = 'CLIENT_SCHEDULES';
protected $_primary_key = 'SCHEDULE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
@ -22,7 +22,7 @@ class Model_SCHEDULE_CLIENT extends TSM_ORM {
protected $_display_filters = array(
'STARTTIME'=>array(
array('TSM_ORM::date',array(':value','h:m')),
array('ORM_TSM::date',array(':value','h:m')),
),
);

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_STGPOOL extends TSM_ORM {
class Model_STGPOOL extends ORM_TSM {
protected $_table_name = 'STGPOOLS';
protected $_primary_key = 'STGPOOL_NAME';
protected $_sorting = array(

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_SUMMARY extends TSM_ORM {
class Model_SUMMARY extends ORM_TSM {
protected $_table_name = 'SUMMARY';
protected $_primary_key = 'ACTIVITY'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
@ -20,10 +20,10 @@ class Model_SUMMARY extends TSM_ORM {
protected $_display_filters = array(
'START_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
'END_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M H:i')),
array('ORM_TSM::date',array(':value','d-M H:i')),
),
);
}

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLHISTORY extends TSM_ORM {
class Model_VOLHISTORY extends ORM_TSM {
protected $_table_name = 'VOLHISTORY';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
@ -23,7 +23,7 @@ class Model_VOLHISTORY extends TSM_ORM {
protected $_display_filters = array(
'DATE_TIME'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
);

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLUME extends TSM_ORM {
class Model_VOLUME extends ORM_TSM {
protected $_table_name = 'VOLUMES';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
@ -27,10 +27,10 @@ class Model_VOLUME extends TSM_ORM {
protected $_display_filters = array(
'LAST_READ_DATE'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
'LAST_WRITE_DATE'=>array(
array('TSM_ORM::date',array(':value','d-M-Y')),
array('ORM_TSM::date',array(':value','d-M-Y')),
),
);

View File

@ -9,7 +9,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLUMEUSAGE extends TSM_ORM {
class Model_VOLUMEUSAGE extends ORM_TSM {
protected $_table_name = 'VOLUMEUSAGE';
protected $_primary_key = 'NODE_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(

View File

@ -10,7 +10,7 @@
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://dev.osbill.net/license.html
*/
abstract class TSM_ORM extends ORM {
abstract class ORM_TSM extends ORM {
// Suppress ORMs inclusion of <table_name>.*
protected $_disable_wild_select = TRUE;
// Suppress ORMs inclusion of <table_name>. to column joins
@ -58,11 +58,16 @@ abstract class TSM_ORM extends ORM {
}
public function find() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
Log::instance()->add(LOG::DEBUG,'METHOD :method: isCacheable: :cable, table: :table',array(':method'=>__METHOD__,':cable'=>($x=$this->isCacheable()) ? $x : 'N',':table'=>$this->_table_name));
// Check if we can preload our data and havent already done it
if ($time = $this->isCacheable() AND is_null(Cache::instance(Kohana::$config->load('config')->cache)->get($cache_key = 'PRELOAD:'.$this->_table_name))) {
// Kohana uses Kohana::cache here, instead of Cache()
if ($time = $this->isCacheable() AND is_null(Kohana::cache($cache_key = 'PRELOAD:'.$this->_table_name))) {
Log::instance()->add(LOG::DEBUG,'PRELOADING :method: table: :table',array(':method'=>__METHOD__,':table'=>$this->_table_name));
// Firstly set our cache, so that we dont get in a loop
Cache::instance()->set($cache_key,TRUE,$time-1);
Kohana::cache($cache_key,TRUE,$time-1);
// Find all records of this type
$c = get_class($this);
@ -75,7 +80,7 @@ abstract class TSM_ORM extends ORM {
// Code, as extracted from ORM to complete building the SQL
$y->_build(Database::SELECT);
$y->_db_builder->from($y->_table_name);
$y->_db_builder->from(array($y->_table_name,$y->_object_name));
if (! isset($y->_db_applied['order_by']) AND ! empty($y->_sorting))
foreach ($y->_sorting as $column => $direction) {
if (strpos($column, '.') === FALSE)
@ -91,20 +96,22 @@ abstract class TSM_ORM extends ORM {
// Cache the record, our subsequent find should get a cache hit now.
Kohana::cache($cache_key, array($record->as_array()), $time);
Log::instance()->add(LOG::DEBUG,'Cache SET for TIME: :time, KEY: :cache_key',array(':cache_key'=>$cache_key,':time'=>$time));
}
unset($x);
}
Log::instance()->add(LOG::DEBUG,'LEAVE :method',array(':method'=>__METHOD__));
// Contiue as normal
return parent::find();
}
private function isCacheable() {
$preload = array('NODES','VOLUMES');
$config = Kohana::$config->load('database')->{Database::$default};
$config = Kohana::$config->load('database')->{Kohana::$config->load('config')->client_type};
//echo Debug::vars(array('m'=>__METHOD__,'cpl'=>$config['cachepreload'],'tn'=>$this->_table_name,'db'=>count($this->_db_pending),'pend'=>$this->_db_pending,'pk'=>$this->_primary_key));
if ($config['caching'] AND isset($config['cachepreload'][$this->_table_name]) AND count($this->_db_pending) == 1 AND $this->_db_pending[0]['name'] == 'where' AND $this->_db_pending[0]['args'][0] == $this->_primary_key AND $this->_db_pending[0]['args'][1] == '=')
return $config['cachepreload'][$this->_table_name];
else
@ -127,12 +134,12 @@ abstract class TSM_ORM extends ORM {
* @return array
* @todo This cache time needs to be better integrated with other caching times.
*/
public function list_columns() {
public function list_columns() {
// We'll cache our query results
if ($this->_db->caching('SCHEMA')) {
// Set the cache key based on the database instance name and SQL
$cache_key = 'Database::query(LC:'.$this->_table_name.')';
if (! is_null($result = Cache::instance()->get($cache_key)))
// Return a cached result
return $result;

View File

@ -157,7 +157,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
if ($this->auto_render) {
// Application Title
$this->meta->title = 'Application Title';
$this->meta->title = Kohana::$config->load('config')->appname;
$this->template->title = '';
// Style Sheets Properties
@ -218,7 +218,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
* Default Method to call from the tree menu
*/
public function action_menu() {
$this->template->content = 'See menu on tree';
$this->template->content = _('Please choose from the menu on the left - you may need to expand the items by pressing on the plus.');
}
protected function _headimages() {

View File

@ -11,6 +11,7 @@
*/
return array(
'appname' => 'phpTSMadmin',
'cache_type' => 'file',
'cache' => 'apc',
'cache_time' => 86400,

View File

@ -1,10 +1,11 @@
/** Login Style Sheet **/
table.login {
width: 5%;
margin-left: auto;
margin-right: auto;
background-color: #F9F9FA;
border: 1px solid #AAAACC;
background-color: #FBFBFB;
border: 1px solid #A0A0A0;
padding: 10px;
}

View File

@ -13,6 +13,7 @@
<td>MGMT Class</td>
<td>HSM Pool</td>
<td>1st Backup Pool</td>
<td>Next Backup Pool</td>
<td>Ver Exist</td>
<td>Ver Del</td>
<td>Frequency</td>
@ -21,7 +22,8 @@
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo $mco->display('CLASS_NAME'); ?><?php echo $mco->DEFAULTMC=='Yes' ? ' <sup>*</sup>' : ''; ?></td>
<td class="data"><?php echo $mco->display('MIGDESTINATION'); ?></td>
<td class="data"><?php echo $mco->COPYGROUP_BU->display('DESTINATION'); ?></td>
<td class="data"><?php echo HTML::anchor('stgpool/detail/'.$mco->COPYGROUP_BU->DESTINATION,$mco->COPYGROUP_BU->display('DESTINATION')); ?></td>
<td class="data"><?php echo HTML::anchor('stgpool/detail/'.$mco->COPYGROUP_BU->STGPOOL->NEXTSTGPOOL,$mco->COPYGROUP_BU->STGPOOL->display('NEXTSTGPOOL')); ?></td>
<td class="data"><?php printf('%s/%s',$mco->COPYGROUP_BU->display('VEREXISTS'),$mco->COPYGROUP_BU->display('RETEXTRA')); ?></td>
<td class="data"><?php printf('%s/%s',$mco->COPYGROUP_BU->display('VERDELETED'),$mco->COPYGROUP_BU->display('RETONLY')); ?></td>
<td class="data"><?php echo $mco->COPYGROUP_BU->display('FREQUENCY'); ?></td>

View File

@ -28,7 +28,7 @@
<?php foreach ($o->vols_bypoolbybtype($spo->STGPOOL_NAME,$ctype) as $vuo) {
$vo = $vuo->VOLUME; ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo HTML::anchor('volume/detail/'.$vo->VOLUME_NAME,$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo HTML::anchor('volume/detail/'.base64_encode($vo->VOLUME_NAME),$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo $vo->display('LAST_READ_DATE'); ?></td>
<td class="data"><?php echo $vo->display('LAST_WRITE_DATE'); ?></td>
<td class="data"><?php echo $vo->display('ACCESS'); ?></td>

View File

@ -19,16 +19,16 @@
<td class="right"><?php echo $spo->display('STGPOOL_NAME'); ?> <span style="vertical-align: super; font-size: 60%;"><?php echo $spo->display('POOLTYPE'); ?></span></td>
<?php } ?>
</tr>
<?php $i=0; foreach ($o->fs() as $fso) { ?>
<?php $i=0; foreach ($o->fs() as $fso) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo $fso->display('FILESPACE_NAME'); ?></td>
<td class="data"><?php echo ($btype == 'Bkup') ? $fso->display('BACKUP_END') : '&nbsp;'; ?></td>
<td class="data-right"><?php echo number_format($fso->utilsation(),2); ?></td>
<?php foreach ($o->stgpools() as $spo) { ?>
<td class="data-right"><?php echo number_format($fso->pool_logical_util($spo->STGPOOL_NAME,$btype),2); ?> (<?php echo $fso->pool_numvols($spo->STGPOOL_NAME,$ctype); ?>)</td>
<?php } ?>
<?php foreach ($o->stgpools() as $spo) { ?>
<td class="data-right"><?php echo number_format($fso->logmb_bypoolbybtype($spo->STGPOOL_NAME,$btype),2); ?> (<?php echo count($fso->vols_bypoolbybtype($spo->STGPOOL_NAME,$ctype)); ?>)</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>
<?php } else { ?>
<tr><td>There is no <?php echo $ctype; ?> Data for this Node.</td></tr>
<?php } ?>

View File

@ -28,7 +28,7 @@
<?php foreach ($o->vols_bypoolbybtype($spo->STGPOOL_NAME,$ctype) as $vuo) {
$vo = $vuo->VOLUME; ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo HTML::anchor('volume/detail/'.$vo->VOLUME_NAME,$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo HTML::anchor('volume/detail/'.base64_encode($vo->VOLUME_NAME),$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo $vo->display('LAST_READ_DATE'); ?></td>
<td class="data"><?php echo $vo->display('LAST_WRITE_DATE'); ?></td>
<td class="data"><?php echo $vo->display('ACCESS'); ?></td>

View File

@ -22,7 +22,7 @@
</tr>
<?php $i=0; foreach ($o->VOLUME->find_all() as $vo) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo HTML::anchor('volume/detail/'.$vo->VOLUME_NAME,$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo HTML::anchor('volume/detail/'.base64_encode($vo->VOLUME_NAME),$vo->display('VOLUME_NAME')); ?></td>
<td class="data"><?php echo $vo->display('LAST_READ_DATE'); ?></td>
<td class="data"><?php echo $vo->display('LAST_WRITE_DATE'); ?></td>
<td class="data"><?php echo $vo->display('ACCESS'); ?></td>

View File

@ -12,7 +12,7 @@
</tr>
<tr>
<td>Storage Pool</td>
<td class="data"><?php echo HTML::anchor('stgpool/detail'.$o->STGPOOL_NAME,$o->display('STGPOOL_NAME')); ?></td>
<td class="data"><?php echo HTML::anchor('stgpool/detail/'.$o->STGPOOL_NAME,$o->display('STGPOOL_NAME')); ?></td>
</tr>
<tr>
<td>Estimated Capacity</td>