summaryrefslogtreecommitdiff
path: root/Simulator/include/database/Queries.h
diff options
context:
space:
mode:
authorMatthijs Bijman <matthijs@bijman.org>2017-02-16 22:06:09 +0100
committerMatthijs Bijman <matthijs@bijman.org>2017-02-16 22:06:09 +0100
commite0b305fd1d845cba1b11578722f88adb193f756e (patch)
tree90440eafff0f2b72571eee8a9b9c644d39ae4b75 /Simulator/include/database/Queries.h
parent6fa9f879a5dab29cdf481e70b6f303caf69bd76f (diff)
Update simulator to work with new db schema
The new schema removes the queued_simulation_section table and introduces the state and last_simulated_tick columns to the experiments table.
Diffstat (limited to 'Simulator/include/database/Queries.h')
-rw-r--r--Simulator/include/database/Queries.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/Simulator/include/database/Queries.h b/Simulator/include/database/Queries.h
index 73afc1a1..33e8cdb9 100644
--- a/Simulator/include/database/Queries.h
+++ b/Simulator/include/database/Queries.h
@@ -6,11 +6,15 @@ namespace Database
namespace Queries
{
Query<int> GET_QUEUED_EXPERIMENTS(std::string(R"query(
- SELECT experiment_id FROM queued_experiments;
+ SELECT id FROM experiments WHERE state LIKE 'QUEUED';
)query"));
- Query<> REMOVE_QUEUED_EXPERIMENT(std::string(R"query(
- DELETE FROM queued_experiments WHERE experiment_id = $id;
+ Query<> SET_EXPERIMENT_STATE_SIMULATING(std::string(R"query(
+ UPDATE experiments SET state='SIMULATING' WHERE id=$id;
+ )query"));
+
+ Query<> SET_EXPERIMENT_STATE_FINISHED(std::string(R"query(
+ UPDATE experiments SET state='FINISHED' WHERE id=$id;
)query"));
Query<int, int, int, int, std::string, std::string> GET_EXPERIMENT_BY_ID(std::string(R"query(
@@ -25,7 +29,10 @@ namespace Database
SELECT id, path_id, datacenter_id, start_tick FROM sections WHERE path_id = $id;
)query"));
-
+ Query<> WRITE_EXPERIMENT_LAST_SIMULATED_TICK(std::string(R"query(
+ UPDATE experiments SET last_simulated_tick = $val WHERE id = $id;
+ )query"));
+
/*
Returns the type of the scheduler of the given simulation section.
Returns: <std::string : scheduler_name>