WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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(std::shared_ptr<Workflow> workflow, std::string file_path,
55  bool generate_host_utilization_layout = false, bool writing_file = true);
56 
57  void dumpWorkflowGraphJSON(std::shared_ptr<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 dumpLinkUsageJSON(std::string file_path, bool writing_file = true);
66 
67  void dumpUnifiedJSON(std::shared_ptr<Workflow> workflow, std::string file_path,
68  bool include_platform = false,
69  bool include_workflow_exec = true,
70  bool include_workflow_graph = false,
71  bool include_energy = false,
72  bool generate_host_utilization_layout = false,
73  bool include_disk = false,
74  bool include_bandwidth = false);
75 
76  void enableWorkflowTaskTimestamps(bool enabled);
77 
78  void enableFileReadWriteCopyTimestamps(bool enabled);
79 
80  void enableEnergyTimestamps(bool enabled);
81 
82  void enableDiskTimestamps(bool enabled);
83 
84  void enableBandwidthTimestamps(bool enabled);
85 
86  /***********************/
88  /***********************/
89 
90  void addTimestampTaskStart(double date, std::shared_ptr<WorkflowTask>task);
91 
92  void addTimestampTaskFailure(double date, std::shared_ptr<WorkflowTask>task);
93 
94  void addTimestampTaskCompletion(double date, std::shared_ptr<WorkflowTask>task);
95 
96  void addTimestampTaskTermination(double date, std::shared_ptr<WorkflowTask>task);
97 
98  void addTimestampFileReadStart(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
99  std::shared_ptr<WorkflowTask>task = nullptr);
100 
101  void addTimestampFileReadFailure(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
102  std::shared_ptr<WorkflowTask>task = nullptr);
103 
104  void addTimestampFileReadCompletion(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
105  std::shared_ptr<WorkflowTask>task = nullptr);
106 
107  void addTimestampFileWriteStart(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
108  std::shared_ptr<WorkflowTask>task = nullptr);
109 
110  void addTimestampFileWriteFailure(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
111  std::shared_ptr<WorkflowTask>task = nullptr);
112 
113  void addTimestampFileWriteCompletion(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src, std::shared_ptr<StorageService> service,
114  std::shared_ptr<WorkflowTask>task = nullptr);
115 
116  void addTimestampFileCopyStart(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src,
117  std::shared_ptr<FileLocation> dst);
118 
119  void addTimestampFileCopyFailure(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src,
120  std::shared_ptr<FileLocation> dst);
121 
122  void addTimestampFileCopyCompletion(double date, std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src,
123  std::shared_ptr<FileLocation> dst);
124 
125  void
126  addTimestampDiskReadStart(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number);
127 
128  void
129  addTimestampDiskReadFailure(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number);
130 
131  void addTimestampDiskReadCompletion(double date, std::string hostname, std::string mount, double bytes,
132  int unique_sequence_number);
133 
134  void
135  addTimestampDiskWriteStart(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number);
136 
137  void
138  addTimestampDiskWriteFailure(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number);
139 
140  void addTimestampDiskWriteCompletion(double date, std::string hostname, std::string mount, double bytes,
141  int unique_sequence_number);
142 
143  void addTimestampPstateSet(double date, std::string hostname, int pstate);
144 
145  void addTimestampEnergyConsumption(double date, std::string hostname, double joules);
146 
147  void addTimestampLinkUsage(double date, std::string linkname, double bytes_per_second);
148 
155  template<class T>
156  void addTimestamp(T *timestamp) {
157  std::type_index type_index = std::type_index(typeid(T));
158  if (this->traces.find(type_index) == this->traces.end()) {
159  this->traces[type_index] = new SimulationTrace<T>();
160  }
161  ((SimulationTrace<T> *) (this->traces[type_index]))->addTimestamp(new SimulationTimestamp<T>(timestamp));
162  }
163 
164  /***********************/
166  /***********************/
167 
168  /***********************/
170  /***********************/
171 
172  ~SimulationOutput();
173 
175 
176  /***********************/
178  /***********************/
179 
180  private:
181  std::map<std::type_index, GenericSimulationTrace *> traces;
182  nlohmann::json platform_json_part;
183  nlohmann::json workflow_exec_json_part;
184  nlohmann::json workflow_graph_json_part;
185  nlohmann::json energy_json_part;
186  nlohmann::json disk_json_part;
187  nlohmann::json bandwidth_json_part;
188 
189  std::map<std::type_index, bool> enabledStatus;
190 
196  template<class T>
197  bool isEnabled() {
198  std::type_index type_index = std::type_index(typeid(T));
199  return this->enabledStatus[type_index];
200  }
201 
207  template<class T>
208  void setEnabled(bool enabled) {
209  std::type_index type_index = std::type_index(typeid(T));
210  this->enabledStatus[type_index] = enabled;
211  }
212  };
213 };
214 
215 #endif //WRENCH_SIMULATIONOUTPUT_H
wrench::SimulationOutput::addTimestamp
void addTimestamp(T *timestamp)
Append a simulation timestamp to a simulation output trace.
Definition: SimulationOutput.h:156
wrench::SimulationOutput::enableFileReadWriteCopyTimestamps
void enableFileReadWriteCopyTimestamps(bool enabled)
Enable or Disable the insertion of file-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:2031
wrench::SimulationOutput::addTimestampDiskReadStart
void addTimestampDiskReadStart(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file read start timestamp.
Definition: SimulationOutput.cpp:1811
wrench::SimulationOutput::addTimestampTaskFailure
void addTimestampTaskFailure(double date, std::shared_ptr< WorkflowTask >task)
Add a task start failure.
Definition: SimulationOutput.cpp:1608
wrench::SimulationOutput::enableBandwidthTimestamps
void enableBandwidthTimestamps(bool enabled)
Enable or Disable the insertion of link-usage-related timestamps in the simulation output (enabled by...
Definition: SimulationOutput.cpp:2058
wrench::SimulationOutput::addTimestampTaskCompletion
void addTimestampTaskCompletion(double date, std::shared_ptr< WorkflowTask >task)
Add a task start completion.
Definition: SimulationOutput.cpp:1619
wrench::SimulationOutput::addTimestampTaskTermination
void addTimestampTaskTermination(double date, std::shared_ptr< WorkflowTask >task)
Add a task start termination.
Definition: SimulationOutput.cpp:1630
wrench::SimulationOutput::addTimestampFileCopyStart
void addTimestampFileCopyStart(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< FileLocation > dst)
Add a file copy start timestamp.
Definition: SimulationOutput.cpp:1760
wrench::SimulationTrace
A template class to represent a trace of timestamps.
Definition: SimulationTrace.h:48
wrench::SimulationOutput::addTimestampFileCopyFailure
void addTimestampFileCopyFailure(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< FileLocation > dst)
Add a file copy failure timestamp.
Definition: SimulationOutput.cpp:1776
wrench::SimulationOutput::enableDiskTimestamps
void enableDiskTimestamps(bool enabled)
Enable or Disable the insertion of disk-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:2017
wrench::SimulationOutput::addTimestampDiskWriteCompletion
void addTimestampDiskWriteCompletion(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file write completion timestamp.
Definition: SimulationOutput.cpp:1902
wrench::SimulationOutput::addTimestampDiskReadFailure
void addTimestampDiskReadFailure(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file read failure timestamp.
Definition: SimulationOutput.cpp:1830
wrench::SimulationOutput::addTimestampDiskReadCompletion
void addTimestampDiskReadCompletion(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file read completion timestamp.
Definition: SimulationOutput.cpp:1848
wrench::SimulationOutput::addTimestampPstateSet
void addTimestampPstateSet(double date, std::string hostname, int pstate)
Add a pstate change/set timestamp.
Definition: SimulationOutput.cpp:1918
wrench::SimulationTimestamp
A time-stamped simulation event stored in SimulationOutput.
Definition: SimulationTimestamp.h:26
wrench::SimulationOutput::dumpPlatformGraphJSON
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:1032
wrench::SimulationOutput::addTimestampEnergyConsumption
void addTimestampEnergyConsumption(double date, std::string hostname, double joules)
Add an energy consumption timestamp.
Definition: SimulationOutput.cpp:1931
wrench::SimulationOutput::dumpUnifiedJSON
void dumpUnifiedJSON(std::shared_ptr< 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, bool include_bandwidth=false)
Function that generates a unified JSON file containing the information specified by boolean arguments...
Definition: SimulationOutput.cpp:169
wrench::SimulationOutput::addTimestampFileReadCompletion
void addTimestampFileReadCompletion(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file read completion timestamp.
Definition: SimulationOutput.cpp:1683
wrench::SimulationOutput::getTrace
std::vector< SimulationTimestamp< T > * > getTrace()
Retrieve a copy of a simulation output trace once the simulation has completed.
Definition: SimulationOutput.h:38
wrench
Definition: Action.cpp:28
wrench::SimulationOutput::enableEnergyTimestamps
void enableEnergyTimestamps(bool enabled)
Enable or Disable the insertion of energy-related timestamps in the simulation output (enabled by def...
Definition: SimulationOutput.cpp:2048
wrench::SimulationOutput::dumpHostEnergyConsumptionJSON
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:877
wrench::SimulationOutput::dumpWorkflowExecutionJSON
void dumpWorkflowExecutionJSON(std::shared_ptr< 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:527
wrench::SimulationOutput::addTimestampFileCopyCompletion
void addTimestampFileCopyCompletion(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< FileLocation > dst)
Add a file copy completion timestamp.
Definition: SimulationOutput.cpp:1793
wrench::SimulationOutput::addTimestampDiskWriteStart
void addTimestampDiskWriteStart(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file write start timestamp.
Definition: SimulationOutput.cpp:1866
wrench::SimulationOutput::addTimestampFileWriteFailure
void addTimestampFileWriteFailure(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file write failure timestamp.
Definition: SimulationOutput.cpp:1722
wrench::SimulationOutput::addTimestampTaskStart
void addTimestampTaskStart(double date, std::shared_ptr< WorkflowTask >task)
Add a task start timestamp.
Definition: SimulationOutput.cpp:1597
wrench::SimulationOutput::addTimestampLinkUsage
void addTimestampLinkUsage(double date, std::string linkname, double bytes_per_second)
Add a link usage timestamp.
Definition: SimulationOutput.cpp:1969
wrench::SimulationOutput::addTimestampFileReadStart
void addTimestampFileReadStart(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file read start timestamp.
Definition: SimulationOutput.cpp:1644
wrench::SimulationOutput::dumpLinkUsageJSON
void dumpLinkUsageJSON(std::string file_path, bool writing_file=true)
Definition: SimulationOutput.cpp:1492
wrench::SimulationOutput::addTimestampFileWriteCompletion
void addTimestampFileWriteCompletion(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file write completion timestamp.
Definition: SimulationOutput.cpp:1742
wrench::SimulationOutput::addTimestampDiskWriteFailure
void addTimestampDiskWriteFailure(double date, std::string hostname, std::string mount, double bytes, int unique_sequence_number)
Add a file write failure timestamp.
Definition: SimulationOutput.cpp:1884
wrench::SimulationOutput::addTimestampFileWriteStart
void addTimestampFileWriteStart(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file write start timestamp.
Definition: SimulationOutput.cpp:1703
wrench::SimulationOutput
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
wrench::SimulationOutput::enableWorkflowTaskTimestamps
void enableWorkflowTaskTimestamps(bool enabled)
Enable or Disable the insertion of task-related timestamps in the simulation output (enabled by defau...
Definition: SimulationOutput.cpp:2005
wrench::SimulationOutput::dumpDiskOperationsJSON
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:1328
wrench::SimulationOutput::dumpWorkflowGraphJSON
void dumpWorkflowGraphJSON(std::shared_ptr< Workflow > workflow, std::string file_path, bool writing_file=true)
Writes a JSON graph representation of the Workflow to a file.
Definition: SimulationOutput.cpp:752
wrench::SimulationOutput::addTimestampFileReadFailure
void addTimestampFileReadFailure(double date, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src, std::shared_ptr< StorageService > service, std::shared_ptr< WorkflowTask >task=nullptr)
Add a file read failure timestamp.
Definition: SimulationOutput.cpp:1663