SimulationOutput.h
1 
10 #ifndef WRENCH_SIMULATIONOUTPUT_H
11 #define WRENCH_SIMULATIONOUTPUT_H
12 
13 #include <typeinfo>
14 #include <typeindex>
15 #include <iostream>
16 
17 #include "wrench/simulation/SimulationTimestamp.h"
18 #include "wrench/simulation/SimulationTrace.h"
19 
20 
21 namespace wrench {
22  class Simulation;
23 
28 
29  public:
37  template<class T>
38  std::vector<SimulationTimestamp<T> *> getTrace() {
39  std::type_index type_index = std::type_index(typeid(T));
40 
41  // Is the trace empty?
42  if (this->traces.find(type_index) == this->traces.end()) {
43  return {};
44  }
45 
46  std::vector<SimulationTimestamp<T> *> non_generic_vector;
47  auto trace = (SimulationTrace<T> *) (this->traces[type_index]);
48  for (auto ts : trace->getTrace()) {
49  non_generic_vector.push_back((SimulationTimestamp<T> *) ts);
50  }
51  return non_generic_vector;
52  }
53 
54  void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path,
55  bool generate_host_utilization_layout = false, bool writing_file = true);
56 
57  void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path, bool writing_file = true);
58 
59  void dumpHostEnergyConsumptionJSON(std::string file_path, bool writing_file = true);
60 
61  void dumpPlatformGraphJSON(std::string file_path, bool writing_file = true);
62 
63  void dumpDiskOperationsJSON(std::string file_path, bool writing_file = true);
64 
65  void dumpUnifiedJSON(Workflow *workflow, std::string file_path, bool include_platform = false,
66  bool include_workflow_exec = true,
67  bool include_workflow_graph = false, bool include_energy = false,
68  bool generate_host_utilization_layout = false, bool include_disk = false);
69 
70  void enableWorkflowTaskTimestamps(bool enabled);
71 
72  void enableFileReadWriteCopyTimestamps(bool enabled);
73 
74  void enableEnergyTimestamps(bool enabled);
75 
76  void enableDiskTimestamps(bool enabled);
77 
78  /***********************/
80  /***********************/
81 
82  void addTimestampTaskStart(WorkflowTask *task);
83 
84  void addTimestampTaskFailure(WorkflowTask *task);
85 
86  void addTimestampTaskCompletion(WorkflowTask *task);
87 
88  void addTimestampTaskTermination(WorkflowTask *task);
89 
90  void addTimestampFileReadStart(WorkflowFile *file, FileLocation *src, StorageService *service,
91  WorkflowTask *task = nullptr);
92 
93  void addTimestampFileReadFailure(WorkflowFile *file, FileLocation *src, StorageService *service,
94  WorkflowTask *task = nullptr);
95 
96  void addTimestampFileReadCompletion(WorkflowFile *file, FileLocation *src, StorageService *service,
97  WorkflowTask *task = nullptr);
98 
99  void addTimestampFileWriteStart(WorkflowFile *file, FileLocation *src, StorageService *service,
100  WorkflowTask *task = nullptr);
101 
102  void addTimestampFileWriteFailure(WorkflowFile *file, FileLocation *src, StorageService *service,
103  WorkflowTask *task = nullptr);
104 
105  void addTimestampFileWriteCompletion(WorkflowFile *file, FileLocation *src, StorageService *service,
106  WorkflowTask *task = nullptr);
107 
108  void addTimestampFileCopyStart(WorkflowFile *file, std::shared_ptr<FileLocation> src,
109  std::shared_ptr<FileLocation> dst);
110 
111  void addTimestampFileCopyFailure(WorkflowFile *file, std::shared_ptr<FileLocation> src,
112  std::shared_ptr<FileLocation> dst);
113 
114  void addTimestampFileCopyCompletion(WorkflowFile *file, std::shared_ptr<FileLocation> src,
115  std::shared_ptr<FileLocation> dst);
116 
117  void
118  addTimestampDiskReadStart(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
119 
120  void
121  addTimestampDiskReadFailure(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
122 
123  void addTimestampDiskReadCompletion(std::string hostname, std::string mount, double bytes,
124  int unique_sequence_number);
125 
126  void
127  addTimestampDiskWriteStart(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
128 
129  void
130  addTimestampDiskWriteFailure(std::string hostname, std::string mount, double bytes, int unique_sequence_number);
131 
132  void addTimestampDiskWriteCompletion(std::string hostname, std::string mount, double bytes,
133  int unique_sequence_number);
134 
135  void addTimestampPstateSet(std::string hostname, int pstate);
136 
137  void addTimestampEnergyConsumption(std::string hostname, double joules);
138 
145  template<class T>
146  void addTimestamp(T *timestamp) {
147  std::type_index type_index = std::type_index(typeid(T));
148  if (this->traces.find(type_index) == this->traces.end()) {
149  this->traces[type_index] = new SimulationTrace<T>();
150  }
151  ((SimulationTrace<T> *) (this->traces[type_index]))->addTimestamp(new SimulationTimestamp<T>(timestamp));
152  }
153 
154  /***********************/
156  /***********************/
157 
158  /***********************/
160  /***********************/
161 
162  ~SimulationOutput();
163 
164  SimulationOutput();
165 
166  /***********************/
168  /***********************/
169 
170  private:
171  std::map<std::type_index, GenericSimulationTrace *> traces;
172  nlohmann::json platform_json_part;
173  nlohmann::json workflow_exec_json_part;
174  nlohmann::json workflow_graph_json_part;
175  nlohmann::json energy_json_part;
176  nlohmann::json disk_json_part;
177 
178  std::map<std::type_index, bool> enabledStatus;
179 
185  template<class T>
186  bool isEnabled() {
187  std::type_index type_index = std::type_index(typeid(T));
188  return this->enabledStatus[type_index];
189  }
190 
196  template<class T>
197  void setEnabled(bool enabled) {
198  std::type_index type_index = std::type_index(typeid(T));
199  this->enabledStatus[type_index] = enabled;
200  }
201  };
202 };
203 
204 #endif //WRENCH_SIMULATIONOUTPUT_H
void enableFileReadWriteCopyTimestamps(bool enabled)
Enable or Disable the insertion of file-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1750
void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path, bool generate_host_utilization_layout=false, bool writing_file=true)
Writes WorkflowTask execution history for each task to a file, formatted as a JSON array.
Definition: SimulationOutput.cpp:508
void enableDiskTimestamps(bool enabled)
Enable or Disable the insertion of disk-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1736
void dumpUnifiedJSON(Workflow *workflow, std::string file_path, bool include_platform=false, bool include_workflow_exec=true, bool include_workflow_graph=false, bool include_energy=false, bool generate_host_utilization_layout=false, bool include_disk=false)
Function that generates a unified JSON file containing the information specified by boolean arguments...
Definition: SimulationOutput.cpp:145
A time-stamped simulation event stored in SimulationOutput.
Definition: SimulationTimestamp.h:26
void dumpPlatformGraphJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing all hosts, network links, and the routes between each host.
Definition: SimulationOutput.cpp:995
The storage service base class.
Definition: StorageService.h:36
std::vector< SimulationTimestamp< T > * > getTrace()
Retrieve a copy of a simulation output trace once the simulation has completed.
Definition: SimulationOutput.h:38
Definition: Alarm.cpp:20
A workflow (to be executed by a WMS)
Definition: Workflow.h:33
void enableEnergyTimestamps(bool enabled)
Enable or Disable the insertion of energy-related timestamps in the simulation output (enabled by def...
Definition: SimulationOutput.cpp:1767
void dumpHostEnergyConsumptionJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing host energy consumption information as a JSON array.
Definition: SimulationOutput.cpp:847
A computational task in a Workflow.
Definition: WorkflowTask.h:27
A class that encodes a file location.
Definition: FileLocation.h:28
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
void enableWorkflowTaskTimestamps(bool enabled)
Enable or Disable the insertion of task-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:1724
void dumpDiskOperationsJSON(std::string file_path, bool writing_file=true)
Writes a JSON file containing disk operation information as a JSON array.
Definition: SimulationOutput.cpp:1293
void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path, bool writing_file=true)
Writes a JSON graph representation of the Workflow to a file.
Definition: SimulationOutput.cpp:721
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26