Commit 8293b317 authored by unknown's avatar unknown

[PATCH] WL#3704 mgmapi timeouts: Add bool timeout flag to Streams

Index: ndb-work/storage/ndb/include/util/InputStream.hpp
===================================================================


storage/ndb/include/util/InputStream.hpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/include/util/OutputStream.hpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/common/util/InputStream.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/common/util/OutputStream.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/src/mgmsrv/Services.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
storage/ndb/test/ndbapi/testMgm.cpp:
  WL#3704 mgmapi timeouts: Add bool timeout flag to Streams
parent 45f698c5
...@@ -50,10 +50,14 @@ class SocketInputStream : public InputStream { ...@@ -50,10 +50,14 @@ class SocketInputStream : public InputStream {
NDB_SOCKET_TYPE m_socket; NDB_SOCKET_TYPE m_socket;
unsigned m_timeout_ms; unsigned m_timeout_ms;
bool m_startover; bool m_startover;
bool m_timedout;
public: public:
SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 1000); SocketInputStream(NDB_SOCKET_TYPE socket, unsigned read_timeout_ms = 1000);
virtual ~SocketInputStream() {} virtual ~SocketInputStream() {}
char* gets(char * buf, int bufLen); char* gets(char * buf, int bufLen);
bool timedout() { return m_timedout; };
void reset_timeout() { m_timedout= false; };
}; };
#endif #endif
...@@ -45,9 +45,12 @@ public: ...@@ -45,9 +45,12 @@ public:
class SocketOutputStream : public OutputStream { class SocketOutputStream : public OutputStream {
NDB_SOCKET_TYPE m_socket; NDB_SOCKET_TYPE m_socket;
unsigned m_timeout_ms; unsigned m_timeout_ms;
bool m_timedout;
public: public:
SocketOutputStream(NDB_SOCKET_TYPE socket, unsigned write_timeout_ms = 1000); SocketOutputStream(NDB_SOCKET_TYPE socket, unsigned write_timeout_ms = 1000);
virtual ~SocketOutputStream() {} virtual ~SocketOutputStream() {}
bool timedout() { return m_timedout; };
void reset_timeout() { m_timedout= false; };
int print(const char * fmt, ...); int print(const char * fmt, ...);
int println(const char * fmt, ...); int println(const char * fmt, ...);
......
...@@ -38,10 +38,13 @@ SocketInputStream::SocketInputStream(NDB_SOCKET_TYPE socket, ...@@ -38,10 +38,13 @@ SocketInputStream::SocketInputStream(NDB_SOCKET_TYPE socket,
: m_socket(socket) { : m_socket(socket) {
m_startover= true; m_startover= true;
m_timeout_ms = read_timeout_ms; m_timeout_ms = read_timeout_ms;
m_timedout= false;
} }
char* char*
SocketInputStream::gets(char * buf, int bufLen) { SocketInputStream::gets(char * buf, int bufLen) {
if(timedout())
return 0;
assert(bufLen >= 2); assert(bufLen >= 2);
int offset= 0; int offset= 0;
if(m_startover) if(m_startover)
...@@ -63,7 +66,10 @@ SocketInputStream::gets(char * buf, int bufLen) { ...@@ -63,7 +66,10 @@ SocketInputStream::gets(char * buf, int bufLen) {
m_startover= true; m_startover= true;
if(res == -1) if(res == -1)
{
m_timedout= true;
return 0; return 0;
}
return buf; return buf;
} }
...@@ -45,21 +45,38 @@ SocketOutputStream::SocketOutputStream(NDB_SOCKET_TYPE socket, ...@@ -45,21 +45,38 @@ SocketOutputStream::SocketOutputStream(NDB_SOCKET_TYPE socket,
unsigned write_timeout_ms){ unsigned write_timeout_ms){
m_socket = socket; m_socket = socket;
m_timeout_ms = write_timeout_ms; m_timeout_ms = write_timeout_ms;
m_timedout= false;
} }
int int
SocketOutputStream::print(const char * fmt, ...){ SocketOutputStream::print(const char * fmt, ...){
va_list ap; va_list ap;
if(timedout())
return -1;
va_start(ap, fmt); va_start(ap, fmt);
const int ret = vprint_socket(m_socket, m_timeout_ms, fmt, ap); const int ret = vprint_socket(m_socket, m_timeout_ms, fmt, ap);
va_end(ap); va_end(ap);
if (errno==ETIMEDOUT)
m_timedout= true;
return ret; return ret;
} }
int int
SocketOutputStream::println(const char * fmt, ...){ SocketOutputStream::println(const char * fmt, ...){
va_list ap; va_list ap;
if(timedout())
return -1;
va_start(ap, fmt); va_start(ap, fmt);
const int ret = vprintln_socket(m_socket, m_timeout_ms, fmt, ap); const int ret = vprintln_socket(m_socket, m_timeout_ms, fmt, ap);
va_end(ap); va_end(ap);
if (errno==ETIMEDOUT)
m_timedout= true;
return ret; return ret;
} }
...@@ -1641,7 +1641,12 @@ MgmApiSession::get_mgmd_nodeid(Parser_t::Context &ctx, ...@@ -1641,7 +1641,12 @@ MgmApiSession::get_mgmd_nodeid(Parser_t::Context &ctx,
Properties const &args) Properties const &args)
{ {
m_output->println("get mgmd nodeid reply"); m_output->println("get mgmd nodeid reply");
m_output->println("nodeid:%u",m_mgmsrv.getOwnNodeId()); m_output->println("nodeid:%u",m_mgmsrv.getOwnNodeId());
if(ERROR_INSERTED(1))
{
NdbSleep_SecSleep(10);
}
m_output->println(""); m_output->println("");
} }
......
...@@ -218,16 +218,12 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -218,16 +218,12 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
ndb_mgm_set_connectstring(h, mgm); ndb_mgm_set_connectstring(h, mgm);
ndb_mgm_connect(h,0,0,0); ndb_mgm_connect(h,0,0,0);
ndbout << "Connected" << endl;
if(ndb_mgm_check_connection(h) < 0) if(ndb_mgm_check_connection(h) < 0)
{ {
result= NDBT_FAILED; result= NDBT_FAILED;
goto done; goto done;
} }
ndbout << "Checked Connection" << endl;
ndb_mgm_reply reply; ndb_mgm_reply reply;
reply.return_code= 0; reply.return_code= 0;
...@@ -238,9 +234,7 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -238,9 +234,7 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
goto done; goto done;
} }
ndbout << "Inserted session error" << endl; ndb_mgm_set_timeout(h,2500);
ndb_mgm_set_timeout(h,1000,1000);
cc= ndb_mgm_check_connection(h); cc= ndb_mgm_check_connection(h);
if(cc < 0) if(cc < 0)
...@@ -248,7 +242,29 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -248,7 +242,29 @@ int runTestApiTimeout1(NDBT_Context* ctx, NDBT_Step* step)
else else
result= NDBT_FAILED; result= NDBT_FAILED;
ndbout << "Tried check connection with result: " << cc << endl; ndbout << "test 2" << endl;
ndb_mgm_connect(h,0,0,0);
cc= ndb_mgm_get_mgmd_nodeid(h);
if(cc==0)
result= NDBT_OK;
else
result= NDBT_FAILED;
if(ndb_mgm_insert_error(h, 3, 0, &reply)< 0)
{
ndbout << "failed to remove inserted error " << endl;
result= NDBT_FAILED;
goto done;
}
cc= ndb_mgm_get_mgmd_nodeid(h);
ndbout << "got node id: " << cc << endl;
if(cc==0)
result= NDBT_FAILED;
else
result= NDBT_OK;
done: done:
ndb_mgm_disconnect(h); ndb_mgm_disconnect(h);
ndb_mgm_destroy_handle(&h); ndb_mgm_destroy_handle(&h);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment