Skip to content

Commit 08d736d

Browse files
author
Tiago Alves
committed
Fix build break due to the usage of std::map
Replaced std::map with Properties.
1 parent 9284c1b commit 08d736d

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

storage/ndb/test/run-test/setup.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
#include <ndb_global.h>
1919
#include <util/ndb_opts.h>
20-
#include <map>
21-
#include <string>
2220
#include <util/BaseString.hpp>
2321
#include <util/File.hpp>
2422
#include <util/NdbOut.hpp>
23+
#include <util/Properties.hpp>
2524
#include "atrt.hpp"
2625

2726
extern int g_mt;
@@ -124,8 +123,7 @@ bool setup_config(atrt_config& config, const char* atrt_mysqld) {
124123
* Find all processes...
125124
*/
126125
for (j = 0; j < (size_t)argc; j++) {
127-
if (ndb_is_load_default_arg_separator(tmp[j]))
128-
continue;
126+
if (ndb_is_load_default_arg_separator(tmp[j])) continue;
129127
for (unsigned k = 0; proc_args[k].name; k++) {
130128
if (!strncmp(tmp[j], proc_args[k].name, strlen(proc_args[k].name))) {
131129
proc_args[k].value = tmp[j] + strlen(proc_args[k].name);
@@ -1030,28 +1028,27 @@ static bool pr_set_customprocs_connectstring(Properties& props,
10301028
proc_rule_ctx& ctx, int) {
10311029
atrt_cluster& cluster = *ctx.m_cluster;
10321030

1033-
std::map<BaseString, BaseString> connectstrings;
1034-
std::map<BaseString, BaseString>::iterator it;
1031+
Properties connectstrings;
10351032
for (unsigned i = 0; i < cluster.m_processes.size(); i++) {
10361033
atrt_process* proc = cluster.m_processes[i];
10371034
if (proc->m_type != atrt_process::AP_CUSTOM) continue;
10381035

1039-
BaseString host_list;
1036+
if (connectstrings.contains(proc->m_name.c_str())) {
1037+
BaseString str;
1038+
str.assfmt(",%s", proc->m_host->m_hostname.c_str());
10401039

1041-
it = connectstrings.find(proc->m_name);
1042-
if (it != connectstrings.end()) {
1043-
host_list = it->second;
1044-
host_list.appfmt(",%s", proc->m_host->m_hostname.c_str());
1040+
connectstrings.append(proc->m_name.c_str(), str.c_str());
10451041
} else {
1046-
host_list.assign(proc->m_host->m_hostname);
1042+
connectstrings.put(proc->m_name.c_str(),
1043+
proc->m_host->m_hostname.c_str());
10471044
}
10481045

10491046
const char* portno;
10501047
if (proc->m_options.m_generated.get("--port", &portno)) {
1051-
host_list.appfmt(":%s", portno);
1048+
BaseString str;
1049+
str.assfmt(":%s", portno);
1050+
connectstrings.append(proc->m_name.c_str(), str.c_str());
10521051
}
1053-
1054-
connectstrings[proc->m_name] = host_list;
10551052
}
10561053

10571054
for (unsigned i = 0; i < cluster.m_processes.size(); i++) {
@@ -1061,13 +1058,18 @@ static bool pr_set_customprocs_connectstring(Properties& props,
10611058
proc->m_type & (atrt_process::AP_CLIENT | atrt_process::AP_NDB_API);
10621059
if (!client_or_api) continue;
10631060

1064-
for (it = connectstrings.begin(); it != connectstrings.end(); ++it) {
1065-
BaseString connstr(it->first);
1061+
const char* name;
1062+
Properties::Iterator it(&connectstrings);
1063+
while ((name = it.next())) {
1064+
BaseString connstr(name);
10661065
connstr.ndb_toupper();
10671066
connstr.append("_CONNECTSTRING");
10681067

1068+
const char* value;
1069+
(void)connectstrings.get(name, &value);
1070+
10691071
if (!proc->m_proc.m_env.empty()) proc->m_proc.m_env.append(" ");
1070-
proc->m_proc.m_env.appfmt("%s=%s", connstr.c_str(), it->second.c_str());
1072+
proc->m_proc.m_env.appfmt("%s=%s", connstr.c_str(), value);
10711073
}
10721074
}
10731075

0 commit comments

Comments
 (0)