From 03ef427b31f01fc472835a3773a24f6237e7c587 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 11 May 2017 21:49:35 -0500 Subject: [PATCH] ceph-syn: parse --num-client locally; remove global option Signed-off-by: Sage Weil --- src/ceph_syn.cc | 10 +++++----- src/client/SyntheticClient.cc | 10 +++++++--- src/client/SyntheticClient.h | 1 + src/common/config_opts.h | 1 - src/test/daemon_config.cc | 16 ++++++++-------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/ceph_syn.cc b/src/ceph_syn.cc index a8cbba4de2e..81f15cc51d0 100644 --- a/src/ceph_syn.cc +++ b/src/ceph_syn.cc @@ -57,11 +57,11 @@ int main(int argc, const char **argv, char *envp[]) list clients; list synclients; - Messenger* messengers[g_conf->num_client]; - MonClient* mclients[g_conf->num_client]; + Messenger* messengers[num_client]; + MonClient* mclients[num_client]; - cout << "ceph-syn: starting " << g_conf->num_client << " syn client(s)" << std::endl; - for (int i=0; inum_client; i++) { + cout << "ceph-syn: starting " << num_client << " syn client(s)" << std::endl; + for (int i=0; ibind(g_conf->public_addr); @@ -91,7 +91,7 @@ int main(int argc, const char **argv, char *envp[]) delete client; } - for (int i = 0; i < g_conf->num_client; ++i) { + for (int i = 0; i < num_client; ++i) { // wait for messenger to finish delete mclients[i]; messengers[i]->shutdown(); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 14c10467a90..88574e07a20 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -48,7 +48,7 @@ using namespace std; //void trace_include(SyntheticClient *syn, Client *cl, string& prefix); //void trace_openssh(SyntheticClient *syn, Client *cl, string& prefix); - +int num_client = 1; list syn_modes; list syn_iargs; list syn_sargs; @@ -59,6 +59,10 @@ void parse_syn_options(vector& args) vector nargs; for (unsigned i=0; icct->_conf->num_client ? client->cct->_conf->num_client : 1; + int numc = num_client ? num_client : 1; int start, inc, end; @@ -3243,7 +3247,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) if (sp < 0) dirnum++; //dout(0) << "leading dir " << filename << " " << dirnum << dendl; - if (dirnum % client->cct->_conf->num_client != client->get_nodeid()) { + if (dirnum % num_client != client->get_nodeid()) { dout(20) << "skipping leading dir " << dirnum << " " << filename << dendl; continue; } diff --git a/src/client/SyntheticClient.h b/src/client/SyntheticClient.h index 5dd247de4f3..d1deff113c8 100644 --- a/src/client/SyntheticClient.h +++ b/src/client/SyntheticClient.h @@ -95,6 +95,7 @@ void parse_syn_options(vector& args); +extern int num_client; class SyntheticClient { StandaloneClient *client; diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 2ce005d8f05..502b2372105 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -20,7 +20,6 @@ OPTION(public_bind_addr, OPT_ADDR, entity_addr_t()) OPTION(cluster_addr, OPT_ADDR, entity_addr_t()) OPTION(public_network, OPT_STR, "") OPTION(cluster_network, OPT_STR, "") -OPTION(num_client, OPT_INT, 1) OPTION(monmap, OPT_STR, "") OPTION(mon_host, OPT_STR, "") OPTION(mon_dns_srv_name, OPT_STR, "ceph-mon") diff --git a/src/test/daemon_config.cc b/src/test/daemon_config.cc index 3db9500e253..da494bcad6f 100644 --- a/src/test/daemon_config.cc +++ b/src/test/daemon_config.cc @@ -31,13 +31,13 @@ using std::string; TEST(DaemonConfig, SimpleSet) { int ret; - ret = g_ceph_context->_conf->set_val("num_client", "21"); + ret = g_ceph_context->_conf->set_val("log_graylog_port", "21"); ASSERT_EQ(ret, 0); g_ceph_context->_conf->apply_changes(NULL); char buf[128]; memset(buf, 0, sizeof(buf)); char *tmp = buf; - ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf)); + ret = g_ceph_context->_conf->get_val("log_graylog_port", &tmp, sizeof(buf)); ASSERT_EQ(ret, 0); ASSERT_EQ(string("21"), string(buf)); } @@ -147,7 +147,7 @@ TEST(DaemonConfig, ArgV) { ASSERT_EQ(string("/tmp/my-keyfile"), string(buf)); memset(buf, 0, sizeof(buf)); - ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf)); + ret = g_ceph_context->_conf->get_val("log_graylog_port", &tmp, sizeof(buf)); ASSERT_EQ(ret, 0); ASSERT_EQ(string("22"), string(buf)); @@ -169,14 +169,14 @@ TEST(DaemonConfig, InjectArgs) { ASSERT_EQ(string("42"), string(buf)); memset(buf, 0, sizeof(buf)); - ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf)); + ret = g_ceph_context->_conf->get_val("log_graylog_port", &tmp, sizeof(buf)); ASSERT_EQ(ret, 0); ASSERT_EQ(string("56"), string(buf)); injection = "--num-client 57"; ret = g_ceph_context->_conf->injectargs(injection, &cout); ASSERT_EQ(ret, 0); - ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf)); + ret = g_ceph_context->_conf->get_val("log_graylog_port", &tmp, sizeof(buf)); ASSERT_EQ(ret, 0); ASSERT_EQ(string("57"), string(buf)); } @@ -195,7 +195,7 @@ TEST(DaemonConfig, InjectArgsReject) { // But, debug should still be set... memset(buf, 0, sizeof(buf)); - ret = g_ceph_context->_conf->get_val("num_client", &tmp, sizeof(buf)); + ret = g_ceph_context->_conf->get_val("log_graylog_port", &tmp, sizeof(buf)); ASSERT_EQ(ret, 0); ASSERT_EQ(string("28"), string(buf)); @@ -342,13 +342,13 @@ TEST(DaemonConfig, InvalidIntegers) { { long long bad_value = (long long)std::numeric_limits::max() + 1; string str = boost::lexical_cast(bad_value); - int ret = g_ceph_context->_conf->set_val("num_client", str); + int ret = g_ceph_context->_conf->set_val("log_graylog_port", str); ASSERT_EQ(ret, -EINVAL); } { // 4G must be greater than INT_MAX ASSERT_GT(4LL * 1024 * 1024 * 1024, (long long)std::numeric_limits::max()); - int ret = g_ceph_context->_conf->set_val("num_client", "4G"); + int ret = g_ceph_context->_conf->set_val("log_graylog_port", "4G"); ASSERT_EQ(ret, -EINVAL); } } -- 2.39.5