Skip to content
Snippets Groups Projects
Commit e4f7f4b8 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-398: update load test notebook and bug fix

parent e9158c3a
No related branches found
No related tags found
1 merge request!161Resolve L2SS-398 "Archiver multi es"
...@@ -17,15 +17,6 @@ from .archiver_base import * ...@@ -17,15 +17,6 @@ from .archiver_base import *
logger = logging.getLogger() logger = logging.getLogger()
def parse_attribute_name(attribute_name:str): def parse_attribute_name(attribute_name:str):
"""
Parse the attribute names since most of the archiving operations require only
Tango full-qualified names.
"""
chunk_num = len(attribute_name.split('/'))
if (chunk_num!=4):
raise AttributeFormatException
def reduce_attribute_name(attribute_name:str):
""" """
For some operations Tango attribute must be transformed from the form 'tango://db:port/domain/family/name/attribute' For some operations Tango attribute must be transformed from the form 'tango://db:port/domain/family/name/attribute'
to canonical 'domain/family/name/attribute' to canonical 'domain/family/name/attribute'
...@@ -57,7 +48,7 @@ class Archiver(): ...@@ -57,7 +48,7 @@ class Archiver():
raise Exception("Configuration Manager is in FAULT state") raise Exception("Configuration Manager is in FAULT state")
except Exception as e: except Exception as e:
raise Exception("Connection failed with Configuration Manager device") from e raise Exception("Connection failed with Configuration Manager device") from e
self.es_list = [DeviceProxy(es_name) for es_name in self.get_subscribers(from_db=True)] or [] self.es_list = [es_name for es_name in self.get_subscribers(from_db=True)] or []
self.cm.write_attribute('Context',context) # Set default Context Archiving for all the subscribers self.cm.write_attribute('Context',context) # Set default Context Archiving for all the subscribers
self.selector = Selector() if selector_filename is None else Selector(selector_filename) # Create selector for customized strategies self.selector = Selector() if selector_filename is None else Selector(selector_filename) # Create selector for customized strategies
try: try:
...@@ -136,17 +127,17 @@ class Archiver(): ...@@ -136,17 +127,17 @@ class Archiver():
raise Exception from e raise Exception from e
return env_dict return env_dict
def add_attribute_to_archiver(self, attribute_name: str, polling_period: int, event_period: int, strategy: str = 'RUN'): def add_attribute_to_archiver(self, attribute_name: str, polling_period: int, event_period: int, strategy: str = 'RUN', es_name:str=None):
""" """
Takes as input the attribute name, polling period (ms), event period (ms) and archiving strategy, Takes as input the attribute name, polling period (ms), event period (ms) and archiving strategy,
and adds the selected attribute to the subscriber's list of archiving attributes. and adds the selected attribute to the subscriber's list of archiving attributes.
The ConfigurationManager and EventSubscriber devices must be already up and running. The ConfigurationManager and EventSubscriber devices must be already up and running.
The archiving-DBMS must be already properly configured. The archiving-DBMS must be already properly configured.
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
try: try:
self.cm.write_attribute('SetAttributeName', attribute_name) self.cm.write_attribute('SetAttributeName', attribute_name)
self.cm.write_attribute('SetArchiver', self.get_next_subscriber()) self.cm.write_attribute('SetArchiver', es_name or self.get_next_subscriber())
self.cm.write_attribute('SetStrategy', strategy) self.cm.write_attribute('SetStrategy', strategy)
self.cm.write_attribute('SetPollingPeriod', polling_period) self.cm.write_attribute('SetPollingPeriod', polling_period)
self.cm.write_attribute('SetPeriodEvent', event_period) self.cm.write_attribute('SetPeriodEvent', event_period)
...@@ -158,7 +149,7 @@ class Archiver(): ...@@ -158,7 +149,7 @@ class Archiver():
else: else:
logger.warning(f"Attribute {attribute_name} already in archiving list!") logger.warning(f"Attribute {attribute_name} already in archiving list!")
def add_attributes_by_device(self,device_name,global_archive_period:int = None, exclude:list = []): def add_attributes_by_device(self,device_name,global_archive_period:int = None, es_name:str=None, exclude:list = []):
""" """
Add sequentially all the attributes of the selected device in the event subscriber list, if not already present Add sequentially all the attributes of the selected device in the event subscriber list, if not already present
""" """
...@@ -171,12 +162,12 @@ class Archiver(): ...@@ -171,12 +162,12 @@ class Archiver():
attr_proxy = AttributeProxy(attr_fullname) attr_proxy = AttributeProxy(attr_fullname)
if attr_proxy.is_polled() is True: # if not polled attribute is also not archived if attr_proxy.is_polled() is True: # if not polled attribute is also not archived
try: try:
es = DeviceProxy(self.get_next_subscriber()) es = DeviceProxy(es_name or self.get_next_subscriber()) # choose an e.s. or get the first one available
if es.AttributeList is None or not(self.cm.AttributeSearch(a)): if es.AttributeList is None or not(self.cm.AttributeSearch(a)):
polling_period = attr_proxy.get_poll_period() or self.dev_polling_time polling_period = attr_proxy.get_poll_period() or self.dev_polling_time
archive_period = global_archive_period or int(attr_proxy.get_property('archive_period')['archive_period'][0]) or self.dev_archive_time archive_period = global_archive_period or int(attr_proxy.get_property('archive_period')['archive_period'][0]) or self.dev_archive_time
self.add_attribute_to_archiver(attr_fullname,polling_period=polling_period, self.add_attribute_to_archiver(attr_fullname,polling_period=polling_period,
event_period=archive_period) event_period=archive_period, es_name = es.name())
#time.sleep(0.5) #time.sleep(0.5)
except IndexError as e: except IndexError as e:
logger.warning(f"Attribute {attr_fullname} will not be archived because archive event period is not defined!") logger.warning(f"Attribute {attr_fullname} will not be archived because archive event period is not defined!")
...@@ -189,7 +180,7 @@ class Archiver(): ...@@ -189,7 +180,7 @@ class Archiver():
""" """
Stops the data archiving of the attribute passed as input, and remove it from the subscriber's list. Stops the data archiving of the attribute passed as input, and remove it from the subscriber's list.
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
try: try:
self.cm.AttributeStop(attribute_name) self.cm.AttributeStop(attribute_name)
self.cm.AttributeRemove(attribute_name) self.cm.AttributeRemove(attribute_name)
...@@ -230,7 +221,7 @@ class Archiver(): ...@@ -230,7 +221,7 @@ class Archiver():
exclude_list = [a.lower() for a in exclude] exclude_list = [a.lower() for a in exclude]
attrs_list = [a.lower() for a in list(attributes_nok) if a.lower() not in exclude_list] attrs_list = [a.lower() for a in list(attributes_nok) if a.lower() not in exclude_list]
for a in attrs_list: for a in attrs_list:
attr_fullname = reduce_attribute_name(a) attr_fullname = parse_attribute_name(a)
self.remove_attribute_from_archiver(attr_fullname) self.remove_attribute_from_archiver(attr_fullname)
def start_archiving_attribute(self, attribute_name:str): def start_archiving_attribute(self, attribute_name:str):
...@@ -238,7 +229,7 @@ class Archiver(): ...@@ -238,7 +229,7 @@ class Archiver():
Starts the archiving of the attribute passed as input. Starts the archiving of the attribute passed as input.
The attribute must be already present in the subscriber's list The attribute must be already present in the subscriber's list
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
try: try:
self.cm.AttributeStart(attribute_name) self.cm.AttributeStart(attribute_name)
except Exception as e: except Exception as e:
...@@ -252,7 +243,7 @@ class Archiver(): ...@@ -252,7 +243,7 @@ class Archiver():
Stops the archiving of the attribute passed as input. Stops the archiving of the attribute passed as input.
The attribute must be already present in the subscriber's list The attribute must be already present in the subscriber's list
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
try: try:
self.cm.AttributeStop(attribute_name) self.cm.AttributeStop(attribute_name)
except Exception as e: except Exception as e:
...@@ -265,7 +256,7 @@ class Archiver(): ...@@ -265,7 +256,7 @@ class Archiver():
""" """
Check if an attribute is in the archiving list Check if an attribute is in the archiving list
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
attributes = self.cm.AttributeSearch(attribute_name.lower()) attributes = self.cm.AttributeSearch(attribute_name.lower())
if len(attributes)>1: if len(attributes)>1:
# Handle case same attribute_name r/rw # Handle case same attribute_name r/rw
...@@ -323,7 +314,7 @@ class Archiver(): ...@@ -323,7 +314,7 @@ class Archiver():
""" """
Return the error related to the attribute Return the error related to the attribute
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
errs_dict = self.get_subscriber_errors() errs_dict = self.get_subscriber_errors()
for e in errs_dict: for e in errs_dict:
if attribute_name in e: if attribute_name in e:
...@@ -348,13 +339,14 @@ class Archiver(): ...@@ -348,13 +339,14 @@ class Archiver():
""" """
Given an attribute name, return the event subscriber associated with it Given an attribute name, return the event subscriber associated with it
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
# If the ConfManager manages more than one subscriber # If the ConfManager manages more than one subscriber
if len(self.get_subscribers())>1: if len(self.get_subscribers())>1:
for es_name in self.get_subscribers(): for es_name in self.get_subscribers():
# Search the attribute in the subscriber list # Search the attribute in the subscriber list (search substring because of the Tango naming conventions)
if attribute_name.lower() in list(DeviceProxy(es_name).AttributeList): for a in list(DeviceProxy(es_name).AttributeList or []):
return es_name if attribute_name.lower() in a:
return es_name
else: else:
return self.get_next_subscriber() return self.get_next_subscriber()
...@@ -362,7 +354,7 @@ class Archiver(): ...@@ -362,7 +354,7 @@ class Archiver():
""" """
Return the attribute archiving frequency in events/minute Return the attribute archiving frequency in events/minute
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
if self.is_attribute_archived(attribute_name): if self.is_attribute_archived(attribute_name):
es = DeviceProxy(self.get_attribute_subscriber(attribute_name)) es = DeviceProxy(self.get_attribute_subscriber(attribute_name))
freq_dict = dict((a,r) for a,r in zip(es.AttributeList,es.AttributeRecordFreqList)) freq_dict = dict((a,r) for a,r in zip(es.AttributeList,es.AttributeRecordFreqList))
...@@ -376,7 +368,7 @@ class Archiver(): ...@@ -376,7 +368,7 @@ class Archiver():
""" """
Return the attribute failure archiving frequency in events/minute Return the attribute failure archiving frequency in events/minute
""" """
parse_attribute_name(attribute_name) attribute_name = parse_attribute_name(attribute_name)
if self.is_attribute_archived(attribute_name): if self.is_attribute_archived(attribute_name):
es = DeviceProxy(self.get_attribute_subscriber(attribute_name)) es = DeviceProxy(self.get_attribute_subscriber(attribute_name))
fail_dict = dict((a,r) for a,r in zip(es.AttributeList,es.AttributeFailureFreqList)) fail_dict = dict((a,r) for a,r in zip(es.AttributeList,es.AttributeFailureFreqList))
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
"devices":{ "devices":{
"LTS/RECV/1": { "LTS/RECV/1": {
"environment": "development", "environment": "development",
"include": ["rcu_temperature_r"], "include": [],
"exclude": ["CLK_Enable_PWR_R","CLK_I2C_STATUS_R","CLK_PLL_error_R","CLK_PLL_locked_R","CLK_translator_busy_R"] "exclude": ["CLK_Enable_PWR_R","CLK_I2C_STATUS_R","CLK_PLL_error_R","CLK_PLL_locked_R","CLK_translator_busy_R"]
}, },
"LTS/SDP/1": { "LTS/SDP/1": {
"environment": "development", "environment": "development",
"include": [], "include": [],
"exclude": [] "exclude": ["FPGA_scrap_R","FPGA_scrap_RW"]
}, },
"LTS/SST/1": { "LTS/SST/1": {
"environment": "development", "environment": "development",
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment