From 7a3539cb95496537db413740743103134ae56934 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 7 Dec 2012 14:33:16 +1100 Subject: [PATCH] Some more performance improvements and caching --- application/classes/Model/DOMAIN.php | 257 +++++++++++++----- application/classes/Model/NODE.php | 238 ++++++++++------ application/classes/ORM/TSM.php | 6 + application/views/domain/detail.php | 4 +- application/views/domain/nodes.php | 4 +- application/views/domain/stgpool_pool.php | 39 +++ application/views/domain/stgpool_summary.php | 36 --- application/views/domain/stgpool_type.php | 39 +++ application/views/domain/volumes.php | 5 +- application/views/node/filesystems.php | 7 +- .../{stgpool_summary.php => stgpool_pool.php} | 6 +- application/views/node/stgpool_type.php | 32 +++ application/views/node/volumes.php | 5 +- 13 files changed, 475 insertions(+), 203 deletions(-) create mode 100644 application/views/domain/stgpool_pool.php delete mode 100644 application/views/domain/stgpool_summary.php create mode 100644 application/views/domain/stgpool_type.php rename application/views/node/{stgpool_summary.php => stgpool_pool.php} (80%) create mode 100644 application/views/node/stgpool_type.php diff --git a/application/classes/Model/DOMAIN.php b/application/classes/Model/DOMAIN.php index 722aaf3..8cf9b1d 100644 --- a/application/classes/Model/DOMAIN.php +++ b/application/classes/Model/DOMAIN.php @@ -36,19 +36,84 @@ class Model_DOMAIN extends ORM_TSM { * Get all the NODES in this DOMAIN */ private function _nodes() { - $result = array(); + $k = sprintf('%s-%s',__METHOD__,$this->DOMAIN_NAME); + $c = Kohana::$config->load('config')->cache; - // In the interest of performance, we load all the records and get PHP to process it. - // Our ORM caching we reduce the hit on TSM. - foreach (ORM::factory('NODE')->find_all() as $o) - if ($o->DOMAIN_NAME == $this->DOMAIN_NAME) - array_push($result,$o); + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + // In the interest of performance, we load all the records and get PHP to process it. + // Our ORM caching we reduce the hit on TSM. + foreach (ORM::factory('NODE')->find_all() as $o) + if ($o->DOMAIN_NAME == $this->DOMAIN_NAME) + array_push($result,$o); + + // @todo Cache time should be configurble + Cache::instance($c)->set($k,$result,300); + } return $result; } - public function nodes() { - return $this->_nodes(); + private function _node_int($method,$data) { + $k = sprintf('%s-%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$method,$data); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + $result = 0; + + foreach ($this->_nodes() as $no) + $result += $no->{$method}($data); + + // @todo Cache time should be configurble + Cache::instance($c)->set($k,$result,300); + } + + return $result; + } + + private function _node_bypoolbybtype($pool,$method,$type) { + $k = sprintf('%s-%s-%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$pool,$method,$type); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + $result = 0; + + foreach ($this->_nodes() as $no) + $result += $no->{$method}($pool,$type); + + // @todo Cache time should be configurble + Cache::instance($c)->set($k,$result,300); + } + + return $result; + } + + /** + * Return the BACKUP TYPES used by NODES in this DOMAIN + * ie: Bkup/Arch/SpMg + */ + public function btypes() { + $k = sprintf('%s-%s',__METHOD__,$this->DOMAIN_NAME); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + foreach ($this->_nodes() as $no) + $result = array_merge($result,$no->btypes()); + + $result = array_unique($result); + + // @todo Cache time should be configurble + Cache::instance($c)->set($k,$result,300); + } + + return $result; + } + + public function file_bybtype($type) { + return $this->_node_int('file_bybtype',$type); } /** @@ -56,20 +121,19 @@ class Model_DOMAIN extends ORM_TSM { * @param $pool is STORAGE POOL NAME */ public function file_bypool($pool) { - $k = sprintf('%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$pool); - $c = Kohana::$config->load('config')->cache; + return $this->_node_int('file_bypool',$pool); + } - if (is_null($result = Cache::instance($c)->get($k))) { - $result = 0; + public function file_bypoolbybtype($pool,$type) { + return $this->_node_bypoolbybtype($pool,'file_bypoolbybtype',$type); + } - foreach ($this->_nodes() as $no) - $result += $no->file_bypool($pool); + public function file_byptype($type) { + return $this->_node_int('file_byptype',$type); + } - // @todo Cache time should be configurble - Cache::instance($c)->set($k,$result,300); - } - - return $result; + public function logmb_bybtype($type) { + return $this->_node_int('logmb_bybtype',$type); } /** @@ -77,19 +141,27 @@ class Model_DOMAIN extends ORM_TSM { * @param $pool is STORAGE POOL NAME */ public function logmb_bypool($pool) { - $k = sprintf('%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$pool); - $c = Kohana::$config->load('config')->cache; + return $this->_node_int('logmb_bypool',$pool); + } - if (is_null($result = Cache::instance($c)->get($k))) { - $result = 0; + public function logmb_bypoolbybtype($pool,$type) { + return $this->_node_bypoolbybtype($pool,'logmb_bypoolbybtype',$type); + } - foreach ($this->_nodes() as $no) - $result += $no->logmb_bypool($pool); + public function logmb_byptype($type) { + return $this->_node_int('logmb_byptype',$type); + } - // @todo Cache time should be configurble - Cache::instance($c)->set($k,$result,300); - } + public function nodes() { + return $this->_nodes(); + } + public function nodes_bybtype($type) { + $result = array(); + + foreach ($this->_nodes() as $no) + if ($no->file_bybtype($type)) + array_push($result,$no); return $result; } @@ -107,6 +179,26 @@ class Model_DOMAIN extends ORM_TSM { return $result; } + public function nodes_bypoolbybtype($pool,$type) { + $result = array(); + + foreach ($this->_nodes() as $no) + if ($no->file_bypoolbybtype($pool,$type)) + array_push($result,$no); + + return $result; + } + + public function nodes_byptype($type) { + $result = array(); + + foreach ($this->_nodes() as $no) + if ($no->file_byptype($type) AND ! in_array($no,$result)) + array_push($result,$no); + + return $result; + } + /** * Return the STORAGE POOLS used by NODES in this DOMAIN */ @@ -117,7 +209,7 @@ class Model_DOMAIN extends ORM_TSM { if (is_null($result = Cache::instance($c)->get($k))) { $result = array(); - foreach ($this->nodes() as $no) + foreach ($this->_nodes() as $no) foreach ($no->stgpools() as $spo) if (! in_array($spo,$result)) array_push($result,$spo); @@ -129,29 +221,6 @@ class Model_DOMAIN extends ORM_TSM { return $result; } - /** - * Return the STORAGE POOL TYPES used by NODES in this DOMAIN - * ie: ACTIVE/PRIMARY/COPY - * @todo This should be sorted by PRIMARY/ACTIVE/COPY - */ - public function stgpooltypes() { - $k = sprintf('%s-%s',__METHOD__,$this->DOMAIN_NAME); - $c = Kohana::$config->load('config')->cache; - - if (is_null($result = Cache::instance($c)->get($k))) { - $result = array(); - - foreach ($this->stgpools() as $spo) - if (! in_array($spo->POOLTYPE,$result)) - array_push($result,$spo->POOLTYPE); - - // @todo Cache time should be configurble - Cache::instance($c)->set($k,$result,300); - } - - return $result; - } - /** * Return the STORAGE POOLS that NODES in this DOMAIN uses by BACKUP TYPE * @param $type is Bkup/Arch/SpMg @@ -200,22 +269,21 @@ class Model_DOMAIN extends ORM_TSM { } /** - * Return the VOLUMES that NODES in this DOMAIN use - * @param $pool is STORAGE POOL NAME + * Return the STORAGE POOL TYPES used by NODES in this DOMAIN + * ie: ACTIVE/PRIMARY/COPY + * @todo This should be sorted by PRIMARY/ACTIVE/COPY */ - public function vols_bypool($pool) { - $k = sprintf('%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$pool); + public function stgpooltypes() { + $k = sprintf('%s-%s',__METHOD__,$this->DOMAIN_NAME); $c = Kohana::$config->load('config')->cache; if (is_null($result = Cache::instance($c)->get($k))) { - $x = $result = array(); + $result = array(); foreach ($this->_nodes() as $no) - foreach ($no->vols_bypool($pool) as $vuo) - if (! in_array($vuo->VOLUME_NAME,$x)) { - array_push($result,$vuo); - array_push($x,$vuo->VOLUME_NAME); - } + $result = array_merge($result,$no->stgpooltypes()); + + $result = array_unique($result); // @todo Cache time should be configurble Cache::instance($c)->set($k,$result,300); @@ -224,6 +292,10 @@ class Model_DOMAIN extends ORM_TSM { return $result; } + public function vols_bybtype($type) { + return $this->vols_byctype($this->datatypemap($type)); + } + /** * Return the VOLUMES that NODES in this DOMAIN uses by BACKUP TYPE * @param $type is BACKUP/ARCHIVE/SPACE MANAGED @@ -232,15 +304,13 @@ class Model_DOMAIN extends ORM_TSM { $k = sprintf('%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$type); $c = Kohana::$config->load('config')->cache; - if (TRUE OR is_null($result = Cache::instance($c)->get($k))) { - $x = $result = array(); + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); foreach ($this->_nodes() as $no) - foreach ($no->vols_byctype($type) as $vuo) - if (! in_array($vuo->VOLUME_NAME,$x)) { - array_push($result,$vuo); - array_push($x,$vuo->VOLUME_NAME); - } + foreach ($no->vols_byctype($type) as $vo) + if (! in_array($vo->VOLUME_NAME,$result)) + array_push($result,$vo); // @todo Cache time should be configurble Cache::instance($c)->set($k,$result,300); @@ -249,6 +319,33 @@ class Model_DOMAIN extends ORM_TSM { return $result; } + /** + * Return the VOLUMES that NODES in this DOMAIN use + * @param $pool is STORAGE POOL NAME + */ + public function vols_bypool($pool) { + $k = sprintf('%s-%s-%s',__METHOD__,$this->DOMAIN_NAME,$pool); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + foreach ($this->_nodes() as $no) + foreach ($no->vols_bypool($pool) as $vo) + if (! in_array($vo->VOLUME_NAME,$result)) + array_push($result,$vo); + + // @todo Cache time should be configurble + Cache::instance($c)->set($k,$result,300); + } + + return $result; + } + + public function vols_bypoolbybtype($pool,$type) { + return $this->vols_bypoolbyctype($pool,$this->datatypemap($type)); + } + /** * Return the VOLUMES that this NODE uses by pool and BACKUP TYPE * @param $pool is STORAGE POOL NAME @@ -257,11 +354,23 @@ class Model_DOMAIN extends ORM_TSM { public function vols_bypoolbyctype($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); - } + foreach ($this->_nodes() as $no) + foreach ($no->vols_bypoolbyctype($pool,$type) as $vo) + if (! in_array($vo->VOLUME_NAME,$result)) + array_push($result,$vo); + + return $result; + } + + public function vols_byptype($type) { + $x = $result = array(); + + foreach ($this->_nodes() as $no) + foreach ($no->vols_byptype($type) as $vuo) + if (! in_array($vuo->VOLUME_NAME,$x)) { + array_push($result,$vuo); + array_push($x,$vuo->VOLUME_NAME); + } return $result; } diff --git a/application/classes/Model/NODE.php b/application/classes/Model/NODE.php index ad29ac8..5c27074 100644 --- a/application/classes/Model/NODE.php +++ b/application/classes/Model/NODE.php @@ -133,14 +133,25 @@ class Model_NODE extends ORM_TSM { * Get all the OCCUPANCY for this NODE */ private function _occupancy() { - $result = array(); + Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - // In the interest of performance, we load all the records and get PHP to process it. - // Our ORM caching we reduce the hit on TSM. - foreach (ORM::factory('OCC')->find_all() as $o) - if ($o->NODE_NAME == $this->NODE_NAME) - array_push($result,$o); + $k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME); + $c = Kohana::$config->load('config')->cache; + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + // In the interest of performance, we load all the records and get PHP to process it. + // Our ORM caching we reduce the hit on TSM. + foreach (ORM::factory('OCC')->find_all() as $o) + if ($o->NODE_NAME == $this->NODE_NAME) + array_push($result,$o); + + // @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; } @@ -148,21 +159,28 @@ class Model_NODE extends ORM_TSM { * Get all the VOLUMES for this NODE */ private function _volumeusage() { - $result = array(); + Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - // In the interest of performance, we load all the records and get PHP to process it. - // Our ORM caching we reduce the hit on TSM. - foreach (ORM::factory('VOLUMEUSAGE')->find_all() as $o) - if ($o->NODE_NAME == $this->NODE_NAME) - array_push($result,$o); + $k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME); + $c = Kohana::$config->load('config')->cache; + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + // In the interest of performance, we load all the records and get PHP to process it. + // Our ORM caching we reduce the hit on TSM. + foreach (ORM::factory('VOLUMEUSAGE')->find_all() as $o) + if ($o->NODE_NAME == $this->NODE_NAME) + array_push($result,$o); + + // @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 fs() { - return $this->_filespaces(); - } - /** * Return the version of the TSM client */ @@ -249,47 +267,48 @@ class Model_NODE extends ORM_TSM { return $this->vols_byctype($type) ? TRUE : FALSE; } - // $dtype is BACKUP or ARCHIVE - // $ptype is pool type (PRIMARY,ACTIVE,COPY) -#zz - public function getStorageModeVols($dtype,$ptype,$spo='') { - $result = array(); + /** + * Return the BACKUP TYPES used by this NODE + * ie: Bkup/Arch/SpMg + */ + public function btypes() { + Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - foreach ($this->_volumeusage() as $vo) - if ($vo->COPY_TYPE == $dtype AND (! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $ptype) - if (! isset($result[$vo->VOLUME_NAME])) - $result[$vo->VOLUME_NAME] = $vo; + $k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME); + $c = Kohana::$config->load('config')->cache; - return $result; - } + if (is_null($result = Cache::instance($c)->get($k))) { + $x = $result = array(); - // $ptype is pool type (PRIMARY,ACTIVE,COPY) -#zz - public function getStorageTypeVols($ptype,$spo='') { - $result = array(); + foreach ($this->_occupancy() as $oo) + if (! in_array($oo->TYPE,$result)) + array_push($result,$oo->TYPE); - foreach (Kohana::$config->load('config')->tsmdatatypes as $btype => $ctype) - $result = array_merge($result,$this->getStorageModeVols($ctype,$ptype,$spo)); + // @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 NODE has in a STORAGE POOL - * @param $pool is STORAGE POOL NAME + * Return the total of a field for this NODE has by backup TYPE + * @param $field the field to check + * @param $data the value of that field to match * @param $metric is metric of the storpage pool, eg: NUM_FILES */ - private function data_bypool($pool,$metric) { + private function _data_int($field,$data,$metric) { Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - $k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool,$metric); + $k = sprintf('%s-%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$field,$data,$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) + if ($oo->{$field} == $data) $result += $oo->{$metric}; // @todo Cache time should be configurble @@ -300,13 +319,54 @@ class Model_NODE extends ORM_TSM { return $result; } + /** + * Return the data that this NODE has in a STORAGE POOL by backup TYPE + * @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',__METHOD__,$this->NODE_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 FILES that this NODE has by backup TYPE + * @param $type is Bkup/Arch/SpMg + */ + public function file_bybtype($type) { + Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__)); + return $this->_data_int('TYPE',$type,'NUM_FILES'); + } + /** * 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'); + return $this->_data_int('STGPOOL_NAME',$pool,'NUM_FILES'); + } + + public function file_bypoolbybtype($pool,$type) { + Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__)); + return $this->_data_bypoolbybtype($pool,'NUM_FILES',$type); } /** @@ -325,13 +385,31 @@ class Model_NODE extends ORM_TSM { return $result; } + public function fs() { + return $this->_filespaces(); + } + + /** + * Return the LOGICAL_MB that this NODE has by backup TYPE + * @param $type is Bkup/Arch/SpMg + */ + public function logmb_bybtype($type) { + Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__)); + return $this->_data_int('TYPE',$type,'LOGICAL_MB'); + } + /** * 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'); + return $this->_data_int('STGPOOL_NAME',$pool,'LOGICAL_MB'); + } + + public function logmb_bypoolbybtype($pool,$type) { + Log::instance()->add(LOG::DEBUG,'FLYBY :method',array(':method'=>__METHOD__)); + return $this->_data_bypoolbybtype($pool,'LOGICAL_MB',$type); } /** @@ -419,10 +497,10 @@ class Model_NODE extends ORM_TSM { if (is_null($result = Cache::instance($c)->get($k))) { $x = $result = array(); - foreach ($this->_occupancy() as $vuo) - if ($vuo->TYPE == $type AND ! in_array($vuo->STGPOOL_NAME,$x)) { - array_push($result,$vuo->STGPOOL); - array_push($x,$vuo->STGPOOL_NAME); + foreach ($this->_occupancy() as $oo) + if ($oo->TYPE == $type AND ! in_array($oo->STGPOOL_NAME,$x)) { + array_push($result,$oo->STGPOOL); + array_push($x,$oo->STGPOOL_NAME); } // @todo Cache time should be configurble @@ -458,21 +536,21 @@ class Model_NODE extends ORM_TSM { return $result; } - /** - * Return the VOLUMES that this NODE uses by BACKUP TYPE - * @param $type is BACKUP/ARCHIVE/SPACE MANAGED - */ - public function vols_byctype($type) { + public function vols_bybtype($type) { + return $this->vols_byctype($this->datatypemap($type)); + } + + private function _vols_metric($metric,$data) { Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - $k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type); + $k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$metric,$data); $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->COPY_TYPE == $type AND ! in_array($vuo->VOLUME_NAME,$x)) { + if ($vuo->{$metric} == $data AND ! in_array($vuo->VOLUME_NAME,$x)) { array_push($result,$vuo->VOLUME); array_push($x,$vuo->VOLUME_NAME); } @@ -486,32 +564,20 @@ class Model_NODE extends ORM_TSM { return $result; } + /** + * Return the VOLUMES that this NODE uses by BACKUP TYPE + * @param $type is BACKUP/ARCHIVE/SPACE MANAGED + */ + public function vols_byctype($type) { + return $this->_vols_metric('COPY_TYPE',$type); + } + /** * Return the VOLUMES that this NODE uses * @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)) { - array_push($result,$vuo); - array_push($x,$vuo->VOLUME_NAME); - } - - Sort::MASort($result,'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; + return $this->_vols_metric('STGPOOL_NAME',$pool); } /** @@ -530,6 +596,15 @@ class Model_NODE extends ORM_TSM { return $result; } + /** + * Return the VOLUMES that this NODE uses by POOL and BACKUP TYPE + * @param $pool is STORAGE POOL NAME + * @param $type is Bkup/Arch/SpMg + */ + public function vols_bypoolbybtype($pool,$type) { + return $this->vols_bypoolbyctype($pool,$this->datatypemap($type)); + } + /** * Return the VOLUMES that this NODE uses by POOL and BACKUP TYPE * @param $pool is STORAGE POOL NAME @@ -538,13 +613,20 @@ class Model_NODE extends ORM_TSM { public function vols_bypoolbyctype($pool,$type) { Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); - $x = $result = array(); + $k = sprintf('%s-%s-%s-%s',__METHOD__,$this->NODE_NAME,$pool,$type); + $c = Kohana::$config->load('config')->cache; - 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); - } + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + foreach ($this->_volumeusage() as $vuo) + if ($vuo->STGPOOL_NAME == $pool AND $vuo->COPY_TYPE == $type AND ! in_array($vuo->VOLUME_NAME,$result)) + array_push($result,$vuo->VOLUME); + + Sort::MASort($result,'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; diff --git a/application/classes/ORM/TSM.php b/application/classes/ORM/TSM.php index 9edb192..a859b28 100644 --- a/application/classes/ORM/TSM.php +++ b/application/classes/ORM/TSM.php @@ -163,5 +163,11 @@ abstract class ORM_TSM extends ORM { public static function date($date,$format) { return $date ? date($format,strtotime($date)) : ''; } + + protected function datatypemap($type) { + $x = Kohana::$config->load('config')->tsmdatatypes; + + return array_key_exists($type,$x) ? $x[$type] : $x; + } } ?> diff --git a/application/views/domain/detail.php b/application/views/domain/detail.php index 44c875a..3d24bf6 100644 --- a/application/views/domain/detail.php +++ b/application/views/domain/detail.php @@ -6,8 +6,8 @@   - set('o',$o); ?> -   + set('o',$o); ?> + set('o',$o); ?>   diff --git a/application/views/domain/nodes.php b/application/views/domain/nodes.php index 337d463..6bad3a3 100644 --- a/application/views/domain/nodes.php +++ b/application/views/domain/nodes.php @@ -16,7 +16,7 @@ load('config')->tsmdatatypes as $btype => $ctype) { ?> - load('config')->tsmpooltypes as $type) { ?> + stgpooltypes() as $type) { ?> (Vol/Fil/Dat) @@ -31,7 +31,7 @@ load('config')->tsmdatatypes as $btype => $ctype) { ?> hasData($ctype) ? 'Y' : 'N'; ?> - load('config')->tsmpooltypes as $type) { ?> + stgpooltypes() as $type) { ?> vols_byptype($type)); ?> file_byptype($type),0); ?> logmb_byptype($type),0); ?> diff --git a/application/views/domain/stgpool_pool.php b/application/views/domain/stgpool_pool.php new file mode 100644 index 0000000..56942b7 --- /dev/null +++ b/application/views/domain/stgpool_pool.php @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + stgpooltypes() as $type) { ?> + + + + + + + + stgpools_byptype($type) as $spo) { ?> + + + + + + + + + + + + +
Storage By Pools Summary for Nodes in this Domain
 
Storage Pool and TypeScr UseScr AvlNodesVolsFilesMB
nodes_byptype($type)); ?>vols_byptype($type)); ?>file_byptype($type),0); ?>logmb_byptype($type),0); ?>
 STGPOOL_NAME,$spo->display('STGPOOL_NAME')); ?>display('NUMSCRATCHUSED'); ?>display('MAXSCRATCH'); ?>nodes_bypool($spo)); ?>vols_bypool($spo)); ?>file_bypool($spo),0); ?>logmb_bypool($spo),0); ?>
