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/stat.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "client/SyntheticClient.h"
|
|
|
|
#include "client/Client.h"
|
|
|
|
|
|
|
|
#include "msg/SimpleMessenger.h"
|
|
|
|
|
2008-03-08 00:26:35 +00:00
|
|
|
#include "mon/MonClient.h"
|
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
#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
|
|
|
|
|
|
|
#ifndef DARWIN
|
|
|
|
#include <envz.h>
|
|
|
|
#endif // DARWIN
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2008-07-08 23:44:43 +00:00
|
|
|
int main(int argc, const char **argv, char *envp[])
|
|
|
|
{
|
2008-01-01 22:04:31 +00:00
|
|
|
//cerr << "csyn starting" << std::endl;
|
|
|
|
vector<const char*> args;
|
2007-10-17 23:34:54 +00:00
|
|
|
argv_to_vec(argc, argv, args);
|
2009-09-25 23:19:38 +00:00
|
|
|
common_init(args, "csyn", false, true);
|
2007-10-17 23:34:54 +00:00
|
|
|
parse_syn_options(args); // for SyntheticClient
|
|
|
|
|
|
|
|
vec_to_argv(args, argc, argv);
|
|
|
|
|
|
|
|
if (g_conf.clock_tare) g_clock.tare();
|
|
|
|
|
2008-03-10 05:32:16 +00:00
|
|
|
// get monmap
|
2009-06-26 20:49:12 +00:00
|
|
|
MonClient mc;
|
|
|
|
if (mc.build_initial_monmap() < 0)
|
2008-03-10 05:32:16 +00:00
|
|
|
return -1;
|
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
// start up network
|
2010-01-08 00:53:51 +00:00
|
|
|
SimpleMessenger *messenger = new SimpleMessenger();
|
2009-10-08 17:02:22 +00:00
|
|
|
cout << "starting csyn" << std::endl;
|
2008-01-07 20:59:25 +00:00
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
list<Client*> clients;
|
|
|
|
list<SyntheticClient*> synclients;
|
|
|
|
|
|
|
|
cout << "mounting and starting " << g_conf.num_client << " syn client(s)" << std::endl;
|
|
|
|
for (int i=0; i<g_conf.num_client; i++) {
|
2010-01-08 00:53:51 +00:00
|
|
|
messenger->register_entity(entity_name_t(entity_name_t::TYPE_CLIENT,-1));
|
|
|
|
Client *client = new Client(messenger, &mc);
|
2007-10-17 23:34:54 +00:00
|
|
|
SyntheticClient *syn = new SyntheticClient(client);
|
|
|
|
clients.push_back(client);
|
|
|
|
synclients.push_back(syn);
|
|
|
|
}
|
|
|
|
|
2010-01-08 00:53:51 +00:00
|
|
|
messenger->start();
|
2008-11-13 22:36:48 +00:00
|
|
|
|
|
|
|
for (list<SyntheticClient*>::iterator p = synclients.begin();
|
|
|
|
p != synclients.end();
|
|
|
|
p++)
|
|
|
|
(*p)->start_thread();
|
|
|
|
|
2007-10-17 23:34:54 +00:00
|
|
|
cout << "waiting for client(s) to finish" << std::endl;
|
|
|
|
while (!clients.empty()) {
|
|
|
|
Client *client = clients.front();
|
|
|
|
SyntheticClient *syn = synclients.front();
|
|
|
|
clients.pop_front();
|
|
|
|
synclients.pop_front();
|
|
|
|
syn->join_thread();
|
|
|
|
delete syn;
|
|
|
|
delete client;
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait for messenger to finish
|
2010-01-08 00:53:51 +00:00
|
|
|
messenger->wait();
|
2007-10-17 23:34:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|