]>
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.
20 #include "common/config.h"
22 #include "client/SyntheticClient.h"
23 #include "client/Client.h"
25 #include "msg/Messenger.h"
27 #include "mon/MonClient.h"
29 #include "common/Timer.h"
30 #include "global/global_init.h"
31 #include "common/ceph_argparse.h"
32 #include "common/pick_address.h"
34 #include <sys/types.h>
37 extern int syn_filer_flags
;
39 int main(int argc
, const char **argv
, char *envp
[])
41 //cerr << "ceph-syn starting" << std::endl;
42 vector
<const char*> args
;
43 argv_to_vec(argc
, argv
, args
);
45 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
46 CODE_ENVIRONMENT_UTILITY
, 0);
47 common_init_finish(g_ceph_context
);
49 parse_syn_options(args
); // for SyntheticClient
51 pick_addresses(g_ceph_context
, CEPH_PICK_ADDRESS_PUBLIC
);
54 MonClient
mc(g_ceph_context
);
55 if (mc
.build_initial_monmap() < 0)
58 list
<Client
*> clients
;
59 list
<SyntheticClient
*> synclients
;
60 Messenger
* messengers
[g_conf
->num_client
];
61 MonClient
* mclients
[g_conf
->num_client
];
63 cout
<< "ceph-syn: starting " << g_conf
->num_client
<< " syn client(s)" << std::endl
;
64 for (int i
=0; i
<g_conf
->num_client
; i
++) {
65 messengers
[i
] = Messenger::create_client_messenger(g_ceph_context
,
67 messengers
[i
]->bind(g_conf
->public_addr
);
68 mclients
[i
] = new MonClient(g_ceph_context
);
69 mclients
[i
]->build_initial_monmap();
70 auto client
= new StandaloneClient(messengers
[i
], mclients
[i
]);
71 client
->set_filer_flags(syn_filer_flags
);
72 SyntheticClient
*syn
= new SyntheticClient(client
);
73 clients
.push_back(client
);
74 synclients
.push_back(syn
);
75 messengers
[i
]->start();
78 for (list
<SyntheticClient
*>::iterator p
= synclients
.begin();
79 p
!= synclients
.end();
83 //cout << "waiting for client(s) to finish" << std::endl;
84 while (!clients
.empty()) {
85 Client
*client
= clients
.front();
86 SyntheticClient
*syn
= synclients
.front();
88 synclients
.pop_front();
94 for (int i
= 0; i
< g_conf
->num_client
; ++i
) {
95 // wait for messenger to finish
97 messengers
[i
]->shutdown();
98 messengers
[i
]->wait();