]>
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_SLAVEUPDATE 21
36 #define EVENT_COMMITTED 23
38 #define EVENT_TABLECLIENT 42
39 #define EVENT_TABLESERVER 43
41 #define EVENT_SUBTREEMAP_TEST 50
45 #include "include/buffer_fwd.h"
46 #include "include/Context.h"
47 #include "include/utime.h"
56 typedef __u32 EventType
;
61 static LogEvent
*decode_event(bufferlist
& bl
, bufferlist::iterator
& p
, EventType type
);
71 explicit LogEvent(int t
)
72 : _type(t
), _start_off(0), _segment(0) { }
73 virtual ~LogEvent() { }
75 string
get_type_str() const;
76 static EventType
str_to_type(boost::string_view str
);
77 EventType
get_type() const { return _type
; }
78 void set_type(EventType t
) { _type
= t
; }
80 uint64_t get_start_off() const { return _start_off
; }
81 void set_start_off(uint64_t o
) { _start_off
= o
; }
83 utime_t
get_stamp() const { return stamp
; }
84 void set_stamp(utime_t t
) { stamp
= t
; }
87 virtual void encode(bufferlist
& bl
, uint64_t features
) const = 0;
88 virtual void decode(bufferlist::iterator
&bl
) = 0;
89 static LogEvent
*decode(bufferlist
&bl
);
90 virtual void dump(Formatter
*f
) const = 0;
92 void encode_with_header(bufferlist
& bl
, uint64_t features
) {
93 ::encode(EVENT_NEW_ENCODING
, bl
);
94 ENCODE_START(1, 1, bl
)
100 virtual void print(ostream
& out
) const {
101 out
<< "event(" << _type
<< ")";
104 /*** live journal ***/
105 /* update_segment() - adjust any state we need to in the LogSegment
107 virtual void update_segment() { }
110 /* replay() - replay given event. this is idempotent.
112 virtual void replay(MDSRank
*m
) { ceph_abort(); }
115 * If the subclass embeds a MetaBlob, return it here so that
116 * tools can examine metablobs while traversing lists of LogEvent.
118 virtual EMetaBlob
*get_metablob() { return NULL
; }
121 static const std::map
<std::string
, LogEvent::EventType
> types
;
124 inline ostream
& operator<<(ostream
& out
, const LogEvent
&le
) {