]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/LogEvent.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_LOGEVENT_H
16 #define CEPH_LOGEVENT_H
18 #define EVENT_NEW_ENCODING 0 // indicates that the encoding is versioned
19 #define EVENT_UNUSED 1 // was previously EVENT_STRING
21 #define EVENT_SUBTREEMAP 2
22 #define EVENT_EXPORT 3
23 #define EVENT_IMPORTSTART 4
24 #define EVENT_IMPORTFINISH 5
25 #define EVENT_FRAGMENT 6
27 #define EVENT_RESETJOURNAL 9
29 #define EVENT_SESSION 10
30 #define EVENT_SESSIONS_OLD 11
31 #define EVENT_SESSIONS 12
33 #define EVENT_UPDATE 20
34 #define EVENT_PEERUPDATE 21
36 #define EVENT_COMMITTED 23
37 #define EVENT_PURGED 24
39 #define EVENT_TABLECLIENT 42
40 #define EVENT_TABLESERVER 43
42 #define EVENT_SUBTREEMAP_TEST 50
46 #include "include/buffer_fwd.h"
47 #include "include/Context.h"
48 #include "include/utime.h"
57 typedef __u32 EventType
;
61 explicit LogEvent(int t
) : _type(t
) {}
62 LogEvent(const LogEvent
&) = delete;
63 LogEvent
& operator=(const LogEvent
&) = delete;
64 virtual ~LogEvent() {}
66 std::string_view
get_type_str() const;
67 static EventType
str_to_type(std::string_view str
);
68 EventType
get_type() const { return _type
; }
69 void set_type(EventType t
) { _type
= t
; }
71 uint64_t get_start_off() const { return _start_off
; }
72 void set_start_off(uint64_t o
) { _start_off
= o
; }
74 utime_t
get_stamp() const { return stamp
; }
75 void set_stamp(utime_t t
) { stamp
= t
; }
78 virtual void encode(bufferlist
& bl
, uint64_t features
) const = 0;
79 virtual void decode(bufferlist::const_iterator
&) = 0;
80 static std::unique_ptr
<LogEvent
> decode_event(bufferlist::const_iterator
);
81 virtual void dump(Formatter
*f
) const = 0;
83 void encode_with_header(bufferlist
& bl
, uint64_t features
) {
85 encode(EVENT_NEW_ENCODING
, bl
);
86 ENCODE_START(1, 1, bl
)
88 this->encode(bl
, features
);
92 virtual void print(std::ostream
& out
) const {
93 out
<< "event(" << _type
<< ")";
96 /*** live journal ***/
97 /* update_segment() - adjust any state we need to in the LogSegment
99 virtual void update_segment() { }
102 /* replay() - replay given event. this is idempotent.
104 virtual void replay(MDSRank
*m
) { ceph_abort(); }
107 * If the subclass embeds a MetaBlob, return it here so that
108 * tools can examine metablobs while traversing lists of LogEvent.
110 virtual EMetaBlob
*get_metablob() { return NULL
; }
113 LogSegment
* get_segment() { return _segment
; }
114 LogSegment
const* get_segment() const { return _segment
; }
119 static const std::map
<std::string
, LogEvent::EventType
> types
;
121 static std::unique_ptr
<LogEvent
> decode_event(bufferlist::const_iterator
&, EventType
);
124 uint64_t _start_off
= 0;
125 LogSegment
*_segment
= nullptr;
128 inline std::ostream
& operator<<(std::ostream
& out
, const LogEvent
&le
) {