blob: 7f867d6c2199b2c7236d2c12d6fbdf4178e42eea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#pragma once
#include "simulation/Section.h"
#include "modeling/ModelingTypes.h"
#include <sqlite3.h>
#include "simulation/Experiment.h"
namespace Database
{
/*
The Database class provides a wrapper for the sqlite interface.
*/
class Database
{
public:
/*
Initializes a database with the given name. If it does not yet exist is creates a $name.db file.
*/
explicit Database(char* name);
/*
Closes the database connection.
*/
~Database();
/*
Starts a sqlite transaction.
*/
void startTransaction() const;
/*
Ends a sqlite transaction.
*/
void endTransaction() const;
/*
Writes the history of the experiment to the database.
*/
void writeExperimentHistory(Simulation::Experiment& simulation) const;
/*
Polls the database for new simulation sections to simulate.
If there are no rows in the table, this returns -1.
*/
int pollQueuedExperiments() const;
/*
Removes a row of the queued simulation sections.
*/
void dequeueExperiment(int id) const;
/*
Marks the given experiment as finished in the database.
*/
void finishExperiment(int id) const;
/*
Creates a simulation object from a simulation in the database.
*/
Simulation::Experiment createExperiment(uint32_t id);
private:
/*
Sets the scheduler of the datacenter
*/
Simulation::Scheduler* loadScheduler(uint32_t simulationSectionId) const;
DefaultDatacenter loadDatacenter(uint32_t datacenterId) const;
/*
Fills the datacenter with workloads from the database.
*/
Simulation::WorkloadPool loadWorkloads(uint32_t traceId) const;
// The sqlite db connection.
sqlite3 *db;
};
}
|