17
17
18
18
#include < ndb_global.h>
19
19
#include < util/ndb_opts.h>
20
- #include < map>
21
- #include < string>
22
20
#include < util/BaseString.hpp>
23
21
#include < util/File.hpp>
24
22
#include < util/NdbOut.hpp>
23
+ #include < util/Properties.hpp>
25
24
#include " atrt.hpp"
26
25
27
26
extern int g_mt;
@@ -124,8 +123,7 @@ bool setup_config(atrt_config& config, const char* atrt_mysqld) {
124
123
* Find all processes...
125
124
*/
126
125
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 ;
129
127
for (unsigned k = 0 ; proc_args[k].name ; k++) {
130
128
if (!strncmp (tmp[j], proc_args[k].name , strlen (proc_args[k].name ))) {
131
129
proc_args[k].value = tmp[j] + strlen (proc_args[k].name );
@@ -1030,28 +1028,27 @@ static bool pr_set_customprocs_connectstring(Properties& props,
1030
1028
proc_rule_ctx& ctx, int ) {
1031
1029
atrt_cluster& cluster = *ctx.m_cluster ;
1032
1030
1033
- std::map<BaseString, BaseString> connectstrings;
1034
- std::map<BaseString, BaseString>::iterator it;
1031
+ Properties connectstrings;
1035
1032
for (unsigned i = 0 ; i < cluster.m_processes .size (); i++) {
1036
1033
atrt_process* proc = cluster.m_processes [i];
1037
1034
if (proc->m_type != atrt_process::AP_CUSTOM) continue ;
1038
1035
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 ());
1040
1039
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 ());
1045
1041
} 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 ());
1047
1044
}
1048
1045
1049
1046
const char * portno;
1050
1047
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 ());
1052
1051
}
1053
-
1054
- connectstrings[proc->m_name ] = host_list;
1055
1052
}
1056
1053
1057
1054
for (unsigned i = 0 ; i < cluster.m_processes .size (); i++) {
@@ -1061,13 +1058,18 @@ static bool pr_set_customprocs_connectstring(Properties& props,
1061
1058
proc->m_type & (atrt_process::AP_CLIENT | atrt_process::AP_NDB_API);
1062
1059
if (!client_or_api) continue ;
1063
1060
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);
1066
1065
connstr.ndb_toupper ();
1067
1066
connstr.append (" _CONNECTSTRING" );
1068
1067
1068
+ const char * value;
1069
+ (void )connectstrings.get (name, &value);
1070
+
1069
1071
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 );
1071
1073
}
1072
1074
}
1073
1075
0 commit comments