summaryrefslogtreecommitdiff
path: root/ndb/src
diff options
context:
space:
mode:
authorunknown <joreland@mysql.com>2004-08-05 16:21:33 +0200
committerunknown <joreland@mysql.com>2004-08-05 16:21:33 +0200
commit73770db3f524426ca006f1038021c0e64fc5c5d0 (patch)
tree1372a44505734d50c1465a4519e5f3e98c97bea4 /ndb/src
parent1479ed3f5aaa0bfd1413a867952857695712786b (diff)
downloadmariadb-git-73770db3f524426ca006f1038021c0e64fc5c5d0.tar.gz
Initial support for updating configuration "on the fly"
Only updates values mgmsrv's on main memory to be used in test prg's ndb/include/mgmapi/mgmapi_debug.h: Update on config ndb/include/util/ConfigValues.hpp: Update on config ndb/src/mgmapi/mgmapi.cpp: Update on config ndb/src/mgmsrv/MgmtSrvr.cpp: Update on config ndb/src/mgmsrv/MgmtSrvr.hpp: Update on config ndb/src/mgmsrv/Services.cpp: Update on config ndb/src/mgmsrv/Services.hpp: Update on config
Diffstat (limited to 'ndb/src')
-rw-r--r--ndb/src/mgmapi/mgmapi.cpp136
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.cpp101
-rw-r--r--ndb/src/mgmsrv/MgmtSrvr.hpp2
-rw-r--r--ndb/src/mgmsrv/Services.cpp29
-rw-r--r--ndb/src/mgmsrv/Services.hpp2
5 files changed, 269 insertions, 1 deletions
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index 8f0c9e3ccf7..c75315f2d89 100644
--- a/ndb/src/mgmapi/mgmapi.cpp
+++ b/ndb/src/mgmapi/mgmapi.cpp
@@ -283,6 +283,7 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
while((name = iter.next()) != NULL) {
PropertiesType t;
Uint32 val_i;
+ Uint64 val_64;
BaseString val_s;
cmd_args->getTypeOf(name, &t);
@@ -291,11 +292,15 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
cmd_args->get(name, &val_i);
out.println("%s: %d", name, val_i);
break;
+ case PropertiesType_Uint64:
+ cmd_args->get(name, &val_64);
+ out.println("%s: %Ld", name, val_64);
+ break;
case PropertiesType_char:
cmd_args->get(name, val_s);
out.println("%s: %s", name, val_s.c_str());
break;
- default:
+ case PropertiesType_Properties:
/* Ignore */
break;
}
@@ -1591,3 +1596,132 @@ ndb_mgm_rep_command(NdbMgmHandle handle, unsigned int request,
delete reply;
return 0;
}
+
+extern "C"
+int
+ndb_mgm_set_int_parameter(NdbMgmHandle handle,
+ int node,
+ int param,
+ unsigned value,
+ struct ndb_mgm_reply*){
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("node: ", node);
+ args.put("param: ", param);
+ args.put("value: ", value);
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("set parameter reply", NULL, ""),
+ MGM_ARG("result", String, Mandatory, "Error message"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop= ndb_mgm_call(handle, reply, "set parameter", &args);
+
+ if(prop == NULL) {
+ SET_ERROR(handle, EIO, "Unable set parameter");
+ 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;
+ }
+ res= 0;
+ } while(0);
+
+ delete prop;
+ return res;
+}
+
+extern "C"
+int
+ndb_mgm_set_int64_parameter(NdbMgmHandle handle,
+ int node,
+ int param,
+ unsigned long long value,
+ struct ndb_mgm_reply*){
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("node: ", node);
+ args.put("param: ", param);
+ args.put("value: ", value);
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("set parameter reply", NULL, ""),
+ MGM_ARG("result", String, Mandatory, "Error message"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop= ndb_mgm_call(handle, reply, "set parameter", &args);
+
+ if(prop == NULL) {
+ SET_ERROR(handle, EIO, "Unable set parameter");
+ 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;
+ }
+ res= 0;
+ } while(0);
+
+ delete prop;
+ return res;
+}
+
+extern "C"
+int
+ndb_mgm_set_string_parameter(NdbMgmHandle handle,
+ int node,
+ int param,
+ const char * value,
+ struct ndb_mgm_reply*){
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("node: ", node);
+ args.put("parameter: ", param);
+ args.put("value: ", value);
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("set parameter reply", NULL, ""),
+ MGM_ARG("result", String, Mandatory, "Error message"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop= ndb_mgm_call(handle, reply, "set parameter", &args);
+
+ if(prop == NULL) {
+ SET_ERROR(handle, EIO, "Unable set parameter");
+ 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;
+ }
+ res= 0;
+ } while(0);
+
+ delete prop;
+ return res;
+}
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index 2fe4624ab59..a8b095439e4 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -2777,3 +2777,104 @@ MgmtSrvr::Allocated_resources::reserve_node(NodeId id)
m_mgmsrv.m_reserved_nodes.set(id);
}
+int
+MgmtSrvr::setDbParameter(int node, int param, const char * value,
+ BaseString& msg){
+ /**
+ * Check parameter
+ */
+ ndb_mgm_configuration_iterator iter(* _config->m_configValues,
+ CFG_SECTION_NODE);
+ if(iter.first() != 0){
+ msg.assign("Unable to find node section (iter.first())");
+ return -1;
+ }
+
+ Uint32 type = NODE_TYPE_DB + 1;
+ if(node != 0){
+ if(iter.find(CFG_NODE_ID, node) != 0){
+ msg.assign("Unable to find node (iter.find())");
+ return -1;
+ }
+ if(iter.get(CFG_TYPE_OF_SECTION, &type) != 0){
+ msg.assign("Unable to get node type(iter.get(CFG_TYPE_OF_SECTION))");
+ return -1;
+ }
+ } else {
+ do {
+ if(iter.get(CFG_TYPE_OF_SECTION, &type) != 0){
+ msg.assign("Unable to get node type(iter.get(CFG_TYPE_OF_SECTION))");
+ return -1;
+ }
+ if(type == NODE_TYPE_DB)
+ break;
+ } while(iter.next() == 0);
+ }
+
+ if(type != NODE_TYPE_DB){
+ msg.assfmt("Invalid node type or no such node (%d %d)",
+ type, NODE_TYPE_DB);
+ return -1;
+ }
+
+ int p_type;
+ unsigned val_32;
+ unsigned long long val_64;
+ const char * val_char;
+ do {
+ p_type = 0;
+ if(iter.get(param, &val_32) == 0){
+ val_32 = atoi(value);
+ break;
+ }
+
+ p_type++;
+ if(iter.get(param, &val_64) == 0){
+ val_64 = atoll(value);
+ break;
+ }
+ p_type++;
+ if(iter.get(param, &val_char) == 0){
+ val_char = value;
+ break;
+ }
+ msg.assign("Could not get parameter");
+ return -1;
+ } while(0);
+
+ bool res = false;
+ do {
+ int ret = iter.get(CFG_TYPE_OF_SECTION, &type);
+ assert(ret == 0);
+
+ if(type != NODE_TYPE_DB)
+ continue;
+
+ Uint32 node;
+ ret = iter.get(CFG_NODE_ID, &node);
+ assert(ret == 0);
+
+ ConfigValues::Iterator i2(_config->m_configValues->m_config,
+ iter.m_config);
+ switch(p_type){
+ case 0:
+ res = i2.set(param, val_32);
+ ndbout_c("Updateing node %d param: %d to %d", node, param, val_32);
+ break;
+ case 1:
+ res = i2.set(param, val_64);
+ ndbout_c("Updateing node %d param: %d to %Ld", node, param, val_32);
+ break;
+ case 2:
+ res = i2.set(param, val_char);
+ ndbout_c("Updateing node %d param: %d to %s", node, param, val_char);
+ break;
+ default:
+ abort();
+ }
+ assert(res);
+ } while(node == 0 && iter.next() == 0);
+
+ msg.assign("Success");
+ return 0;
+}
diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp
index 1145f4a5a6b..f677cdbb2d0 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.hpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.hpp
@@ -517,6 +517,8 @@ public:
*/
int getPort() const;
+ int setDbParameter(int node, int parameter, const char * value, BaseString&);
+
//**************************************************************************
private:
//**************************************************************************
diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp
index c94e1455554..c77ddd3f277 100644
--- a/ndb/src/mgmsrv/Services.cpp
+++ b/ndb/src/mgmsrv/Services.cpp
@@ -225,6 +225,16 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("parameter", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"),
+ MGM_CMD("config lock", &MgmApiSession::configLock, ""),
+
+ MGM_CMD("config unlock", &MgmApiSession::configUnlock, ""),
+ MGM_ARG("commit", Int, Mandatory, "Commit changes"),
+
+ MGM_CMD("set parameter", &MgmApiSession::setParameter, ""),
+ MGM_ARG("node", String, Mandatory, "Node"),
+ MGM_ARG("parameter", String, Mandatory, "Parameter"),
+ MGM_ARG("value", String, Mandatory, "Value"),
+
MGM_END()
};
@@ -1248,5 +1258,24 @@ MgmStatService::stopSessions(){
NDB_CLOSE_SOCKET(m_sockets[i]);
m_sockets.erase(i);
}
+}
+
+void
+MgmApiSession::setParameter(Parser_t::Context &,
+ Properties const &args) {
+ BaseString node, param, value;
+ args.get("node", node);
+ args.get("parameter", param);
+ args.get("value", value);
+
+ BaseString result;
+ int ret = m_mgmsrv.setDbParameter(atoi(node.c_str()),
+ atoi(param.c_str()),
+ value.c_str(),
+ result);
+ m_output->println("set parameter reply");
+ m_output->println("message: %s", result.c_str());
+ m_output->println("result: %d", ret);
+ m_output->println("");
}
diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp
index f5d10031d7a..9cf8b59be8f 100644
--- a/ndb/src/mgmsrv/Services.hpp
+++ b/ndb/src/mgmsrv/Services.hpp
@@ -82,6 +82,8 @@ public:
void configUnlock(Parser_t::Context &ctx, const class Properties &args);
void configChange(Parser_t::Context &ctx, const class Properties &args);
+ void setParameter(Parser_t::Context &ctx, const class Properties &args);
+
void repCommand(Parser_t::Context &ctx, const class Properties &args);
};