Пример #1
0
    import signal
except ImportError:
    log.msg("Couldn't import signal module")

SCHEMAS = loadStorageSchemas()
AGGREGATION_SCHEMAS = loadAggregationSchemas()
CACHE_SIZE_LOW_WATERMARK = settings.MAX_CACHE_SIZE * 0.95

# Inititalize token buckets so that we can enforce rate limits on creates and
# updates if the config wants them.
CREATE_BUCKET = None
UPDATE_BUCKET = None
if settings.MAX_CREATES_PER_MINUTE != float('inf'):
    capacity = settings.MAX_CREATES_PER_MINUTE
    fill_rate = float(settings.MAX_CREATES_PER_MINUTE) / 60
    CREATE_BUCKET = TokenBucket(capacity, fill_rate)

if settings.MAX_UPDATES_PER_SECOND != float('inf'):
    capacity = settings.MAX_UPDATES_PER_SECOND
    fill_rate = settings.MAX_UPDATES_PER_SECOND
    UPDATE_BUCKET = TokenBucket(capacity, fill_rate)


def optimalWriteOrder():
    """Generates metrics with the most cached values first and applies a soft
  rate limit on new metrics"""
    while MetricCache:
        (metric, datapoints) = MetricCache.pop()
        if state.cacheTooFull and MetricCache.size < CACHE_SIZE_LOW_WATERMARK:
            events.cacheSpaceAvailable()
Пример #2
0
    import signal
except ImportError:
    log.msg("Couldn't import signal module")

SCHEMAS = loadStorageSchemas()
AGGREGATION_SCHEMAS = loadAggregationSchemas()


# Inititalize token buckets so that we can enforce rate limits on creates and
# updates if the config wants them.
CREATE_BUCKET = None
UPDATE_BUCKET = None
if settings.MAX_CREATES_PER_MINUTE != float('inf'):
  capacity = settings.MAX_CREATES_PER_MINUTE
  fill_rate = float(settings.MAX_CREATES_PER_MINUTE) / 60
  CREATE_BUCKET = TokenBucket(capacity, fill_rate, reactor)

if settings.MAX_UPDATES_PER_SECOND != float('inf'):
  capacity = settings.MAX_UPDATES_PER_SECOND
  fill_rate = settings.MAX_UPDATES_PER_SECOND
  UPDATE_BUCKET = TokenBucket(capacity, fill_rate, reactor)


class TagQueue(object):
  def __init__(self, maxsize=0, update_interval=1):
    self.add_queue = queue.Queue(maxsize)
    self.update_queue = queue.Queue(maxsize)
    self.update_interval = update_interval
    self.update_counter = 0

  def add(self, metric):