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

@ -5,7 +5,7 @@
using namespace fail;
extern Logger log;
static Logger LOG("Importer");
bool Importer::init(const std::string &variant, const std::string &benchmark, Database *db) {
this->db = db;
@ -13,7 +13,7 @@ bool Importer::init(const std::string &variant, const std::string &benchmark, Da
if (!m_variant_id) {
return false;
}
log << "Importing to variant " << variant << "/" << benchmark
LOG << "Importing to variant " << variant << "/" << benchmark
<< " (ID: " << m_variant_id << ")" << std::endl;
return true;
}
@ -23,7 +23,7 @@ bool Importer::clear_database() {
ss << "DELETE FROM trace WHERE variant_id = " << m_variant_id;
bool ret = db->query(ss.str().c_str()) == 0 ? false : true;
log << "deleted " << db->affected_rows() << " rows from trace table" << std::endl;
LOG << "deleted " << db->affected_rows() << " rows from trace table" << std::endl;
return ret;
}
@ -69,12 +69,12 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
// we're currently looking at; the EC is defined by
// data_address [instr1, instr2] (instr_absolute)
if (!add_trace_event(instr1, instr2, ev)) {
log << "add_trace_event failed" << std::endl;
LOG << "add_trace_event failed" << std::endl;
return false;
}
row_count ++;
if (row_count % 1000 == 0) {
log << "Imported " << row_count << " traces into the database" << std::endl;
LOG << "Imported " << row_count << " traces into the database" << std::endl;
}
if (ev.accesstype() == ev.READ) {
@ -91,7 +91,7 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
}
}
log << "Inserted " << row_count << " traces into the database" << std::endl;
LOG << "Inserted " << row_count << " traces into the database" << std::endl;
// FIXME
// close all open intervals (right end of the fault-space) with fake trace event