summaryrefslogtreecommitdiff
path: root/ndb/include
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.bredbandsbolaget.se>2004-06-23 00:48:07 +0000
committerunknown <tomas@poseidon.bredbandsbolaget.se>2004-06-23 00:48:07 +0000
commitdc2544fdee9e510614cc7d674726ea388284e57f (patch)
tree409861ce85381636f2e02207aaf198f1f030dac9 /ndb/include
parentfb89fac462d5f8d3c5a7e2663d30f65a0623fc0d (diff)
downloadmariadb-git-dc2544fdee9e510614cc7d674726ea388284e57f.tar.gz
WL 1748
ndb/include/kernel/signaldata/ApiRegSignalData.hpp: Added info about connected nodes to ApiRegConf ndb/include/mgmapi/mgmapi.h: New mgmapi command to get nodeid dynamically ndb/include/mgmapi/mgmapi_config_parameters.h: New config param to specify port on for transporter setup ndb/include/mgmcommon/ConfigRetriever.hpp: added notetype to getConfig ndb/include/portlib/NdbTCP.h: small detail ndb/include/transporter/TransporterRegistry.hpp: changed performstates and interface to connect/disconnect transporters added TransporterService for transporter setup changed model for setting up transporters ndb/src/common/mgmcommon/ConfigInfo.cpp: removed some config params as mandatory ndb/src/common/mgmcommon/ConfigRetriever.cpp: added dynamic alloc of nodeid ndb/src/common/mgmcommon/LocalConfig.cpp: added default localhost:2200 and dynamic id ndb/src/common/transporter/TCP_Transporter.cpp: moved TCP hostname stuff from TCP_Transporter to parent class Transporter changed TCP connection setup to use just one port for all transporters ndb/src/common/transporter/TCP_Transporter.hpp: moved TCP hostname stuff from TCP_Transporter to parent class Transporter changed TCP connection setup to use just one port for all transporters ndb/src/common/transporter/Transporter.cpp: moved TCP hostname stuff from TCP_Transporter to parent class Transporter changed TCP connection setup to use just one port for all transporters ndb/src/common/transporter/Transporter.hpp: moved TCP hostname stuff from TCP_Transporter to parent class Transporter changed TCP connection setup to use just one port for all transporters ndb/src/common/transporter/TransporterRegistry.cpp: changed performstates and interface to connect/disconnect transporters added TransporterService for transporter setup changed model for setting up transporters ndb/src/common/util/Makefile.am: New SocketAuthenticator ndb/src/common/util/SocketServer.cpp: small detail ndb/src/kernel/Makefile.am: small detail ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp: new interface to performstates + cleanup ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: changed signal ApiRegConf ndb/src/kernel/vm/ThreadConfig.cpp: changed naming ndb/src/mgmapi/mgmapi.cpp: Use new Socket client New methid for allocating dynamic id ndb/src/mgmsrv/MgmtSrvr.cpp: moved port setup from main.cpp to MgmtSrvr new method getNextFreeNodeId ndb/src/mgmsrv/MgmtSrvr.hpp: .. ndb/src/mgmsrv/Services.cpp: allocate new nodeid ndb/src/mgmsrv/Services.hpp: .. ndb/src/mgmsrv/main.cpp: moved setup port to MgmtSrvr.cpp Rearranged setup order ndb/src/ndbapi/ClusterMgr.cpp: new API_REGCONF ndb/src/ndbapi/ClusterMgr.hpp: bitmask to hold connected nodes ndb/src/ndbapi/TransporterFacade.cpp: New transporter connect ndb/src/ndbapi/TransporterFacade.hpp: removed function not used ndb/src/kernel/main.cpp: new transporter setup
Diffstat (limited to 'ndb/include')
-rw-r--r--ndb/include/kernel/signaldata/ApiRegSignalData.hpp4
-rw-r--r--ndb/include/mgmapi/mgmapi.h5
-rw-r--r--ndb/include/mgmapi/mgmapi_config_parameters.h2
-rw-r--r--ndb/include/mgmcommon/ConfigRetriever.hpp4
-rw-r--r--ndb/include/portlib/NdbTCP.h2
-rw-r--r--ndb/include/transporter/TransporterRegistry.hpp82
-rw-r--r--ndb/include/util/SocketAuthenticator.hpp39
-rw-r--r--ndb/include/util/SocketClient.hpp38
8 files changed, 147 insertions, 29 deletions
diff --git a/ndb/include/kernel/signaldata/ApiRegSignalData.hpp b/ndb/include/kernel/signaldata/ApiRegSignalData.hpp
index 84dca8fb260..9ce99d3e45c 100644
--- a/ndb/include/kernel/signaldata/ApiRegSignalData.hpp
+++ b/ndb/include/kernel/signaldata/ApiRegSignalData.hpp
@@ -80,13 +80,15 @@ class ApiRegConf {
friend class ClusterMgr;
public:
- STATIC_CONST( SignalLength = 3 + NodeState::DataLength );
+ STATIC_CONST( SignalLength = 3 + NodeState::DataLength +
+ NdbNodeBitmask::Size );
private:
Uint32 qmgrRef;
Uint32 version; // Version of NDB node
Uint32 apiHeartbeatFrequency;
NodeState nodeState;
+ Bitmask<NdbNodeBitmask::Size>::Data connected_nodes;
};
#endif
diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h
index 7b2f728bda8..45a421855b0 100644
--- a/ndb/include/mgmapi/mgmapi.h
+++ b/ndb/include/mgmapi/mgmapi.h
@@ -666,6 +666,11 @@ extern "C" {
*/
struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle,
unsigned version);
+
+ int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
+ unsigned version,
+ unsigned *pnodeid,
+ int nodetype);
/**
* Config iterator
*/
diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h
index d3bb44c1523..22b9f8f31dd 100644
--- a/ndb/include/mgmapi/mgmapi_config_parameters.h
+++ b/ndb/include/mgmapi/mgmapi_config_parameters.h
@@ -76,6 +76,8 @@
#define CFG_DB_DISCLESS 148
+#define CFG_DB_SERVER_PORT 149
+
#define CFG_NODE_ARBIT_RANK 200
#define CFG_NODE_ARBIT_DELAY 201
diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp
index 50d333b54dd..c1de751b797 100644
--- a/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -77,7 +77,7 @@ public:
* Get config using socket
*/
struct ndb_mgm_configuration * getConfig(const char * mgmhost, short port,
- int versionId);
+ int versionId, int nodetype);
/**
* Get config from file
*/
@@ -98,7 +98,7 @@ private:
char * m_connectString;
char * m_defaultConnectString;
-
+
/**
* Verify config
*/
diff --git a/ndb/include/portlib/NdbTCP.h b/ndb/include/portlib/NdbTCP.h
index 42c34855c39..4dc8435eef1 100644
--- a/ndb/include/portlib/NdbTCP.h
+++ b/ndb/include/portlib/NdbTCP.h
@@ -64,7 +64,7 @@ typedef int socklen_t;
#define NDB_NONBLOCK O_NONBLOCK
#define NDB_SOCKET_TYPE int
#define NDB_INVALID_SOCKET -1
-#define NDB_CLOSE_SOCKET(x) close(x)
+#define NDB_CLOSE_SOCKET(x) ::close(x)
#define InetErrno errno
diff --git a/ndb/include/transporter/TransporterRegistry.hpp b/ndb/include/transporter/TransporterRegistry.hpp
index 6c979777f18..7a750b81478 100644
--- a/ndb/include/transporter/TransporterRegistry.hpp
+++ b/ndb/include/transporter/TransporterRegistry.hpp
@@ -29,20 +29,10 @@
#define TransporterRegistry_H
#include "TransporterDefinitions.hpp"
+#include <SocketServer.hpp>
#include <NdbTCP.h>
-// A transporter is always in a PerformState.
-// PerformIO is used initially and as long as any of the events
-// PerformConnect, ...
-enum PerformState {
- PerformNothing = 4, // Does nothing
- PerformIO = 0, // Is connected
- PerformConnect = 1, // Is trying to connect
- PerformDisconnect = 2, // Trying to disconnect
- RemoveTransporter = 3 // Will be removed
-};
-
// A transporter is always in an IOState.
// NoHalt is used initially and as long as it is no restrictions on
// sending or receiving.
@@ -60,18 +50,45 @@ enum TransporterType {
tt_OSE_TRANSPORTER = 4
};
+static const char *performStateString[] =
+ { "is connected",
+ "is trying to connect",
+ "does nothing",
+ "is trying to disconnect" };
+
class Transporter;
class TCP_Transporter;
class SCI_Transporter;
class SHM_Transporter;
class OSE_Transporter;
+class TransporterRegistry;
+class SocketAuthenticator;
+
+class TransporterService : public SocketServer::Service {
+ SocketAuthenticator * m_auth;
+ TransporterRegistry * m_transporter_registry;
+public:
+ TransporterService(SocketAuthenticator *auth= 0)
+ {
+ m_auth= auth;
+ m_transporter_registry= 0;
+ }
+ void setTransporterRegistry(TransporterRegistry *t)
+ {
+ m_transporter_registry= t;
+ }
+ SocketServer::Session * newSession(NDB_SOCKET_TYPE socket);
+};
+
/**
* @class TransporterRegistry
* @brief ...
*/
class TransporterRegistry {
friend class OSE_Receiver;
+ friend class Transporter;
+ friend class TransporterService;
public:
/**
* Constructor
@@ -98,6 +115,12 @@ public:
*/
~TransporterRegistry();
+ bool start_service(SocketServer& server);
+ bool start_clients();
+ bool stop_clients();
+ void start_clients_thread();
+ void update_connections();
+
/**
* Start/Stop receiving
*/
@@ -110,16 +133,26 @@ public:
void startSending();
void stopSending();
+ // A transporter is always in a PerformState.
+ // PerformIO is used initially and as long as any of the events
+ // PerformConnect, ...
+ enum PerformState {
+ CONNECTED = 0,
+ CONNECTING = 1,
+ DISCONNECTED = 2,
+ DISCONNECTING = 3
+ };
+ const char *getPerformStateString(NodeId nodeId) const
+ { return performStateString[(unsigned)performStates[nodeId]]; };
+
/**
* Get and set methods for PerformState
*/
- PerformState performState(NodeId nodeId);
- void setPerformState(NodeId nodeId, PerformState state);
-
- /**
- * Set perform state for all transporters
- */
- void setPerformState(PerformState state);
+ void do_connect(NodeId node_id);
+ void do_disconnect(NodeId node_id);
+ bool is_connected(NodeId node_id) { return performStates[node_id] == CONNECTED; };
+ void report_connect(NodeId node_id);
+ void report_disconnect(NodeId node_id, int errnum);
/**
* Get and set methods for IOState
@@ -174,8 +207,6 @@ public:
void performReceive();
void performSend();
- void checkConnections();
-
/**
* Force sending if more than or equal to sendLimit
* number have asked for send. Returns 0 if not sending
@@ -192,6 +223,12 @@ protected:
private:
void * callbackObj;
+ TransporterService *m_transporter_service;
+ unsigned short m_service_port;
+ char *m_interface_name;
+ struct NdbThread *m_start_clients_thread;
+ bool m_run_start_clients_thread;
+
int sendCounter;
NodeId localNodeId;
bool nodeIdSpecified;
@@ -202,11 +239,6 @@ private:
int nSHMTransporters;
int nOSETransporters;
- int m_ccCount;
- int m_ccIndex;
- int m_ccStep;
- int m_nTransportersPerformConnect;
- bool m_ccReady;
/**
* Arrays holding all transporters in the order they are created
*/
diff --git a/ndb/include/util/SocketAuthenticator.hpp b/ndb/include/util/SocketAuthenticator.hpp
new file mode 100644
index 00000000000..b42c7beb70f
--- /dev/null
+++ b/ndb/include/util/SocketAuthenticator.hpp
@@ -0,0 +1,39 @@
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef SOCKET_AUTHENTICATOR_HPP
+#define SOCKET_AUTHENTICATOR_HPP
+
+class SocketAuthenticator
+{
+public:
+ virtual ~SocketAuthenticator() {};
+ virtual bool client_authenticate(int sockfd) = 0;
+ virtual bool server_authenticate(int sockfd) = 0;
+};
+
+class SocketAuthSimple : public SocketAuthenticator
+{
+ const char *m_passwd;
+ char *m_buf;
+public:
+ SocketAuthSimple(const char *passwd);
+ virtual ~SocketAuthSimple();
+ virtual bool client_authenticate(int sockfd);
+ virtual bool server_authenticate(int sockfd);
+};
+
+#endif // SOCKET_AUTHENTICATOR_HPP
diff --git a/ndb/include/util/SocketClient.hpp b/ndb/include/util/SocketClient.hpp
new file mode 100644
index 00000000000..de9a081464a
--- /dev/null
+++ b/ndb/include/util/SocketClient.hpp
@@ -0,0 +1,38 @@
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef SOCKET_CLIENT_HPP
+#define SOCKET_CLIENT_HPP
+
+#include <NdbTCP.h>
+class SocketAuthenticator;
+
+class SocketClient
+{
+ NDB_SOCKET_TYPE m_sockfd;
+ struct sockaddr_in m_servaddr;
+ unsigned short m_port;
+ char *m_server_name;
+ SocketAuthenticator *m_auth;
+public:
+ SocketClient(const char *server_name, unsigned short port, SocketAuthenticator *sa = 0);
+ ~SocketClient();
+ bool init();
+ NDB_SOCKET_TYPE connect();
+ bool close();
+};
+
+#endif // SOCKET_ClIENT_HPP