X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcls%2Flock%2Fcls_lock_types.cc;fp=src%2Fceph%2Fsrc%2Fcls%2Flock%2Fcls_lock_types.cc;h=38a0d93df4689fd4a388c715bf77ab1caceda77a;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/cls/lock/cls_lock_types.cc b/src/ceph/src/cls/lock/cls_lock_types.cc new file mode 100644 index 0000000..38a0d93 --- /dev/null +++ b/src/ceph/src/cls/lock/cls_lock_types.cc @@ -0,0 +1,98 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "common/Formatter.h" + +#include "cls/lock/cls_lock_types.h" + +using namespace rados::cls::lock; + +static void generate_lock_id(locker_id_t& i, int n, const string& cookie) +{ + i.locker = entity_name_t(entity_name_t::CLIENT(n)); + i.cookie = cookie; +} + +void locker_id_t::dump(Formatter *f) const +{ + f->dump_stream("locker") << locker; + f->dump_string("cookie", cookie); +} + +void locker_id_t::generate_test_instances(list& o) +{ + locker_id_t *i = new locker_id_t; + generate_lock_id(*i, 1, "cookie"); + o.push_back(i); + o.push_back(new locker_id_t); +} + +void locker_info_t::dump(Formatter *f) const +{ + f->dump_stream("expiration") << expiration; + f->dump_stream("addr") << addr; + f->dump_string("description", description); +} + +static void generate_test_addr(entity_addr_t& a, int nonce, int port) +{ + a.set_type(entity_addr_t::TYPE_LEGACY); + a.set_nonce(nonce); + a.set_family(AF_INET); + a.set_in4_quad(0, 127); + a.set_in4_quad(1, 0); + a.set_in4_quad(2, 1); + a.set_in4_quad(3, 2); + a.set_port(port); +} + +void locker_info_t::generate_test_instances(list& o) +{ + locker_info_t *i = new locker_info_t; + i->expiration = utime_t(5, 0); + generate_test_addr(i->addr, 1, 2); + i->description = "description"; + o.push_back(i); + o.push_back(new locker_info_t); +} + +void lock_info_t::dump(Formatter *f) const +{ + f->dump_int("lock_type", lock_type); + f->dump_string("tag", tag); + f->open_array_section("lockers"); + for (auto &i : lockers) { + f->open_object_section("locker"); + f->dump_object("id", i.first); + f->dump_object("info", i.second); + f->close_section(); + } + f->close_section(); +} + +void lock_info_t::generate_test_instances(list& o) +{ + lock_info_t *i = new lock_info_t; + locker_id_t id; + locker_info_t info; + generate_lock_id(id, 1, "cookie"); + info.expiration = utime_t(5, 0); + generate_test_addr(info.addr, 1, 2); + info.description = "description"; + i->lockers[id] = info; + i->lock_type = LOCK_EXCLUSIVE; + i->tag = "tag"; + o.push_back(i); + o.push_back(new lock_info_t); +}