13 #include <wrench/services/metering/EnergyMeterService.h>
14 #include <wrench/services/metering/BandwidthMeterService.h>
15 #include "wrench/services/Service.h"
16 #include "wrench/wms/DynamicOptimization.h"
17 #include "wrench/wms/StaticOptimization.h"
18 #include "wrench/wms/scheduler/PilotJobScheduler.h"
19 #include "wrench/wms/scheduler/StandardJobScheduler.h"
20 #include "wrench/services/compute/cloud/CloudComputeService.h"
21 #include "wrench/workflow/execution_events/StandardJobCompletedEvent.h"
22 #include "wrench/workflow/execution_events/StandardJobFailedEvent.h"
23 #include "wrench/workflow/execution_events/PilotJobStartedEvent.h"
24 #include "wrench/workflow/execution_events/PilotJobExpiredEvent.h"
25 #include "wrench/workflow/execution_events/FileCopyCompletedEvent.h"
26 #include "wrench/workflow/execution_events/FileCopyFailedEvent.h"
27 #include "wrench/workflow/execution_events/TimerEvent.h"
28 #include "wrench/workflow/Workflow.h"
34 class CloudComputeService;
35 class VirtualizedClusterComputeService;
37 class NetworkProximityService;
38 class FileRegistryService;
62 WMS(std::unique_ptr<StandardJobScheduler> standard_job_scheduler,
63 std::unique_ptr<PilotJobScheduler> pilot_job_scheduler,
64 const std::set<std::shared_ptr<ComputeService>> &compute_services,
65 const std::set<std::shared_ptr<StorageService>> &storage_services,
66 const std::set<std::shared_ptr<NetworkProximityService>> &network_proximity_services,
67 std::shared_ptr<FileRegistryService> file_registry_service,
68 const std::string &hostname,
69 const std::string suffix);
72 void checkDeferredStart();
74 void setTimer(
double date, std::string message);
76 std::shared_ptr<JobManager> createJobManager();
77 std::shared_ptr<DataMovementManager> createDataMovementManager();
78 std::shared_ptr<EnergyMeterService> createEnergyMeter(
const std::map<std::string, double> &measurement_periods);
79 std::shared_ptr<EnergyMeterService> createEnergyMeter(
const std::vector<std::string> &hostnames,
double measurement_period);
80 std::shared_ptr<BandwidthMeterService> createBandwidthMeter(
const std::map<std::string, double> &measurement_periods);
81 std::shared_ptr<BandwidthMeterService> createBandwidthMeter(
const std::vector<std::string> &linknames,
double measurement_period);
83 void runDynamicOptimizations();
85 void runStaticOptimizations();
93 std::set<std::shared_ptr<T>> getAvailableComputeServices() {
94 bool is_cloud = (std::type_index(
typeid(T)) == std::type_index(
typeid(
CloudComputeService)));
95 std::set<std::shared_ptr<T>> to_return;
96 for (
auto const &h : this->compute_services) {
98 auto shared_ptr = std::dynamic_pointer_cast<T>(h);
100 to_return.insert(shared_ptr);
103 auto shared_ptr_cloud = std::dynamic_pointer_cast<T>(h);
104 auto shared_ptr_vc = std::dynamic_pointer_cast<VirtualizedClusterComputeService>(h);
105 if (shared_ptr_cloud and (not shared_ptr_vc)) {
106 to_return.insert(shared_ptr_cloud);
135 std::set<std::shared_ptr<StorageService>> getAvailableStorageServices();
136 std::set<std::shared_ptr<NetworkProximityService>> getAvailableNetworkProximityServices();
137 std::shared_ptr<FileRegistryService> getAvailableFileRegistryService();
139 void waitForAndProcessNextEvent();
140 bool waitForAndProcessNextEvent(
double timeout);
141 std::shared_ptr<WorkflowExecutionEvent> waitForNextEvent();
142 std::shared_ptr<WorkflowExecutionEvent> waitForNextEvent(
double timeout);
143 virtual void processEventStandardJobCompletion(std::shared_ptr<StandardJobCompletedEvent>);
145 virtual void processEventStandardJobFailure(std::shared_ptr<StandardJobFailedEvent>);
147 virtual void processEventPilotJobStart(std::shared_ptr<PilotJobStartedEvent>);
149 virtual void processEventPilotJobExpiration(std::shared_ptr<PilotJobExpiredEvent>);
151 virtual void processEventFileCopyCompletion(std::shared_ptr<FileCopyCompletedEvent>);
153 virtual void processEventFileCopyFailure(std::shared_ptr<FileCopyFailedEvent>);
155 virtual void processEventTimer(std::shared_ptr<TimerEvent>);
167 friend class DataMovementManager;
168 friend class JobManager;
175 std::set<std::shared_ptr<ComputeService>> compute_services;
177 std::set<std::shared_ptr<StorageService>> storage_services;
179 std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
181 std::shared_ptr<FileRegistryService> file_registry_service;
184 std::shared_ptr<StandardJobScheduler> standard_job_scheduler;
186 std::shared_ptr<PilotJobScheduler> pilot_job_scheduler;
189 std::vector<std::unique_ptr<DynamicOptimization>> dynamic_optimizations;
191 std::vector<std::unique_ptr<StaticOptimization>> static_optimizations;
198 virtual int main() = 0;
205 #endif //WRENCH_WMS_H