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"
|
2009-02-09 23:46:02 +00:00
|
|
|
#include "common/common_init.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2008-03-10 05:32:16 +00:00
|
|
|
#include "mon/MonClient.h"
|
2007-10-17 23:34:54 +00:00
|
|
|
|
2009-03-10 21:57:24 +00:00
|
|
|
void usage()
|
|
|
|
{
|
2009-03-11 21:58:58 +00:00
|
|
|
cerr << "usage: cmds -i name [flags] [--mds rank] [--shadow rank]\n";
|
2009-03-10 22:22:52 +00:00
|
|
|
cerr << " -m monitorip:port\n";
|
|
|
|
cerr << " connect to monitor at given address\n";
|
|
|
|
cerr << " --debug_mds n\n";
|
|
|
|
cerr << " debug MDS level (e.g. 10)\n";
|
|
|
|
generic_server_usage();
|
2009-03-10 21:57:24 +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);
|
2009-03-20 19:12:33 +00:00
|
|
|
common_init(args, "mds", true);
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
// mds specific args
|
|
|
|
for (unsigned i=0; i<args.size(); i++) {
|
2009-03-11 21:58:58 +00:00
|
|
|
cerr << "unrecognized arg " << args[i] << std::endl;
|
|
|
|
usage();
|
2007-10-17 23:34:54 +00:00
|
|
|
}
|
2009-03-11 21:58:58 +00:00
|
|
|
if (!g_conf.id) {
|
|
|
|
cerr << "must specify '-i name' with the cmds instance name" << std::endl;
|
2009-03-11 20:04:03 +00:00
|
|
|
usage();
|
2009-03-11 21:58:58 +00:00
|
|
|
}
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
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();
|
2009-03-12 17:56:25 +00:00
|
|
|
cout << "starting mds." << g_conf.id
|
|
|
|
<< " at " << rank.get_rank_addr()
|
|
|
|
<< " fsid " << monmap.get_fsid()
|
|
|
|
<< std::endl;
|
2008-11-13 18:40:11 +00:00
|
|
|
|
2009-03-11 20:42:19 +00:00
|
|
|
Messenger *m = rank.register_entity(entity_name_t::MDS(-1));
|
2009-02-13 00:47:56 +00:00
|
|
|
assert_warn(m);
|
|
|
|
if (!m)
|
|
|
|
return 1;
|
2008-11-13 18:40:11 +00:00
|
|
|
|
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
|
2009-03-11 21:58:58 +00:00
|
|
|
MDS *mds = new MDS(g_conf.id, m, &monmap);
|
2009-03-10 21:57:24 +00:00
|
|
|
mds->init();
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
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
|
2009-04-19 03:11:55 +00:00
|
|
|
delete mds;
|
2007-10-17 23:34:54 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|