DatabaseCampaign: abstract campain for interaction with MySQL Database

The DatabaseCampaign interacts with the MySQL tables that are created
by the import-trace and prune-trace tools. It does offer all
unfinished experiment pilots from the database to the
fail-clients. Those clients send back a (by the experiment) defined
protobuf message as a result. The custom protobuf message does have to
need the form:

   import "DatabaseCampaignMessage.proto";

   message ExperimentMsg {
       required DatabaseCampaignMessage fsppilot = 1;

       repeated group Result = 2 {
          // custom fields
          required int32 bitoffset = 1;
          optional int32 result = 2;
       }
   }

The DatabaseCampaignMessage is the pilot identifier from the
database. For each of the repeated result entries a row in a table is
allocated. The structure of this table is constructed (by protobuf
reflection) from the description of the message. Each field in the
Result group becomes a column in the result table. For the given
example it would be:

    CREATE TABLE result_ExperimentMessage(
           pilot_id INT,
           bitoffset INT NOT NULL,
           result INT,
           PRIMARY_KEY(pilot_id)
    )

Change-Id: I28fb5488e739d4098b823b42426c5760331027f8
This commit is contained in:
Christian Dietrich
2013-03-25 16:04:05 +01:00
parent 59e5fd3169
commit f18cddc63c
25 changed files with 1161 additions and 119 deletions

View File

@ -17,12 +17,12 @@ using std::cerr;
using std::endl;
using std::cout;
Logger log("import-trace", true);
static Logger LOG("import-trace", true);
ProtoIStream openProtoStream(std::string input_file) {
std::ifstream *gz_test_ptr = new std::ifstream(input_file.c_str()), &gz_test = *gz_test_ptr;
if (!gz_test) {
log << "couldn't open " << input_file << endl;
LOG << "couldn't open " << input_file << endl;
exit(-1);
}
unsigned char b1, b2;
@ -31,16 +31,16 @@ ProtoIStream openProtoStream(std::string input_file) {
if (b1 == 0x1f && b2 == 0x8b) {
igzstream *tracef = new igzstream(input_file.c_str());
if (!tracef) {
log << "couldn't open " << input_file << endl;
LOG << "couldn't open " << input_file << endl;
exit(-1);
}
log << "opened file " << input_file << " in GZip mode" << endl;
LOG << "opened file " << input_file << " in GZip mode" << endl;
delete gz_test_ptr;
ProtoIStream ps(tracef);
return ps;
}
log << "opened file " << input_file << " in normal mode" << endl;
LOG << "opened file " << input_file << " in normal mode" << endl;
ProtoIStream ps(gz_test_ptr);
return ps;
}
@ -85,18 +85,18 @@ int main(int argc, char *argv[]) {
if (cmd[IMPORTER].count() > 0) {
std::string imp(cmd[IMPORTER].first()->arg);
if (imp == "BasicImporter") {
log << "Using BasicImporter" << endl;
LOG << "Using BasicImporter" << endl;
importer = new BasicImporter();
} else if (imp == "DCiAOKernelImporter") {
log << "Using DCiAOKernelImporter" << endl;
LOG << "Using DCiAOKernelImporter" << endl;
importer = new DCiAOKernelImporter();
} else {
log << "Unkown import method: " << imp << endl;
LOG << "Unkown import method: " << imp << endl;
exit(-1);
}
} else {
log << "Using BasicImporter" << endl;
LOG << "Using BasicImporter" << endl;
importer = new BasicImporter();
}
@ -133,7 +133,7 @@ int main(int argc, char *argv[]) {
if (!importer->init(variant, benchmark, db)) {
log << "importer->init() failed" << endl;
LOG << "importer->init() failed" << endl;
exit(-1);
}
importer->set_elf_file(elf_file);
@ -143,17 +143,17 @@ int main(int argc, char *argv[]) {
////////////////////////////////////////////////////////////////
if (!importer->create_database()) {
log << "create_database() failed" << endl;
LOG << "create_database() failed" << endl;
exit(-1);
}
if (!importer->clear_database()) {
log << "clear_database() failed" << endl;
LOG << "clear_database() failed" << endl;
exit(-1);
}
if (!importer->copy_to_database(ps)) {
log << "copy_to_database() failed" << endl;
LOG << "copy_to_database() failed" << endl;
exit(-1);
}
}