19 #include <ndb_global.h>
29 #include <HugoTransactions.hpp>
31 int main(
int argc,
const char** argv){
38 const char* _tabname = NULL;
42 {
"loops",
'l', arg_integer, &_loops,
"number of times to run this program(0=infinite loop)",
"loops" },
43 {
"records",
'r', arg_integer, &_records,
"Number of records",
"recs" },
44 {
"locktime",
't', arg_integer, &_lockTime,
"Time in ms to hold lock(default=1000)",
"ms" },
45 {
"percent",
'p', arg_integer, &_percentVal,
"Percent of records to lock(default=1%)",
"%" },
46 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
48 int num_args =
sizeof(args) /
sizeof(args[0]);
52 "This program will lock p% of the records in the table for x milliseconds\n"\
53 "then it will lock the next 1% and continue to do so until it has locked \n"\
54 "all records in the table\n";
56 if(getarg(args, num_args, argc, argv, &optind) ||
57 argv[optind] == NULL || _records == 0 || _help) {
58 arg_printusage(args, num_args, argv[0], desc);
59 return NDBT_ProgramExit(NDBT_WRONGARGS);
61 _tabname = argv[optind];
67 return NDBT_ProgramExit(NDBT_FAILED);
69 Ndb MyNdb(&con,
"TEST_DB" );
71 if(MyNdb.init() != 0){
72 ERR(MyNdb.getNdbError());
73 return NDBT_ProgramExit(NDBT_FAILED);
76 while(MyNdb.waitUntilReady() != 0)
77 ndbout <<
"Waiting for ndb to become ready..." << endl;
82 ndbout <<
" Table " << _tabname <<
" does not exist!" << endl;
83 return NDBT_ProgramExit(NDBT_WRONGARGS);
88 while (i<_loops || _loops==0) {
90 if (hugoTrans.lockRecords(&MyNdb, _records, _percentVal, _lockTime) != 0){
91 return NDBT_ProgramExit(NDBT_FAILED);
96 return NDBT_ProgramExit(NDBT_OK);