summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ndb/include/mgmapi/mgmapi_debug.h25
-rw-r--r--ndb/include/util/ConfigValues.hpp6
-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
-rw-r--r--ndb/src/ndbapi/NdbConnection.cpp21
8 files changed, 319 insertions, 3 deletions
diff --git a/ndb/include/mgmapi/mgmapi_debug.h b/ndb/include/mgmapi/mgmapi_debug.h
index 2723263e7a7..1c562cd164f 100644
--- a/ndb/include/mgmapi/mgmapi_debug.h
+++ b/ndb/include/mgmapi/mgmapi_debug.h
@@ -106,6 +106,31 @@ extern "C" {
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
}
#endif
diff --git a/ndb/include/util/ConfigValues.hpp b/ndb/include/util/ConfigValues.hpp
index 3fbeedb25a0..457488e3c42 100644
--- a/ndb/include/util/ConfigValues.hpp
+++ b/ndb/include/util/ConfigValues.hpp
@@ -32,9 +32,8 @@ public:
class ConstIterator {
friend class ConfigValuesFactory;
const ConfigValues & m_cfg;
- protected:
- Uint32 m_currentSection;
public:
+ Uint32 m_currentSection;
ConstIterator(const ConfigValues&c) : m_cfg(c) { m_currentSection = 0;}
bool openSection(Uint32 key, Uint32 no);
@@ -57,6 +56,9 @@ public:
ConfigValues & m_cfg;
public:
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, Uint64 value);
diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp
index 963e159424a..1085c747c16 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;
}
@@ -1593,4 +1598,133 @@ ndb_mgm_rep_command(NdbMgmHandle handle, unsigned int request,
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;
+}
+
template class Vector<const ParserRow<ParserDummy>*>;
diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp
index ccc63cc7e70..523883f7832 100644
--- a/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -2779,3 +2779,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 4a1b5d71898..99913face05 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()
};
@@ -1249,5 +1259,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);
};
diff --git a/ndb/src/ndbapi/NdbConnection.cpp b/ndb/src/ndbapi/NdbConnection.cpp
index db6201ee9bb..cd051bb4609 100644
--- a/ndb/src/ndbapi/NdbConnection.cpp
+++ b/ndb/src/ndbapi/NdbConnection.cpp
@@ -1477,6 +1477,17 @@ from other transactions.
theGlobalCheckpointId = tGCI;
} else if ((tNoComp >= tNoSent) &&
(theLastExecOpInList->theCommitIndicator == 1)){
+
+
+ if (m_abortOption == IgnoreError && theError.code != 0){
+ /**
+ * There's always a TCKEYCONF when using IgnoreError
+ */
+#ifdef VM_TRACE
+ ndbout_c("Not completing transaction 2");
+#endif
+ return -1;
+ }
/**********************************************************************/
// We sent the transaction with Commit flag set and received a CONF with
// no Commit flag set. This is clearly an anomaly.
@@ -1720,6 +1731,16 @@ NdbConnection::OpCompleteFailure()
if (theSimpleState == 1) {
theCommitStatus = NdbConnection::Aborted;
}//if
+ if (m_abortOption == IgnoreError){
+ /**
+ * There's always a TCKEYCONF when using IgnoreError
+ */
+#ifdef VM_TRACE
+ ndbout_c("Not completing transaction");
+#endif
+ return -1;
+ }
+
return 0; // Last operation received
} else if (tNoComp > tNoSent) {
setOperationErrorCodeAbort(4113); // Too many operations,