Commit 87c85d6f authored by unknown's avatar unknown

Part 1 of impl2 of WL2278 (Dynamic port allocation of cluster nodes).

Implementation of "get connection parameter" mgmd call for getting from mgmd what port to use for a connection between two nodes.

(The actual use of this function is not yet implemented)


ndb/include/mgmapi/mgmapi_debug.h:
  Add ndb_mgm_get_connection_int_parameter() prototype
ndb/src/mgmapi/mgmapi.cpp:
  Add ndb_mgm_get_connection_int_parameter() implementation
ndb/src/mgmsrv/MgmtSrvr.cpp:
  Add implementation of MgmtSrvr::getConnectionDbParameter()
ndb/src/mgmsrv/MgmtSrvr.hpp:
  Add prototype for get_connectionDbParemeter
ndb/src/mgmsrv/Services.cpp:
  Add "get connection parameter" mgmd command (for over the wire)
  
  add getConnectionParameter handler for it
ndb/src/mgmsrv/Services.hpp:
  Add prototype for getConnectionParameter
parent 9035f5cf
...@@ -149,6 +149,25 @@ extern "C" { ...@@ -149,6 +149,25 @@ extern "C" {
unsigned value, unsigned value,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/**
* Get an integer parameter for a connection
*
* @param handle the NDB management handle.
* @param node1 the node1 id
* @param node2 the node2 id
* @param param the parameter (e.g. CFG_CONNECTION_SERVER_PORT)
* @param value where to store the retreived value. In the case of
* error, value is not changed.
* @param reply from ndb_mgmd
* @return 0 on success. < 0 on error.
*/
int ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
int node1,
int node2,
int param,
unsigned *value,
struct ndb_mgm_reply* reply);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -2020,5 +2020,49 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, ...@@ -2020,5 +2020,49 @@ ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle,
return res; return res;
} }
extern "C"
int
ndb_mgm_get_connection_int_parameter(NdbMgmHandle handle,
int node1,
int node2,
int param,
unsigned *value,
struct ndb_mgm_reply* mgmreply){
DBUG_ENTER("ndb_mgm_get_connection_int_parameter");
CHECK_HANDLE(handle, -1);
CHECK_CONNECTED(handle, -1);
Properties args;
args.put("node1", node1);
args.put("node2", node2);
args.put("param", param);
const ParserRow<ParserDummy> reply[]= {
MGM_CMD("get connection parameter reply", NULL, ""),
MGM_ARG("result", String, Mandatory, "Error message"),
MGM_ARG("value", Int, Mandatory, "Current Value"),
MGM_END()
};
const Properties *prop;
prop= ndb_mgm_call(handle, reply, "get connection parameter", &args);
CHECK_REPLY(prop, -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;
}
res= 0;
} while(0);
prop->get("value",value);
delete prop;
return res;
}
template class Vector<const ParserRow<ParserDummy>*>; template class Vector<const ParserRow<ParserDummy>*>;
...@@ -2785,6 +2785,42 @@ MgmtSrvr::setConnectionDbParameter(int node1, ...@@ -2785,6 +2785,42 @@ MgmtSrvr::setConnectionDbParameter(int node1,
} }
int
MgmtSrvr::getConnectionDbParameter(int node1,
int node2,
int param,
unsigned *value,
BaseString& msg){
DBUG_ENTER("MgmtSrvr::getConnectionDbParameter");
ndb_mgm_configuration_iterator iter(* _config->m_configValues,
CFG_SECTION_CONNECTION);
if(iter.first() != 0){
msg.assign("Unable to find connection section (iter.first())");
return -1;
}
for(;iter.valid();iter.next()) {
Uint32 n1,n2;
iter.get(CFG_CONNECTION_NODE_1, &n1);
iter.get(CFG_CONNECTION_NODE_2, &n2);
if(n1 == (unsigned)node1 && n2 == (unsigned)node2)
break;
}
if(!iter.valid()) {
msg.assign("Unable to find connection between nodes");
return -1;
}
if(iter.get(param, value) < 0) {
msg.assign("Unable to get current value of parameter");
return -1;
}
msg.assfmt("%u",*value);
return 1;
}
template class Vector<SigMatch>; template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560 #if __SUNPRO_CC != 0x560
......
...@@ -502,6 +502,9 @@ public: ...@@ -502,6 +502,9 @@ public:
int setDbParameter(int node, int parameter, const char * value, BaseString&); int setDbParameter(int node, int parameter, const char * value, BaseString&);
int setConnectionDbParameter(int node1, int node2, int param, int value, int setConnectionDbParameter(int node1, int node2, int param, int value,
BaseString& msg); BaseString& msg);
int getConnectionDbParameter(int node1, int node2, int param,
unsigned *value, BaseString& msg);
const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); } const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); }
......
...@@ -245,6 +245,12 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -245,6 +245,12 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("param", String, Mandatory, "Parameter"), MGM_ARG("param", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"), MGM_ARG("value", String, Mandatory, "Value"),
MGM_CMD("get connection parameter",
&MgmApiSession::getConnectionParameter, ""),
MGM_ARG("node1", String, Mandatory, "Node1 ID"),
MGM_ARG("node2", String, Mandatory, "Node2 ID"),
MGM_ARG("param", String, Mandatory, "Parameter"),
MGM_CMD("listen event", &MgmApiSession::listen_event, ""), MGM_CMD("listen event", &MgmApiSession::listen_event, ""),
MGM_ARG("node", Int, Optional, "Node"), MGM_ARG("node", Int, Optional, "Node"),
MGM_ARG("filter", String, Mandatory, "Event category"), MGM_ARG("filter", String, Mandatory, "Event category"),
...@@ -1376,6 +1382,29 @@ MgmApiSession::setConnectionParameter(Parser_t::Context &ctx, ...@@ -1376,6 +1382,29 @@ MgmApiSession::setConnectionParameter(Parser_t::Context &ctx,
m_output->println(""); m_output->println("");
} }
void
MgmApiSession::getConnectionParameter(Parser_t::Context &ctx,
Properties const &args) {
BaseString node1, node2, param;
unsigned value = 0;
args.get("node1", node1);
args.get("node2", node2);
args.get("param", param);
BaseString result;
int ret = m_mgmsrv.getConnectionDbParameter(atoi(node1.c_str()),
atoi(node2.c_str()),
atoi(param.c_str()),
&value,
result);
m_output->println("set connection parameter reply");
m_output->println("message: %s", result.c_str());
m_output->println("value: %u", value);
m_output->println("result: %s", (ret>0)?"Ok":"Failed");
m_output->println("");
}
void void
MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx, MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
......
...@@ -90,6 +90,8 @@ public: ...@@ -90,6 +90,8 @@ public:
void setParameter(Parser_t::Context &ctx, const class Properties &args); void setParameter(Parser_t::Context &ctx, const class Properties &args);
void setConnectionParameter(Parser_t::Context &ctx, void setConnectionParameter(Parser_t::Context &ctx,
const class Properties &args); const class Properties &args);
void getConnectionParameter(Parser_t::Context &ctx,
Properties const &args);
void listen_event(Parser_t::Context &ctx, const class Properties &args); void listen_event(Parser_t::Context &ctx, const class Properties &args);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment