2007-10-17 23:34:54 +00:00
|
|
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
|
|
|
// vim: ts=8 sw=2 smarttab
|
|
|
|
/*
|
|
|
|
* Ceph - scalable distributed file system
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
|
|
|
*
|
|
|
|
* 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 <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "mon/MonMap.h"
|
|
|
|
#include "mds/MDS.h"
|
|
|
|
|
|
|
|
#include "msg/SimpleMessenger.h"
|
|
|
|
|
|
|
|
#include "common/Timer.h"
|
|
|
|
|
2008-03-10 05:32:16 +00:00
|
|
|
#include "mon/MonClient.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2008-01-01 22:04:31 +00:00
|
|
|
int main(int argc, const char **argv)
|
2007-10-17 23:34:54 +00:00
|
|
|
{
|
2008-01-01 22:04:31 +00:00
|
|
|
vector<const char*> args;
|
2007-10-17 23:34:54 +00:00
|
|
|
argv_to_vec(argc, argv, args);
|
2008-11-05 22:54:13 +00:00
|
|
|
env_to_vec(args);
|
2007-10-17 23:34:54 +00:00
|
|
|
parse_config_options(args);
|
|
|
|
|
|
|
|
// mds specific args
|
2008-03-10 05:32:16 +00:00
|
|
|
const char *monhost = 0;
|
2007-10-17 23:34:54 +00:00
|
|
|
int whoami = -1;
|
|
|
|
bool standby = false; // by default, i'll start active.
|
2008-12-23 19:44:28 +00:00
|
|
|
int standby_replay_for = -1;
|
2007-10-17 23:34:54 +00:00
|
|
|
for (unsigned i=0; i<args.size(); i++) {
|
|
|
|
if (strcmp(args[i], "--standby") == 0)
|
|
|
|
standby = true;
|
|
|
|
else if (strcmp(args[i], "--mds") == 0)
|
|
|
|
whoami = atoi(args[++i]);
|
2008-12-17 21:32:11 +00:00
|
|
|
else if (strcmp(args[i], "--standby_replay_for") == 0)
|
|
|
|
whoami = standby_replay_for = atoi(args[++i]);
|
2008-03-10 05:32:16 +00:00
|
|
|
else if (monhost == 0)
|
|
|
|
monhost = args[i];
|
2007-10-17 23:34:54 +00:00
|
|
|
else {
|
|
|
|
cerr << "unrecognized arg " << args[i] << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_conf.clock_tare) g_clock.tare();
|
|
|
|
|
2008-03-10 05:32:16 +00:00
|
|
|
// get monmap
|
2007-10-17 23:34:54 +00:00
|
|
|
MonMap monmap;
|
2008-03-10 05:32:16 +00:00
|
|
|
MonClient mc;
|
|
|
|
if (mc.get_monmap(&monmap) < 0)
|
2008-01-31 22:43:18 +00:00
|
|
|
return -1;
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2008-01-26 17:33:13 +00:00
|
|
|
rank.bind();
|
|
|
|
cout << "starting mds? at " << rank.get_rank_addr() << std::endl;
|
2008-11-13 18:40:11 +00:00
|
|
|
|
|
|
|
Messenger *m = rank.register_entity(entity_name_t::MDS(whoami));
|
|
|
|
assert(m);
|
|
|
|
|
2008-10-13 18:56:31 +00:00
|
|
|
rank.set_policy(entity_name_t::TYPE_MON, Rank::Policy::lossy_fail_after(1.0));
|
|
|
|
rank.set_policy(entity_name_t::TYPE_MDS, Rank::Policy::lossless());
|
|
|
|
rank.set_policy(entity_name_t::TYPE_OSD, Rank::Policy::lossless());
|
|
|
|
rank.set_policy(entity_name_t::TYPE_CLIENT, Rank::Policy::lossless()); // mds does its own timeout/markdown
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2008-11-13 18:40:11 +00:00
|
|
|
rank.start();
|
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
// start mds
|
|
|
|
MDS *mds = new MDS(whoami, m, &monmap);
|
2008-12-17 21:32:11 +00:00
|
|
|
mds->standby_replay_for = standby_replay_for;
|
2007-10-17 23:34:54 +00:00
|
|
|
mds->init(standby);
|
|
|
|
|
|
|
|
rank.wait();
|
|
|
|
|
|
|
|
// yuck: grab the mds lock, so we can be sure that whoever in *mds
|
|
|
|
// called shutdown finishes what they were doing.
|
|
|
|
mds->mds_lock.Lock();
|
|
|
|
mds->mds_lock.Unlock();
|
|
|
|
|
|
|
|
// done
|
|
|
|
//delete mds;
|
|
|
|
|
2008-11-04 22:50:21 +00:00
|
|
|
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
|
|
|
|
char s[20];
|
|
|
|
sprintf(s, "gmon/%d", getpid());
|
|
|
|
if (mkdir(s, 0755) == 0)
|
|
|
|
chdir(s);
|
|
|
|
|
2008-04-17 20:00:40 +00:00
|
|
|
generic_dout(0) << "stopped." << dendl;
|
2007-10-17 23:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|