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
37 lines
908 B
C++
37 lines
908 B
C++
#ifndef __IMPORTER_H__
|
|
#define __IMPORTER_H__
|
|
|
|
#include <mysql/mysql.h>
|
|
#include <map>
|
|
#include "util/ProtoStream.hpp"
|
|
#include "util/ElfReader.hpp"
|
|
#include "sal/SALConfig.hpp"
|
|
#include "util/Database.hpp"
|
|
#include "comm/TracePlugin.pb.h"
|
|
|
|
|
|
class Importer {
|
|
protected:
|
|
int m_variant_id;
|
|
fail::ElfReader *m_elf;
|
|
fail::Database *db;
|
|
|
|
public:
|
|
typedef unsigned instruction_count_t;
|
|
|
|
bool init(const std::string &variant, const std::string &benchmark, fail::Database *db);
|
|
|
|
virtual bool create_database() = 0;
|
|
virtual bool copy_to_database(fail::ProtoIStream &ps);
|
|
virtual bool clear_database();
|
|
virtual bool add_trace_event(instruction_count_t begin, instruction_count_t end,
|
|
const Trace_Event &event, bool is_fake = false) = 0;
|
|
|
|
void set_elf_file(fail::ElfReader *elf) {m_elf = elf;};
|
|
protected:
|
|
private:
|
|
typedef std::map<fail::address_t, instruction_count_t> AddrLastaccessMap;
|
|
};
|
|
|
|
#endif
|