Exemplo n.º 1
0
    def test_read_metric(self):
        tsd = LevelTsdBase('/tmp')
        reader = LevelTsdReader(tsd)
        writer = LevelTsdWriter(tsd)

        self.assertTrue(writer.write("just.purge", 1, 2.4))
        self.assertTrue(writer.write("just.delete", 1, 2.4))
        self.assertTrue(writer.write("fubar.zigar", 112, 3.14))
        self.assertTrue(writer.write("fubar.zigar", 90000, 3.14))
        self.assertTrue(writer.write("fubar.zigar", 90000000, 2.18))

        tsd.flush(True)

        just_children = reader.get_child_nodes('just')
        self.assertTrue('purge' in just_children)
        self.assertTrue('delete' in just_children)
        self.assertTrue(reader.is_node_leaf('just.purge'))

        dp = list(reader.get_range_data("just.purge", 1, 100))
        print dp
        self.assertEqual(len(dp), 1)

        dp = list(reader.get_range_data("fubar.zigar", 1, 100000))
        print dp
        self.assertEqual(len(dp), 2)
Exemplo n.º 2
0
class LevelTsdRpc(jsonrpc.JSONRPC):
    def __init__(self):
        self.reader = LevelTsdReader(LevelTsdCarbon._pesudo_singleton.db)
        self.writer = LevelTsdWriter(LevelTsdCarbon._pesudo_singleton.db)

    def jsonrpc_get_child_nodes(self, parent_path):
        return self.reader.get_child_nodes(parent_path)

    def jsonrpc_is_node_leaf(self, path):
        return self.reader.is_node_leaf(path)

    def jsonrpc_get_range_data(self, metric, start_time, end_time):
        return list(self.reader.get_range_data(metric, start_time, end_time))
Exemplo n.º 3
0
 def __init__(self):
     self.reader = LevelTsdReader(LevelTsdCarbon._pesudo_singleton.db)
     self.writer = LevelTsdWriter(LevelTsdCarbon._pesudo_singleton.db)