本文整理汇总了C++中Ndb_cluster_connection类的典型用法代码示例。如果您正苦于以下问题:C++ Ndb_cluster_connection类的具体用法?C++ Ndb_cluster_connection怎么用?C++ Ndb_cluster_connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ndb_cluster_connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char** argv){
ndb_init();
int _help = 0;
char * _database = "BANK";
struct getargs args[] = {
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "database", 'd', arg_string, &_database, "Database name", ""}
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"This program will make GL records in the bank\n";
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Bank bank(con,_database);
if (bank.performMakeGLs() != 0)
return NDBT_ProgramExit(NDBT_FAILED);
return NDBT_ProgramExit(NDBT_OK);
}
示例2: main
int main(int argc, const char** argv){
ndb_init();
int _parallelism = 240;
const char* _tabname = NULL;
const char* _indexname = NULL;
int _help = 0;
struct getargs args[] = {
{ "parallelism", 's', arg_integer, &_parallelism, "parallelism", "parallelism" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"tabname indexname\n"\
"This program will verify the index [indexname] and compare it to data\n"
"in table [tablename]\n";
if(getarg(args, num_args, argc, argv, &optind) ||
argv[optind] == NULL || argv[optind+1] == NULL || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
_tabname = argv[optind];
_indexname = argv[optind+1];
// Connect to Ndb
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Connect to Ndb and wait for it to become ready
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
// Check if table exists in db
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
if(pTab == NULL){
ndbout << " Table " << _tabname << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
int rows = 0;
UtilTransactions utilTrans(*pTab);
if (utilTrans.verifyIndex(&MyNdb,
_indexname,
_parallelism) != 0){
return NDBT_ProgramExit(NDBT_FAILED);
}
return NDBT_ProgramExit(NDBT_OK);
}
示例3: desc_datafile
int desc_datafile(Ndb_cluster_connection &con, Ndb *myndb, char* name)
{
unsigned id;
NdbDictionary::Dictionary *dict= myndb->getDictionary();
assert(dict);
Ndb_cluster_connection_node_iter iter;
con.init_get_next_node(iter);
while ((id= con.get_next_node(iter)))
{
NdbDictionary::Datafile df= dict->getDatafile(id, name);
NdbError err= dict->getNdbError();
if ((int) err.classification != (int) ndberror_cl_none)
return 0;
ndbout << "Type: Datafile" << endl;
ndbout << "Name: " << name << endl;
ndbout << "Node: " << id << endl;
ndbout << "Path: " << df.getPath() << endl;
ndbout << "Size: " << df.getSize() << endl;
ndbout << "Free: " << df.getFree() << endl;
ndbout << "Tablespace: " << df.getTablespace() << endl;
/** We probably don't need to display this ever...
ndbout << "Number: " << uf.getFileNo() << endl;
*/
ndbout << endl;
}
return 1;
}
示例4: runSetup
int runSetup(NDBT_Context* ctx, NDBT_Step* step, int waitGroupSize){
int records = ctx->getNumRecords();
int batchSize = ctx->getProperty("BatchSize", 1);
int transactions = (records / 100) + 1;
int operations = (records / transactions) + 1;
Ndb* pNdb = GETNDB(step);
HugoAsynchTransactions hugoTrans(*ctx->getTab());
if (hugoTrans.loadTableAsynch(pNdb, records, batchSize,
transactions, operations) != 0){
return NDBT_FAILED;
}
Ndb_cluster_connection* conn = &pNdb->get_ndb_cluster_connection();
/* The first call to create_multi_ndb_wait_group() should succeed ... */
global_poll_group = conn->create_ndb_wait_group(waitGroupSize);
if(global_poll_group == 0) {
return NDBT_FAILED;
}
/* and subsequent calls should fail */
if(conn->create_ndb_wait_group(waitGroupSize) != 0) {
return NDBT_FAILED;
}
return NDBT_OK;
}
示例5: main
int main(int argc, const char** argv){
ndb_init();
int _records = 0;
const char* _tabname = NULL;
int _help = 0;
int _batch = 512;
const char* db = "TEST_DB";
struct getargs args[] = {
{ "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" },
{ "database", 'd', arg_string, &db, "Database", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"tabname\n"\
"This program will load one table in Ndb with calculated data \n"\
"until the database is full. \n";
if(getarg(args, num_args, argc, argv, &optind) ||
argv[optind] == NULL || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
_tabname = argv[optind];
// Connect to Ndb
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, db);
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Connect to Ndb and wait for it to become ready
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
// Check if table exists in db
const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
if(pTab == NULL){
ndbout << " Table " << _tabname << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
HugoTransactions hugoTrans(*pTab);
if (hugoTrans.fillTable(&MyNdb,
_batch) != 0){
return NDBT_ProgramExit(NDBT_FAILED);
}
return NDBT_ProgramExit(NDBT_OK);
}
示例6: main
int main(int argc, const char** argv){
ndb_init();
int _help = 0;
int _wait = 30;
char * _database="BANK";
struct getargs args[] = {
{ "wait", 'w', arg_integer, &_wait, "Max time to wait between days", "secs" },
{ "database", 'd', arg_string, &_database, "Database name", ""},
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"This program will increase time in the bank\n";
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Bank bank(con,_database);
if (bank.performIncreaseTime(_wait) != 0)
return NDBT_ProgramExit(NDBT_FAILED);
return NDBT_ProgramExit(NDBT_OK);
}
示例7: Ndb_cluster_connection_new_wrapper
/* Ndb_cluster_connection(const char * connectstring = 0);
*/
Handle<Value> Ndb_cluster_connection_new_wrapper(const Arguments &args) {
DEBUG_MARKER(UDEB_DETAIL);
HandleScope scope;
REQUIRE_CONSTRUCTOR_CALL();
REQUIRE_ARGS_LENGTH(1);
JsValueConverter<const char *> arg0(args[0]);
Ndb_cluster_connection * c = new Ndb_cluster_connection(arg0.toC());
/* We do not expose set_max_adaptive_send_time() to JavaScript nor even
consider using the default value of 10 ms.
*/
c->set_max_adaptive_send_time(1);
wrapPointerInObject(c, NdbccEnvelope, args.This());
freeFromGC(c, args.This());
return args.This();
}
示例8: main
int main(int argc, const char** argv){
ndb_init();
int _temp = false;
int _help = 0;
struct getargs args[] = {
{ "temp", 't', arg_flag, &_temp, "Temporary table", "temp" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"This program will create all standard tables in Ndb.\n"\
"The tables is selected from a fixed list of tables\n"\
"defined in NDBT_Tables class\n";
if(getarg(args, num_args, argc, argv, &optind) || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
// Connect to Ndb
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
return NDBT_Tables::createAllTables(&MyNdb, _temp);
}
示例9: exit
Ndb_cluster_connection* JniNdbEventStreamingImp::connect_to_cluster(const char *connection_string) {
Ndb_cluster_connection* c;
if (ndb_init())
exit(EXIT_FAILURE);
c = new Ndb_cluster_connection(connection_string);
if (c->connect(RETRIES, DELAY_BETWEEN_RETRIES, VERBOSE)) {
fprintf(stderr, "Unable to connect to cluster.\n\n");
exit(EXIT_FAILURE);
}
if (c->wait_until_ready(WAIT_UNTIL_READY, WAIT_UNTIL_READY) < 0) {
fprintf(stderr, "Cluster was not ready.\n\n");
exit(EXIT_FAILURE);
}
return c;
}
示例10: Ndb_cluster_connection_new_wrapper
/* Ndb_cluster_connection(const char * connectstring = 0);
*/
void Ndb_cluster_connection_new_wrapper(const Arguments &args) {
DEBUG_MARKER(UDEB_DETAIL);
EscapableHandleScope scope(args.GetIsolate());
REQUIRE_CONSTRUCTOR_CALL();
REQUIRE_ARGS_LENGTH(1);
JsValueConverter<const char *> arg0(args[0]);
Ndb_cluster_connection * c = new Ndb_cluster_connection(arg0.toC());
/* We do not expose set_max_adaptive_send_time() to JavaScript nor even
consider using the default value of 10 ms.
*/
c->set_max_adaptive_send_time(1);
Local<Value> wrapper = NdbccEnvelope.wrap(c);
NdbccEnvelope.freeFromGC(c, wrapper);
args.GetReturnValue().Set(wrapper);
}
示例11: connect_to_cluster
// Init the connection to an NDB cluster.
Ndb_cluster_connection* connect_to_cluster(char* conn_string)
{
Ndb_cluster_connection* c;
if(ndb_init())
exit(EXIT_FAILURE);
c= new Ndb_cluster_connection(conn_string);
if(c->connect(4, 5, 1))
{
fprintf(stderr, "Unable to connect to cluster within 30 seconds.\n\n");
exit(EXIT_FAILURE);
}
if(c->wait_until_ready(30, 0) < 0)
{
fprintf(stderr, "Cluster was not ready within 30 seconds.\n\n");
exit(EXIT_FAILURE);
}
return c;
}
示例12: desc_undofile
int desc_undofile(Ndb_cluster_connection &con, Ndb *myndb, char* name)
{
unsigned id;
NdbDictionary::Dictionary *dict= myndb->getDictionary();
Ndb_cluster_connection_node_iter iter;
assert(dict);
con.init_get_next_node(iter);
while ((id= con.get_next_node(iter)))
{
NdbDictionary::Undofile uf= dict->getUndofile(0, name);
NdbError err= dict->getNdbError();
if ((int) err.classification != (int) ndberror_cl_none)
return 0;
ndbout << "Type: Undofile" << endl;
ndbout << "Name: " << name << endl;
ndbout << "Node: " << id << endl;
ndbout << "Path: " << uf.getPath() << endl;
ndbout << "Size: " << uf.getSize() << endl;
ndbout << "Logfile Group: " << uf.getLogfileGroup() << endl;
/** FIXME: are these needed, the functions aren't there
but the prototypes are...
ndbout << "Number: " << uf.getFileNo() << endl;
*/
ndbout << endl;
}
return 1;
}
示例13: main
int main(int argc, const char** argv){
ndb_init();
int _records = 0;
int _loops = 1;
int _parallelism = 1;
int _ver2 = 0;
const char* _tabname = NULL, *db = 0;
int _help = 0;
struct getargs args[] = {
{ "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
{ "parallelism", 'p', arg_integer, &_parallelism, "parallelism(1-240)", "para" },
{ "records", 'r', arg_integer, &_records, "Number of records", "recs" },
{ "ver2", '2', arg_flag, &_ver2, "Use version 2 of scanUpdateRecords", "" },
{ "ver2", '1', arg_negative_flag, &_ver2, "Use version 1 of scanUpdateRecords (default)", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "database", 'd', arg_string, &db, "Database", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"tabname\n"\
"This program will scan update all records in one table in Ndb\n";
if(getarg(args, num_args, argc, argv, &optind) ||
argv[optind] == NULL || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
_tabname = argv[optind];
// Connect to Ndb
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb( &con, db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
// Check if table exists in db
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
if(pTab == NULL){
ndbout << " Table " << _tabname << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
HugoTransactions hugoTrans(*pTab);
int i = 0;
int res = NDBT_FAILED;
while (i<_loops || _loops==0) {
ndbout << i << ": ";
if (_ver2 == 0){
res = hugoTrans.scanUpdateRecords(&MyNdb,
_records,
0,
_parallelism);
} else{
res = hugoTrans.scanUpdateRecords2(&MyNdb,
_records,
0,
_parallelism);
}
if (res != NDBT_OK ){
return NDBT_ProgramExit(NDBT_FAILED);
}
i++;
//NdbSleep_MilliSleep(300);
}
return NDBT_ProgramExit(NDBT_OK);
}
示例14: main
int main(int argc, const char** argv){
ndb_init();
int _records = 0;
int _loops = 1;
int _threads = 1;
int _stats = 0;
int _abort = 0;
int _batch = 1;
const char* _tabname = NULL, *db = 0;
int _help = 0;
struct getargs args[] = {
{ "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" },
{ "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
{ "threads", 't', arg_integer, &_threads, "number of threads (default 1)", "threads" },
{ "stats", 's', arg_flag, &_stats, "report latency per batch", "stats" },
// { "batch", 'b', arg_integer, &_batch, "batch value", "batch" },
{ "records", 'r', arg_integer, &_records, "Number of records", "records" },
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "database", 'd', arg_string, &db, "Database", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
char desc[] =
"tabname\n"\
"This program will update all records in a table using PK\n";
if(getarg(args, num_args, argc, argv, &optind) ||
argv[optind] == NULL || _records == 0 || _help) {
arg_printusage(args, num_args, argv[0], desc);
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
_tabname = argv[optind];
// Connect to Ndb
Ndb_cluster_connection con;
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb( &con, db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Check if table exists in db
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
if(pTab == NULL){
ndbout << " Table " << _tabname << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
// threads
NDBT_ThreadSet ths(_threads);
// create Ndb object for each thread
if (ths.connect(&con, db ? db : "TEST_DB") == -1) {
ndbout << "connect failed: err=" << ths.get_err() << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
// input is options
ThrInput input;
ths.set_input(&input);
input.pTab = pTab;
input.records = _records;
input.batch = _batch;
input.stats = _stats;
// output is stats
ThrOutput output;
ths.set_output<ThrOutput>();
int i = 0;
while (i < _loops || _loops == 0) {
ndbout << i << ": ";
ths.set_func(hugoPkUpdate);
ths.start();
ths.stop();
if (ths.get_err())
NDBT_ProgramExit(NDBT_FAILED);
if (_stats) {
NDBT_Stats latency;
// add stats from each thread
int n;
for (n = 0; n < ths.get_count(); n++) {
//.........这里部分代码省略.........
示例15: main
int
main(int argc, const char** argv) {
ndb_init();
int verbose = 1;
int optind = 0;
struct getargs args[1+P_MAX] = {
{ "verbose", 'v', arg_flag, &verbose, "Print verbose status", "verbose" }
};
const int num_args = 1 + P_MAX;
int i;
for(i = 0; i<P_MAX; i++) {
args[i+1].long_name = g_paramters[i].name;
args[i+1].short_name = * g_paramters[i].name;
args[i+1].type = arg_integer;
args[i+1].value = &g_paramters[i].value;
BaseString tmp;
tmp.assfmt("min: %d max: %d", g_paramters[i].min, g_paramters[i].max);
args[i+1].help = strdup(tmp.c_str());
args[i+1].arg_help = 0;
}
if(getarg(args, num_args, argc, argv, &optind)) {
arg_printusage(args, num_args, argv[0], "tabname1 tabname2 ...");
return NDBT_WRONGARGS;
}
myRandom48Init(NdbTick_CurrentMillisecond());
memset(g_times, 0, sizeof(g_times));
Ndb_cluster_connection con;
if(con.connect(12, 5, 1))
{
return NDBT_ProgramExit(NDBT_FAILED);
}
g_ndb = new Ndb(&con, "TEST_DB");
if(g_ndb->init() != 0) {
g_err << "init() failed" << endl;
goto error;
}
if(g_ndb->waitUntilReady() != 0) {
g_err << "Wait until ready failed" << endl;
goto error;
}
for(i = optind; i<argc; i++) {
const char * T = argv[i];
g_info << "Testing " << T << endl;
BaseString::snprintf(g_table, sizeof(g_table), T);
BaseString::snprintf(g_ordered, sizeof(g_ordered), "IDX_O_%s", T);
BaseString::snprintf(g_unique, sizeof(g_unique), "IDX_U_%s", T);
if(create_table())
goto error;
if(load_table())
goto error;
for(int l = 0; l<g_paramters[P_LOOPS].value; l++) {
for(int j = 0; j<P_OP_TYPES; j++) {
g_paramters[P_OPER].value = j;
if(run_read())
goto error;
}
}
print_result();
}
if(g_ndb) delete g_ndb;
return NDBT_OK;
error:
if(g_ndb) delete g_ndb;
return NDBT_FAILED;
}