コード例 #1
0
    def test_CeresReader_fetch(self):
        self.create_ceres('ceres.reader.tests.worker1.cpu')
        self.addCleanup(self.wipe_ceres)

        reader = CeresReader(ceres.CeresTree(self.test_dir).getNode('ceres.reader.tests.worker1.cpu'), 'ceres.reader.tests.worker1.cpu')

        (_, values) = reader.fetch(self.start_ts, self.start_ts+1)
        self.assertEqual(values, [60])
コード例 #2
0
    def test_CeresReader_get_intervals(self):
        self.create_ceres('ceres.reader.tests.worker1.cpu')
        self.addCleanup(self.wipe_ceres)

        reader = CeresReader(ceres.CeresTree(self.test_dir).getNode('ceres.reader.tests.worker1.cpu'), 'ceres.reader.tests.worker1.cpu')
        intervals = reader.get_intervals()
        for interval in intervals:
          self.assertEqual(interval.start, self.start_ts)
          self.assertEqual(interval.end, self.start_ts+1)
コード例 #3
0
    def test_CeresReader_fetch(self):
        self.create_ceres('ceres.reader.tests.worker1.cpu')
        self.addCleanup(self.wipe_ceres)

        reader = CeresReader(
            ceres.CeresTree(
                self.test_dir).getNode('ceres.reader.tests.worker1.cpu'),
            'ceres.reader.tests.worker1.cpu')

        (_, values) = reader.fetch(self.start_ts, self.start_ts + 1)
        self.assertEqual(values, [60])
コード例 #4
0
    def test_CeresReader_get_intervals(self):
        self.create_ceres('ceres.reader.tests.worker1.cpu')
        self.addCleanup(self.wipe_ceres)

        reader = CeresReader(
            ceres.CeresTree(
                self.test_dir).getNode('ceres.reader.tests.worker1.cpu'),
            'ceres.reader.tests.worker1.cpu')
        intervals = reader.get_intervals()
        for interval in intervals:
            self.assertEqual(interval.start, self.start_ts)
            self.assertEqual(interval.end, self.start_ts + 1)
コード例 #5
0
ファイル: ceres.py プロジェクト: vbichov/graphite-web
    def find_nodes(self, query):

        # translate query pattern if it is tagged
        tagged = not query.pattern.startswith(
            '_tagged.') and ';' in query.pattern
        if tagged:
            # tagged series are stored in ceres using encoded names, so to retrieve them we need to encode the
            # query pattern using the same scheme used in carbon when they are written.
            variants = [TaggedSeries.encode(query.pattern)]
        else:
            variants = extract_variants(query.pattern)

        for variant in variants:
            for fs_path in glob(self.tree.getFilesystemPath(variant)):
                metric_path = self.tree.getNodePath(fs_path)

                if CeresNode.isNodeDir(fs_path):
                    ceres_node = self.tree.getNode(metric_path)

                    if ceres_node.hasDataForInterval(query.startTime,
                                                     query.endTime):
                        real_metric_path = get_real_metric_path(
                            fs_path, metric_path)
                        reader = CeresReader(ceres_node, real_metric_path)
                        # if we're finding by tag, return the proper metric path
                        if tagged:
                            metric_path = query.pattern
                        yield LeafNode(metric_path, reader)

                elif os.path.isdir(fs_path):
                    yield BranchNode(metric_path)
コード例 #6
0
    def test_CeresReader_init(self):
        self.create_ceres('ceres.reader.tests.worker1.cpu')
        self.addCleanup(self.wipe_ceres)

        reader = CeresReader(
            ceres.CeresTree(
                self.test_dir).getNode('ceres.reader.tests.worker1.cpu'),
            'ceres.reader.tests.worker1.cpu')
        self.assertIsNotNone(reader)
コード例 #7
0
ファイル: finders.py プロジェクト: tsabirgaliev/graphite-web
  def find_nodes(self, query):
    for fs_path in glob( self.tree.getFilesystemPath(query.pattern) ):
      metric_path = self.tree.getNodePath(fs_path)

      if CeresNode.isNodeDir(fs_path):
        ceres_node = self.tree.getNode(metric_path)

        if ceres_node.hasDataForInterval(query.startTime, query.endTime):
          real_metric_path = get_real_metric_path(fs_path, metric_path)
          reader = CeresReader(ceres_node, real_metric_path)
          yield LeafNode(metric_path, reader)

      elif isdir(fs_path):
        yield BranchNode(metric_path)
コード例 #8
0
  def find_nodes(self, query):

    variants = extract_variants(query.pattern)

    for variant in variants:
      for fs_path in glob( self.tree.getFilesystemPath(variant)):
        metric_path = self.tree.getNodePath(fs_path)

        if CeresNode.isNodeDir(fs_path):
          ceres_node = self.tree.getNode(metric_path)

          if ceres_node.hasDataForInterval(query.startTime, query.endTime):
            relative_path = fs_path[len(self.directory):].lstrip('/')
            real_metric_path = get_real_metric_path(fs_path, relative_path)
            reader = CeresReader(ceres_node, real_metric_path)
            yield LeafNode(metric_path, reader)

        elif os.path.isdir(fs_path):
          yield BranchNode(metric_path)