From af36c088717ac8028ffe40b025d17be85292e9b0 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Sun, 3 Dec 2017 23:48:04 -0800 Subject: [PATCH] cls/otp: implement otp_info_t::dump() Signed-off-by: Yehuda Sadeh --- src/cls/CMakeLists.txt | 3 +-- src/cls/otp/cls_otp_types.cc | 34 ++++++++++++++++++++++++++++++++++ src/cls/otp/cls_otp_types.h | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/cls/otp/cls_otp_types.cc diff --git a/src/cls/CMakeLists.txt b/src/cls/CMakeLists.txt index d6a401b405a25..48bb3b6084b7b 100644 --- a/src/cls/CMakeLists.txt +++ b/src/cls/CMakeLists.txt @@ -80,8 +80,7 @@ install(TARGETS cls_otp DESTINATION ${cls_dir}) set(cls_otp_client_srcs otp/cls_otp_client.cc -# otp/cls_otp_types.cc -# otp/cls_otp_ops.cc + otp/cls_otp_types.cc ) add_library(cls_otp_client STATIC ${cls_otp_client_srcs}) list(APPEND cls_embedded_srcs ${cls_otp_srcs} ${cls_otp_client_srcs}) diff --git a/src/cls/otp/cls_otp_types.cc b/src/cls/otp/cls_otp_types.cc new file mode 100644 index 0000000000000..98c4d2560c4c0 --- /dev/null +++ b/src/cls/otp/cls_otp_types.cc @@ -0,0 +1,34 @@ +// -*- 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 "common/Clock.h" +#include "common/ceph_json.h" + +#include "include/utime.h" + +#include "cls/otp/cls_otp_types.h" + +using namespace rados::cls::otp; + +void otp_info_t::dump(Formatter *f) const +{ + encode_json("type", (int)type, f); + encode_json("id", id, f); + encode_json("seed", seed, f); + encode_json("time_ofs", utime_t(time_ofs), f); + encode_json("step_size", step_size, f); + encode_json("window", window, f); +} + diff --git a/src/cls/otp/cls_otp_types.h b/src/cls/otp/cls_otp_types.h index e4b62aca535c8..29b9837dacc86 100644 --- a/src/cls/otp/cls_otp_types.h +++ b/src/cls/otp/cls_otp_types.h @@ -52,6 +52,7 @@ namespace rados { ::decode(window, bl); DECODE_FINISH(bl); } + void dump(Formatter *f) const; }; WRITE_CLASS_ENCODER(rados::cls::otp::otp_info_t) -- 2.39.5