Work on performance improvements with caching

This commit is contained in:
Deon George
2012-12-04 11:52:10 +11:00
parent eafb80f7fc
commit 1bf8a520e2
30 changed files with 877 additions and 495 deletions

View File

@@ -27,6 +27,43 @@ class Model_STGPOOL extends TSM_ORM {
'OCC'=>array('foreign_key'=>'STGPOOL_NAME','far_key'=>'STGPOOL_NAME'),
);
/**
* Get all the OCCUPANCY for this STORAGE POOL
*/
private function _occupancy() {
$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->STGPOOL_NAME == $this->STGPOOL_NAME)
array_push($result,$o);
return $result;
}
/**
* Get all the NODES for this STORAGE POOL
*/
public function nodes() {
$k = sprintf('%s-%s',__METHOD__,$this->STGPOOL_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
// @todo This might want to return the NODE object.
foreach ($this->_occupancy() as $oo)
if (! in_array($oo->NODE_NAME,$result))
array_push($result,$oo->NODE_NAME);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
return $result;
}
// Return a list of volumes
// @param $inout IN|OUT of the library
// @param $status volume status FULL|FILLING|PENDING|EMPTY