summaryrefslogtreecommitdiff
path: root/src/ceph_syn.cc
diff options
context:
space:
mode:
authorSage Weil <sage.weil@dreamhost.com>2011-09-23 09:57:45 -0700
committerSage Weil <sage.weil@dreamhost.com>2011-09-23 10:04:52 -0700
commit0fdc86389a80fcb1031e411592aefb9d43a931b1 (patch)
treec9c65af4d34a61b8c9c1789719c631cb066933ad /src/ceph_syn.cc
parent5369c776d0d5a665bbde2a643e49dea4b384c473 (diff)
downloadceph-0fdc86389a80fcb1031e411592aefb9d43a931b1.tar.gz
rename source files c* -> ceph-*
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Diffstat (limited to 'src/ceph_syn.cc')
-rw-r--r--src/ceph_syn.cc105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/ceph_syn.cc b/src/ceph_syn.cc
new file mode 100644
index 00000000000..e1a6bdb43ce
--- /dev/null
+++ b/src/ceph_syn.cc
@@ -0,0 +1,105 @@
+// -*- 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 "common/config.h"
+
+#include "client/SyntheticClient.h"
+#include "client/Client.h"
+
+#include "msg/SimpleMessenger.h"
+
+#include "mon/MonClient.h"
+
+#include "common/Timer.h"
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+
+#ifndef DARWIN
+#include <envz.h>
+#endif // DARWIN
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+extern int syn_filer_flags;
+
+int main(int argc, const char **argv, char *envp[])
+{
+ //cerr << "ceph-syn starting" << std::endl;
+ vector<const char*> args;
+ argv_to_vec(argc, argv, args);
+
+ global_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+ common_init_finish(g_ceph_context);
+
+ parse_syn_options(args); // for SyntheticClient
+
+ vec_to_argv(args, argc, argv);
+
+ // get monmap
+ MonClient mc(g_ceph_context);
+ if (mc.build_initial_monmap() < 0)
+ return -1;
+
+ list<Client*> clients;
+ list<SyntheticClient*> synclients;
+ SimpleMessenger* messengers[g_conf->num_client];
+ MonClient* mclients[g_conf->num_client];
+
+ cout << "ceph-syn: starting " << g_conf->num_client << " syn client(s)" << std::endl;
+ for (int i=0; i<g_conf->num_client; i++) {
+ messengers[i] = new SimpleMessenger(g_ceph_context);
+ messengers[i]->register_entity(entity_name_t(entity_name_t::TYPE_CLIENT,-1));
+ messengers[i]->bind(i * 1000000 + getpid());
+ mclients[i] = new MonClient(g_ceph_context);
+ mclients[i]->build_initial_monmap();
+ Client *client = new Client(messengers[i], mclients[i]);
+ client->set_filer_flags(syn_filer_flags);
+ SyntheticClient *syn = new SyntheticClient(client);
+ clients.push_back(client);
+ synclients.push_back(syn);
+ messengers[i]->start();
+ }
+
+ for (list<SyntheticClient*>::iterator p = synclients.begin();
+ p != synclients.end();
+ p++)
+ (*p)->start_thread();
+
+ //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;
+ }
+
+ for (int i = 0; i < g_conf->num_client; ++i) {
+ // wait for messenger to finish
+ delete mclients[i];
+ messengers[i]->wait();
+ messengers[i]->destroy();
+ }
+ return 0;
+}
+