Commit 69da579a authored by unknown's avatar unknown

Finish WL2278 Impl 3 - Dynamic port allocation of cluster nodes.


ndb/include/util/SocketClient.hpp:
  Add SocketClient::set_port(unsigned short port)
  - Sets both m_port and m_servaddr.sin_port
ndb/src/common/transporter/Transporter.hpp:
  Fix set_r_port to call m_socket_client->set_port(port) (if there's a socket client).
ndb/src/common/transporter/TransporterRegistry.cpp:
  Handle non-TCP Transporter nodes correctly
ndb/src/mgmsrv/main.cpp:
  Better document and error check connecting back to our own ndb_mgmd
parent ccbadbc9
......@@ -31,6 +31,10 @@ public:
SocketClient(const char *server_name, unsigned short port, SocketAuthenticator *sa = 0);
~SocketClient();
bool init();
void set_port(unsigned short port) {
m_port = port;
m_servaddr.sin_port = htons(m_port);
};
NDB_SOCKET_TYPE connect();
bool close();
};
......
......@@ -77,7 +77,11 @@ public:
/**
* Set r_port to connect to
*/
void set_r_port(unsigned int port) { m_r_port = port; };
void set_r_port(unsigned int port) {
m_r_port = port;
if(m_socket_client)
m_socket_client->set_port(port);
};
protected:
Transporter(TransporterRegistry &,
......
......@@ -1189,8 +1189,7 @@ TransporterRegistry::start_clients_thread()
const NodeId nodeId = t->getRemoteNodeId();
switch(performStates[nodeId]){
case CONNECTING:
if(!t->isConnected() && !t->isServer
&& theTransporterTypes[nodeId] == tt_TCP_TRANSPORTER) {
if(!t->isConnected() && !t->isServer) {
if(t->get_r_port() <= 0) { // Port is dynamic
Uint32 server_port= 0;
struct ndb_mgm_reply mgm_reply;
......@@ -1211,7 +1210,7 @@ TransporterRegistry::start_clients_thread()
ndbout_c("Failed to get dynamic port to connect to: %d", res);
}
if(theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|| t->get_r_port() > 0)
|| t->get_r_port() > 0)
t->connect_client();
else
NdbSleep_MilliSleep(400);
......
......@@ -246,6 +246,7 @@ int main(int argc, char** argv)
goto error_end;
}
/* Construct a fake connectstring to connect back to ourselves */
char connect_str[20];
if(!opt_connect_str) {
snprintf(connect_str,20,"localhost:%u",glob.mgmObject->getPort());
......@@ -263,7 +264,15 @@ int main(int argc, char** argv)
* 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)));
int mgm_connect_result;
mgm_connect_result = glob.mgmObject->get_config_retriever()->
do_connect(0,0,0);
if(mgm_connect_result<0) {
ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
mgm_connect_result);
ndbout_c("This is probably a bug.");
}
if (glob.daemon) {
......
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