From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/ceph_syn.cc | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/ceph_syn.cc (limited to 'src/ceph_syn.cc') diff --git a/src/ceph_syn.cc b/src/ceph_syn.cc new file mode 100644 index 00000000..5c469474 --- /dev/null +++ b/src/ceph_syn.cc @@ -0,0 +1,101 @@ +// -*- 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 + * + * 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 "common/config.h" + +#include "client/SyntheticClient.h" +#include "client/Client.h" + +#include "msg/Messenger.h" + +#include "mon/MonClient.h" + +#include "common/Timer.h" +#include "global/global_init.h" +#include "common/ceph_argparse.h" +#include "common/pick_address.h" + +#include +#include + +extern int syn_filer_flags; + +int main(int argc, const char **argv, char *envp[]) +{ + //cerr << "ceph-syn starting" << std::endl; + vector args; + argv_to_vec(argc, argv, args); + + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); + common_init_finish(g_ceph_context); + + parse_syn_options(args); // for SyntheticClient + + pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC); + + // get monmap + MonClient mc(g_ceph_context); + if (mc.build_initial_monmap() < 0) + return -1; + + list clients; + list synclients; + vector messengers{static_cast(num_client), nullptr}; + vector mclients{static_cast(num_client), nullptr}; + + cout << "ceph-syn: starting " << num_client << " syn client(s)" << std::endl; + for (int i=0; ibuild_initial_monmap(); + auto client = new StandaloneClient(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::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 < num_client; ++i) { + // wait for messenger to finish + delete mclients[i]; + messengers[i]->shutdown(); + messengers[i]->wait(); + delete messengers[i]; + } + return 0; +} + -- cgit v1.2.3