本文整理汇总了C++中NdbTransaction::executeAsynchPrepare方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbTransaction::executeAsynchPrepare方法的具体用法?C++ NdbTransaction::executeAsynchPrepare怎么用?C++ NdbTransaction::executeAsynchPrepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbTransaction
的用法示例。
在下文中一共展示了NdbTransaction::executeAsynchPrepare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runV2MultiWait_Producer
/* Producer thread */
int runV2MultiWait_Producer(NDBT_Context* ctx, NDBT_Step* step,
int thd_id, int nthreads)
{
int records = ctx->getNumRecords();
HugoOperations hugoOps(*ctx->getTab());
/* For three threads (2 producers + 1 consumer) we loop 0-7.
producer 0 is slow if (loop & 1)
producer 1 is slow if (loop & 2)
consumer is slow if (loop & 4)
*/
for (int loop = 0; loop < V2_NLOOPS; loop++)
{
ctx->getPropertyWait("LOOP", loop+1);
bool slow = loop & (thd_id+1);
for (int j=0; j < records; j++)
{
if(j % nthreads == thd_id)
{
Ndb* ndb = global_ndb_pool->getNdb();
NdbTransaction* trans = ndb->startTransaction();
check(trans != NULL, (*ndb));
ndb->setCustomData(trans);
NdbOperation* readOp = trans->getNdbOperation(ctx->getTab());
check(readOp != NULL, (*trans));
check(readOp->readTuple() == 0, (*readOp));
check(hugoOps.equalForRow(readOp, j) == 0, hugoOps);
/* Read all other cols */
for (int k=0; k < ctx->getTab()->getNoOfColumns(); k++)
{
check(readOp->getValue(ctx->getTab()->getColumn(k)) != NULL,
(*readOp));
}
trans->executeAsynchPrepare(NdbTransaction::Commit,
NULL,
NULL,
NdbOperation::AbortOnError);
ndb->sendPreparedTransactions();
global_poll_group->push(ndb);
if(slow)
{
int tm = myRandom48(3) * myRandom48(3);
if(tm) NdbSleep_MilliSleep(tm);
}
}
}
}
return NDBT_OK;
}
示例2: runPkReadMultiBasic
int runPkReadMultiBasic(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
const int MAX_NDBS = 200;
Ndb* pNdb = GETNDB(step);
Ndb_cluster_connection* conn = &pNdb->get_ndb_cluster_connection();
int i = 0;
HugoOperations hugoOps(*ctx->getTab());
Ndb* ndbObjs[ MAX_NDBS ];
NdbTransaction* transArray[ MAX_NDBS ];
Ndb ** ready_ndbs;
for (int j=0; j < MAX_NDBS; j++)
{
Ndb* ndb = new Ndb(conn);
check(ndb->init() == 0, (*ndb));
ndbObjs[ j ] = ndb;
}
while (i<loops) {
ndbout << "Loop : " << i << ": ";
int recordsLeft = records;
do
{
/* Define and execute Pk read requests on
* different Ndb objects
*/
int ndbcnt = 0;
int pollcnt = 0;
int lumpsize = 1 + myRandom48(MIN(recordsLeft, MAX_NDBS));
while(lumpsize &&
recordsLeft &&
ndbcnt < MAX_NDBS)
{
Ndb* ndb = ndbObjs[ ndbcnt ];
NdbTransaction* trans = ndb->startTransaction();
check(trans != NULL, (*ndb));
NdbOperation* readOp = trans->getNdbOperation(ctx->getTab());
check(readOp != NULL, (*trans));
check(readOp->readTuple() == 0, (*readOp));
check(hugoOps.equalForRow(readOp, recordsLeft) == 0, hugoOps);
/* Read all other cols */
for (int k=0; k < ctx->getTab()->getNoOfColumns(); k++)
{
check(readOp->getValue(ctx->getTab()->getColumn(k)) != NULL,
(*readOp));
}
/* Now send em off */
trans->executeAsynchPrepare(NdbTransaction::Commit,
NULL,
NULL,
NdbOperation::AbortOnError);
ndb->sendPreparedTransactions();
transArray[ndbcnt] = trans;
global_poll_group->addNdb(ndb);
ndbcnt++;
pollcnt++;
recordsLeft--;
lumpsize--;
};
/* Ok, now wait for the Ndbs to complete */
while (pollcnt)
{
/* Occasionally check with no timeout */
Uint32 timeout_millis = myRandom48(2)?10000:0;
int count = global_poll_group->wait(ready_ndbs, timeout_millis);
if (count > 0)
{
for (int y=0; y < count; y++)
{
Ndb *ndb = ready_ndbs[y];
check(ndb->pollNdb(0, 1) != 0, (*ndb));
}
pollcnt -= count;
}
}
/* Ok, now close the transactions */
for (int t=0; t < ndbcnt; t++)
{
transArray[t]->close();
}
} while (recordsLeft);
i++;
}
for (int j=0; j < MAX_NDBS; j++)
{
delete ndbObjs[ j ];
}
//.........这里部分代码省略.........