19 #include <ndb_global.h>
26 #include <NDBT_Thread.hpp>
27 #include <NDBT_Stats.hpp>
31 #include <HugoTransactions.hpp>
33 static NDBT_ThreadFunc hugoPkUpdate;
46 static int _refresh = 0;
48 int main(
int argc,
const char** argv){
57 const char* _tabname = NULL, *db = 0;
61 {
"aborts",
'a', arg_integer, &_abort,
"percent of transactions that are aborted",
"abort%" },
62 {
"loops",
'l', arg_integer, &_loops,
"number of times to run this program(0=infinite loop)",
"loops" },
63 {
"threads",
't', arg_integer, &_threads,
"number of threads (default 1)",
"threads" },
64 {
"stats",
's', arg_flag, &_stats,
"report latency per batch",
"stats" },
66 {
"records",
'r', arg_integer, &_records,
"Number of records",
"records" },
67 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" },
68 {
"database",
'd', arg_string, &db,
"Database",
"" },
69 {
"refresh", 0, arg_flag, &_refresh,
"refresh record rather than update them",
"" }
72 int num_args =
sizeof(args) /
sizeof(args[0]);
76 "This program will update all records in a table using PK\n";
78 if(getarg(args, num_args, argc, argv, &optind) ||
79 argv[optind] == NULL || _records == 0 || _help) {
80 arg_printusage(args, num_args, argv[0], desc);
81 return NDBT_ProgramExit(NDBT_WRONGARGS);
83 _tabname = argv[optind];
89 return NDBT_ProgramExit(NDBT_FAILED);
94 ndbout <<
"Cluster nodes not ready in 30 seconds." << endl;
95 return NDBT_ProgramExit(NDBT_FAILED);
98 Ndb MyNdb( &con, db ? db :
"TEST_DB" );
100 if(MyNdb.init() != 0){
101 ERR(MyNdb.getNdbError());
102 return NDBT_ProgramExit(NDBT_FAILED);
108 ndbout <<
" Table " << _tabname <<
" does not exist!" << endl;
109 return NDBT_ProgramExit(NDBT_WRONGARGS);
116 if (ths.connect(&con, db ? db :
"TEST_DB") == -1) {
117 ndbout <<
"connect failed: err=" << ths.get_err() << endl;
118 return NDBT_ProgramExit(NDBT_FAILED);
123 ths.set_input(&input);
125 input.records = _records;
126 input.batch = _batch;
127 input.stats = _stats;
134 while (i < _loops || _loops == 0) {
137 ths.set_func(hugoPkUpdate);
144 NDBT_ProgramExit(NDBT_FAILED);
152 for (n = 0; n < ths.get_count(); n++) {
155 latency += output->latency;
159 <<
"latency per batch (us): "
160 <<
" samples=" << latency.getCount()
161 <<
" min=" << (int)latency.getMin()
162 <<
" max=" << (int)latency.getMax()
163 <<
" mean=" << (int)latency.getMean()
164 <<
" stddev=" << (int)latency.getStddev()
172 return NDBT_ProgramExit(NDBT_OK);
181 output->latency.reset();
183 hugoTrans.setStatsLatency(&output->latency);
186 hugoTrans.setThrInfo(ths.get_count(), thr.get_thread_no());
191 ret = hugoTrans.pkUpdateRecords(thr.get_ndb(),
197 ret = hugoTrans.pkRefreshRecords(thr.get_ndb(),