summaryrefslogtreecommitdiffstats
path: root/src/mds/LogEvent.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/mds/LogEvent.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mds/LogEvent.h')
-rw-r--r--src/mds/LogEvent.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h
new file mode 100644
index 00000000..7c7273f8
--- /dev/null
+++ b/src/mds/LogEvent.h
@@ -0,0 +1,132 @@
+// -*- 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 <sage@newdream.net>
+ *
+ * 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.
+ *
+ */
+
+#ifndef CEPH_LOGEVENT_H
+#define CEPH_LOGEVENT_H
+
+#define EVENT_NEW_ENCODING 0 // indicates that the encoding is versioned
+#define EVENT_UNUSED 1 // was previously EVENT_STRING
+
+#define EVENT_SUBTREEMAP 2
+#define EVENT_EXPORT 3
+#define EVENT_IMPORTSTART 4
+#define EVENT_IMPORTFINISH 5
+#define EVENT_FRAGMENT 6
+
+#define EVENT_RESETJOURNAL 9
+
+#define EVENT_SESSION 10
+#define EVENT_SESSIONS_OLD 11
+#define EVENT_SESSIONS 12
+
+#define EVENT_UPDATE 20
+#define EVENT_SLAVEUPDATE 21
+#define EVENT_OPEN 22
+#define EVENT_COMMITTED 23
+
+#define EVENT_TABLECLIENT 42
+#define EVENT_TABLESERVER 43
+
+#define EVENT_SUBTREEMAP_TEST 50
+#define EVENT_NOOP 51
+
+
+#include "include/buffer_fwd.h"
+#include "include/Context.h"
+#include "include/utime.h"
+
+class MDSRank;
+class LogSegment;
+class EMetaBlob;
+
+// generic log event
+class LogEvent {
+public:
+ friend class MDLog;
+ typedef __u32 EventType;
+
+ LogEvent() = delete;
+ explicit LogEvent(int t) : _type(t) {}
+ LogEvent(const LogEvent&) = delete;
+ LogEvent& operator=(const LogEvent&) = delete;
+ virtual ~LogEvent() {}
+
+ std::string_view get_type_str() const;
+ static EventType str_to_type(std::string_view str);
+ EventType get_type() const { return _type; }
+ void set_type(EventType t) { _type = t; }
+
+ uint64_t get_start_off() const { return _start_off; }
+ void set_start_off(uint64_t o) { _start_off = o; }
+
+ utime_t get_stamp() const { return stamp; }
+ void set_stamp(utime_t t) { stamp = t; }
+
+ // encoding
+ virtual void encode(bufferlist& bl, uint64_t features) const = 0;
+ virtual void decode(bufferlist::const_iterator &) = 0;
+ static std::unique_ptr<LogEvent> decode_event(bufferlist::const_iterator);
+ virtual void dump(Formatter *f) const = 0;
+
+ void encode_with_header(bufferlist& bl, uint64_t features) {
+ using ceph::encode;
+ encode(EVENT_NEW_ENCODING, bl);
+ ENCODE_START(1, 1, bl)
+ encode(_type, bl);
+ this->encode(bl, features);
+ ENCODE_FINISH(bl);
+ }
+
+ virtual void print(ostream& out) const {
+ out << "event(" << _type << ")";
+ }
+
+ /*** live journal ***/
+ /* update_segment() - adjust any state we need to in the LogSegment
+ */
+ virtual void update_segment() { }
+
+ /*** recovery ***/
+ /* replay() - replay given event. this is idempotent.
+ */
+ virtual void replay(MDSRank *m) { ceph_abort(); }
+
+ /**
+ * If the subclass embeds a MetaBlob, return it here so that
+ * tools can examine metablobs while traversing lists of LogEvent.
+ */
+ virtual EMetaBlob *get_metablob() { return NULL; }
+
+protected:
+ utime_t stamp;
+
+ LogSegment* get_segment() { return _segment; }
+ LogSegment const* get_segment() const { return _segment; }
+
+private:
+ static const std::map<std::string, LogEvent::EventType> types;
+
+ static std::unique_ptr<LogEvent> decode_event(bufferlist::const_iterator&, EventType);
+
+ EventType _type = 0;
+ uint64_t _start_off = 0;
+ LogSegment *_segment = nullptr;
+};
+
+inline ostream& operator<<(ostream& out, const LogEvent &le) {
+ le.print(out);
+ return out;
+}
+
+#endif