mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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
This commit is contained in:
@@ -106,6 +106,31 @@ extern "C" {
|
|||||||
struct ndb_mgm_reply* reply);
|
struct ndb_mgm_reply* reply);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param handle the NDB management handle.
|
||||||
|
* @param nodeId the node id. 0 = all db nodes
|
||||||
|
* @param errrorCode the errorCode.
|
||||||
|
* @param reply the reply message.
|
||||||
|
* @return 0 if successful or an error code.
|
||||||
|
*/
|
||||||
|
int ndb_mgm_set_int_parameter(NdbMgmHandle handle,
|
||||||
|
int node,
|
||||||
|
int param,
|
||||||
|
unsigned value,
|
||||||
|
struct ndb_mgm_reply* reply);
|
||||||
|
|
||||||
|
int ndb_mgm_set_int64_parameter(NdbMgmHandle handle,
|
||||||
|
int node,
|
||||||
|
int param,
|
||||||
|
unsigned long long value,
|
||||||
|
struct ndb_mgm_reply* reply);
|
||||||
|
|
||||||
|
int ndb_mgm_set_string_parameter(NdbMgmHandle handle,
|
||||||
|
int node,
|
||||||
|
int param,
|
||||||
|
const char * value,
|
||||||
|
struct ndb_mgm_reply* reply);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -32,9 +32,8 @@ public:
|
|||||||
class ConstIterator {
|
class ConstIterator {
|
||||||
friend class ConfigValuesFactory;
|
friend class ConfigValuesFactory;
|
||||||
const ConfigValues & m_cfg;
|
const ConfigValues & m_cfg;
|
||||||
protected:
|
|
||||||
Uint32 m_currentSection;
|
|
||||||
public:
|
public:
|
||||||
|
Uint32 m_currentSection;
|
||||||
ConstIterator(const ConfigValues&c) : m_cfg(c) { m_currentSection = 0;}
|
ConstIterator(const ConfigValues&c) : m_cfg(c) { m_currentSection = 0;}
|
||||||
|
|
||||||
bool openSection(Uint32 key, Uint32 no);
|
bool openSection(Uint32 key, Uint32 no);
|
||||||
@@ -57,6 +56,9 @@ public:
|
|||||||
ConfigValues & m_cfg;
|
ConfigValues & m_cfg;
|
||||||
public:
|
public:
|
||||||
Iterator(ConfigValues&c) : ConstIterator(c), m_cfg(c) {}
|
Iterator(ConfigValues&c) : ConstIterator(c), m_cfg(c) {}
|
||||||
|
Iterator(ConfigValues&c, const ConstIterator& i):ConstIterator(c),m_cfg(c){
|
||||||
|
m_currentSection = i.m_currentSection;
|
||||||
|
}
|
||||||
|
|
||||||
bool set(Uint32 key, Uint32 value);
|
bool set(Uint32 key, Uint32 value);
|
||||||
bool set(Uint32 key, Uint64 value);
|
bool set(Uint32 key, Uint64 value);
|
||||||
|
@@ -283,6 +283,7 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
|
|||||||
while((name = iter.next()) != NULL) {
|
while((name = iter.next()) != NULL) {
|
||||||
PropertiesType t;
|
PropertiesType t;
|
||||||
Uint32 val_i;
|
Uint32 val_i;
|
||||||
|
Uint64 val_64;
|
||||||
BaseString val_s;
|
BaseString val_s;
|
||||||
|
|
||||||
cmd_args->getTypeOf(name, &t);
|
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);
|
cmd_args->get(name, &val_i);
|
||||||
out.println("%s: %d", name, val_i);
|
out.println("%s: %d", name, val_i);
|
||||||
break;
|
break;
|
||||||
|
case PropertiesType_Uint64:
|
||||||
|
cmd_args->get(name, &val_64);
|
||||||
|
out.println("%s: %Ld", name, val_64);
|
||||||
|
break;
|
||||||
case PropertiesType_char:
|
case PropertiesType_char:
|
||||||
cmd_args->get(name, val_s);
|
cmd_args->get(name, val_s);
|
||||||
out.println("%s: %s", name, val_s.c_str());
|
out.println("%s: %s", name, val_s.c_str());
|
||||||
break;
|
break;
|
||||||
default:
|
case PropertiesType_Properties:
|
||||||
/* Ignore */
|
/* Ignore */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1591,3 +1596,132 @@ ndb_mgm_rep_command(NdbMgmHandle handle, unsigned int request,
|
|||||||
delete reply;
|
delete reply;
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
@@ -2777,3 +2777,104 @@ MgmtSrvr::Allocated_resources::reserve_node(NodeId id)
|
|||||||
m_mgmsrv.m_reserved_nodes.set(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;
|
||||||
|
}
|
||||||
|
@@ -517,6 +517,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
int getPort() const;
|
int getPort() const;
|
||||||
|
|
||||||
|
int setDbParameter(int node, int parameter, const char * value, BaseString&);
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
private:
|
private:
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
@@ -225,6 +225,16 @@ ParserRow<MgmApiSession> commands[] = {
|
|||||||
MGM_ARG("parameter", String, Mandatory, "Parameter"),
|
MGM_ARG("parameter", String, Mandatory, "Parameter"),
|
||||||
MGM_ARG("value", String, Mandatory, "Value"),
|
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()
|
MGM_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1248,5 +1258,24 @@ MgmStatService::stopSessions(){
|
|||||||
NDB_CLOSE_SOCKET(m_sockets[i]);
|
NDB_CLOSE_SOCKET(m_sockets[i]);
|
||||||
m_sockets.erase(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("");
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,8 @@ public:
|
|||||||
void configUnlock(Parser_t::Context &ctx, const class Properties &args);
|
void configUnlock(Parser_t::Context &ctx, const class Properties &args);
|
||||||
void configChange(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);
|
void repCommand(Parser_t::Context &ctx, const class Properties &args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user