2755 Magnus Svensson 2008-09-12 [merge]
Merge
2754 Magnus Svensson 2008-09-12 [merge]
Merge
modified:
storage/ndb/include/kernel/signaldata/CopyGCIReq.hpp
storage/ndb/include/ndb_version.h.in
storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
=== modified file 'storage/ndb/src/mgmapi/Makefile.am'
--- a/storage/ndb/src/mgmapi/Makefile.am 2007-04-13 09:33:08 +0000
+++ b/storage/ndb/src/mgmapi/Makefile.am 2008-09-12 09:09:01 +0000
@@ -27,8 +27,6 @@ DEFS_LOC = -DNDB_MGMAPI -DMYSQLCLUSTERDI
include $(top_srcdir)/storage/ndb/config/common.mk.am
include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-#ndbtest_PROGRAMS = ndb_test_mgmapi
-
# Don't update the files from bitkeeper
%::SCCS/s.%
=== modified file 'storage/ndb/src/mgmapi/mgmapi.cpp'
--- a/storage/ndb/src/mgmapi/mgmapi.cpp 2008-08-21 22:18:36 +0000
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp 2008-09-12 09:09:01 +0000
@@ -332,12 +332,26 @@ ndb_mgm_get_latest_error_msg(const NdbMg
return "Error"; // Unknown Error message
}
+
/*
- * Call an operation, and return the reply
+ ndb_mgm_call
+
+ Send command, command arguments and any command bulk data to
+ ndb_mgmd.
+ Read and return result
+
+ @param The mgmapi handle
+ @param List describing the expected reply
+ @param Name of the command to call
+ @param Arguments for the command
+ @param Any bulk data to send after the command
+
*/
static const Properties *
-ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
- const char *cmd, const Properties *cmd_args)
+ndb_mgm_call(NdbMgmHandle handle,
+ const ParserRow<ParserDummy> *command_reply,
+ const char *cmd, const Properties *cmd_args,
+ const char* cmd_bulk= NULL)
{
DBUG_ENTER("ndb_mgm_call");
DBUG_PRINT("enter",("handle->socket: %d, cmd: %s",
@@ -394,6 +408,9 @@ ndb_mgm_call(NdbMgmHandle handle, const
}
out.println("");
+ if (cmd_bulk)
+ out.println("%s", cmd_bulk);
+
DBUG_CHECK_TIMEDOUT_RET(handle, in, out, NULL);
Parser_t::Context ctx;
@@ -2935,4 +2952,52 @@ err:
DBUG_RETURN(retval);
}
+
+extern "C"
+int
+ndb_mgm_set_configuration(NdbMgmHandle h, ndb_mgm_configuration *c)
+{
+ const ConfigValues * cfg = (ConfigValues*)c;
+
+ UtilBuffer buf;
+ if (!cfg->pack(buf))
+ {
+ SET_ERROR(h, NDB_MGM_OUT_OF_MEMORY, "Packing config");
+ return -1;
+ }
+
+ BaseString encoded;
+ encoded.assfmt("%*s", base64_needed_encoded_length(buf.length()), "Z");
+ (void) base64_encode(buf.get_data(), buf.length(), (char*)encoded.c_str());
+
+ Properties args;
+ args.put("Content-Length", strlen(encoded.c_str()));
+ args.put("Content-Type", "ndbconfig/octet-stream");
+ args.put("Content-Transfer-Encoding", "base64");
+
+ const ParserRow<ParserDummy> set_config_reply[]= {
+ MGM_CMD("set config reply", NULL, ""),
+ MGM_ARG("result", String, Mandatory, "Result"),
+ MGM_END()
+ };
+
+ const Properties *reply;
+ reply= ndb_mgm_call(h, set_config_reply, "set config", &args,
+ encoded.c_str());
+ CHECK_REPLY(h, reply, -1);
+
+ BaseString result;
+ reply->get("result",result);
+
+ delete reply;
+
+ if(strcmp(result.c_str(), "Ok") != 0) {
+ fprintf(h->errstream, "ERROR Message: %s\n", result.c_str());
+ return -1;
+ }
+
+ return 0;
+}
+
+
template class Vector<const ParserRow<ParserDummy>*>;
=== modified file 'storage/ndb/src/mgmapi/mgmapi_internal.h'
--- a/storage/ndb/src/mgmapi/mgmapi_internal.h 2007-03-22 11:33:56 +0000
+++ b/storage/ndb/src/mgmapi/mgmapi_internal.h 2008-09-12 09:09:01 +0000
@@ -70,6 +70,16 @@ extern "C" {
int ndb_mgm_disconnect_quiet(NdbMgmHandle handle);
+ /**
+ * Set configuration
+ *
+ * @param handle NDB management handle.
+ * @param config The new configuration to set
+ */
+ int ndb_mgm_set_configuration(NdbMgmHandle handle,
+ struct ndb_mgm_configuration* config);
+
+
#ifdef __cplusplus
}
#endif
=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2008-09-02 14:37:17 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2008-09-12 08:45:12 +0000
@@ -441,13 +441,11 @@ MgmtSrvr::start_mgm_service()
type != NODE_TYPE_MGM){
g_eventLogger->error("Node %d is not defined as management server",
_ownNodeId);
- return 0;
DBUG_RETURN(false);
}
if(iter.get(CFG_MGM_PORT, &m_port) != 0){
g_eventLogger->error("PortNumber not defined for node %d", _ownNodeId);
- return 0;
DBUG_RETURN(false);
}
}
=== modified file 'storage/ndb/src/mgmsrv/Services.cpp'
--- a/storage/ndb/src/mgmsrv/Services.cpp 2008-08-05 12:40:25 +0000
+++ b/storage/ndb/src/mgmsrv/Services.cpp 2008-09-12 10:52:01 +0000
@@ -275,6 +275,11 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("get session", &MgmApiSession::getSession, ""),
MGM_ARG("id", Int, Mandatory, "SessionID"),
+ MGM_CMD("set config", &MgmApiSession::setConfig, ""),
+ MGM_ARG("Content-Length", Int, Mandatory, "Length of config"),
+ MGM_ARG("Content-Type", String, Mandatory, "Type of config"),
+ MGM_ARG("Content-Transfer-Encoding", String, Mandatory, "encoding"),
+
MGM_END()
};
@@ -1879,5 +1884,74 @@ MgmApiSession::getSession(Parser_t::Cont
m_output->println("");
}
+
+void MgmApiSession::setConfig(Parser_t::Context &ctx, Properties const &args)
+{
+ BaseString result("Ok");
+ Uint32 len64 = 0;
+
+ {
+ const char* buf;
+ args.get("Content-Type", &buf);
+ if(strcmp(buf, "ndbconfig/octet-stream")) {
+ result.assfmt("Unhandled content type '%s'", buf);
+ goto done;
+ }
+
+ args.get("Content-Transfer-Encoding", &buf);
+ if(strcmp(buf, "base64")) {
+ result.assfmt("Unhandled content encoding '%s'", buf);
+ goto done;
+ }
+ }
+
+ args.get("Content-Length", &len64);
+ if(len64 ==0 || len64 > (1024*1024)) {
+ result.assfmt("Illegal config length size %d", len64);
+ goto done;
+ }
+ len64 += 1; // Trailing \n
+
+ {
+ char* buf64 = new char[len64];
+ int r = 0;
+ size_t start = 0;
+ do {
+ if((r= read_socket(m_socket,30000,
+ &buf64[start],
+ len64-start)) < 1)
+ {
+ delete buf64;
+ result.assfmt("read_socket failed, errno: %d", errno);
+ goto done;
+ }
+ start += r;
+ } while(start < len64);
+
+ char* decoded = new char[base64_needed_decoded_length((size_t)len64 - 1)];
+ int decoded_len= base64_decode(buf64, len64-1, decoded, NULL);
+ delete buf64;
+
+ ConfigValuesFactory cvf;
+ if(!cvf.unpack(decoded, decoded_len))
+ {
+ delete decoded;
+ result.assfmt("Failed to unpack config");
+ goto done;
+ }
+ delete decoded;
+
+ //m_mgmsrv.setConfig(new Config(cvf.getConfigValues()));
+
+ }
+
+done:
+
+ m_output->println("set config reply");
+ m_output->println("result: %s", result.c_str());
+ m_output->println("");
+}
+
+
template class MutexVector<int>;
template class Vector<ParserRow<MgmApiSession> const*>;
=== modified file 'storage/ndb/src/mgmsrv/Services.hpp'
--- a/storage/ndb/src/mgmsrv/Services.hpp 2008-07-29 13:38:18 +0000
+++ b/storage/ndb/src/mgmsrv/Services.hpp 2008-09-12 10:52:01 +0000
@@ -60,6 +60,7 @@ public:
void runSession();
void getConfig(Parser_t::Context &ctx, const class Properties &args);
+ void setConfig(Parser_t::Context &ctx, const class Properties &args);
void get_nodeid(Parser_t::Context &ctx, const class Properties &args);
void getVersion(Parser_t::Context &ctx, const class Properties &args);
=== modified file 'storage/ndb/test/include/NDBT_Test.hpp'
--- a/storage/ndb/test/include/NDBT_Test.hpp 2008-08-04 13:40:17 +0000
+++ b/storage/ndb/test/include/NDBT_Test.hpp 2008-09-11 11:42:10 +0000
@@ -206,7 +206,7 @@ public:
virtual void print() = 0;
virtual void printHTML() = 0;
- const char* getName(){return name;};
+ const char* getName() const { return _name.c_str(); };
virtual bool tableExists(NdbDictionary::Table* aTable) = 0;
virtual bool isVerify(const NdbDictionary::Table* aTable) = 0;
@@ -239,8 +239,6 @@ protected:
BaseString _name;
BaseString _comment;
- const char* name;
- const char* comment;
NDBT_TestSuite* suite;
Properties props;
NdbTimer timer;
=== modified file 'storage/ndb/test/include/NdbMgmd.hpp'
--- a/storage/ndb/test/include/NdbMgmd.hpp 2008-07-22 13:25:43 +0000
+++ b/storage/ndb/test/include/NdbMgmd.hpp 2008-09-12 09:09:01 +0000
@@ -18,12 +18,28 @@
#include <BaseString.hpp>
+#include <mgmapi.h>
+#include <mgmapi_debug.h>
class NdbMgmd {
BaseString m_connect_str;
+ NdbMgmHandle m_handle;
+
+ void error(const char* msg)
+ {
+ ndbout_c("NdbMgmd:%s", msg);
+
+ if (m_handle){
+ ndbout_c(" error: %d, line: %d, desc: %s",
+ ndb_mgm_get_latest_error(m_handle),
+ ndb_mgm_get_latest_error_line(m_handle),
+ ndb_mgm_get_latest_error_desc(m_handle));
+ }
+ }
public:
NdbMgmd() :
- m_connect_str(getenv("NDB_CONNECTSTRING"))
+ m_connect_str(getenv("NDB_CONNECTSTRING")),
+ m_handle(NULL)
{
if (!m_connect_str.length()){
fprintf(stderr, "Could not init NdbConnectString");
@@ -31,9 +47,39 @@ public:
}
}
+ ~NdbMgmd()
+ {
+ if (m_handle)
+ ndb_mgm_destroy_handle(&m_handle);
+ }
+
+ NdbMgmHandle handle(void) const {
+ return m_handle;
+ }
+
const char* getConnectString() const {
return m_connect_str.c_str();
}
+
+ bool connect(void) {
+ m_handle= ndb_mgm_create_handle();
+ if (!m_handle){
+ error("connect: ndb_mgm_create_handle failed");
+ return false;
+ }
+
+ if (ndb_mgm_set_connectstring(m_handle, getConnectString()) != 0){
+ error("connect: ndb_mgm_set_connectstring failed");
+ return false;
+ }
+
+ if (ndb_mgm_connect(m_handle,0,0,0) != 0){
+ error("connect: ndb_mgm_connect failed");
+ return false;
+ }
+ return true;
+ }
+
};
#endif
=== modified file 'storage/ndb/test/ndbapi/Makefile.am'
--- a/storage/ndb/test/ndbapi/Makefile.am 2008-07-01 15:01:50 +0000
+++ b/storage/ndb/test/ndbapi/Makefile.am 2008-09-12 09:09:01 +0000
@@ -87,6 +87,7 @@ testDict_SOURCES = testDict.cpp
testIndex_SOURCES = testIndex.cpp
testLimits_SOURCES = testLimits.cpp
testMgm_SOURCES = testMgm.cpp
+testMgm_CXXFLAGS = -I$(top_srcdir)/storage/ndb/src/mgmapi
testSingleUserMode_SOURCES = testSingleUserMode.cpp
testNdbApi_SOURCES = testNdbApi.cpp
testNodeRestart_SOURCES = testNodeRestart.cpp
@@ -134,11 +135,6 @@ INCLUDES_LOC = -I$(top_srcdir)/storage/n
include $(top_srcdir)/storage/ndb/config/common.mk.am
include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am
-##testDict_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
-##testIndex_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
-##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
-##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
-NdbRepStress_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/include
testBackup_LDADD = $(LDADD) bank/libbank.a
testSRBank_LDADD = bank/libbank.a $(LDADD)
NdbRepStress_LDADD = $(LDADD) $(top_builddir)/libmysql_r/libmysqlclient_r.la
=== modified file 'storage/ndb/test/ndbapi/testMgm.cpp'
--- a/storage/ndb/test/ndbapi/testMgm.cpp 2008-08-04 13:40:17 +0000
+++ b/storage/ndb/test/ndbapi/testMgm.cpp 2008-09-12 09:09:01 +0000
@@ -641,6 +641,55 @@ done:
return result;
}
+
+#include <mgmapi_internal.h>
+
+int runSetConfig(NDBT_Context* ctx, NDBT_Step* step)
+{
+ NdbMgmd mgmd;
+
+ if (!mgmd.connect())
+ return NDBT_FAILED;
+
+ int loops= ctx->getNumLoops();
+ for (int l= 0; l < loops; l++){
+ g_info << l << ": ";
+
+ struct ndb_mgm_configuration* conf=
+ ndb_mgm_get_configuration(mgmd.handle(), 0);
+ if (!conf)
+ return NDBT_FAILED;
+
+ int r= ndb_mgm_set_configuration(mgmd.handle(), conf);
+ free(conf);
+
+ if (r != 0)
+ return NDBT_FAILED;
+ }
+ return NDBT_OK;
+}
+
+
+int runGetConfig(NDBT_Context* ctx, NDBT_Step* step)
+{
+ NdbMgmd mgmd;
+
+ if (!mgmd.connect())
+ return NDBT_FAILED;
+
+ int loops= ctx->getNumLoops();
+ for (int l= 0; l < loops; l++){
+ g_info << l << ": ";
+ struct ndb_mgm_configuration* conf=
+ ndb_mgm_get_configuration(mgmd.handle(), 0);
+ if (!conf)
+ return NDBT_FAILED;
+ free(conf);
+ }
+ return NDBT_OK;
+}
+
+
NDBT_TESTSUITE(testMgm);
DRIVER(DummyDriver); /* turn off use of NdbApi */
TESTCASE("ApiSessionFailure",
@@ -678,6 +727,14 @@ TESTCASE("ApiMgmStructEventTimeout",
INITIALIZER(runTestMgmApiStructEventTimeout);
}
+TESTCASE("SetConfig",
+ "Tests the ndb_mgm_set_configuration function"){
+ INITIALIZER(runSetConfig);
+
+}
+TESTCASE("GetConfig", "Run ndb_mgm_get_configuration in parallel"){
+ STEPS(runGetConfig, 100);
+}
NDBT_TESTSUITE_END(testMgm);
int main(int argc, const char** argv){
=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt 2008-08-26 14:05:01 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt 2008-09-12 08:43:11 +0000
@@ -946,37 +946,9 @@ cmd: DbAsyncGenerator
args: -time 60 -p 1 -proc 25
type: bench
-max-time: 120
+max-time: 300
cmd: testMgm
-args: -n ApiSessionFailure T1
-
-max-time: 15
-cmd: testMgm
-args: -n ApiConnectTimeout T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiTimeoutBasic T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiSessionFailure T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiGetStatusTimeout T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiGetConfigTimeout T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiMgmEventTimeout T1
-
-max-time: 120
-cmd: testMgm
-args: -n ApiMgmStructEventTimeout T1
+args:
max-time: 5000
cmd: testNodeRestart
=== modified file 'storage/ndb/test/src/NDBT_Test.cpp'
--- a/storage/ndb/test/src/NDBT_Test.cpp 2008-08-04 19:02:08 +0000
+++ b/storage/ndb/test/src/NDBT_Test.cpp 2008-09-11 11:42:10 +0000
@@ -373,14 +373,10 @@ NDBT_Finalizer::NDBT_Finalizer(NDBT_Test
NDBT_TestCase::NDBT_TestCase(NDBT_TestSuite* psuite,
const char* pname,
const char* pcomment) :
- name(strdup(pname)) ,
- comment(strdup(pcomment)),
+ _name(pname) ,
+ _comment(pcomment),
suite(psuite)
{
- _name.assign(pname);
- _comment.assign(pcomment);
- name= _name.c_str();
- comment= _comment.c_str();
assert(suite != NULL);
m_all_tables = false;
@@ -610,7 +606,7 @@ void NDBT_TestCaseImpl1::reportStepResul
int NDBT_TestCase::execute(NDBT_Context* ctx){
int res;
- ndbout << "- " << name << " started [" << ctx->suite->getDate()
+ ndbout << "- " << _name << " started [" << ctx->suite->getDate()
<< "]" << endl;
ctx->setCase(this);
@@ -662,11 +658,11 @@ int NDBT_TestCase::execute(NDBT_Context*
runFinal(ctx);
if (res == NDBT_OK) {
- ndbout << "- " << name << " PASSED [" << ctx->suite->getDate() << "]"
+ ndbout << "- " << _name << " PASSED [" << ctx->suite->getDate() << "]"
<< endl;
}
else {
- ndbout << "- " << name << " FAILED [" << ctx->suite->getDate() << "]"
+ ndbout << "- " << _name << " FAILED [" << ctx->suite->getDate() << "]"
<< endl;
}
return res;
@@ -749,7 +745,7 @@ void NDBT_TestCaseImpl1::saveTestResult(
void NDBT_TestCaseImpl1::printTestResult(){
char buf[255];
- ndbout << name<<endl;
+ ndbout << _name<<endl;
for (unsigned i = 0; i < testResults.size(); i++){
NDBT_TestCaseResult* tcr = testResults[i];
@@ -762,8 +758,9 @@ void NDBT_TestCaseImpl1::printTestResult
res = "FAILED TO CREATE TABLE";
else if (tcr->getResult() == FAILED_TO_DISCOVER)
res = "FAILED TO DISCOVER TABLE";
- BaseString::snprintf(buf, 255," %-10s %-5s %-20s", tcr->getName(), res, tcr->getTimeStr());
- ndbout << buf<<endl;
+ BaseString::snprintf(buf, 255," %-10s %-5s %-20s",
+ tcr->getName(), res, tcr->getTimeStr());
+ ndbout << buf<<endl;
}
}
@@ -1480,13 +1477,13 @@ const char* NDBT_TestSuite::getDate(){
void NDBT_TestCaseImpl1::printHTML(){
ndbout << "<tr><td> </td>" << endl;
- ndbout << "<td name=tc>" << endl << name << "</td><td width=70%>"
- << comment << "</td></tr>" << endl;
+ ndbout << "<td name=tc>" << endl << _name << "</td><td width=70%>"
+ << _comment << "</td></tr>" << endl;
}
void NDBT_TestCaseImpl1::print(){
- ndbout << "Test case: " << name << endl;
- ndbout << "Description: "<< comment << endl;
+ ndbout << "Test case: " << _name << endl;
+ ndbout << "Description: "<< _comment << endl;
ndbout << "Parameters: " << endl;
| Thread |
|---|
| • bzr push into mysql-5.1 branch (msvensson:2754 to 2755) | Magnus Svensson | 12 Sep |