]> git.proxmox.com Git - ceph.git/blob - ceph/src/cls/lock/cls_lock_types.cc
1c67bdea5ce419cbac4dd054c791759399bf8137
[ceph.git] / ceph / src / cls / lock / cls_lock_types.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #include "common/Formatter.h"
16
17 #include "cls/lock/cls_lock_types.h"
18
19 using namespace rados::cls::lock;
20
21 static void generate_lock_id(locker_id_t& i, int n, const string& cookie)
22 {
23 i.locker = entity_name_t(entity_name_t::CLIENT(n));
24 i.cookie = cookie;
25 }
26
27 void locker_id_t::dump(Formatter *f) const
28 {
29 f->dump_stream("locker") << locker;
30 f->dump_string("cookie", cookie);
31 }
32
33 void locker_id_t::generate_test_instances(list<locker_id_t*>& o)
34 {
35 locker_id_t *i = new locker_id_t;
36 generate_lock_id(*i, 1, "cookie");
37 o.push_back(i);
38 o.push_back(new locker_id_t);
39 }
40
41 void locker_info_t::dump(Formatter *f) const
42 {
43 f->dump_stream("expiration") << expiration;
44 f->dump_stream("addr") << addr;
45 f->dump_string("description", description);
46 }
47
48 static void generate_test_addr(entity_addr_t& a, int nonce, int port)
49 {
50 a.set_type(entity_addr_t::TYPE_LEGACY);
51 a.set_nonce(nonce);
52 a.set_family(AF_INET);
53 a.set_in4_quad(0, 127);
54 a.set_in4_quad(1, 0);
55 a.set_in4_quad(2, 1);
56 a.set_in4_quad(3, 2);
57 a.set_port(port);
58 }
59
60 void locker_info_t::generate_test_instances(list<locker_info_t*>& o)
61 {
62 locker_info_t *i = new locker_info_t;
63 i->expiration = utime_t(5, 0);
64 generate_test_addr(i->addr, 1, 2);
65 i->description = "description";
66 o.push_back(i);
67 o.push_back(new locker_info_t);
68 }
69