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
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
/**
|
|
* \brief This is the base class for all user-defined data types for
|
|
* experiment parameter and results.
|
|
*/
|
|
|
|
#ifndef __EXPERIMENT_DATA_HPP__
|
|
#define __EXPERIMENT_DATA_HPP__
|
|
|
|
#include <string>
|
|
#include <google/protobuf/message.h>
|
|
|
|
namespace fail {
|
|
|
|
/**
|
|
* \class ExperimentData
|
|
* Container for experiment data with wrapper methods for serialization and deserialization.
|
|
*/
|
|
class ExperimentData {
|
|
protected:
|
|
google::protobuf::Message* msg;
|
|
uint32_t m_workloadID;
|
|
public:
|
|
ExperimentData() : msg(0), m_workloadID(0) {};
|
|
ExperimentData(google::protobuf::Message* m) : msg(m) , m_workloadID(0) { }
|
|
|
|
google::protobuf::Message& getMessage() { return *msg; }
|
|
void setMessage(google::protobuf::Message *msg) { this->msg = msg; }
|
|
uint32_t getWorkloadID() const { return m_workloadID; };
|
|
void setWorkloadID(uint32_t id) { m_workloadID = id; }
|
|
/**
|
|
* Serializes the ExperimentData.
|
|
* @param ped output the target-stream.
|
|
* @return \c true if the serialization was successful, \c false otherwise
|
|
*/
|
|
bool serialize(std::ostream* output) const { return msg->SerializeToOstream(output); }
|
|
/**
|
|
* Unserializes the ExperimentData.
|
|
* @param ped input the stream which is read from
|
|
* @return \c true if the unserialization was successful, \c false otherwise
|
|
*/
|
|
bool unserialize(std::istream* input) { return msg->ParseFromIstream(input); }
|
|
/**
|
|
* Returns a debug string.
|
|
* @return the debug string
|
|
*/
|
|
std::string debugString() const { return msg->DebugString(); };
|
|
};
|
|
|
|
} // end-of-namespace: fail
|
|
|
|
#endif //__EXPERIMENT_DATA_HPP__
|