Skip to content

Commit

Permalink
common: convert ms_type option to SAFE_OPTION
Browse files Browse the repository at this point in the history
We need to modify ms_type in unittest. That use SAFE_OPTION to declare ms_type
is safer than pass `safe=false` to set_val.

Signed-off-by: liuchang0812 <[email protected]>
  • Loading branch information
liuchang0812 committed Mar 22, 2017
1 parent 8838faf commit e6755fa
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/ceph_mds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main(int argc, const char **argv)
uint64_t nonce = 0;
get_random_bytes((char*)&nonce, sizeof(nonce));

std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->ms_type : g_conf->ms_public_type;
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type;
Messenger *msgr = Messenger::create(g_ceph_context, public_msgr_type,
entity_name_t::MDS(-1), "mds",
nonce, Messenger::HAS_MANY_CONNECTIONS);
Expand Down
2 changes: 1 addition & 1 deletion src/ceph_mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ int main(int argc, const char **argv)

// bind
int rank = monmap.get_rank(g_conf->name.get_id());
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->ms_type : g_conf->ms_public_type;
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type;
Messenger *msgr = Messenger::create(g_ceph_context, public_msgr_type,
entity_name_t::MON(rank), "mon",
0, Messenger::HAS_MANY_CONNECTIONS);
Expand Down
4 changes: 2 additions & 2 deletions src/ceph_osd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ int main(int argc, const char **argv)
<< TEXT_NORMAL << dendl;
}

std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->ms_type : g_conf->ms_public_type;
std::string cluster_msgr_type = g_conf->ms_cluster_type.empty() ? g_conf->ms_type : g_conf->ms_cluster_type;
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type;
std::string cluster_msgr_type = g_conf->ms_cluster_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_cluster_type;
Messenger *ms_public = Messenger::create(g_ceph_context, public_msgr_type,
entity_name_t::OSD(whoami), "client",
getpid(),
Expand Down
2 changes: 1 addition & 1 deletion src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ OPTION(heartbeat_file, OPT_STR, "")
OPTION(heartbeat_inject_failure, OPT_INT, 0) // force an unhealthy heartbeat for N seconds
OPTION(perf, OPT_BOOL, true) // enable internal perf counters

OPTION(ms_type, OPT_STR, "async+posix") // messenger backend
SAFE_OPTION(ms_type, OPT_STR, "async+posix") // messenger backend. It will be modified in runtime, so use SAFE_OPTION
OPTION(ms_public_type, OPT_STR, "") // messenger backend
OPTION(ms_cluster_type, OPT_STR, "") // messenger backend
OPTION(ms_tcp_nodelay, OPT_BOOL, true)
Expand Down
2 changes: 1 addition & 1 deletion src/mgr/DaemonServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DaemonServer::~DaemonServer() {
int DaemonServer::init(uint64_t gid, entity_addr_t client_addr)
{
// Initialize Messenger
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->ms_type : g_conf->ms_public_type;
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type;
msgr = Messenger::create(g_ceph_context, public_msgr_type,
entity_name_t::MGR(gid), "server", getpid(), 0);
int r = msgr->bind(g_conf->public_addr);
Expand Down
2 changes: 1 addition & 1 deletion src/msg/Messenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Messenger *Messenger::create_client_messenger(CephContext *cct, string lname)
{
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->ms_type : cct->_conf->ms_public_type;
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->get_val<std::string>("ms_type") : cct->_conf->ms_public_type;
uint64_t nonce = 0;
get_random_bytes((char*)&nonce, sizeof(nonce));
return Messenger::create(cct, public_msgr_type, entity_name_t::CLIENT(),
Expand Down
2 changes: 1 addition & 1 deletion src/test/messenger/simple_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int main(int argc, const char **argv)
"initial msgs (pipe depth) " << n_msgs << " " <<
"data buffer size " << n_dsize << std::endl;

messenger = Messenger::create(g_ceph_context, g_conf->ms_type,
messenger = Messenger::create(g_ceph_context, g_conf->get_val<std::string>("ms_type"),
entity_name_t::MON(-1),
"client",
getpid(), 0);
Expand Down
2 changes: 1 addition & 1 deletion src/test/messenger/simple_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, const char **argv)
dest_str += port;
entity_addr_from_url(&bind_addr, dest_str.c_str());

messenger = Messenger::create(g_ceph_context, g_conf->ms_type,
messenger = Messenger::create(g_ceph_context, g_conf->get_val<std::string>("ms_type"),
entity_name_t::MON(-1),
"simple_server",
0 /* nonce */,
Expand Down
2 changes: 1 addition & 1 deletion src/test/mon/test-mon-msg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MonClientHelper : public Dispatcher
int init_messenger() {
dout(1) << __func__ << dendl;

std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->ms_type : cct->_conf->ms_public_type;
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->get_val<std::string>("ms_type") : cct->_conf->ms_public_type;
msg = Messenger::create(cct, public_msgr_type, entity_name_t::CLIENT(-1),
"test-mon-msg", 0, 0);
assert(msg != NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/test/mon/test_mon_workloadgen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class OSDStub : public TestStub
<< cct->_conf->auth_supported << dendl;
stringstream ss;
ss << "client-osd" << whoami;
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->ms_type : cct->_conf->ms_public_type;
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->get_val<std::string>("ms_type") : cct->_conf->ms_public_type;
messenger.reset(Messenger::create(cct, public_msgr_type, entity_name_t::OSD(whoami),
ss.str().c_str(), getpid(), 0));

Expand Down
2 changes: 1 addition & 1 deletion src/test/msgr/perf_msgr_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int main(int argc, char **argv)
int think_time = atoi(args[4]);
int len = atoi(args[5]);

std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->ms_type : g_ceph_context->_conf->ms_public_type;
std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type;

cerr << " using ms-public-type " << public_msgr_type << std::endl;
cerr << " server ip:port " << args[0] << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/test/msgr/perf_msgr_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int main(int argc, char **argv)

int worker_threads = atoi(args[1]);
int think_time = atoi(args[2]);
std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->ms_type : g_ceph_context->_conf->ms_public_type;
std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type;

cerr << " This tool won't handle connection error alike things, " << std::endl;
cerr << "please ensure the proper network environment to test." << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/test/osd/TestOSDScrub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST(TestOSDScrub, scrub_time_permit) {
g_conf->osd_objectstore,
g_conf->osd_data,
g_conf->osd_journal);
std::string cluster_msgr_type = g_conf->ms_cluster_type.empty() ? g_conf->ms_type : g_conf->ms_cluster_type;
std::string cluster_msgr_type = g_conf->ms_cluster_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_cluster_type;
Messenger *ms = Messenger::create(g_ceph_context, cluster_msgr_type,
entity_name_t::OSD(0), "make_checker",
getpid(), 0);
Expand Down
2 changes: 1 addition & 1 deletion src/test/testmsgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int main(int argc, const char **argv, const char *envp[]) {
std::string sss(ss.str());
g_ceph_context->_conf->set_val("public_addr", sss.c_str());
g_ceph_context->_conf->apply_changes(NULL);
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->ms_type : g_conf->ms_public_type;
std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type;
Messenger *rank = Messenger::create(g_ceph_context,
public_msgr_type,
entity_name_t::MON(whoami), "tester",
Expand Down

0 comments on commit e6755fa

Please sign in to comment.