diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-03-14 13:42:29 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-03-22 11:29:11 -0700 |
commit | 7b56596eafa90ca89e4aafd711c6bcda2afcbf53 (patch) | |
tree | 4e1f4ae10549e4bbaab15df907af3e66a0f159a8 | |
parent | b9c7d946f421b2c1f9ca3a273a67d88281125a8f (diff) | |
download | ceph-7b56596eafa90ca89e4aafd711c6bcda2afcbf53.tar.gz |
cls_log: fixes, other adjustments
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/cls/log/cls_log.cc | 20 | ||||
-rw-r--r-- | src/cls/log/cls_log_client.cc | 17 | ||||
-rw-r--r-- | src/cls/log/cls_log_client.h | 5 |
3 files changed, 33 insertions, 9 deletions
diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index c0bb97be940..b15f93bb8e9 100644 --- a/src/cls/log/cls_log.cc +++ b/src/cls/log/cls_log.cc @@ -42,16 +42,20 @@ static int write_log_entry(cls_method_context_t hctx, string& index, cls_log_ent static void get_index_time_prefix(utime_t& ts, string& index) { char buf[32]; - snprintf(buf, sizeof(buf), "%10ld.%10ld_", (long)ts.sec(), (long)ts.usec()); + snprintf(buf, sizeof(buf), "%010ld.%06ld_", (long)ts.sec(), (long)ts.usec()); index = log_index_prefix + buf; } -static void get_index(utime_t& ts, string& section, string& name, string& index) +static void get_index(cls_method_context_t hctx, utime_t& ts, string& index) { get_index_time_prefix(ts, index); - index += section + ":" + name; + string unique_id; + + cls_cxx_subop_version(hctx, &unique_id); + + index.append(unique_id); } static int cls_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) @@ -70,7 +74,9 @@ static int cls_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist *ou string index; - get_index(entry.timestamp, entry.section, entry.name, index); + get_index(hctx, entry.timestamp, index); + + CLS_LOG(0, "storing entry at %s\n", index.c_str()); int ret = write_log_entry(hctx, index, entry); if (ret < 0) @@ -188,9 +194,9 @@ void __cls_init() cls_register("log", &h_class); /* log */ - cls_register_cxx_method(h_class, "log_add", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_add, &h_log_add); - cls_register_cxx_method(h_class, "log_list", CLS_METHOD_RD, cls_log_list, &h_log_list); - cls_register_cxx_method(h_class, "log_trim", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_trim, &h_log_trim); + cls_register_cxx_method(h_class, "add", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_add, &h_log_add); + cls_register_cxx_method(h_class, "list", CLS_METHOD_RD, cls_log_list, &h_log_list); + cls_register_cxx_method(h_class, "trim", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_trim, &h_log_trim); return; } diff --git a/src/cls/log/cls_log_client.cc b/src/cls/log/cls_log_client.cc index e765f368572..a5f44bfbca3 100644 --- a/src/cls/log/cls_log_client.cc +++ b/src/cls/log/cls_log_client.cc @@ -9,7 +9,6 @@ using namespace librados; - void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry) { bufferlist in; @@ -19,6 +18,19 @@ void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry) op.exec("log", "add", in); } +void cls_log_add(librados::ObjectWriteOperation& op, const utime_t& timestamp, + const string& section, const string& name, bufferlist& bl) +{ + cls_log_entry entry; + + entry.timestamp = timestamp; + entry.section = section; + entry.name = name; + entry.data = bl; + + cls_log_add(op, entry); +} + void cls_log_trim(librados::ObjectWriteOperation& op, utime_t& from, utime_t& to) { bufferlist in; @@ -78,6 +90,9 @@ void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, int max, cls_log_list_op call; call.from_time = from; call.num_entries = max; + + ::encode(call, inbl); + op.exec("log", "list", inbl, new LogListCtx(&entries, truncated)); } diff --git a/src/cls/log/cls_log_client.h b/src/cls/log/cls_log_client.h index ba062c7566d..cf1a541e495 100644 --- a/src/cls/log/cls_log_client.h +++ b/src/cls/log/cls_log_client.h @@ -9,8 +9,11 @@ */ void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry); +void cls_log_add(librados::ObjectWriteOperation& op, const utime_t& timestamp, + const string& section, const string& name, bufferlist& bl); -void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, int max, list<cls_log_entry>& entries); +void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, int max, + list<cls_log_entry>& entries, bool *truncated); void cls_log_trim(librados::ObjectWriteOperation& op, utime_t& from, utime_t& to); int cls_log_trim(librados::IoCtx& io_ctx, string& oid, utime_t& from, utime_t& to); |