diff options
author | unknown <stewart@mysql.com> | 2005-02-11 15:43:43 +1100 |
---|---|---|
committer | unknown <stewart@mysql.com> | 2005-02-11 15:43:43 +1100 |
commit | 6bd9c85acd73aac75c37bdfa15980569ba9fde99 (patch) | |
tree | e74c9d7c460fb54214d5bd6857e1098ab87b8f19 /ndb/src/common | |
parent | 6eae64dd2c69aafe17ca0cefc8ff3e23d1f23c0e (diff) | |
download | mariadb-git-6bd9c85acd73aac75c37bdfa15980569ba9fde99.tar.gz |
WL2278 Dynamic ports - Impl 6, "deal with mgm server restart and multiple mgm servers"
- when connecting to a mgm server as a transporter, create a NdbMgmHandle
- over this mgm handle, report the dynamic ports
- then turn it into a transporter
- this will re-report dynamic ports to mgmds when they restart (as we'll have to
set up our transporter again). This will also report it to all mgmds (as we'll
have transporters to all of them).
ndb/include/mgmapi/mgmapi.h:
Add ndb_mgm_convert_to_transporter
- converts to a transporter connect
- destroys the handle (without disconnecting)
- returns socket
ndb/include/transporter/TransporterRegistry.hpp:
Add prototype for connect_ndb_mgmd
ndb/include/util/SocketClient.hpp:
Remove connect_without_auth
Add get_port() and get_server_name()
ndb/src/common/transporter/Transporter.cpp:
use TransporterRegistry::connect_ndb_mgmd() to make the connection if isMgmConnection
ndb/src/common/transporter/TransporterRegistry.cpp:
Impliment TransporterRegistry::connect_ndb_mgmd
- takes a SocketClient and constructs a connectstring.
- uses this connect string to make a NdbMgmHandle
- send dynamic ports to this mgm server
- transform into a transporter connect
- return socket
ndb/src/common/util/SocketClient.cpp:
Remove connect_without_auth
ndb/src/kernel/main.cpp:
Don't relay dynamic ports. We now do this on transporter connect
ndb/src/mgmapi/mgmapi.cpp:
Impliment ndb_mgm_convert_to_transporter
- converts the mgm connection into a transporter connection
- destroys the handle
- returns the socket that should now be used as a transporter
Diffstat (limited to 'ndb/src/common')
-rw-r--r-- | ndb/src/common/transporter/Transporter.cpp | 12 | ||||
-rw-r--r-- | ndb/src/common/transporter/TransporterRegistry.cpp | 44 | ||||
-rw-r--r-- | ndb/src/common/util/SocketClient.cpp | 21 |
3 files changed, 45 insertions, 32 deletions
diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index f8bcf142a69..86fabc839c7 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -117,7 +117,7 @@ Transporter::connect_client() { return true; if(isMgmConnection) - sockfd= m_socket_client->connect_without_auth(); + sockfd= m_transporter_registry.connect_ndb_mgmd(m_socket_client); else sockfd= m_socket_client->connect(); @@ -131,16 +131,6 @@ Transporter::connect_client() { SocketOutputStream s_output(sockfd); SocketInputStream s_input(sockfd); - if(isMgmConnection) - { - /* - We issue the magic command to the management server to - switch into transporter mode. - */ - s_output.println("transporter connect"); - s_output.println(""); - } - // send info about own id // send info about own transporter type diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index a6cad7b921f..e98ab03dfd6 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -48,6 +48,7 @@ extern int g_ndb_shm_signum; #include <InputStream.hpp> #include <OutputStream.hpp> +#include <mgmapi/mgmapi.h> #include <mgmapi/mgmapi_debug.h> #include <EventLogger.hpp> @@ -1483,4 +1484,47 @@ TransporterRegistry::get_transporter(NodeId nodeId) { return theTransporters[nodeId]; } +NDB_SOCKET_TYPE TransporterRegistry::connect_ndb_mgmd(SocketClient *sc) +{ + NdbMgmHandle h; + struct ndb_mgm_reply mgm_reply; + char *cs, c[100]; + bool d=false; + + h= ndb_mgm_create_handle(); + + if(strlen(sc->get_server_name())>80) + { + /* + * server name is long. malloc enough for it and the port number + */ + cs= (char*)malloc((strlen(sc->get_server_name())+20)*sizeof(char)); + if(!cs) + return -1; + d= true; + } + else + cs = &c[0]; + + snprintf(cs,(d)?strlen(sc->get_server_name()+20):sizeof(c), + "%s:%u",sc->get_server_name(),sc->get_port()); + + ndb_mgm_set_connectstring(h, cs); + + if(ndb_mgm_connect(h, 0, 0, 0)<0) + return -1; + + for(unsigned int i=0;i < m_transporter_interface.size();i++) + ndb_mgm_set_connection_int_parameter(h, + get_localNodeId(), + m_transporter_interface[i].m_remote_nodeId, + CFG_CONNECTION_SERVER_PORT, + m_transporter_interface[i].m_s_service_port, + &mgm_reply); + if(d) + free(cs); + + return ndb_mgm_convert_to_transporter(h); +} + template class Vector<TransporterRegistry::Transporter_interface>; diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp index 1ac105881a2..38df1417eb8 100644 --- a/ndb/src/common/util/SocketClient.cpp +++ b/ndb/src/common/util/SocketClient.cpp @@ -60,27 +60,6 @@ SocketClient::init() return true; } -/** - * SocketClient::connect_without_auth() - * - * Temporarily disables authentication and connects. - * This is useful if you're trying to change what this - * SocketClient object is for (e.g. from mgm to ndb) - */ - -NDB_SOCKET_TYPE -SocketClient::connect_without_auth() -{ - SocketAuthenticator *tmp; - NDB_SOCKET_TYPE retval; - tmp= m_auth; - m_auth= NULL; - retval= connect(); - m_auth= tmp; - - return retval; -} - NDB_SOCKET_TYPE SocketClient::connect() { |