本文整理汇总了C++中NdbRestarter::getMasterNodeId方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbRestarter::getMasterNodeId方法的具体用法?C++ NdbRestarter::getMasterNodeId怎么用?C++ NdbRestarter::getMasterNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbRestarter
的用法示例。
在下文中一共展示了NdbRestarter::getMasterNodeId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runBug25554
int runBug25554(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter restarter;
if (restarter.getNumDbNodes() < 4)
return NDBT_OK;
for (int i = 0; i<loops; i++)
{
int master = restarter.getMasterNodeId();
int node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());
restarter.restartOneDbNode(node1, false, true, true);
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
if (restarter.dumpStateOneNode(master, val2, 2))
return NDBT_FAILED;
if (restarter.insertErrorInNode(master, 7141))
return NDBT_FAILED;
if (restarter.waitNodesNoStart(&node1, 1))
return NDBT_FAILED;
if (restarter.dumpStateOneNode(node1, val2, 2))
return NDBT_FAILED;
if (restarter.insertErrorInNode(node1, 932))
return NDBT_FAILED;
if (restarter.startNodes(&node1, 1))
return NDBT_FAILED;
int nodes[] = { master, node1 };
if (restarter.waitNodesNoStart(nodes, 2))
return NDBT_FAILED;
if (restarter.startNodes(nodes, 2))
return NDBT_FAILED;
if (restarter.waitClusterStarted())
return NDBT_FAILED;
}
return NDBT_OK;
}
示例2: GETNDB
int
runBug32160(NDBT_Context* ctx, NDBT_Step* step)
{
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
Ndb* pNdb = GETNDB(step);
NdbRestarter res;
if (res.getNumDbNodes() < 2)
{
return NDBT_OK;
}
int master = res.getMasterNodeId();
int next = res.getNextMasterNodeId(master);
if (res.insertErrorInNode(next, 7194))
{
return NDBT_FAILED;
}
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
if (res.dumpStateOneNode(master, val2, 2))
return NDBT_FAILED;
if (res.insertErrorInNode(master, 7193))
return NDBT_FAILED;
int val3[] = { 7099 };
if (res.dumpStateOneNode(master, val3, 1))
return NDBT_FAILED;
if (res.waitNodesNoStart(&master, 1))
return NDBT_FAILED;
if (res.startNodes(&master, 1))
return NDBT_FAILED;
if (res.waitClusterStarted())
return NDBT_FAILED;
return NDBT_OK;
}
示例3: while
int
runBug27283(NDBT_Context* ctx, NDBT_Step* step)
{
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
NdbRestarter res;
if (res.getNumDbNodes() < 2)
{
return NDBT_OK;
}
static const int errnos[] = { 7181, 7182, 0 };
Uint32 pos = 0;
for (Uint32 i = 0; i<loops; i++)
{
while (errnos[pos] != 0)
{
int master = res.getMasterNodeId();
int next = res.getNextMasterNodeId(master);
int next2 = res.getNextMasterNodeId(next);
int node = (i & 1) ? next : next2;
ndbout_c("Tesing err: %d", errnos[pos]);
if (res.insertErrorInNode(next, errnos[pos]))
return NDBT_FAILED;
NdbSleep_SecSleep(3);
if (res.waitClusterStarted())
return NDBT_FAILED;
pos++;
}
pos = 0;
}
return NDBT_OK;
}
示例4: runBug25364
int runBug25364(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
NdbRestarter restarter;
Ndb* pNdb = GETNDB(step);
int loops = ctx->getNumLoops();
if (restarter.getNumDbNodes() < 4)
return NDBT_OK;
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
for (; loops; loops --)
{
int master = restarter.getMasterNodeId();
int victim = restarter.getRandomNodeOtherNodeGroup(master, rand());
int second = restarter.getRandomNodeSameNodeGroup(victim, rand());
int dump[] = { 935, victim } ;
if (restarter.dumpStateOneNode(master, dump, 2))
return NDBT_FAILED;
if (restarter.dumpStateOneNode(master, val2, 2))
return NDBT_FAILED;
if (restarter.restartOneDbNode(second, false, true, true))
return NDBT_FAILED;
int nodes[2] = { master, second };
if (restarter.waitNodesNoStart(nodes, 2))
return NDBT_FAILED;
restarter.startNodes(nodes, 2);
if (restarter.waitNodesStarted(nodes, 2))
return NDBT_FAILED;
}
return NDBT_OK;
}
示例5: hugoTrans
int
runTestSingleUserMode(NDBT_Context* ctx, NDBT_Step* step)
{
int result = NDBT_OK;
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
Ndb* pNdb = GETNDB(step);
NdbRestarter restarter;
char tabName[255];
strncpy(tabName, ctx->getTab()->getName(), 255);
ndbout << "tabName="<<tabName<<endl;
int i = 0;
int count;
HugoTransactions hugoTrans(*ctx->getTab());
UtilTransactions utilTrans(*ctx->getTab());
while (i<loops && result == NDBT_OK) {
g_info << i << ": ";
int timeout = 120;
int nodeId = restarter.getMasterNodeId();
// Test that it's not possible to restart one node in single user mode
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
CHECK(restarter.restartOneDbNode(nodeId) != 0)
CHECK(restarter.exitSingleUserMode() == 0);
CHECK(restarter.waitClusterStarted(timeout) == 0);
// Test that the single user mode api can do everything
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(count == records);
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(count == (records/2));
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
CHECK(restarter.exitSingleUserMode() == 0);
CHECK(restarter.waitClusterStarted(timeout) == 0);
// Test create index in single user mode
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
CHECK(create_index_on_pk(pNdb, tabName) == 0);
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(count == records);
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
CHECK(restarter.exitSingleUserMode() == 0);
CHECK(restarter.waitClusterStarted(timeout) == 0);
// Test recreate index in single user mode
CHECK(create_index_on_pk(pNdb, tabName) == 0);
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(create_index_on_pk(pNdb, tabName) == 0);
CHECK(restarter.exitSingleUserMode() == 0);
CHECK(restarter.waitClusterStarted(timeout) == 0);
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
CHECK(utilTrans.clearTable(GETNDB(step), records) == 0);
ndbout << "Restarting cluster" << endl;
CHECK(restarter.restartAll() == 0);
CHECK(restarter.waitClusterStarted(timeout) == 0);
CHECK(pNdb->waitUntilReady(timeout) == 0);
i++;
}
return result;
}
示例6: bzero
int
runBug18612(NDBT_Context* ctx, NDBT_Step* step){
// Assume two replicas
NdbRestarter restarter;
if (restarter.getNumDbNodes() < 2)
{
ctx->stopTest();
return NDBT_OK;
}
Uint32 cnt = restarter.getNumDbNodes();
for(int loop = 0; loop < ctx->getNumLoops(); loop++)
{
int partition0[256];
int partition1[256];
bzero(partition0, sizeof(partition0));
bzero(partition1, sizeof(partition1));
Bitmask<4> nodesmask;
Uint32 node1 = restarter.getDbNodeId(rand()%cnt);
for (Uint32 i = 0; i<cnt/2; i++)
{
do {
int tmp = restarter.getRandomNodeOtherNodeGroup(node1, rand());
if (tmp == -1)
break;
node1 = tmp;
} while(nodesmask.get(node1));
partition0[i] = node1;
partition1[i] = restarter.getRandomNodeSameNodeGroup(node1, rand());
ndbout_c("nodes %d %d", node1, partition1[i]);
assert(!nodesmask.get(node1));
assert(!nodesmask.get(partition1[i]));
nodesmask.set(node1);
nodesmask.set(partition1[i]);
}
ndbout_c("done");
int dump[255];
dump[0] = DumpStateOrd::NdbcntrStopNodes;
memcpy(dump + 1, partition0, sizeof(int)*cnt/2);
Uint32 master = restarter.getMasterNodeId();
if (restarter.dumpStateOneNode(master, dump, 1+cnt/2))
return NDBT_FAILED;
if (restarter.waitNodesNoStart(partition0, cnt/2))
return NDBT_FAILED;
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
if (restarter.dumpStateAllNodes(val2, 2))
return NDBT_FAILED;
if (restarter.insertErrorInAllNodes(932))
return NDBT_FAILED;
dump[0] = 9000;
memcpy(dump + 1, partition0, sizeof(int)*cnt/2);
for (Uint32 i = 0; i<cnt/2; i++)
if (restarter.dumpStateOneNode(partition1[i], dump, 1+cnt/2))
return NDBT_FAILED;
dump[0] = 9000;
memcpy(dump + 1, partition1, sizeof(int)*cnt/2);
for (Uint32 i = 0; i<cnt/2; i++)
if (restarter.dumpStateOneNode(partition0[i], dump, 1+cnt/2))
return NDBT_FAILED;
if (restarter.startNodes(partition0, cnt/2))
return NDBT_FAILED;
if (restarter.waitNodesStartPhase(partition0, cnt/2, 2))
return NDBT_FAILED;
dump[0] = 9001;
for (Uint32 i = 0; i<cnt/2; i++)
if (restarter.dumpStateAllNodes(dump, 2))
return NDBT_FAILED;
if (restarter.waitNodesNoStart(partition0, cnt/2))
return NDBT_FAILED;
for (Uint32 i = 0; i<cnt/2; i++)
if (restarter.restartOneDbNode(partition0[i], true, true, true))
return NDBT_FAILED;
if (restarter.waitNodesNoStart(partition0, cnt/2))
return NDBT_FAILED;
if (restarter.startAll())
return NDBT_FAILED;
//.........这里部分代码省略.........
示例7: 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;
}
示例8: CHECK
int
NdbBackup::Fail(NdbRestarter& _restarter, int *Fail_codes, const int sz, bool onMaster){
CHECK(_restarter.waitClusterStarted() == 0,
"waitClusterStarted failed");
int nNodes = _restarter.getNumDbNodes();
myRandom48Init(NdbTick_CurrentMillisecond());
for(int i = 0; i<sz; i++){
int error = Fail_codes[i];
unsigned int backupId;
const int masterNodeId = _restarter.getMasterNodeId();
CHECK(masterNodeId > 0, "getMasterNodeId failed");
int nodeId;
nodeId = masterNodeId;
if (!onMaster) {
int randomId;
while (nodeId == masterNodeId) {
randomId = myRandom48(nNodes);
nodeId = _restarter.getDbNodeId(randomId);
}
}
g_err << "NdbBackup::Fail node = " << nodeId
<< " error code = " << error << " masterNodeId = "
<< masterNodeId << endl;
CHECK(_restarter.insertErrorInNode(nodeId, error) == 0,
"failed to set error insert");
g_info << "error inserted" << endl;
g_info << "waiting some before starting backup" << endl;
g_info << "starting backup" << endl;
int r = start(backupId);
g_info << "r = " << r
<< " (which should fail) started with id = " << backupId << endl;
if (r == 0) {
g_err << "Backup should have failed on error_insertion " << error << endl
<< "Master = " << masterNodeId << "Node = " << nodeId << endl;
return NDBT_FAILED;
}
CHECK(_restarter.waitClusterStarted() == 0,
"waitClusterStarted failed");
CHECK(_restarter.insertErrorInNode(nodeId, 10099) == 0,
"failed to set error insert");
NdbSleep_SecSleep(5);
int val2[] = { 24, 2424 };
CHECK(_restarter.dumpStateAllNodes(val2, 2) == 0,
"failed to check backup resources RestartOnErrorInsert");
}
return NDBT_OK;
}