mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
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).
This commit is contained in:
parent
64cebff743
commit
196def91b3
8 changed files with 88 additions and 44 deletions
|
@ -140,6 +140,7 @@
|
|||
*/
|
||||
|
||||
#include <ndb_types.h>
|
||||
#include <NdbTCP.h>
|
||||
#include "ndb_logevent.h"
|
||||
#include "mgmapi_config_parameters.h"
|
||||
|
||||
|
@ -970,6 +971,19 @@ extern "C" {
|
|||
|
||||
int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
|
||||
unsigned version, int nodetype);
|
||||
|
||||
|
||||
/**
|
||||
* Convert connection to transporter
|
||||
* @param handle NDB management handle.
|
||||
*
|
||||
* @return socket
|
||||
*
|
||||
* @note the socket is now able to be used as a transporter connection
|
||||
*/
|
||||
NDB_SOCKET_TYPE ndb_mgm_convert_to_transporter(NdbMgmHandle handle);
|
||||
|
||||
|
||||
/**
|
||||
* Config iterator
|
||||
*/
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "TransporterDefinitions.hpp"
|
||||
#include <SocketServer.hpp>
|
||||
#include <SocketClient.hpp>
|
||||
|
||||
#include <NdbTCP.h>
|
||||
|
||||
|
@ -111,6 +112,11 @@ public:
|
|||
*/
|
||||
bool connect_server(NDB_SOCKET_TYPE sockfd);
|
||||
|
||||
/**
|
||||
* use a mgmd connection to connect as a transporter
|
||||
*/
|
||||
NDB_SOCKET_TYPE connect_ndb_mgmd(SocketClient *sc);
|
||||
|
||||
/**
|
||||
* Remove all transporters
|
||||
*/
|
||||
|
|
|
@ -35,8 +35,9 @@ public:
|
|||
m_port = port;
|
||||
m_servaddr.sin_port = htons(m_port);
|
||||
};
|
||||
unsigned short get_port() { return m_port; };
|
||||
char *get_server_name() { return m_server_name; };
|
||||
NDB_SOCKET_TYPE connect();
|
||||
NDB_SOCKET_TYPE connect_without_auth();
|
||||
bool close();
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -205,17 +205,6 @@ int main(int argc, char** argv)
|
|||
|
||||
socket_server.startServer();
|
||||
|
||||
struct ndb_mgm_reply mgm_reply;
|
||||
for(unsigned int i=0;i<globalTransporterRegistry.m_transporter_interface.size();i++)
|
||||
ndb_mgm_set_connection_int_parameter(theConfig->get_config_retriever()->get_mgmHandle(),
|
||||
globalTransporterRegistry.get_localNodeId(),
|
||||
globalTransporterRegistry.m_transporter_interface[i].m_remote_nodeId,
|
||||
CFG_CONNECTION_SERVER_PORT,
|
||||
globalTransporterRegistry.m_transporter_interface[i].m_s_service_port,
|
||||
&mgm_reply);
|
||||
|
||||
|
||||
|
||||
// theConfig->closeConfiguration();
|
||||
|
||||
globalEmulatorData.theThreadConfig->ipControlLoop();
|
||||
|
|
|
@ -2148,4 +2148,25 @@ ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
|
|||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
NDB_SOCKET_TYPE
|
||||
ndb_mgm_convert_to_transporter(NdbMgmHandle handle)
|
||||
{
|
||||
NDB_SOCKET_TYPE s;
|
||||
|
||||
CHECK_HANDLE(handle, -1);
|
||||
CHECK_CONNECTED(handle, -2);
|
||||
|
||||
handle->connected= 0; // we pretend we're disconnected
|
||||
s= handle->socket;
|
||||
|
||||
SocketOutputStream s_output(s);
|
||||
s_output.println("transporter connect");
|
||||
s_output.println("");
|
||||
|
||||
ndb_mgm_destroy_handle(&handle); // set connected=0, so won't disconnect
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
template class Vector<const ParserRow<ParserDummy>*>;
|
||||
|
|
Loading…
Reference in a new issue