Some more performance improvements and caching
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user