MonitoringReporter

This class is used to insert data to a db (currently elasticsearch). It uses an internal list which is used to keep messages in the memory. addRecord is used to insert messages to the internal queue. commit is used to insert the acumulated messages to elasticsearch. It provides two failover mechanism: 1.) If the database is not available, the data will be kept in the memory. 2.) If a MQ is available, we store the messages in MQ service.

Note: In order to not send too many rows to the db we use __maxRecordsInABundle.

class DIRAC.MonitoringSystem.Client.MonitoringReporter.MonitoringReporter(monitoringType='', failoverQueueName='dirac.monitoring')

Bases: object

class MonitoringReporter

This class is used to interact with the db using failover mechanism.

Parameters:
  • __maxRecordsInABundle (int) – limit the number of records to be inserted to the db.
  • __documentLock (threading.RLock) – is used to lock the local store when it is being modified.
  • __documents – contains the recods which will be inserted to the db :type __documents: python:list
  • __monitoringType (str) – type of the records which will be inserted to the db. For example: WMSHistory.
  • __failoverQueueName (str) – the name of the messaging queue. For example: /queue/dirac.certification
__init__(monitoringType='', failoverQueueName='dirac.monitoring')

x.__init__(…) initializes x; see help(type(x)) for signature

addRecord(rec)

It inserts the record to the list :param dict rec: it kontains a key/value pair.

commit()

It inserts the accumulated data to the db. In case of failure it keeps in memory/MQ

processRecords()

It consumes all messaged from the MQ (these are failover messages). In case of failure, the messages will be inserted to the MQ again.

publishRecords(records, mqProducer=None)

send data to the MQ. If the mqProducer instance is provided, it will be used for publishing the data to MQ. :param list records: contains a list of key/value pairs (dictionaries) :param object mqProducer: We can provide the instance of a producer, which will be used to publish the data