]>
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
;
99 * Resolve type string to type enum
101 * Return -1 if not found
103 LogEvent::EventType
LogEvent::str_to_type(std::string
const &str
)
105 std::map
<std::string
, EventType
> types
;
106 types
["SUBTREEMAP"] = EVENT_SUBTREEMAP
;
107 types
["SUBTREEMAP_TEST"] = EVENT_SUBTREEMAP_TEST
;
108 types
["EXPORT"] = EVENT_EXPORT
;
109 types
["IMPORTSTART"] = EVENT_IMPORTSTART
;
110 types
["IMPORTFINISH"] = EVENT_IMPORTFINISH
;
111 types
["FRAGMENT"] = EVENT_FRAGMENT
;
112 types
["RESETJOURNAL"] = EVENT_RESETJOURNAL
;
113 types
["SESSION"] = EVENT_SESSION
;
114 types
["SESSIONS_OLD"] = EVENT_SESSIONS_OLD
;
115 types
["SESSIONS"] = EVENT_SESSIONS
;
116 types
["UPDATE"] = EVENT_UPDATE
;
117 types
["SLAVEUPDATE"] = EVENT_SLAVEUPDATE
;
118 types
["OPEN"] = EVENT_OPEN
;
119 types
["COMMITTED"] = EVENT_COMMITTED
;
120 types
["TABLECLIENT"] = EVENT_TABLECLIENT
;
121 types
["TABLESERVER"] = EVENT_TABLESERVER
;
122 types
["NOOP"] = EVENT_NOOP
;
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
;