本文整理汇总了C++中NdbRestarter::getRandomNotMasterNodeId方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbRestarter::getRandomNotMasterNodeId方法的具体用法?C++ NdbRestarter::getRandomNotMasterNodeId怎么用?C++ NdbRestarter::getRandomNotMasterNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbRestarter
的用法示例。
在下文中一共展示了NdbRestarter::getRandomNotMasterNodeId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runBug24717
int runBug24717(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter restarter;
Ndb* pNdb = GETNDB(step);
HugoTransactions hugoTrans(*ctx->getTab());
int dump[] = { 9002, 0 } ;
Uint32 ownNode = refToNode(pNdb->getReference());
dump[1] = ownNode;
for (; loops; loops --)
{
int nodeId = restarter.getRandomNotMasterNodeId(rand());
restarter.restartOneDbNode(nodeId, false, true, true);
restarter.waitNodesNoStart(&nodeId, 1);
if (restarter.dumpStateOneNode(nodeId, dump, 2))
return NDBT_FAILED;
restarter.startNodes(&nodeId, 1);
do {
for (Uint32 i = 0; i < 100; i++)
{
hugoTrans.pkReadRecords(pNdb, 100, 1, NdbOperation::LM_CommittedRead);
}
} while (restarter.waitClusterStarted(5) != 0);
}
return NDBT_OK;
}
示例2: while
int
runBug27003(NDBT_Context* ctx, NDBT_Step* step)
{
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter res;
static const int errnos[] = { 4025, 4026, 4027, 4028, 0 };
int node = res.getRandomNotMasterNodeId(rand());
ndbout_c("node: %d", node);
if (res.restartOneDbNode(node, false, true, true))
return NDBT_FAILED;
Uint32 pos = 0;
for (Uint32 i = 0; i<loops; i++)
{
while (errnos[pos] != 0)
{
ndbout_c("Tesing err: %d", errnos[pos]);
if (res.waitNodesNoStart(&node, 1))
return NDBT_FAILED;
if (res.insertErrorInNode(node, 1000))
return NDBT_FAILED;
if (res.insertErrorInNode(node, errnos[pos]))
return NDBT_FAILED;
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
if (res.dumpStateOneNode(node, val2, 2))
return NDBT_FAILED;
res.startNodes(&node, 1);
NdbSleep_SecSleep(3);
pos++;
}
pos = 0;
}
if (res.waitNodesNoStart(&node, 1))
return NDBT_FAILED;
res.startNodes(&node, 1);
if (res.waitClusterStarted())
return NDBT_FAILED;
return NDBT_OK;
}
示例3:
int
runBug26481(NDBT_Context* ctx, NDBT_Step* step)
{
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter res;
int node = res.getRandomNotMasterNodeId(rand());
ndbout_c("node: %d", node);
if (res.restartOneDbNode(node, true, true, true))
return NDBT_FAILED;
if (res.waitNodesNoStart(&node, 1))
return NDBT_FAILED;
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
if (res.dumpStateOneNode(node, val2, 2))
return NDBT_FAILED;
if (res.insertErrorInNode(node, 7018))
return NDBT_FAILED;
if (res.startNodes(&node, 1))
return NDBT_FAILED;
res.waitNodesStartPhase(&node, 1, 3);
if (res.waitNodesNoStart(&node, 1))
return NDBT_FAILED;
res.startNodes(&node, 1);
if (res.waitClusterStarted())
return NDBT_FAILED;
return NDBT_OK;
}
示例4: testWorker
int testWorker(NDBT_Context* ctx, NDBT_Step* step)
{
/* Run as a 'T1' testcase - do nothing for other tables */
if (strcmp(ctx->getTab()->getName(), "T1") != 0)
return NDBT_OK;
/* Worker step to run in a separate thread for
* blocking activities
* Generally the blocking of the DIH table definition flush
* blocks the completion of the drop table/node restarts,
* so this must be done in a separate thread to avoid
* deadlocks.
*/
while (!ctx->isTestStopped())
{
ndbout_c("Worker : waiting for request...");
ctx->getPropertyWait("DIHWritesRequest", 1);
if (!ctx->isTestStopped())
{
Uint32 req = ctx->getProperty("DIHWritesRequestType", (Uint32)0);
switch ((Tasks) req)
{
case DROP_TABLE_REQ:
{
/* Drop table */
ndbout_c("Worker : dropping table");
if (dropTable(ctx, step, 2) != NDBT_OK)
{
return NDBT_FAILED;
}
ndbout_c("Worker : table dropped.");
break;
}
case MASTER_RESTART_REQ:
{
ndbout_c("Worker : restarting Master");
NdbRestarter restarter;
int master_nodeid = restarter.getMasterNodeId();
ndbout_c("Worker : Restarting Master (%d)...", master_nodeid);
if (restarter.restartOneDbNode2(master_nodeid,
NdbRestarter::NRRF_NOSTART |
NdbRestarter::NRRF_FORCE |
NdbRestarter::NRRF_ABORT) ||
restarter.waitNodesNoStart(&master_nodeid, 1) ||
restarter.startAll())
{
ndbout_c("Worker : Error restarting Master.");
return NDBT_FAILED;
}
ndbout_c("Worker : Waiting for master to recover...");
if (restarter.waitNodesStarted(&master_nodeid, 1))
{
ndbout_c("Worker : Error waiting for Master restart");
return NDBT_FAILED;
}
ndbout_c("Worker : Master recovered.");
break;
}
case SLAVE_RESTART_REQ:
{
NdbRestarter restarter;
int slave_nodeid = restarter.getRandomNotMasterNodeId(rand());
ndbout_c("Worker : Restarting non-master (%d)...", slave_nodeid);
if (restarter.restartOneDbNode2(slave_nodeid,
NdbRestarter::NRRF_NOSTART |
NdbRestarter::NRRF_FORCE |
NdbRestarter::NRRF_ABORT) ||
restarter.waitNodesNoStart(&slave_nodeid, 1) ||
restarter.startAll())
{
ndbout_c("Worker : Error restarting Slave.");
return NDBT_FAILED;
}
ndbout_c("Worker : Waiting for slave to recover...");
if (restarter.waitNodesStarted(&slave_nodeid, 1))
{
ndbout_c("Worker : Error waiting for Slave restart");
return NDBT_FAILED;
}
ndbout_c("Worker : Slave recovered.");
break;
}
default:
{
break;
}
}
}
ctx->setProperty("DIHWritesRequestType", (Uint32) 0);
ctx->setProperty("DIHWritesRequest", (Uint32) 2);
}
ndbout_c("Worker, done.");
return NDBT_OK;
}