Esempio n. 1
0
  def WriteMetadataDescriptors(self, metrics_metadata, timestamp=None):
    current_metadata = self.Get(
        self.Schema.METRICS_METADATA,
        default=stats_values.StatsStoreMetricsMetadata())

    if current_metadata.AsDict() != metrics_metadata:
      store_metadata = stats_values.StatsStoreMetricsMetadata(
          metrics=metrics_metadata.values())
      self.AddAttribute(
          self.Schema.METRICS_METADATA, store_metadata, age=timestamp)
      self.Flush()
Esempio n. 2
0
  def MultiReadMetadata(self, process_ids=None):
    """Reads metadata of stored values for multiple given processes."""

    if not process_ids:
      process_ids = self.ListUsedProcessIds()

    subjects = [
        self.DATA_STORE_ROOT.Add(process_id) for process_id in process_ids
    ]
    subjects_data = aff4.FACTORY.MultiOpen(
        subjects, mode="r", token=self.token, aff4_type=StatsStoreProcessData)

    results = {}
    for subject_data in subjects_data:
      results[subject_data.urn.Basename()] = subject_data.Get(
          subject_data.Schema.METRICS_METADATA)

    for process_id in process_ids:
      results.setdefault(process_id, stats_values.StatsStoreMetricsMetadata())

    return results