]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph_syn.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
19 #include "common/config.h"
21 #include "client/SyntheticClient.h"
22 #include "client/Client.h"
24 #include "msg/Messenger.h"
26 #include "mon/MonClient.h"
28 #include "common/Timer.h"
29 #include "global/global_init.h"
30 #include "common/ceph_argparse.h"
31 #include "common/pick_address.h"
33 #include <sys/types.h>
36 extern int syn_filer_flags
;
38 int main(int argc
, const char **argv
, char *envp
[])
40 //cerr << "ceph-syn starting" << std::endl;
41 vector
<const char*> args
;
42 argv_to_vec(argc
, argv
, args
);
44 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
45 CODE_ENVIRONMENT_UTILITY
, 0);
46 common_init_finish(g_ceph_context
);
48 parse_syn_options(args
); // for SyntheticClient
50 pick_addresses(g_ceph_context
, CEPH_PICK_ADDRESS_PUBLIC
);
53 MonClient
mc(g_ceph_context
);
54 if (mc
.build_initial_monmap() < 0)
57 list
<Client
*> clients
;
58 list
<SyntheticClient
*> synclients
;
59 vector
<Messenger
*> messengers
{static_cast<unsigned>(num_client
), nullptr};
60 vector
<MonClient
*> mclients
{static_cast<unsigned>(num_client
), nullptr};
62 cout
<< "ceph-syn: starting " << num_client
<< " syn client(s)" << std::endl
;
63 for (int i
=0; i
<num_client
; i
++) {
64 messengers
[i
] = Messenger::create_client_messenger(g_ceph_context
,
66 messengers
[i
]->bind(g_conf()->public_addr
);
67 mclients
[i
] = new MonClient(g_ceph_context
);
68 mclients
[i
]->build_initial_monmap();
69 auto client
= new StandaloneClient(messengers
[i
], mclients
[i
]);
70 client
->set_filer_flags(syn_filer_flags
);
71 SyntheticClient
*syn
= new SyntheticClient(client
);
72 clients
.push_back(client
);
73 synclients
.push_back(syn
);
74 messengers
[i
]->start();
77 for (list
<SyntheticClient
*>::iterator p
= synclients
.begin();
78 p
!= synclients
.end();
82 //cout << "waiting for client(s) to finish" << std::endl;
83 while (!clients
.empty()) {
84 Client
*client
= clients
.front();
85 SyntheticClient
*syn
= synclients
.front();
87 synclients
.pop_front();
93 for (int i
= 0; i
< num_client
; ++i
) {
94 // wait for messenger to finish
96 messengers
[i
]->shutdown();
97 messengers
[i
]->wait();