]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/LogEvent.cc
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 #include "common/config.h"
21 #include "events/ESubtreeMap.h"
22 #include "events/EExport.h"
23 #include "events/EImportStart.h"
24 #include "events/EImportFinish.h"
25 #include "events/EFragment.h"
27 #include "events/EResetJournal.h"
28 #include "events/ESession.h"
29 #include "events/ESessions.h"
31 #include "events/EUpdate.h"
32 #include "events/EPeerUpdate.h"
33 #include "events/EOpen.h"
34 #include "events/ECommitted.h"
35 #include "events/EPurged.h"
37 #include "events/ETableClient.h"
38 #include "events/ETableServer.h"
40 #include "events/ENoOp.h"
42 #define dout_context g_ceph_context
45 std::unique_ptr
<LogEvent
> LogEvent::decode_event(bufferlist::const_iterator p
)
49 std::unique_ptr
<LogEvent
> event
;
53 if (EVENT_NEW_ENCODING
== type
) {
57 event
= decode_event(p
, type
);
60 catch (const buffer::error
&e
) {
61 generic_dout(0) << "failed to decode LogEvent (type maybe " << type
<< ")" << dendl
;
64 } else { // we are using classic encoding
65 event
= decode_event(p
, type
);
71 std::string_view
LogEvent::get_type_str() const
74 case EVENT_SUBTREEMAP
: return "SUBTREEMAP";
75 case EVENT_SUBTREEMAP_TEST
: return "SUBTREEMAP_TEST";
76 case EVENT_EXPORT
: return "EXPORT";
77 case EVENT_IMPORTSTART
: return "IMPORTSTART";
78 case EVENT_IMPORTFINISH
: return "IMPORTFINISH";
79 case EVENT_FRAGMENT
: return "FRAGMENT";
80 case EVENT_RESETJOURNAL
: return "RESETJOURNAL";
81 case EVENT_SESSION
: return "SESSION";
82 case EVENT_SESSIONS_OLD
: return "SESSIONS_OLD";
83 case EVENT_SESSIONS
: return "SESSIONS";
84 case EVENT_UPDATE
: return "UPDATE";
85 case EVENT_PEERUPDATE
: return "PEERUPDATE";
86 case EVENT_OPEN
: return "OPEN";
87 case EVENT_COMMITTED
: return "COMMITTED";
88 case EVENT_PURGED
: return "PURGED";
89 case EVENT_TABLECLIENT
: return "TABLECLIENT";
90 case EVENT_TABLESERVER
: return "TABLESERVER";
91 case EVENT_NOOP
: return "NOOP";
94 generic_dout(0) << "get_type_str: unknown type " << _type
<< dendl
;
99 const std::map
<std::string
, LogEvent::EventType
> LogEvent::types
= {
100 {"SUBTREEMAP", EVENT_SUBTREEMAP
},
101 {"SUBTREEMAP_TEST", EVENT_SUBTREEMAP_TEST
},
102 {"EXPORT", EVENT_EXPORT
},
103 {"IMPORTSTART", EVENT_IMPORTSTART
},
104 {"IMPORTFINISH", EVENT_IMPORTFINISH
},
105 {"FRAGMENT", EVENT_FRAGMENT
},
106 {"RESETJOURNAL", EVENT_RESETJOURNAL
},
107 {"SESSION", EVENT_SESSION
},
108 {"SESSIONS_OLD", EVENT_SESSIONS_OLD
},
109 {"SESSIONS", EVENT_SESSIONS
},
110 {"UPDATE", EVENT_UPDATE
},
111 {"PEERUPDATE", EVENT_PEERUPDATE
},
112 {"OPEN", EVENT_OPEN
},
113 {"COMMITTED", EVENT_COMMITTED
},
114 {"PURGED", EVENT_PURGED
},
115 {"TABLECLIENT", EVENT_TABLECLIENT
},
116 {"TABLESERVER", EVENT_TABLESERVER
},
121 * Resolve type string to type enum
123 * Return -1 if not found
125 LogEvent::EventType
LogEvent::str_to_type(std::string_view str
)
127 return LogEvent::types
.at(std::string(str
));
131 std::unique_ptr
<LogEvent
> LogEvent::decode_event(bufferlist::const_iterator
& p
, LogEvent::EventType type
)
133 const auto length
= p
.get_remaining();
134 generic_dout(15) << "decode_log_event type " << type
<< ", size " << length
<< dendl
;
137 std::unique_ptr
<LogEvent
> le
;
139 case EVENT_SUBTREEMAP
:
140 le
= std::make_unique
<ESubtreeMap
>();
142 case EVENT_SUBTREEMAP_TEST
:
143 le
= std::make_unique
<ESubtreeMap
>();
147 le
= std::make_unique
<EExport
>();
149 case EVENT_IMPORTSTART
:
150 le
= std::make_unique
<EImportStart
>();
152 case EVENT_IMPORTFINISH
:
153 le
= std::make_unique
<EImportFinish
>();
156 le
= std::make_unique
<EFragment
>();
158 case EVENT_RESETJOURNAL
:
159 le
= std::make_unique
<EResetJournal
>();
162 le
= std::make_unique
<ESession
>();
164 case EVENT_SESSIONS_OLD
:
166 auto e
= std::make_unique
<ESessions
>();
167 e
->mark_old_encoding();
172 le
= std::make_unique
<ESessions
>();
175 le
= std::make_unique
<EUpdate
>();
177 case EVENT_PEERUPDATE
:
178 le
= std::make_unique
<EPeerUpdate
>();
181 le
= std::make_unique
<EOpen
>();
183 case EVENT_COMMITTED
:
184 le
= std::make_unique
<ECommitted
>();
187 le
= std::make_unique
<EPurged
>();
189 case EVENT_TABLECLIENT
:
190 le
= std::make_unique
<ETableClient
>();
192 case EVENT_TABLESERVER
:
193 le
= std::make_unique
<ETableServer
>();
196 le
= std::make_unique
<ENoOp
>();
199 generic_dout(0) << "uh oh, unknown log event type " << type
<< " length " << length
<< dendl
;
207 catch (const buffer::error
&e
) {
208 generic_dout(0) << "failed to decode LogEvent type " << type
<< dendl
;
212 ceph_assert(p
.end());