]>
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/ESlaveUpdate.h"
33 #include "events/EOpen.h"
34 #include "events/ECommitted.h"
36 #include "events/ETableClient.h"
37 #include "events/ETableServer.h"
39 #include "events/ENoOp.h"
41 #define dout_context g_ceph_context
44 LogEvent
*LogEvent::decode(bufferlist
& bl
)
47 bufferlist::iterator p
= bl
.begin();
49 LogEvent
*event
= NULL
;
52 if (EVENT_NEW_ENCODING
== type
) {
56 event
= decode_event(bl
, p
, type
);
59 catch (const buffer::error
&e
) {
60 generic_dout(0) << "failed to decode LogEvent (type maybe " << type
<< ")" << dendl
;
63 } else { // we are using classic encoding
64 event
= decode_event(bl
, p
, type
);
70 std::string
LogEvent::get_type_str() const
73 case EVENT_SUBTREEMAP
: return "SUBTREEMAP";
74 case EVENT_SUBTREEMAP_TEST
: return "SUBTREEMAP_TEST";
75 case EVENT_EXPORT
: return "EXPORT";
76 case EVENT_IMPORTSTART
: return "IMPORTSTART";
77 case EVENT_IMPORTFINISH
: return "IMPORTFINISH";
78 case EVENT_FRAGMENT
: return "FRAGMENT";
79 case EVENT_RESETJOURNAL
: return "RESETJOURNAL";
80 case EVENT_SESSION
: return "SESSION";
81 case EVENT_SESSIONS_OLD
: return "SESSIONS_OLD";
82 case EVENT_SESSIONS
: return "SESSIONS";
83 case EVENT_UPDATE
: return "UPDATE";
84 case EVENT_SLAVEUPDATE
: return "SLAVEUPDATE";
85 case EVENT_OPEN
: return "OPEN";
86 case EVENT_COMMITTED
: return "COMMITTED";
87 case EVENT_TABLECLIENT
: return "TABLECLIENT";
88 case EVENT_TABLESERVER
: return "TABLESERVER";
89 case EVENT_NOOP
: return "NOOP";
92 generic_dout(0) << "get_type_str: unknown type " << _type
<< dendl
;
97 const std::map
<std::string
, LogEvent::EventType
> LogEvent::types
= {
98 {"SUBTREEMAP", EVENT_SUBTREEMAP
},
99 {"SUBTREEMAP_TEST", EVENT_SUBTREEMAP_TEST
},
100 {"EXPORT", EVENT_EXPORT
},
101 {"IMPORTSTART", EVENT_IMPORTSTART
},
102 {"IMPORTFINISH", EVENT_IMPORTFINISH
},
103 {"FRAGMENT", EVENT_FRAGMENT
},
104 {"RESETJOURNAL", EVENT_RESETJOURNAL
},
105 {"SESSION", EVENT_SESSION
},
106 {"SESSIONS_OLD", EVENT_SESSIONS_OLD
},
107 {"SESSIONS", EVENT_SESSIONS
},
108 {"UPDATE", EVENT_UPDATE
},
109 {"SLAVEUPDATE", EVENT_SLAVEUPDATE
},
110 {"OPEN", EVENT_OPEN
},
111 {"COMMITTED", EVENT_COMMITTED
},
112 {"TABLECLIENT", EVENT_TABLECLIENT
},
113 {"TABLESERVER", EVENT_TABLESERVER
},
118 * Resolve type string to type enum
120 * Return -1 if not found
122 LogEvent::EventType
LogEvent::str_to_type(boost::string_view str
)
124 return LogEvent::types
.at(std::string(str
));
128 LogEvent
*LogEvent::decode_event(bufferlist
& bl
, bufferlist::iterator
& p
, LogEvent::EventType type
)
130 int length
= bl
.length() - p
.get_off();
131 generic_dout(15) << "decode_log_event type " << type
<< ", size " << length
<< dendl
;
136 case EVENT_SUBTREEMAP
: le
= new ESubtreeMap
; break;
137 case EVENT_SUBTREEMAP_TEST
:
138 le
= new ESubtreeMap
;
141 case EVENT_EXPORT
: le
= new EExport
; break;
142 case EVENT_IMPORTSTART
: le
= new EImportStart
; break;
143 case EVENT_IMPORTFINISH
: le
= new EImportFinish
; break;
144 case EVENT_FRAGMENT
: le
= new EFragment
; break;
146 case EVENT_RESETJOURNAL
: le
= new EResetJournal
; break;
148 case EVENT_SESSION
: le
= new ESession
; break;
149 case EVENT_SESSIONS_OLD
: le
= new ESessions
; (static_cast<ESessions
*>(le
))->mark_old_encoding(); break;
150 case EVENT_SESSIONS
: le
= new ESessions
; break;
152 case EVENT_UPDATE
: le
= new EUpdate
; break;
153 case EVENT_SLAVEUPDATE
: le
= new ESlaveUpdate
; break;
154 case EVENT_OPEN
: le
= new EOpen
; break;
155 case EVENT_COMMITTED
: le
= new ECommitted
; break;
157 case EVENT_TABLECLIENT
: le
= new ETableClient
; break;
158 case EVENT_TABLESERVER
: le
= new ETableServer
; break;
160 case EVENT_NOOP
: le
= new ENoOp
; break;
163 generic_dout(0) << "uh oh, unknown log event type " << type
<< " length " << length
<< dendl
;
171 catch (const buffer::error
&e
) {
172 generic_dout(0) << "failed to decode LogEvent type " << type
<< dendl
;