logclient: adjust link_dispatcher; add unlink_dispatcher

This commit is contained in:
Sage Weil 2008-12-16 11:25:14 -08:00
parent b917de3b80
commit cff97c1247
5 changed files with 22 additions and 10 deletions

View File

@ -45,11 +45,9 @@ class LogClient : public Dispatcher {
void send_log();
void handle_log(MLog *m);
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);
}
LogClient(Messenger *m, MonMap *mm) :
messenger(m), monmap(mm),
log_lock("LogClient::log_lock"), last_log(0) { }
};
#endif

View File

@ -31,7 +31,12 @@ public:
const char *get_type_name() { return "log"; }
void print(ostream& out) {
out << "log";
out << "log(";
if (entries.size())
out << entries.size() << " entries";
if (last)
out << "last " << last;
out << ")";
}
void encode_payload() {

View File

@ -52,6 +52,13 @@ class Dispatcher {
next->link_dispatcher(disp);
}
}
virtual void unlink_dispatcher(Dispatcher *disp) {
assert(next);
if (next == disp)
next = next->next;
else
next->unlink_dispatcher(disp);
}
// how i deal with transmission failures.
virtual void ms_handle_failure(Message *m, const entity_inst_t& inst) { }

View File

@ -256,6 +256,7 @@ OSD::OSD(int id, Messenger *m, Messenger *hbm, MonMap *mm, const char *dev) :
logger(NULL),
store(NULL),
monmap(mm),
logclient(messenger, monmap),
whoami(id), dev_name(dev),
boot_epoch(0), last_active_epoch(0),
state(STATE_BOOTING),
@ -381,7 +382,6 @@ int OSD::init()
assert(whoami == superblock.whoami);
// log
logclient = new LogClient(messenger, monmap, this);
char name[80];
sprintf(name, "osd%d", whoami);
logger = new Logger(name, (LogType*)&osd_logtype);
@ -428,6 +428,7 @@ int OSD::init()
// i'm ready!
messenger->set_dispatcher(this);
link_dispatcher(&logclient);
heartbeat_messenger->set_dispatcher(&heartbeat_dispatcher);
// announce to monitor i exist and have booted.
@ -526,6 +527,7 @@ int OSD::shutdown()
}
pg_map.clear();
unlink_dispatcher(&logclient);
messenger->shutdown();
if (heartbeat_messenger)
heartbeat_messenger->shutdown();
@ -1216,7 +1218,7 @@ void OSD::do_mon_report()
}
// do any pending reports
logclient->send_log();
logclient.send_log();
if (is_booting())
send_boot();
send_alive();

View File

@ -59,7 +59,7 @@ protected:
ObjectStore *store;
MonMap *monmap;
LogClient *logclient;
LogClient logclient;
int whoami;
const char *dev_name;
@ -719,7 +719,7 @@ private:
void force_remount();
LogClient *get_logclient() { return logclient; }
LogClient *get_logclient() { return &logclient; }
};
#endif