]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph_syn.cc
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / ceph_syn.cc
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15#include <sys/stat.h>
16#include <iostream>
17#include <string>
7c673cae
FG
18
19#include "common/config.h"
20
f67539c2 21#include "common/async/context_pool.h"
7c673cae
FG
22#include "client/SyntheticClient.h"
23#include "client/Client.h"
24
25#include "msg/Messenger.h"
26
27#include "mon/MonClient.h"
28
29#include "common/Timer.h"
30#include "global/global_init.h"
31#include "common/ceph_argparse.h"
32#include "common/pick_address.h"
33
34#include <sys/types.h>
35#include <fcntl.h>
36
20effc67
TL
37using namespace std;
38
7c673cae
FG
39extern int syn_filer_flags;
40
41int main(int argc, const char **argv, char *envp[])
42{
43 //cerr << "ceph-syn starting" << std::endl;
20effc67 44 auto args = argv_to_vec(argc, argv);
7c673cae
FG
45
46 auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
47 CODE_ENVIRONMENT_UTILITY, 0);
48 common_init_finish(g_ceph_context);
49
50 parse_syn_options(args); // for SyntheticClient
51
52 pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC);
53
54 // get monmap
f67539c2
TL
55 ceph::async::io_context_pool poolctx(1);
56 MonClient mc(g_ceph_context, poolctx);
7c673cae
FG
57 if (mc.build_initial_monmap() < 0)
58 return -1;
59
60 list<Client*> clients;
61 list<SyntheticClient*> synclients;
11fdf7f2
TL
62 vector<Messenger*> messengers{static_cast<unsigned>(num_client), nullptr};
63 vector<MonClient*> mclients{static_cast<unsigned>(num_client), nullptr};
7c673cae 64
c07f9fc5
FG
65 cout << "ceph-syn: starting " << num_client << " syn client(s)" << std::endl;
66 for (int i=0; i<num_client; i++) {
7c673cae
FG
67 messengers[i] = Messenger::create_client_messenger(g_ceph_context,
68 "synclient");
f67539c2 69 mclients[i] = new MonClient(g_ceph_context, poolctx);
7c673cae 70 mclients[i]->build_initial_monmap();
f67539c2 71 auto client = new StandaloneClient(messengers[i], mclients[i], poolctx);
7c673cae
FG
72 client->set_filer_flags(syn_filer_flags);
73 SyntheticClient *syn = new SyntheticClient(client);
74 clients.push_back(client);
75 synclients.push_back(syn);
76 messengers[i]->start();
77 }
78
79 for (list<SyntheticClient*>::iterator p = synclients.begin();
80 p != synclients.end();
81 ++p)
82 (*p)->start_thread();
83
f67539c2
TL
84 poolctx.stop();
85
7c673cae
FG
86 //cout << "waiting for client(s) to finish" << std::endl;
87 while (!clients.empty()) {
88 Client *client = clients.front();
89 SyntheticClient *syn = synclients.front();
90 clients.pop_front();
91 synclients.pop_front();
92 syn->join_thread();
93 delete syn;
94 delete client;
95 }
96
c07f9fc5 97 for (int i = 0; i < num_client; ++i) {
7c673cae
FG
98 // wait for messenger to finish
99 delete mclients[i];
100 messengers[i]->shutdown();
101 messengers[i]->wait();
102 delete messengers[i];
103 }
104 return 0;
105}