mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
log: use of cascading dispatcher for log messages
This commit is contained in:
parent
a5a7eea27c
commit
a6ed26faf8
@ -82,4 +82,16 @@ void LogClient::handle_log(MLog *m)
|
||||
delete m;
|
||||
}
|
||||
|
||||
bool LogClient::dispatch_impl(Message *m)
|
||||
{
|
||||
dout(20) << "dispatch " << m << dendl;
|
||||
|
||||
switch (m->get_type()) {
|
||||
case MSG_LOG:
|
||||
handle_log((MLog*)m);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,9 +27,11 @@ class MLog;
|
||||
class MonMap;
|
||||
|
||||
|
||||
class LogClient {
|
||||
class LogClient : public Dispatcher {
|
||||
Messenger *messenger;
|
||||
MonMap *monmap;
|
||||
|
||||
bool dispatch_impl(Message *m);
|
||||
public:
|
||||
|
||||
// -- log --
|
||||
@ -42,8 +44,11 @@ class LogClient {
|
||||
void send_log();
|
||||
void handle_log(MLog *m);
|
||||
|
||||
LogClient(Messenger *m, MonMap *mm) : messenger(m), monmap(mm),
|
||||
log_lock("LogClient::log_lock"), last_log(0) {}
|
||||
LogClient(Messenger *m, MonMap *mm, Dispatcher *disp) : messenger(m), monmap(mm),
|
||||
log_lock("LogClient::log_lock"), last_log(0) {
|
||||
if (disp)
|
||||
disp->link_dispatcher(this);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,20 +30,22 @@ class Dispatcher {
|
||||
Dispatcher() : next(NULL) { }
|
||||
|
||||
virtual void dispatch(Message *m) {
|
||||
if (!dispatch_impl(m)) {
|
||||
if (next) {
|
||||
next->dispatch(m);
|
||||
} else {
|
||||
bool ret = false;
|
||||
if (next)
|
||||
ret = next->dispatch_impl(m);
|
||||
|
||||
if (!ret) {
|
||||
if (!dispatch_impl(m)) {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void add(Dispatcher *disp) {
|
||||
virtual void link_dispatcher(Dispatcher *disp) {
|
||||
if (!next) {
|
||||
next = disp;
|
||||
} else {
|
||||
next->add(disp);
|
||||
next->link_dispatcher(disp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ int OSD::init()
|
||||
assert(whoami == superblock.whoami);
|
||||
|
||||
// log
|
||||
logclient = new LogClient(messenger, monmap);
|
||||
logclient = new LogClient(messenger, monmap, this);
|
||||
char name[80];
|
||||
sprintf(name, "osd%d", whoami);
|
||||
logger = new Logger(name, (LogType*)&osd_logtype);
|
||||
@ -1466,10 +1466,6 @@ bool OSD::dispatch_impl(Message *m)
|
||||
delete m;
|
||||
break;
|
||||
|
||||
case MSG_LOG:
|
||||
logclient->handle_log((MLog*)m);
|
||||
break;
|
||||
|
||||
// -- don't need OSDMap --
|
||||
|
||||
// map and replication
|
||||
|
Loading…
Reference in New Issue
Block a user