Exemple #1
0
    def export_commitMarks(self,
                           sourceId,
                           activitiesDict,
                           componentExtraInfo={}):
        """
    Adds marks for activities

    :param int sourceId: component id
    :param dict activitiesDict: the key is the metrice, the value is a dictionary with timestamp and value
                                for example::

                                             {u'CPU': {1583244000: 10.6055594906},
                                              u'Iteration': {1583244420: 1,
                                                             1583244480: 1,
                                                             1583244540: 1,
                                                             1583244600: 1,
                                                             1583244660: 1},
                                              u'MEM': {1583244000: 49.03515625},
                                              u'Processed': {1583244420: 5,
                                                             1583244480: 5,
                                                             1583244540: 5,
                                                             1583244600: 5,
                                                             1583244660: 6}}

    :param dict componentExtraInfo: extra information
    """

        # we have to cast the dictionary keys, because they are timestamps
        activitiesDict = {
            metric: strToIntDict(value)
            for metric, value in activitiesDict.iteritems()
        }
        nowEpoch = Time.toEpoch()
        maxEpoch = nowEpoch + 7200
        minEpoch = nowEpoch - 86400
        invalidActivities = []
        for acName in activitiesDict:
            for time in activitiesDict[acName]:
                if time > maxEpoch or time < minEpoch:
                    gLogger.info(
                        "Time %s  ( [%s,%s] ) is invalid for activity %s" %
                        (time, minEpoch, maxEpoch, acName))
                    invalidActivities.append(acName)
                    break
        for acName in invalidActivities:
            gLogger.info("Not commiting activity %s" % acName)
            del activitiesDict[acName]
        return gServiceInterface.commitMarks(sourceId, activitiesDict,
                                             componentExtraInfo)
Exemple #2
0
 def export_commitMarks( self, sourceId, activitiesDict, componentExtraInfo = {} ):
   """
   Adds marks for activities
   """
   nowEpoch = Time.toEpoch()
   maxEpoch = nowEpoch + 7200
   minEpoch = nowEpoch - 86400
   invalidActivities = []
   for acName in activitiesDict:
     for time in activitiesDict[ acName ]:
       if time > maxEpoch or time < minEpoch:
         gLogger.info( "Time %s  ( [%s,%s] ) is invalid for activity %s" % ( time, minEpoch, maxEpoch, acName ) )
         invalidActivities.append( acName )
         break
   for acName in invalidActivities:
     gLogger.info( "Not commiting activity %s" % acName )
     del( activitiesDict[ acName ] )
   return gServiceInterface.commitMarks( sourceId, activitiesDict, componentExtraInfo )