20 #ifndef _CONFIGFACTORY_HPP
21 #define _CONFIGFACTORY_HPP
23 #include <util/Properties.hpp>
28 static Uint32 get_ndbt_base_port(
void)
31 const char* base_port_str = getenv(
"NDBT_BASE_PORT");
33 port = atoi(base_port_str);
44 Uint32 base_port = get_ndbt_base_port();
46 assert(mgmds >= 1 && ndbds >= 1 && mysqlds >= 1);
47 for (
unsigned n = 1;
n <= ndbds + mgmds + mysqlds;
n++)
52 node_settings.
put(
"NodeId",
n);
57 node_settings.
put(
"HostName",
"localhost");
58 node_settings.
put(
"PortNumber", base_port +
n);
59 }
else if (
n <= mgmds + ndbds)
63 node_settings.
put(
"NoOfReplicas", 1);
65 }
else if (
n <= mgmds + ndbds + mysqlds)
71 config.
put(node,
n, &node_settings);
78 const char* key, Uint32 value)
81 if (!config.getCopy(section, section_no, &p))
83 if (!p->
put(key, value))
85 if (!config.
put(section, section_no, p,
true))
91 write_config_ini(
Properties& config,
const char* path)
93 FILE* config_file = fopen(path,
"w");
94 if (config_file == NULL)
99 while (
const char*
name = it.next())
102 fprintf(config_file,
"[%s]\n",
106 if (!config.get(
name, &p))
111 while (
const char* name2 = it2.next())
115 if (!p->getTypeOf(name2, &type))
119 case PropertiesType_Uint32:
122 if (!p->get(name2, &value))
124 fprintf(config_file,
"%s=%u\n", name2, value);
128 case PropertiesType_char:
131 if (!p->get(name2, &value))
133 fprintf(config_file,
"%s=%s\n", name2, value);
142 fprintf(config_file,
"\n");
150 create_directories(
const char* path,
Properties & config)
154 while (
const char*
name = it.next())
158 printf(
"Creating %s...\n", dir.
c_str());
159 if (!NdbDir::create(dir.
c_str()))