HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
MetricTagsCount.py
Go to the documentation of this file.
1 # coding: utf-8 # pylint: disable-all
2 
3 """@package algorithms
4  @file MetricTagsCount.py
5  @author scorp <developers.hce@gmail.com>
6  @link http://hierarchical-cluster-engine.com/
7  @copyright Copyright &copy; 2013 IOIX Ukraine
8  @license http://hierarchical-cluster-engine.com/license/
9  @package HCE project node API
10  @since 0.1
11  """
12 
13 import logging
14 
15 import app.Consts as APP_CONSTS
16 import app.Utils as Utils # pylint: disable=F0401
17 from BaseMetric import BaseMetric
18 
19 # Logger initialization
20 logger = Utils.MPLogger().getLogger()
21 
22 
23 # #The MetricTagsCount class, class that implements metric counters for tags Metric
24 #
26 
27 
28  # # class constructor
29  #
30  # @param name - metric's name
31  def __init__(self, names):
32  super(MetricTagsCount, self).__init__(names)
33 
34 
35  # # precalculate makes MetricTagsCount metrics precalculating
36  #
37  # @param result - param, that content calculating data in common format
38  # @return precalculated data in common format
39  def precalculate(self, result, metricName):
40  ret = {"count": 0, "percent": 0}
41  for key in result.tags:
42  if result.isTagFilled(key):
43  ret["count"] += 1
44  if len(result.tags) > 0:
45  ret["percent"] = ret["count"] * 100 / len(result.tags)
46  ret = self.retForMultiNames(ret, metricName)
47  return ret
def retForMultiNames(self, retDict, metricName)
Definition: BaseMetric.py:39
def precalculate(self, result, metricName)