Commit a142cea8 authored by unknown's avatar unknown

ndb - more removal of old constructor usage in test prgs


ndb/test/ndbapi/flexAsynch.cpp:
  new constructor
ndb/test/ndbapi/flexHammer.cpp:
  new constructor
ndb/test/ndbapi/flexTT.cpp:
  new constructor
ndb/test/ndbapi/slow_select.cpp:
  new constructor
ndb/test/ndbapi/testDeadlock.cpp:
  new constructor
ndb/test/ndbapi/testLcp.cpp:
  new constructor
parent 3fef20e2
...@@ -143,6 +143,8 @@ tellThreads(StartType what) ...@@ -143,6 +143,8 @@ tellThreads(StartType what)
ThreadStart[i] = what; ThreadStart[i] = what;
} }
static Ndb_cluster_connection *g_cluster_connection= 0;
NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535) NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535)
{ {
ndb_init(); ndb_init();
...@@ -200,7 +202,14 @@ NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535) ...@@ -200,7 +202,14 @@ NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535)
setAttrNames(); setAttrNames();
setTableNames(); setTableNames();
Ndb * pNdb = new Ndb("TEST_DB"); Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
g_cluster_connection= &con;
Ndb * pNdb = new Ndb(g_cluster_connection, "TEST_DB");
pNdb->init(); pNdb->init();
tNodeId = pNdb->getNodeId(); tNodeId = pNdb->getNodeId();
...@@ -225,7 +234,7 @@ NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535) ...@@ -225,7 +234,7 @@ NDB_COMMAND(flexAsynch, "flexAsynch", "flexAsynch", "flexAsynch", 65535)
* Create NDB objects. * * Create NDB objects. *
****************************************************************/ ****************************************************************/
resetThreads(); resetThreads();
for (int i = 0; i < tNoOfThreads ; i++) { for (i = 0; i < tNoOfThreads ; i++) {
pThreadData[i].ThreadNo = i pThreadData[i].ThreadNo = i
; ;
threadLife[i] = NdbThread_Create(threadLoop, threadLife[i] = NdbThread_Create(threadLoop,
...@@ -468,7 +477,7 @@ threadLoop(void* ThreadData) ...@@ -468,7 +477,7 @@ threadLoop(void* ThreadData)
StartType tType; StartType tType;
ThreadNdb* tabThread = (ThreadNdb*)ThreadData; ThreadNdb* tabThread = (ThreadNdb*)ThreadData;
int threadNo = tabThread->ThreadNo; int threadNo = tabThread->ThreadNo;
localNdb = new Ndb("TEST_DB"); localNdb = new Ndb(g_cluster_connection, "TEST_DB");
localNdb->init(1024); localNdb->init(1024);
localNdb->waitUntilReady(10000); localNdb->waitUntilReady(10000);
unsigned int threadBase = (threadNo << 16) + tNodeId ; unsigned int threadBase = (threadNo << 16) + tNodeId ;
......
...@@ -175,6 +175,8 @@ tellThreads(ThreadNdb* threadArrayP, const StartType what) ...@@ -175,6 +175,8 @@ tellThreads(ThreadNdb* threadArrayP, const StartType what)
} // for } // for
} // tellThreads } // tellThreads
static Ndb_cluster_connection *g_cluster_connection= 0;
NDB_COMMAND(flexHammer, "flexHammer", "flexHammer", "flexHammer", 65535) NDB_COMMAND(flexHammer, "flexHammer", "flexHammer", "flexHammer", 65535)
//main(int argc, const char** argv) //main(int argc, const char** argv)
{ {
...@@ -213,7 +215,13 @@ NDB_COMMAND(flexHammer, "flexHammer", "flexHammer", "flexHammer", 65535) ...@@ -213,7 +215,13 @@ NDB_COMMAND(flexHammer, "flexHammer", "flexHammer", "flexHammer", 65535)
// NdbThread_SetConcurrencyLevel(tNoOfThreads + 2); // NdbThread_SetConcurrencyLevel(tNoOfThreads + 2);
// Create and init Ndb object // Create and init Ndb object
pMyNdb = new Ndb("TEST_DB"); Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
g_cluster_connection= &con;
pMyNdb = new Ndb(g_cluster_connection, "TEST_DB");
pMyNdb->init(); pMyNdb->init();
// Wait for Ndb to become ready // Wait for Ndb to become ready
...@@ -345,7 +353,7 @@ flexHammerThread(void* pArg) ...@@ -345,7 +353,7 @@ flexHammerThread(void* pArg)
for (i = 0; i < MAXATTRSIZE; i++) for (i = 0; i < MAXATTRSIZE; i++)
attrValue[i] = 0; attrValue[i] = 0;
// Ndb object for each thread // Ndb object for each thread
pMyNdb = new Ndb( "TEST_DB" ); pMyNdb = new Ndb(g_cluster_connection, "TEST_DB" );
pMyNdb->init(); pMyNdb->init();
if (pMyNdb->waitUntilReady(10000) != 0) { if (pMyNdb->waitUntilReady(10000) != 0) {
// Error, NDB is not ready // Error, NDB is not ready
......
...@@ -169,6 +169,8 @@ tellThreads(StartType what) ...@@ -169,6 +169,8 @@ tellThreads(StartType what)
ThreadStart[i] = what; ThreadStart[i] = what;
} }
static Ndb_cluster_connection *g_cluster_connection= 0;
NDB_COMMAND(flexTT, "flexTT", "flexTT", "flexTT", 65535) NDB_COMMAND(flexTT, "flexTT", "flexTT", "flexTT", 65535)
{ {
ndb_init(); ndb_init();
...@@ -226,7 +228,14 @@ NDB_COMMAND(flexTT, "flexTT", "flexTT", "flexTT", 65535) ...@@ -226,7 +228,14 @@ NDB_COMMAND(flexTT, "flexTT", "flexTT", "flexTT", 65535)
setAttrNames(); setAttrNames();
setTableNames(); setTableNames();
Ndb * pNdb = new Ndb("TEST_DB"); Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
g_cluster_connection= &con;
Ndb * pNdb = new Ndb(g_cluster_connection, "TEST_DB");
pNdb->init(); pNdb->init();
tNodeId = pNdb->getNodeId(); tNodeId = pNdb->getNodeId();
...@@ -334,7 +343,7 @@ threadLoop(void* ThreadData) ...@@ -334,7 +343,7 @@ threadLoop(void* ThreadData)
void * mem = malloc(sizeof(TransNdb)*tNoOfParallelTrans); void * mem = malloc(sizeof(TransNdb)*tNoOfParallelTrans);
TransNdb* pTransData = (TransNdb*)mem; TransNdb* pTransData = (TransNdb*)mem;
localNdb = new Ndb("TEST_DB"); localNdb = new Ndb(g_cluster_connection, "TEST_DB");
localNdb->init(1024); localNdb->init(1024);
localNdb->waitUntilReady(); localNdb->waitUntilReady();
......
...@@ -36,7 +36,14 @@ static void lookup(); ...@@ -36,7 +36,14 @@ static void lookup();
int int
main(void){ main(void){
ndb_init(); ndb_init();
Ndb g_ndb("test");
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return 1;
}
Ndb g_ndb(&con, "test");
g_ndb.init(1024); g_ndb.init(1024);
require(g_ndb.waitUntilReady() == 0); require(g_ndb.waitUntilReady() == 0);
......
...@@ -49,7 +49,7 @@ printusage() ...@@ -49,7 +49,7 @@ printusage()
static Opt g_opt; static Opt g_opt;
static NdbMutex *ndbout_mutex= NULL; static NdbMutex *ndbout_mutex= NULL;
static Ndb_cluster_connection *g_cluster_connection= 0;
#define DBG(x) \ #define DBG(x) \
do { \ do { \
if (! g_opt.m_dbg) break; \ if (! g_opt.m_dbg) break; \
...@@ -217,7 +217,7 @@ Thr::exit() ...@@ -217,7 +217,7 @@ Thr::exit()
static int static int
runstep_connect(Thr& thr) runstep_connect(Thr& thr)
{ {
Ndb* ndb = thr.m_ndb = new Ndb("TEST_DB"); Ndb* ndb = thr.m_ndb = new Ndb(g_cluster_connection, "TEST_DB");
CHN(ndb, ndb->init() == 0); CHN(ndb, ndb->init() == 0);
CHN(ndb, ndb->waitUntilReady() == 0); CHN(ndb, ndb->waitUntilReady() == 0);
DBG(thr << " connected"); DBG(thr << " connected");
...@@ -503,6 +503,14 @@ NDB_COMMAND(testOdbcDriver, "testDeadlock", "testDeadlock", "testDeadlock", 6553 ...@@ -503,6 +503,14 @@ NDB_COMMAND(testOdbcDriver, "testDeadlock", "testDeadlock", "testDeadlock", 6553
printusage(); printusage();
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
g_cluster_connection= &con;
if ( if (
strchr(g_opt.m_scan, 't') != 0 && wl1822_main('t') == -1 || strchr(g_opt.m_scan, 't') != 0 && wl1822_main('t') == -1 ||
strchr(g_opt.m_scan, 'x') != 0 && wl1822_main('x') == -1 strchr(g_opt.m_scan, 'x') != 0 && wl1822_main('x') == -1
......
...@@ -30,6 +30,7 @@ static CASE g_ops[] = ...@@ -30,6 +30,7 @@ static CASE g_ops[] =
const size_t OP_COUNT = (sizeof(g_ops)/sizeof(g_ops[0])); const size_t OP_COUNT = (sizeof(g_ops)/sizeof(g_ops[0]));
static Ndb* g_ndb = 0; static Ndb* g_ndb = 0;
static Ndb_cluster_connection *g_cluster_connection= 0;
static CASE* g_cases; static CASE* g_cases;
static HugoOperations* g_hugo_ops; static HugoOperations* g_hugo_ops;
...@@ -133,7 +134,13 @@ static int parse_args(int argc, char** argv) ...@@ -133,7 +134,13 @@ static int parse_args(int argc, char** argv)
static int connect_ndb() static int connect_ndb()
{ {
g_ndb = new Ndb("TEST_DB"); g_cluster_connection = new Ndb_cluster_connection();
if(g_cluster_connection->connect(12, 5, 1) != 0)
{
return 1;
}
g_ndb = new Ndb(g_cluster_connection, "TEST_DB");
g_ndb->init(); g_ndb->init();
if(g_ndb->waitUntilReady(30) == 0){ if(g_ndb->waitUntilReady(30) == 0){
int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP }; int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
...@@ -145,8 +152,10 @@ static int connect_ndb() ...@@ -145,8 +152,10 @@ static int connect_ndb()
static int disconnect_ndb() static int disconnect_ndb()
{ {
delete g_ndb; delete g_ndb;
delete g_cluster_connection;
g_ndb = 0; g_ndb = 0;
g_table = 0; g_table = 0;
g_cluster_connection= 0;
return 0; return 0;
} }
......
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