diff options
author | unknown <tomas@mc05.(none)> | 2004-06-04 10:24:43 +0200 |
---|---|---|
committer | unknown <tomas@mc05.(none)> | 2004-06-04 10:24:43 +0200 |
commit | bdbaa6b7adabee8fc4f77a1888199590e8784c6d (patch) | |
tree | 67ee34f486f382c42dfa15e55e3cdca17b359d3a /ndb/tools | |
parent | 9be85440427ae21e628a00772763147f07e730ff (diff) | |
download | mariadb-git-bdbaa6b7adabee8fc4f77a1888199590e8784c6d.tar.gz |
fixed bug in ndb_waiter
Diffstat (limited to 'ndb/tools')
-rw-r--r-- | ndb/tools/waiter.cpp | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index 549e0dc1ec3..7ce2739a157 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -22,6 +22,7 @@ #include <NdbSleep.h> #include <getarg.h> #include <kernel/ndb_limits.h> +#include "../src/common/mgmcommon/LocalConfig.hpp" #include <NDBT.hpp> @@ -47,9 +48,43 @@ int main(int argc, const char** argv){ arg_printusage(args, num_args, argv[0], desc); return NDBT_ProgramExit(NDBT_WRONGARGS); } + + char buf[255]; _hostName = argv[optind]; - // NdbRestarter restarter(_hostName); + if (_hostName == NULL){ + LocalConfig lcfg; + if(!lcfg.init()) + { + lcfg.printError(); + lcfg.printUsage(); + g_err << "Error parsing local config file" << endl; + return NDBT_ProgramExit(NDBT_FAILED); + } + + for (int i = 0; i<lcfg.items; i++) + { + MgmtSrvrId * m = lcfg.ids[i]; + + switch(m->type){ + case MgmId_TCP: + snprintf(buf, 255, "%s:%d", m->data.tcp.remoteHost, m->data.tcp.port); + _hostName = buf; + break; + case MgmId_File: + break; + default: + break; + } + if (_hostName != NULL) + break; + } + if (_hostName == NULL) + { + g_err << "No management servers configured in local config file" << endl; + return NDBT_ProgramExit(NDBT_FAILED); + } + } if (waitClusterStarted(_hostName) != 0) return NDBT_ProgramExit(NDBT_FAILED); @@ -137,15 +172,6 @@ waitClusterStarted(const char* _addr, unsigned int _timeout) int _nodes[MAX_NDB_NODES]; int _num_nodes = 0; - if (getStatus() != 0) - return -1; - - // Collect all nodes into nodes - for (size_t i = 0; i < ndbNodes.size(); i++){ - _nodes[i] = ndbNodes[i].node_id; - _num_nodes++; - } - handle = ndb_mgm_create_handle(); if (handle == NULL){ g_err << "handle == NULL" << endl; @@ -158,6 +184,15 @@ waitClusterStarted(const char* _addr, unsigned int _timeout) return -1; } + if (getStatus() != 0) + return -1; + + // Collect all nodes into nodes + for (size_t i = 0; i < ndbNodes.size(); i++){ + _nodes[i] = ndbNodes[i].node_id; + _num_nodes++; + } + unsigned int attempts = 0; unsigned int resetAttempts = 0; const unsigned int MAX_RESET_ATTEMPTS = 10; |