Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
separate subscribed attributes on get_attributes methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sergirubio committed May 5, 2020
1 parent ed3f03a commit ee6b363
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
25 changes: 19 additions & 6 deletions PyTangoArchiving/hdbpp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_manager(self, db_name='', prop=''):
return dp

@Cached(expire=60.)
def get_archivers(self, from_db = True):
def get_subscribers(self, from_db = True):
"""
If not got from_db, the manager may limit the list available
"""
Expand All @@ -198,6 +198,10 @@ def get_archivers(self, from_db = True):
raise Exception('%s Manager not running'%self.manager)

return [d for d in p if d.strip()]

def get_archivers(self, *args, **kwargs):
""" alias to get_subscribers """
return self.get_subscribers(*args,**kwargs)

@Cached(expire=5.)
def get_archiver_attributes(self, archiver, from_db=False, full=False):
Expand Down Expand Up @@ -257,7 +261,10 @@ def get_archiver_errors(self,archiver):
return dict((a,e) for a,e in zip(al,er) if e)

def get_archiver_load(self,archiver,use_freq=True):

"""
if use_freq=True, returns attribute record frequency
if false, returns attribute list size
"""
if use_freq:
return fn.tango.read_attribute(archiver+'/attributerecordfreq')
else:
Expand Down Expand Up @@ -350,24 +357,30 @@ def get_attributes_by_table(self,table='',as_id=False):
" where att_conf_data_type_id = %s" % (w,i))) for t,i in types)

@Cached(depth=10,expire=60.)
def get_archived_attributes(self,search=''):
def get_subscribed_attributes(self,search=''):
"""
It gets attributes currently assigned to archiver and updates
It gets attributes currently assigned to subscribers and updates
internal attribute/archiver index.
DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
"""
#print('get_archived_attributes(%s)'%str(search))
attrs = []
[self.get_archiver_attributes(d,from_db=True)
for d in self.get_archivers()]
for d in self.get_subscribers()]
for d,dattrs in self.dedicated.items():
for a in dattrs:
self.attributes[a].archiver = d
if not search or fn.clsearch(search,a):
attrs.append(a)
return attrs

def get_archived_attributes(self, *args, **kwargs):
"""
alias to get_subscribed_attributes, to be overloaded in subclasses
"""
return self.get_subscribed_attributes(*args, **kwargs)

def get_attribute_ID(self,attr):
# returns only 1 ID
return self.get_attributes_IDs(attr,as_dict=0)[0][1]
Expand Down Expand Up @@ -605,7 +618,7 @@ def add_attribute(self,attribute,archiver=None,period=0,
"""
set _event arguments to -1 to ignore them and not modify the database
code_event will be set to True if no other event is setup
"""
attribute = parse_tango_model(attribute,fqdn=True).fullname
archiver = archiver or self.get_next_archiver(
Expand Down
4 changes: 2 additions & 2 deletions PyTangoArchiving/hdbpp/periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_archived_attributes(self,search='',periodic=True):
DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
"""
#print('get_archived_attributes(%s)'%str(search))
attrs = HDBppDB.get_archived_attributes(self, search)
attrs = HDBppDB.get_subscribed_attributes(self, search)
if periodic:
attrs.extend(self.get_periodic_attributes())
return sorted(set(fn.tango.get_full_name(a,fqdn=True).lower()
Expand Down Expand Up @@ -201,4 +201,4 @@ def clear_periodic_caches(self):
self.get_periodic_archiver_attributes.cache.clear()
self.get_periodic_archivers_attributes.cache.clear()
self.get_periodic_attribute_archiver.cache.clear()
self.get_periodic_attribute_period.cache.clear()
self.get_periodic_attribute_period.cache.clear()

0 comments on commit ee6b363

Please sign in to comment.