diff --git a/ndb/include/mgmapi/mgmapi_debug.h b/ndb/include/mgmapi/mgmapi_debug.h index 1c562cd164f..efd3ffe44fa 100644 --- a/ndb/include/mgmapi/mgmapi_debug.h +++ b/ndb/include/mgmapi/mgmapi_debug.h @@ -131,6 +131,24 @@ extern "C" { int param, const char * value, struct ndb_mgm_reply* reply); + + /** + * Set 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 what to set it to + * @param reply from ndb_mgmd + */ + int ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, + int node1, + int node2, + int param, + unsigned value, + struct ndb_mgm_reply* reply); + #ifdef __cplusplus } #endif diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index e22ceffe773..0ba7b1c8b0f 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1975,4 +1975,46 @@ ndb_mgm_check_connection_error: return -1; } +extern "C" +int +ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle, + int node1, + int node2, + int param, + unsigned value, + struct ndb_mgm_reply* mgmreply){ + CHECK_HANDLE(handle, 0); + CHECK_CONNECTED(handle, 0); + + Properties args; + args.put("node1: ", node1); + args.put("node2: ", node2); + args.put("param: ", param); + args.put("value: ", value); + + const ParserRow reply[]= { + MGM_CMD("set connection parameter reply", NULL, ""), + MGM_ARG("result", String, Mandatory, "Error message"), + MGM_END() + }; + + const Properties *prop; + prop= ndb_mgm_call(handle, reply, "set 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); + + delete prop; + return res; +} + + template class Vector*>; diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 061aa2e0cb8..c74dcc54037 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2732,6 +2732,60 @@ MgmtSrvr::setDbParameter(int node, int param, const char * value, return 0; } +int +MgmtSrvr::setConnectionDbParameter(int node1, + int node2, + int param, + int value, + BaseString& msg){ + Uint32 current_value,new_value; + + DBUG_ENTER("MgmtSrvr::setConnectionDbParameter"); + + 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, ¤t_value) < 0) { + msg.assign("Unable to get current value of parameter"); + return -1; + } + + ConfigValues::Iterator i2(_config->m_configValues->m_config, + iter.m_config); + + if(i2.set(param, (unsigned)value) < 0) { + msg.assign("Unable to set new value of parameter"); + return -1; + } + + if(iter.get(param, &new_value) < 0) { + msg.assign("Unable to get parameter after setting it."); + return -1; + } + + msg.assfmt("%u -> %u",current_value,new_value); + return 1; +} + + + template class Vector; #if __SUNPRO_CC != 0x560 template bool SignalQueue::waitFor(Vector&, SigMatch*&, NdbApiSignal*&, unsigned); diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 1afb0848ecc..5978ca76fd2 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -500,6 +500,9 @@ public: int getPort() const; int setDbParameter(int node, int parameter, const char * value, BaseString&); + int setConnectionDbParameter(int node1, int node2, int param, int value, + BaseString& msg); + const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); } void get_connected_nodes(NodeBitmask &connected_nodes) const; diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 5834d40cc78..76823ea6055 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -238,6 +238,13 @@ ParserRow commands[] = { MGM_ARG("parameter", String, Mandatory, "Parameter"), MGM_ARG("value", String, Mandatory, "Value"), + MGM_CMD("set connection parameter", + &MgmApiSession::setConnectionParameter, ""), + MGM_ARG("node1", String, Mandatory, "Node1 ID"), + MGM_ARG("node2", String, Mandatory, "Node2 ID"), + MGM_ARG("param", String, Mandatory, "Parameter"), + MGM_ARG("value", String, Mandatory, "Value"), + MGM_CMD("listen event", &MgmApiSession::listen_event, ""), MGM_ARG("node", Int, Optional, "Node"), MGM_ARG("filter", String, Mandatory, "Event category"), @@ -1347,6 +1354,29 @@ MgmApiSession::setParameter(Parser_t::Context &, m_output->println(""); } +void +MgmApiSession::setConnectionParameter(Parser_t::Context &ctx, + Properties const &args) { + BaseString node1, node2, param, value; + args.get("node1", node1); + args.get("node2", node2); + args.get("param", param); + args.get("value", value); + + BaseString result; + int ret = m_mgmsrv.setConnectionDbParameter(atoi(node1.c_str()), + atoi(node2.c_str()), + atoi(param.c_str()), + atoi(value.c_str()), + result); + + m_output->println("set connection parameter reply"); + m_output->println("message: %s", result.c_str()); + m_output->println("result: %s", (ret>0)?"Ok":"Failed"); + m_output->println(""); +} + + void MgmApiSession::listen_event(Parser::Context & ctx, Properties const & args) { diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp index 6a5f06a659e..6e1e887cf38 100644 --- a/ndb/src/mgmsrv/Services.hpp +++ b/ndb/src/mgmsrv/Services.hpp @@ -88,6 +88,9 @@ public: void configChange(Parser_t::Context &ctx, const class Properties &args); void setParameter(Parser_t::Context &ctx, const class Properties &args); + void setConnectionParameter(Parser_t::Context &ctx, + const class Properties &args); + void listen_event(Parser_t::Context &ctx, const class Properties &args); void purge_stale_sessions(Parser_t::Context &ctx, const class Properties &args);