#At file:///home/msvensson/mysql/6.4-wl4350/ based on revid:msvensson@stripped
3169 Magnus Svensson 2008-12-16
WL#4350 Extend Config class
modified:
storage/ndb/src/mgmsrv/Config.cpp
storage/ndb/src/mgmsrv/Config.hpp
per-file messages:
storage/ndb/src/mgmsrv/Config.cpp
Add 'pack64' and 'getConnectString' to Config
storage/ndb/src/mgmsrv/Config.hpp
Add 'pack64' and 'getConnectString' to Config
=== modified file 'storage/ndb/src/mgmsrv/Config.cpp'
--- a/storage/ndb/src/mgmsrv/Config.cpp 2008-12-16 11:53:18 +0000
+++ b/storage/ndb/src/mgmsrv/Config.cpp 2008-12-16 16:30:58 +0000
@@ -233,6 +233,27 @@ Config::pack(UtilBuffer& buf) const
}
+#include <base64.h>
+
+bool
+Config::pack64(BaseString& encoded) const
+{
+ UtilBuffer buf;
+ if (m_configValues->m_config.pack(buf) == 0)
+ return false;
+
+ // Expand the string to correct length by filling with Z
+ encoded.assfmt("%*s",
+ base64_needed_encoded_length(buf.length()),
+ "Z");
+
+ if (base64_encode(buf.get_data(),
+ buf.length(),
+ (char*)encoded.c_str()))
+ return false;
+ return true;
+}
+
enum diff_types {
DT_DIFF, // Value differed
@@ -725,3 +746,34 @@ bool Config::illegal_change(const Config
return illegal_change(diff_list);
}
+
+void Config::getConnectString(BaseString& connectstring,
+ const BaseString& separator) const
+{
+ bool first= true;
+ ConfigIter it(this, CFG_SECTION_NODE);
+
+ for(;it.valid(); it.next())
+ {
+ /* Get type of Node */
+ Uint32 nodeType;
+ require(it.get(CFG_TYPE_OF_SECTION, &nodeType) == 0);
+
+ if (nodeType != NODE_TYPE_MGM)
+ continue;
+
+ Uint32 port;
+ const char* hostname;
+ require(it.get(CFG_NODE_HOST, &hostname) == 0);
+ require(it.get(CFG_MGM_PORT, &port) == 0);
+
+ if (!first)
+ connectstring.append(separator);
+ first= false;
+
+ connectstring.appfmt("%s:%d", hostname, port);
+
+ }
+ ndbout << connectstring << endl;
+}
+
=== modified file 'storage/ndb/src/mgmsrv/Config.hpp'
--- a/storage/ndb/src/mgmsrv/Config.hpp 2008-12-16 11:53:18 +0000
+++ b/storage/ndb/src/mgmsrv/Config.hpp 2008-12-16 16:30:58 +0000
@@ -73,6 +73,11 @@ public:
Uint32 pack(UtilBuffer&) const;
/*
+ Pack the config as base64
+ */
+ bool pack64(BaseString&) const;
+
+ /*
Compare against another config and return a list of
differences in a Properties object
*/
@@ -84,6 +89,15 @@ public:
*/
void print_diff(const Config* other) const;
+
+ /*
+ Get the full connectstring for this configuration. ie
+ a list of all the mgmd servers and their port separated
+ by separator.
+ */
+ void getConnectString(BaseString&,
+ const BaseString& separator = BaseString(";")) const;
+
/*
Print the difference to string buffer
*/
@@ -100,6 +114,7 @@ public:
bool equal(const Config*, const unsigned* exclude = NULL) const;
struct ndb_mgm_configuration * m_configValues;
+ struct ndb_mgm_configuration * values(void) const { return m_configValues; };
private:
bool setValue(Uint32 section, Uint32 section_no,
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (msvensson:3169) WL#4350 | Magnus Svensson | 16 Dec |