summaryrefslogtreecommitdiff
path: root/ndb/src/mgmapi
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/src/mgmapi
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/src/mgmapi')
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp83
1 files changed, 57 insertions, 26 deletions
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index bb4b6be8221..21a2ab074e7 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -24,6 +24,7 @@
#include <NdbOut.hpp>
#include <SocketServer.hpp>
+#include <SocketClient.hpp>
#include <Parser.hpp>
#include <OutputStream.hpp>
#include <InputStream.hpp>
@@ -318,8 +319,8 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
/**
* Print some info about why the parser returns NULL
*/
-// ndbout << " status=" << ctx.m_status << ", curr="
-// << ctx.m_currentToken << endl;
+ //ndbout << " status=" << ctx.m_status << ", curr="
+ //<< ctx.m_currentToken << endl;
}
#ifdef MGMAPI_LOG
else {
@@ -362,30 +363,11 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv)
/**
* Do connect
*/
- const NDB_SOCKET_TYPE sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sockfd == NDB_INVALID_SOCKET) {
- SET_ERROR(handle, NDB_MGM_ILLEGAL_SOCKET, "");
- return -1;
- }
-
- struct sockaddr_in servaddr;
- memset(&servaddr, 0, sizeof(servaddr));
- servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons(handle->port);
- // Convert ip address presentation format to numeric format
- const int res1 = Ndb_getInAddr(&servaddr.sin_addr, handle->hostname);
- if (res1 != 0) {
- DEBUG("Ndb_getInAddr(...) == -1");
- setError(handle, EINVAL, __LINE__, "Invalid hostname/address");
- return -1;
- }
-
- const int res2 = connect(sockfd, (struct sockaddr*) &servaddr,
- sizeof(servaddr));
- if (res2 == -1) {
- NDB_CLOSE_SOCKET(sockfd);
- setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, "Unable to connect to %s",
- mgmsrv);
+ SocketClient s(handle->hostname, handle->port);
+ const NDB_SOCKET_TYPE sockfd = s.connect();
+ if (sockfd < 0) {
+ setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__,
+ "Unable to connect to %s", mgmsrv);
return -1;
}
@@ -1523,6 +1505,55 @@ ndb_mgm_get_configuration(NdbMgmHandle handle, unsigned int version) {
return 0;
}
+extern "C"
+int
+ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, unsigned *pnodeid, int nodetype)
+{
+
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("version", version);
+ args.put("nodetype", nodetype);
+ args.put("nodeid", *pnodeid);
+ args.put("user", "mysqld");
+ args.put("password", "mysqld");
+ args.put("public key", "a public key");
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("get nodeid reply", NULL, ""),
+ MGM_ARG("nodeid", Int, Optional, "Error message"),
+ MGM_ARG("result", String, Mandatory, "Error message"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop= ndb_mgm_call(handle, reply, "get nodeid", &args);
+
+ if(prop == NULL) {
+ SET_ERROR(handle, EIO, "Unable to alloc nodeid");
+ return -1;
+ }
+
+ int res= -1;
+ do {
+ const char * buf;
+ if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
+ ndbout_c("ERROR Message: %s\n", buf);
+ break;
+ }
+ if(!prop->get("nodeid", pnodeid) != 0){
+ ndbout_c("ERROR Message: <nodeid Unspecified>\n");
+ break;
+ }
+ res= 0;
+ }while(0);
+
+ delete prop;
+ return res;
+}
+
/*****************************************************************************
* Global Replication
******************************************************************************/