Commit 5de74593 authored by unknown's avatar unknown

Along the road to a working Impl3 of WL2278.


ndb/src/common/transporter/TransporterRegistry.cpp:
  Only try to get dynamic port number for TCP transporters.
ndb/src/mgmapi/mgmapi.cpp:
  DBUG_RETURN in ndb_mgm_set_connection_int_parameter
  
  Unique negative error codes for ndb_mgm_get_connection_int_parameter
ndb/src/mgmsrv/MgmtSrvr.cpp:
  add MgmtSrvr::set_connect_string(const char *str)
ndb/src/mgmsrv/MgmtSrvr.hpp:
  Add:
  - prototype for set_connect_string
  - get_config_retriever
ndb/src/mgmsrv/main.cpp:
  Fake a connect string and connect back to ourselves.
  
  This enables us to use mgmapi routines to get configuration information.
  i.e. ndb_mgm_get_connection_int_parameter for getting dynamic port numbers to connect to.
parent 85313326
...@@ -1189,12 +1189,14 @@ TransporterRegistry::start_clients_thread() ...@@ -1189,12 +1189,14 @@ TransporterRegistry::start_clients_thread()
const NodeId nodeId = t->getRemoteNodeId(); const NodeId nodeId = t->getRemoteNodeId();
switch(performStates[nodeId]){ switch(performStates[nodeId]){
case CONNECTING: case CONNECTING:
if(!t->isConnected() && !t->isServer) { if(!t->isConnected() && !t->isServer
&& theTransporterTypes[nodeId] == tt_TCP_TRANSPORTER) {
if(t->get_r_port() <= 0) { // Port is dynamic if(t->get_r_port() <= 0) { // Port is dynamic
Uint32 server_port=0; Uint32 server_port= 0;
struct ndb_mgm_reply mgm_reply; struct ndb_mgm_reply mgm_reply;
int res; int res;
res=ndb_mgm_get_connection_int_parameter(m_mgm_handle,
res= ndb_mgm_get_connection_int_parameter(m_mgm_handle,
t->getRemoteNodeId(), t->getRemoteNodeId(),
t->getLocalNodeId(), t->getLocalNodeId(),
CFG_CONNECTION_SERVER_PORT, CFG_CONNECTION_SERVER_PORT,
...@@ -1206,9 +1208,10 @@ TransporterRegistry::start_clients_thread() ...@@ -1206,9 +1208,10 @@ TransporterRegistry::start_clients_thread()
if(res>=0) if(res>=0)
t->set_r_port(server_port); t->set_r_port(server_port);
else else
ndbout_c("Failed to get dynamic port to connect to."); ndbout_c("Failed to get dynamic port to connect to: %d", res);
} }
if(t->get_r_port()>0) if(theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|| t->get_r_port() > 0)
t->connect_client(); t->connect_client();
else else
NdbSleep_MilliSleep(400); NdbSleep_MilliSleep(400);
......
...@@ -2084,7 +2084,7 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, ...@@ -2084,7 +2084,7 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle,
} while(0); } while(0);
delete prop; delete prop;
return res; DBUG_RETURN(res);
} }
extern "C" extern "C"
...@@ -2097,7 +2097,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle, ...@@ -2097,7 +2097,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
struct ndb_mgm_reply* mgmreply){ struct ndb_mgm_reply* mgmreply){
DBUG_ENTER("ndb_mgm_get_connection_int_parameter"); DBUG_ENTER("ndb_mgm_get_connection_int_parameter");
CHECK_HANDLE(handle, -1); CHECK_HANDLE(handle, -1);
CHECK_CONNECTED(handle, -1); CHECK_CONNECTED(handle, -2);
Properties args; Properties args;
args.put("node1", node1); args.put("node1", node1);
...@@ -2113,7 +2113,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle, ...@@ -2113,7 +2113,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
const Properties *prop; const Properties *prop;
prop = ndb_mgm_call(handle, reply, "get connection parameter", &args); prop = ndb_mgm_call(handle, reply, "get connection parameter", &args);
CHECK_REPLY(prop, -2); CHECK_REPLY(prop, -3);
int res= -1; int res= -1;
do { do {
...@@ -2127,7 +2127,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle, ...@@ -2127,7 +2127,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
if(!prop->get("value",value)){ if(!prop->get("value",value)){
ndbout_c("Unable to get value"); ndbout_c("Unable to get value");
res = -3; res = -4;
} }
delete prop; delete prop;
......
...@@ -2883,6 +2883,12 @@ MgmtSrvr::getConnectionDbParameter(int node1, ...@@ -2883,6 +2883,12 @@ MgmtSrvr::getConnectionDbParameter(int node1,
DBUG_RETURN(1); DBUG_RETURN(1);
} }
int MgmtSrvr::set_connect_string(const char *str)
{
return ndb_mgm_set_connectstring(m_config_retriever->get_mgmHandle(),str);
}
template class Vector<SigMatch>; template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560 #if __SUNPRO_CC != 0x560
template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch**, NdbApiSignal**, unsigned); template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch**, NdbApiSignal**, unsigned);
......
...@@ -512,7 +512,9 @@ public: ...@@ -512,7 +512,9 @@ public:
int getConnectionDbParameter(int node1, int node2, int param, int getConnectionDbParameter(int node1, int node2, int param,
unsigned *value, BaseString& msg); unsigned *value, BaseString& msg);
int set_connect_string(const char *str);
ConfigRetriever *get_config_retriever() { return m_config_retriever; };
const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); } const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); }
void get_connected_nodes(NodeBitmask &connected_nodes) const; void get_connected_nodes(NodeBitmask &connected_nodes) const;
......
...@@ -246,12 +246,26 @@ int main(int argc, char** argv) ...@@ -246,12 +246,26 @@ int main(int argc, char** argv)
goto error_end; goto error_end;
} }
char connect_str[20];
if(!opt_connect_str) {
snprintf(connect_str,20,"localhost:%u",glob.mgmObject->getPort());
opt_connect_str= connect_str;
}
glob.mgmObject->set_connect_string(connect_str);
if(!glob.mgmObject->check_start()){ if(!glob.mgmObject->check_start()){
ndbout_c("Unable to check start management server."); ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file."); ndbout_c("Probably caused by illegal initial configuration file.");
goto error_end; goto error_end;
} }
/*
* Connect back to ourselves so we can use mgmapi to fetch
* config info
*/
DBUG_PRINT("info",("CONNECT RESULT: %d",glob.mgmObject->get_config_retriever()->do_connect(0,0,0)));
if (glob.daemon) { if (glob.daemon) {
// Become a daemon // Become a daemon
char *lockfile= NdbConfig_PidFileName(glob.localNodeId); char *lockfile= NdbConfig_PidFileName(glob.localNodeId);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment