2
Copyright (C) 2003-2007 MySQL AB
3
All rights reserved. Use is subject to license terms.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
#include <ndb_global.h>
25
#include <HugoTransactions.hpp>
29
int main(int argc, const char** argv){
33
const char* _tabname = NULL;
36
const char* db = "TEST_DB";
38
struct getargs args[] = {
39
{ "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" },
40
{ "database", 'd', arg_string, &db, "Database", "" },
41
{ "usage", '?', arg_flag, &_help, "Print help", "" }
43
int num_args = sizeof(args) / sizeof(args[0]);
47
"This program will load one table in Ndb with calculated data \n"\
48
"until the database is full. \n";
50
if(getarg(args, num_args, argc, argv, &optind) ||
51
argv[optind] == NULL || _help) {
52
arg_printusage(args, num_args, argv[0], desc);
53
return NDBT_ProgramExit(NDBT_WRONGARGS);
55
_tabname = argv[optind];
58
Ndb_cluster_connection con;
59
if(con.connect(12, 5, 1) != 0)
61
return NDBT_ProgramExit(NDBT_FAILED);
65
if(MyNdb.init() != 0){
66
ERR(MyNdb.getNdbError());
67
return NDBT_ProgramExit(NDBT_FAILED);
70
// Connect to Ndb and wait for it to become ready
71
while(MyNdb.waitUntilReady() != 0)
72
ndbout << "Waiting for ndb to become ready..." << endl;
74
// Check if table exists in db
75
const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
77
ndbout << " Table " << _tabname << " does not exist!" << endl;
78
return NDBT_ProgramExit(NDBT_WRONGARGS);
81
HugoTransactions hugoTrans(*pTab);
82
if (hugoTrans.fillTable(&MyNdb,
84
return NDBT_ProgramExit(NDBT_FAILED);
87
return NDBT_ProgramExit(NDBT_OK);