diff options
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/include/mgmapi/mgmapi_debug.h | 4 | ||||
-rw-r--r-- | ndb/include/transporter/TransporterRegistry.hpp | 4 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/IPCConfig.cpp | 13 | ||||
-rw-r--r-- | ndb/src/common/transporter/TransporterRegistry.cpp | 46 | ||||
-rw-r--r-- | ndb/src/kernel/main.cpp | 2 | ||||
-rw-r--r-- | ndb/src/mgmapi/mgmapi.cpp | 8 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.cpp | 14 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.hpp | 2 | ||||
-rw-r--r-- | ndb/src/mgmsrv/Services.cpp | 4 | ||||
-rw-r--r-- | ndb/src/mgmsrv/main.cpp | 2 | ||||
-rw-r--r-- | ndb/src/ndbapi/ndb_cluster_connection.cpp | 2 |
11 files changed, 67 insertions, 34 deletions
diff --git a/ndb/include/mgmapi/mgmapi_debug.h b/ndb/include/mgmapi/mgmapi_debug.h index cbf9878f163..32a89535456 100644 --- a/ndb/include/mgmapi/mgmapi_debug.h +++ b/ndb/include/mgmapi/mgmapi_debug.h @@ -146,7 +146,7 @@ extern "C" { int node1, int node2, int param, - unsigned value, + int value, struct ndb_mgm_reply* reply); /** @@ -165,7 +165,7 @@ extern "C" { int node1, int node2, int param, - Uint32 *value, + int *value, struct ndb_mgm_reply* reply); #ifdef __cplusplus diff --git a/ndb/include/transporter/TransporterRegistry.hpp b/ndb/include/transporter/TransporterRegistry.hpp index da0849c3f50..ff4e1d89a37 100644 --- a/ndb/include/transporter/TransporterRegistry.hpp +++ b/ndb/include/transporter/TransporterRegistry.hpp @@ -232,12 +232,12 @@ public: class Transporter_interface { public: NodeId m_remote_nodeId; - unsigned short m_service_port; + int m_s_service_port; // signed port number const char *m_interface; }; Vector<Transporter_interface> m_transporter_interface; void add_transporter_interface(NodeId remoteNodeId, const char *interf, - unsigned short port); + int s_port); // signed port. <0 is dynamic Transporter* get_transporter(NodeId nodeId); NodeId get_localNodeId() { return localNodeId; }; diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index dd78e1dbfbd..c343f4d43fd 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -371,6 +371,19 @@ IPCConfig::configureTransporters(Uint32 nodeId, } DBUG_PRINT("info", ("Transporter between this node %d and node %d using port %d, signalId %d, checksum %d", nodeId, remoteNodeId, server_port, sendSignalId, checksum)); + /* + This may be a dynamic port. It depends on when we're getting + our configuration. If we've been restarted, we'll be getting + a configuration with our old dynamic port in it, hence the number + here is negative (and we try the old port number first). + + On a first-run, server_port will be zero (with dynamic ports) + + If we're not using dynamic ports, we don't do anything. + */ + if((int)server_port<0) + server_port= -server_port; + switch(type){ case CONNECTION_TYPE_SHM:{ SHM_TransporterConfiguration conf; diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index 6db69beebef..7b2fa900e6a 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -1189,7 +1189,7 @@ TransporterRegistry::start_clients_thread() case CONNECTING: if(!t->isConnected() && !t->isServer) { if(t->get_r_port() <= 0) { // Port is dynamic - Uint32 server_port= 0; + int server_port= 0; struct ndb_mgm_reply mgm_reply; int res; @@ -1199,9 +1199,13 @@ TransporterRegistry::start_clients_thread() CFG_CONNECTION_SERVER_PORT, &server_port, &mgm_reply); - DBUG_PRINT("info",("Got dynamic port %u for %d -> %d (ret: %d)", + DBUG_PRINT("info",("Got %s port %u for %d -> %d (ret: %d)", + (server_port<=0)?"dynamic":"static", server_port,t->getRemoteNodeId(), t->getLocalNodeId(),res)); + if(server_port<0) + server_port = -server_port; // was a dynamic port + if(res>=0) t->set_r_port(server_port); else @@ -1263,17 +1267,17 @@ TransporterRegistry::stop_clients() void TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, const char *interf, - unsigned short port) + int s_port) { DBUG_ENTER("TransporterRegistry::add_transporter_interface"); - DBUG_PRINT("enter",("interface=%s, port= %d", interf, port)); + DBUG_PRINT("enter",("interface=%s, s_port= %d", interf, s_port)); if (interf && strlen(interf) == 0) interf= 0; for (unsigned i= 0; i < m_transporter_interface.size(); i++) { Transporter_interface &tmp= m_transporter_interface[i]; - if (port != tmp.m_service_port || tmp.m_service_port==0) + if (s_port != tmp.m_s_service_port || tmp.m_s_service_port==0) continue; if (interf != 0 && tmp.m_interface != 0 && strcmp(interf, tmp.m_interface) == 0) @@ -1287,7 +1291,7 @@ TransporterRegistry::add_transporter_interface(NodeId remoteNodeId, } Transporter_interface t; t.m_remote_nodeId= remoteNodeId; - t.m_service_port= port; + t.m_s_service_port= s_port; t.m_interface= interf; m_transporter_interface.push_back(t); DBUG_PRINT("exit",("interface and port added")); @@ -1307,18 +1311,34 @@ TransporterRegistry::start_service(SocketServer& socket_server) { Transporter_interface &t= m_transporter_interface[i]; + unsigned short port= (unsigned short)t.m_s_service_port; + if(t.m_s_service_port<0) + port= -t.m_s_service_port; // is a dynamic port TransporterService *transporter_service = new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd")); if(!socket_server.setup(transporter_service, - &t.m_service_port, t.m_interface)) + &port, t.m_interface)) { - ndbout_c("Unable to setup transporter service port: %s:%d!\n" - "Please check if the port is already used,\n" - "(perhaps the node is already running)", - t.m_interface ? t.m_interface : "*", t.m_service_port); - delete transporter_service; - return false; + DBUG_PRINT("info", ("Trying new port")); + port= 0; + if(t.m_s_service_port>0 + || !socket_server.setup(transporter_service, + &port, t.m_interface)) + { + /* + * If it wasn't a dynamically allocated port, or + * our attempts at getting a new dynamic port failed + */ + ndbout_c("Unable to setup transporter service port: %s:%d!\n" + "Please check if the port is already used,\n" + "(perhaps the node is already running)", + t.m_interface ? t.m_interface : "*", t.m_s_service_port); + delete transporter_service; + return false; + } } + t.m_s_service_port= (t.m_s_service_port<=0)?-port:port; // -`ve if dynamic + DBUG_PRINT("info", ("t.m_s_service_port = %d",t.m_s_service_port)); transporter_service->setTransporterRegistry(this); } return true; diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 7d435d4505b..68fc52a6b68 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -211,7 +211,7 @@ int main(int argc, char** argv) globalTransporterRegistry.get_localNodeId(), globalTransporterRegistry.m_transporter_interface[i].m_remote_nodeId, CFG_CONNECTION_SERVER_PORT, - globalTransporterRegistry.m_transporter_interface[i].m_service_port, + globalTransporterRegistry.m_transporter_interface[i].m_s_service_port, &mgm_reply); diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index ac3383537bf..f44cc5fb6a3 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -2054,7 +2054,7 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, int node1, int node2, int param, - unsigned value, + int value, struct ndb_mgm_reply* mgmreply){ DBUG_ENTER("ndb_mgm_set_connection_int_parameter"); CHECK_HANDLE(handle, 0); @@ -2064,7 +2064,7 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, args.put("node1", node1); args.put("node2", node2); args.put("param", param); - args.put("value", value); + args.put("value", (Uint32)value); const ParserRow<ParserDummy> reply[]= { MGM_CMD("set connection parameter reply", NULL, ""), @@ -2097,7 +2097,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle, int node1, int node2, int param, - Uint32 *value, + int *value, struct ndb_mgm_reply* mgmreply){ DBUG_ENTER("ndb_mgm_get_connection_int_parameter"); CHECK_HANDLE(handle, -1); @@ -2129,7 +2129,7 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle, res= 0; } while(0); - if(!prop->get("value",value)){ + if(!prop->get("value",(Uint32*)value)){ ndbout_c("Unable to get value"); res = -4; } diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 0de914d076c..9efc73b9a1f 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -620,18 +620,18 @@ MgmtSrvr::start(BaseString &error_string) TransporterRegistry *reg = theFacade->get_registry(); for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) { BaseString msg; - DBUG_PRINT("info",("Setting dynamic port %d->%d : %u", + DBUG_PRINT("info",("Setting dynamic port %d->%d : %d", reg->get_localNodeId(), reg->m_transporter_interface[i].m_remote_nodeId, - reg->m_transporter_interface[i].m_service_port + reg->m_transporter_interface[i].m_s_service_port ) ); int res = setConnectionDbParameter((int)reg->get_localNodeId(), (int)reg->m_transporter_interface[i] .m_remote_nodeId, (int)CFG_CONNECTION_SERVER_PORT, - (int)reg->m_transporter_interface[i] - .m_service_port, + reg->m_transporter_interface[i] + .m_s_service_port, msg); DBUG_PRINT("info",("Set result: %d: %s",res,msg.c_str())); } @@ -2849,7 +2849,7 @@ int MgmtSrvr::getConnectionDbParameter(int node1, int node2, int param, - unsigned *value, + int *value, BaseString& msg){ DBUG_ENTER("MgmtSrvr::getConnectionDbParameter"); @@ -2874,12 +2874,12 @@ MgmtSrvr::getConnectionDbParameter(int node1, return -1; } - if(iter.get(param, value) < 0) { + if(iter.get(param, (Uint32*)value) < 0) { msg.assign("Unable to get current value of parameter"); return -1; } - msg.assfmt("%u",*value); + msg.assfmt("%d",*value); DBUG_RETURN(1); } diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 450dbf15160..0d5f3f33b3c 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -510,7 +510,7 @@ public: int setConnectionDbParameter(int node1, int node2, int param, int value, BaseString& msg); int getConnectionDbParameter(int node1, int node2, int param, - unsigned *value, BaseString& msg); + int *value, BaseString& msg); int set_connect_string(const char *str); diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 447bc8bdc2b..a940b781865 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -1373,7 +1373,7 @@ void MgmApiSession::getConnectionParameter(Parser_t::Context &ctx, Properties const &args) { BaseString node1, node2, param; - unsigned value = 0; + int value = 0; args.get("node1", node1); args.get("node2", node2); @@ -1387,7 +1387,7 @@ MgmApiSession::getConnectionParameter(Parser_t::Context &ctx, result); m_output->println("get connection parameter reply"); - m_output->println("value: %u", value); + m_output->println("value: %d", value); m_output->println("result: %s", (ret>0)?"Ok":result.c_str()); m_output->println(""); } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 7d075344afc..d897e8cd063 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -296,7 +296,7 @@ int main(int argc, char** argv) snprintf(connect_str,20,"localhost:%u",glob.mgmObject->getPort()); opt_connect_str= connect_str; } - glob.mgmObject->set_connect_string(connect_str); + glob.mgmObject->set_connect_string(opt_connect_str); if(!glob.mgmObject->check_start()){ ndbout_c("Unable to check start management server."); diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index aefcb0d97d0..c77f8c62f98 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -506,7 +506,7 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, CFG_CONNECTION_SERVER_PORT, m_impl.m_transporter_facade->get_registry() ->m_transporter_interface[i] - .m_service_port, + .m_s_service_port, &mgm_reply); ndb_mgm_destroy_configuration(props); |