// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- /* * Ceph - scalable distributed file system * * Copyright (C) 2004-2006 Sage Weil * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. * */ #include #include #include #include #include #include using namespace std; #include "config.h" #include "mon/MonMap.h" #include "mon/Monitor.h" #include "msg/SimpleMessenger.h" #include "common/Timer.h" class C_Die : public Context { public: void finish(int) { cerr << "die" << endl; exit(1); } }; class C_Debug : public Context { public: void finish(int) { int size = &g_conf.debug_after - &g_conf.debug; memcpy((char*)&g_conf.debug, (char*)&g_debug_after_conf.debug, size); dout(0) << "debug_after flipping debug settings" << endl; } }; int main(int argc, char **argv) { vector args; argv_to_vec(argc, argv, args); parse_config_options(args); if (g_conf.kill_after) g_timer.add_event_after(g_conf.kill_after, new C_Die); if (g_conf.debug_after) g_timer.add_event_after(g_conf.debug_after, new C_Debug); // args int whoami = -1; char *monmap_fn = ".ceph_monmap"; for (unsigned i=0; i= 0); } else { // i am specific monitor. // read monmap cout << "reading monmap from .ceph_monmap" << endl; int r = monmap.read(monmap_fn); assert(r >= 0); // bind to a specific port cout << "starting mon" << whoami << " at " << monmap.get_inst(whoami) << endl; g_my_addr = monmap.get_inst(whoami).addr; rank.start_rank(); } // start monitor Messenger *m = rank.register_entity(MSG_ADDR_MON(whoami)); Monitor *mon = new Monitor(whoami, m, &monmap); mon->init(); // wait cout << "waiting for shutdown ..." << endl; rank.wait(); // done delete mon; return 0; }