~chrismd/graphite/graphite-0.9.9

« back to all changes in this revision

Viewing changes to carbon/lib/carbon/storage.py

  • Committer: Chris Davis
  • Date: 2011-09-25 21:16:17 UTC
  • mfrom: (573.1.2 graphite)
  • Revision ID: chrismd@gmail.com-20110925211617-awpjyhzp1al0z0w2
mergingĀ inĀ lp:~jerith/graphite/storage-aggregation

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
STORAGE_SCHEMAS_CONFIG = join(settings.CONF_DIR, 'storage-schemas.conf')
 
29
STORAGE_AGGREGATION_CONFIG = join(settings.CONF_DIR, 'storage-aggregation.conf')
29
30
STORAGE_LISTS_DIR = join(settings.CONF_DIR, 'lists')
30
31
 
31
32
def getFilesystemPath(metric):
146
147
  schemaList.append(defaultSchema)
147
148
  return schemaList
148
149
 
 
150
 
 
151
def loadAggregationSchemas():
 
152
  # NOTE: This abuses the Schema classes above, and should probably be refactored.
 
153
  schemaList = []
 
154
  config = OrderedConfigParser()
 
155
 
 
156
  try:
 
157
    config.read(STORAGE_AGGREGATION_CONFIG)
 
158
  except IOError:
 
159
    log.msg("%s not found, ignoring." % STORAGE_AGGREGATION_CONFIG)
 
160
 
 
161
  for section in config.sections():
 
162
    options = dict( config.items(section) )
 
163
    matchAll = options.get('match-all')
 
164
    pattern = options.get('pattern')
 
165
    listName = options.get('list')
 
166
 
 
167
    xFilesFactor = options.get('xfilesfactor')
 
168
    aggregationMethod = options.get('aggregationmethod')
 
169
 
 
170
    try:
 
171
      if xFilesFactor is not None:
 
172
        xFilesFactor = float(xFilesFactor)
 
173
        assert 0 <= xFilesFactor <= 1
 
174
      if aggregationMethod is not None:
 
175
        assert aggregationMethod in whisper.aggregationMethods
 
176
    except:
 
177
      log.msg("Invalid schemas found in %s." % section )
 
178
      continue
 
179
 
 
180
    archives = (xFilesFactor, aggregationMethod)
 
181
 
 
182
    if matchAll:
 
183
      mySchema = DefaultSchema(section, archives)
 
184
 
 
185
    elif pattern:
 
186
      mySchema = PatternSchema(section, pattern, archives)
 
187
 
 
188
    elif listName:
 
189
      mySchema = ListSchema(section, listName, archives)
 
190
 
 
191
    schemaList.append(mySchema)
 
192
 
 
193
  schemaList.append(defaultAggregation)
 
194
  return schemaList
 
195
 
149
196
defaultArchive = Archive(60, 60 * 24 * 7) #default retention for unclassified data (7 days of minutely data)
150
197
defaultSchema = DefaultSchema('default', [defaultArchive])
 
198
defaultAggregation = DefaultSchema('default', (None, None))