diff --git a/application/views/domain/stgpool_summary.php b/application/views/domain/stgpool_summary.php deleted file mode 100644 index 88e9111..0000000 --- a/application/views/domain/stgpool_summary.php +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - stgpooltypes() as $type) { ?> - - - - stgpools_byptype($type) as $spo) { ?> - - - - - - - - - - - - -
Storage By Pools Summary for Nodes in this Domain
 
Storage Pool and TypeScr UseScr AvlNodesVolsFilesMB
 STGPOOL_NAME,$spo->display('STGPOOL_NAME')); ?>display('NUMSCRATCHUSED'); ?>display('MAXSCRATCH'); ?>nodes_bypool($spo)); ?>vols_bypool($spo)); ?>file_bypool($spo),0); ?>logmb_bypool($spo),0); ?>
- diff --git a/application/views/domain/stgpool_type.php b/application/views/domain/stgpool_type.php new file mode 100644 index 0000000..d1ac347 --- /dev/null +++ b/application/views/domain/stgpool_type.php @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + btypes() as $type) { ?> + + + + + + + + stgpools_bybtype($type) as $spo) { ?> + + + + + + + + + + + + +
Storage By Type Summary for Nodes in this Domain
 
Storage Pool and TypeScr UseScr AvlNodesVolsFilesMB
nodes_bybtype($type)); ?>vols_bybtype($type)); ?>file_bybtype($type),0); ?>logmb_bybtype($type),0); ?>
 STGPOOL_NAME,$spo->display('STGPOOL_NAME')); ?>display('NUMSCRATCHUSED'); ?>display('MAXSCRATCH'); ?>nodes_bypoolbybtype($spo,$type)); ?>vols_bypoolbybtype($spo,$type)); ?>file_bypoolbybtype($spo,$type),0); ?>logmb_bypoolbybtype($spo,$type),0); ?>
