Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-11 16:48:37+02:00, tomas@stripped +1 -0
extent listen_event to do:
- look at the events
- optionally reconnect after cluster failure
- optionally connect _directly_ after first node connected
storage/ndb/test/tools/listen.cpp@stripped, 2007-05-11 16:48:35+02:00, tomas@stripped +78 -16
extent listen_event to do:
- look at the events
- optionally reconnect after cluster failure
- optionally connect _directly_ after first node connected
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: tomas
# Host: whalegate.ndb.mysql.com
# Root: /home/tomas/mysql-5.1-wl2325-5.0
--- 1.1/storage/ndb/test/tools/listen.cpp 2005-09-15 12:53:53 +02:00
+++ 1.2/storage/ndb/test/tools/listen.cpp 2007-05-11 16:48:35 +02:00
@@ -29,10 +29,14 @@
int _help = 0;
- const char* db = 0;
+ int do_reconnect = 0;
+ int wait_only_first_node = 0;
+ const char* db = "TEST_DB";
struct getargs args[] = {
{ "database", 'd', arg_string, &db, "Database", "" },
+ { "do-reconnect", 'r', arg_flag, &do_reconnect, "If cluster goes away try to reconnect", "" },
+ { "wait-only-first-node", 'w', arg_flag, &wait_only_first_node, "", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
@@ -60,13 +64,21 @@
}
// Connect to Ndb and wait for it to become ready
- while(MyNdb.waitUntilReady() != 0)
+ int result;
+ Uint64 last_gci;
+ Uint32 cnt, cnt_i, cnt_u, cnt_d;
+ Uint64 failed_ops;
+ while((result= con.wait_until_ready(1, wait_only_first_node ? 0 : 1)) != 0)
+ {
+ if (wait_only_first_node && result > 0)
+ break; // we have connected, but not to all
ndbout << "Waiting for ndb to become ready..." << endl;
+ }
- int result = 0;
- Uint64 last_gci= 0, cnt= 0;
+ result = 0;
NdbDictionary::Dictionary *myDict = MyNdb.getDictionary();
+ Vector<const NdbDictionary::Table*> tables;
Vector<NdbDictionary::Event*> events;
Vector<NdbEventOperation*> event_ops;
for(i= optind; i<argc; i++)
@@ -114,9 +126,21 @@
}
}
+ tables.push_back(table);
events.push_back(myEvent);
+ }
- NdbEventOperation* pOp = MyNdb.createEventOperation(name.c_str());
+reconnect:
+ while((result= con.wait_until_ready(1, wait_only_first_node ? 0 : 1)) != 0)
+ {
+ if (wait_only_first_node && result > 0)
+ break; // we have connected, but not to all
+ ndbout << "Waiting for ndb to become ready after reconnect..." << endl;
+ }
+ for(i= 0; i < (int)events.size(); i++)
+ {
+ NdbEventOperation* pOp = MyNdb.createEventOperation(events[i]->getName());
+ const NdbDictionary::Table* table= tables[i];
if ( pOp == NULL ) {
g_err << "Event operation creation failed" << endl;
result = 1;
@@ -128,9 +152,12 @@
pOp->getValue(table->getColumn(a)->getName());
pOp->getPreValue(table->getColumn(a)->getName());
}
+
+ pOp->setCustomData((void *)i);
event_ops.push_back(pOp);
}
+ failed_ops= 0;
for(i= 0; i<(int)event_ops.size(); i++)
{
if (event_ops[i]->execute())
@@ -140,30 +167,65 @@
result = 1;
goto end;
}
+ failed_ops|= 1LLU << i;
}
- while(true)
+ while(failed_ops)
{
while(MyNdb.pollEvents(100) == 0);
- NdbEventOperation* pOp;
- while((pOp= MyNdb.nextEvent()) != 0)
+ NdbEventOperation* pOp= MyNdb.nextEvent();
+ if (!pOp)
+ abort();
+ while (pOp)
{
- if(pOp->getGCI() != last_gci)
- {
- if(cnt) ndbout_c("GCI: %lld events: %lld", last_gci, cnt);
- cnt= 1;
- last_gci= pOp->getGCI();
- }
- else
+ last_gci= pOp->getGCI();
+ cnt= cnt_i= cnt_u= cnt_d= 0;
+ while (pOp && last_gci == pOp->getGCI())
{
- cnt++;
+ switch(pOp->getEventType())
+ {
+ case NdbDictionary::Event::TE_INSERT:
+ cnt_i++;
+ break;
+ case NdbDictionary::Event::TE_DELETE:
+ cnt_d++;
+ case NdbDictionary::Event::TE_UPDATE:
+ cnt_u++;
+ break;
+ case NdbDictionary::Event::TE_CLUSTER_FAILURE:
+ failed_ops&= ~(1LLU << (Uint64)pOp->getCustomData());
+ break;
+ case NdbDictionary::Event::TE_ALTER:
+ case NdbDictionary::Event::TE_DROP:
+ cnt++;
+ break;
+ default:
+ /* We should REALLY never get here. */
+ ndbout_c("Error: unknown event type: %u",
+ (Uint32)pOp->getEventType());
+ abort();
+ }
+ pOp= MyNdb.nextEvent();
}
+ ndbout_c("GCI: %lld events: %u(e) %u(i) %u(u) %u(d)",
+ last_gci, cnt, cnt_i, cnt_u, cnt_d);
}
}
end:
+ for(i= 0; i<(int)event_ops.size(); i++)
+ {
+ MyNdb.dropEventOperation(event_ops[i]);
+ }
+ if (do_reconnect)
+ {
+ event_ops.clear();
+ goto reconnect;
+ }
+
return NDBT_ProgramExit(NDBT_OK);
}
+template class Vector<const NdbDictionary::Table*>;
template class Vector<NdbDictionary::Event*>;
template class Vector<NdbEventOperation*>;
| Thread |
|---|
| • bk commit into 5.1 tree (tomas:1.2145) | tomas | 11 May |