ceph/src/ceph_syn.cc
Kefu Chai 4718b7cb2f common,rbd,rgw,osd: extract config values into ConfigValues
this change introduce three classes: ConfigValues, ConfigProxy and
ConfigReader. in seastar port of OSD, each CPU shard will hold its own
reference of configuration, and upon changes of settings, each
shard will be updated with the new setting in async. so this forces us
to be able to keep two set of configuration at the same time. so we
need to extract the changeable part of md_config_t out. so we can
replace the old one with new one on demand, and let different shards
share the same unchanged part, amon the other things, the Options map
and the lookup tables. that's why we need ConfigValues. we will add
a policy template for this class, so we can specialize for Seastar
implementation to allow different ConfigProxy instances to point
md_config_impl<> to different ConfigValues.

because the observer interface is still using md_config_t, to minimise
the impact of this change, handle_conf_change() and
handle_subsys_change() are not changed. but as it accepts a `const
md_config_t`, which cannot be used to create/reference the ConfigProxy
holding it, we need to introduce ConfigReader for reading the updated
setting from md_config_t in a simpler way, without exposing the
internal "values" member variable.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2018-07-10 22:51:22 +08:00

103 lines
2.7 KiB
C++

// -*- 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>
#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 <sys/types.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);
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<Client*> clients;
list<SyntheticClient*> synclients;
vector<Messenger*> messengers{static_cast<unsigned>(num_client), nullptr};
vector<MonClient*> mclients{static_cast<unsigned>(num_client), nullptr};
cout << "ceph-syn: starting " << num_client << " syn client(s)" << std::endl;
for (int i=0; i<num_client; i++) {
messengers[i] = Messenger::create_client_messenger(g_ceph_context,
"synclient");
messengers[i]->bind(g_conf()->public_addr);
mclients[i] = new MonClient(g_ceph_context);
mclients[i]->build_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<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 < num_client; ++i) {
// wait for messenger to finish
delete mclients[i];
messengers[i]->shutdown();
messengers[i]->wait();
delete messengers[i];
}
return 0;
}