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:
@ -2,7 +2,7 @@
|
||||
#include "util/Logger.hpp"
|
||||
#include "BasicImporter.hpp"
|
||||
|
||||
extern fail::Logger log;
|
||||
static fail::Logger LOG("BasicImporter");
|
||||
|
||||
bool BasicImporter::create_database() {
|
||||
std::string create_statement = "CREATE TABLE IF NOT EXISTS trace ("
|
||||
@ -28,7 +28,7 @@ bool BasicImporter::add_trace_event(instruction_count_t begin, instruction_count
|
||||
"VALUES (?,?,?,?, ?,?,?)");
|
||||
stmt = mysql_stmt_init(db->getHandle());
|
||||
if (mysql_stmt_prepare(stmt, sql.c_str(), sql.length())) {
|
||||
log << "query '" << sql << "' failed: " << mysql_error(db->getHandle()) << std::endl;
|
||||
LOG << "query '" << sql << "' failed: " << mysql_error(db->getHandle()) << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -61,12 +61,12 @@ bool BasicImporter::add_trace_event(instruction_count_t begin, instruction_count
|
||||
}
|
||||
}
|
||||
if (mysql_stmt_bind_param(stmt, bind)) {
|
||||
log << "mysql_stmt_bind_param() failed: " << mysql_stmt_error(stmt) << std::endl;
|
||||
LOG << "mysql_stmt_bind_param() failed: " << mysql_stmt_error(stmt) << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (mysql_stmt_execute(stmt)) {
|
||||
log << "mysql_stmt_execute() failed: " << mysql_stmt_error(stmt) << std::endl;
|
||||
log << "IP: " << std::hex<< event.ip() << std::endl;
|
||||
LOG << "mysql_stmt_execute() failed: " << mysql_stmt_error(stmt) << std::endl;
|
||||
LOG << "IP: " << std::hex<< event.ip() << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -1,22 +1,10 @@
|
||||
## Setup desired protobuf descriptions HERE ##
|
||||
set(MY_PROTOS
|
||||
../../src/plugins/tracing/trace.proto
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
Importer.cc
|
||||
BasicImporter.cc
|
||||
DCiAOKernelImporter.cc
|
||||
)
|
||||
|
||||
#### PROTOBUFS ####
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MY_PROTOS})
|
||||
|
||||
## This is the example's campaign server distributing experiment parameters
|
||||
add_executable(import-trace main.cc ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS})
|
||||
target_link_libraries(import-trace ${PROTOBUF_LIBRARY} -lmysqlclient fail-util fail-sal)
|
||||
target_link_libraries(import-trace ${PROTOBUF_LIBRARY} -lmysqlclient fail-util fail-sal fail-comm)
|
||||
install(TARGETS import-trace RUNTIME DESTINATION bin)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "util/Logger.hpp"
|
||||
extern fail::Logger log;
|
||||
static fail::Logger LOG("DCiAOKernelImporter");
|
||||
|
||||
using namespace fail;
|
||||
|
||||
@ -18,12 +18,12 @@ bool DCiAOKernelImporter::inDynamicKernelMemory(fail::address_t addr) {
|
||||
|
||||
bool DCiAOKernelImporter::copy_to_database(fail::ProtoIStream &ps) {
|
||||
if (m_elf == 0) {
|
||||
log << "Please give an ELF Binary as a parameter" << std::endl;
|
||||
LOG << "Please give an ELF Binary as a parameter" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (getEnterKernelAddress() == 0 || getLeaveKernelAddress() == 0) {
|
||||
log << "Pleave give a valid CiAO Binary with kernel dependability options enabled" << std::endl;
|
||||
LOG << "Pleave give a valid CiAO Binary with kernel dependability options enabled" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -93,12 +93,12 @@ bool DCiAOKernelImporter::copy_to_database(fail::ProtoIStream &ps) {
|
||||
// we're currently looking at; the EC is defined by
|
||||
// data_address [last_kernel_leave, read_instr] (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ bool DCiAOKernelImporter::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;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
#include "util/ElfReader.hpp"
|
||||
#include "sal/SALConfig.hpp"
|
||||
#include "util/Database.hpp"
|
||||
#include "trace.pb.h"
|
||||
#include "comm/TracePlugin.pb.h"
|
||||
|
||||
|
||||
class Importer {
|
||||
protected:
|
||||
int m_variant_id;
|
||||
fail::ElfReader *m_elf;
|
||||
fail::Database *db;
|
||||
fail::Database *db;
|
||||
|
||||
public:
|
||||
typedef unsigned instruction_count_t;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user