diff --git a/application/views/domain/volumes.php b/application/views/domain/volumes.php index 321fcb3..ad4ca35 100644 --- a/application/views/domain/volumes.php +++ b/application/views/domain/volumes.php @@ -28,14 +28,13 @@ DEVCLASS == 'DISK') - printf('%s: Utilised: %s%%, Device Type: %s',$spo->STGPOOL_NAME,$spo->PCT_UTILIZED,$spo->DEVCLASS); + printf('%s: Utilised: %s%%, Device Type: %s',$spo->STGPOOL_NAME,$spo->PCT_MIGR,$spo->DEVCLASS); else printf('%s: Reclaim: %s%%, Scratch Usage: %s/%s, Device Type: %s',$spo->STGPOOL_NAME,$spo->RECLAIM,$spo->NUMSCRATCHUSED,$spo->MAXSCRATCH,$spo->DEVCLASSES->DEVTYPE); ?> - vols_bypoolbyctype($spo->STGPOOL_NAME,$ctype) as $vuo) { - $vo = $vuo->VOLUME; ?> + vols_bypoolbyctype($spo->STGPOOL_NAME,$ctype) as $vo) { ?> VOLUME_NAME),$vo->display('VOLUME_NAME')); ?> display('LAST_READ_DATE'); ?> diff --git a/application/views/node/filesystems.php b/application/views/node/filesystems.php index 19d7d2e..45572fc 100644 --- a/application/views/node/filesystems.php +++ b/application/views/node/filesystems.php @@ -1,7 +1,7 @@ - - vols_bypoolbyctype($spo->STGPOOL_NAME,$ctype) as $vuo) { - $vo = $vuo->VOLUME; ?> + vols_bypoolbyctype($spo->STGPOOL_NAME,$ctype) as $vo) { ?>
+ load('config')->tsmdatatypes as $btype => $ctype) { ?> @@ -36,6 +36,9 @@
- + + + +
set('o',$o); ?>set('o',$o); ?>
set('o',$o); ?>
diff --git a/application/views/node/stgpool_summary.php b/application/views/node/stgpool_pool.php similarity index 80% rename from application/views/node/stgpool_summary.php rename to application/views/node/stgpool_pool.php index b788d10..59eac8c 100644 --- a/application/views/node/stgpool_summary.php +++ b/application/views/node/stgpool_pool.php @@ -1,7 +1,7 @@ - + @@ -15,14 +15,14 @@ stgpooltypes() as $type) { ?> - + stgpools_byptype($type) as $spo) { ?> - + diff --git a/application/views/node/stgpool_type.php b/application/views/node/stgpool_type.php new file mode 100644 index 0000000..18a252e --- /dev/null +++ b/application/views/node/stgpool_type.php @@ -0,0 +1,32 @@ + +
Storage By Pool SummaryStorage By Pool Summary
 
getStorageTypeVols($type)); ?>vols_byptype($type)); ?> file_byptype($type),0); ?> logmb_byptype($type),0); ?>
 STGPOOL_NAME,$spo->display('STGPOOL_NAME')); ?> vols_bypool($spo)); ?> file_bypool($spo),0); ?> logmb_bypool($spo),0); ?>
