]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-syn: parse --num-client locally; remove global option
authorSage Weil <sage@redhat.com>
Fri, 12 May 2017 02:49:35 +0000 (21:49 -0500)
committerJohn Spray <john.spray@redhat.com>
Fri, 21 Jul 2017 10:27:22 +0000 (06:27 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_syn.cc
src/client/SyntheticClient.cc
src/client/SyntheticClient.h
src/common/config_opts.h
src/test/daemon_config.cc

index a8cbba4de2ee1b235a603c1abf71d30297bd37a6..81f15cc51d0fc076e19af3fdb821231de36386ea 100644 (file)
@@ -57,11 +57,11 @@ int main(int argc, const char **argv, char *envp[])
 
   list<Client*> clients;
   list<SyntheticClient*> 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; i<g_conf->num_client; i++) {
+  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);
@@ -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();
index 14c10467a901f75f404ab887e5a7eddba4a9bf48..88574e07a202cdf0fd4b3f5fc0a38d391bd9bec4 100644 (file)
@@ -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<int> syn_modes;
 list<int> syn_iargs;
 list<string> syn_sargs;
@@ -59,6 +59,10 @@ void parse_syn_options(vector<const char*>& args)
   vector<const char*> nargs;
 
   for (unsigned i=0; i<args.size(); i++) {
+    if (strcmp(args[i],"--num-client") == 0) {
+      num_client = atoi(args[++i]);
+      continue;
+    }
     if (strcmp(args[i],"--syn") == 0) {
       ++i;
 
@@ -2232,7 +2236,7 @@ public:
 int SyntheticClient::create_objects(int nobj, int osize, int inflight)
 {
   // divy up
-  int numc = client->cct->_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;
     }
index 5dd247de4f32b5ba7d48b32dc04ec135356c10e8..d1deff113c8a2c01a7ea22bc66e53e2c3fa6ab63 100644 (file)
@@ -95,6 +95,7 @@
 
 
 void parse_syn_options(vector<const char*>& args);
+extern int num_client;
 
 class SyntheticClient {
   StandaloneClient *client;
index 2ce005d8f05ed2144e9a367c2e74ab7f0779c55c..502b23721059d395ae313d0cd34bef80e316f4ad 100644 (file)
@@ -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")
index 3db9500e253c707f61125b889f999e59c24f7a61..da494bcad6fba600565cb85d74053e773f65eeb9 100644 (file)
@@ -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<int>::max() + 1;
     string str = boost::lexical_cast<string>(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<int>::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);
   }
 }