+ + + + + + + + + + + + + btypes() as $type) { ?> + + + + + + + stgpools_bybtype($type) as $spo) { ?> + + + + + + + + + +
Storage By Type Summary
 
Storage Pool and TypeVolsFilesMB
vols_bybtype($type)); ?>file_bybtype($type),0); ?>logmb_bybtype($type),0); ?>
 STGPOOL_NAME,$spo->display('STGPOOL_NAME')); ?>vols_bypoolbybtype($spo,$type)); ?>file_bypoolbybtype($spo,$type),0); ?>logmb_bypoolbybtype($spo,$type),0); ?>
diff --git a/application/views/node/volumes.php b/application/views/node/volumes.php index 0ef546b..370919d 100644 --- a/application/views/node/volumes.php +++ b/application/views/node/volumes.php @@ -28,14 +28,13 @@
DEVCLASS == 'DISK') - printf('%s: Utilised: %s%%, Device Type: %s',$spo->STGPOOL_NAME,$spo->PCT_UTILIZED,$spo->DEVCLASS); + printf('%s: Utilised: %s%%, Device Type: %s',$spo->STGPOOL_NAME,$spo->PCT_MIGR,$spo->DEVCLASS); else printf('%s: Reclaim: %s%%, Scratch Usage: %s/%s, Device Type: %s',$spo->STGPOOL_NAME,$spo->RECLAIM,$spo->NUMSCRATCHUSED,$spo->MAXSCRATCH,$spo->DEVCLASSES->DEVTYPE); ?>
VOLUME_NAME),$vo->display('VOLUME_NAME')); ?> display('LAST_READ_DATE'); ?>