13 #include <wrench/managers/EnergyMeterService.h>
14 #include "wrench/services/Service.h"
15 #include "wrench/wms/DynamicOptimization.h"
16 #include "wrench/wms/StaticOptimization.h"
17 #include "wrench/wms/scheduler/PilotJobScheduler.h"
18 #include "wrench/wms/scheduler/StandardJobScheduler.h"
19 #include "wrench/services/compute/cloud/CloudComputeService.h"
20 #include "wrench/workflow/execution_events/StandardJobCompletedEvent.h"
21 #include "wrench/workflow/execution_events/StandardJobFailedEvent.h"
22 #include "wrench/workflow/execution_events/PilotJobStartedEvent.h"
23 #include "wrench/workflow/execution_events/PilotJobExpiredEvent.h"
24 #include "wrench/workflow/execution_events/FileCopyCompletedEvent.h"
25 #include "wrench/workflow/execution_events/FileCopyFailedEvent.h"
26 #include "wrench/workflow/execution_events/TimerEvent.h"
27 #include "wrench/workflow/Workflow.h"
33 class CloudComputeService;
34 class VirtualizedClusterComputeService;
36 class NetworkProximityService;
37 class FileRegistryService;
61 WMS(std::unique_ptr<StandardJobScheduler> standard_job_scheduler,
62 std::unique_ptr<PilotJobScheduler> pilot_job_scheduler,
63 const std::set<std::shared_ptr<ComputeService>> &compute_services,
64 const std::set<std::shared_ptr<StorageService>> &storage_services,
65 const std::set<std::shared_ptr<NetworkProximityService>> &network_proximity_services,
66 std::shared_ptr<FileRegistryService> file_registry_service,
67 const std::string &hostname,
68 const std::string suffix);
71 void checkDeferredStart();
73 void setTimer(
double date, std::string message);
75 std::shared_ptr<JobManager> createJobManager();
76 std::shared_ptr<DataMovementManager> createDataMovementManager();
77 std::shared_ptr<EnergyMeterService> createEnergyMeter(
const std::map<std::string, double> &measurement_periods);
78 std::shared_ptr<EnergyMeterService> createEnergyMeter(
const std::vector<std::string> &hostnames,
double measurement_period);
80 void runDynamicOptimizations();
82 void runStaticOptimizations();
90 std::set<std::shared_ptr<T>> getAvailableComputeServices() {
91 bool is_cloud = (std::type_index(
typeid(T)) == std::type_index(
typeid(
CloudComputeService)));
92 std::set<std::shared_ptr<T>> to_return;
93 for (
auto const &h : this->compute_services) {
95 auto shared_ptr = std::dynamic_pointer_cast<T>(h);
97 to_return.insert(shared_ptr);
100 auto shared_ptr_cloud = std::dynamic_pointer_cast<T>(h);
101 auto shared_ptr_vc = std::dynamic_pointer_cast<VirtualizedClusterComputeService>(h);
102 if (shared_ptr_cloud and (not shared_ptr_vc)) {
103 to_return.insert(shared_ptr_cloud);
132 std::set<std::shared_ptr<StorageService>> getAvailableStorageServices();
133 std::set<std::shared_ptr<NetworkProximityService>> getAvailableNetworkProximityServices();
134 std::shared_ptr<FileRegistryService> getAvailableFileRegistryService();
136 void waitForAndProcessNextEvent();
137 bool waitForAndProcessNextEvent(
double timeout);
138 std::shared_ptr<WorkflowExecutionEvent> waitForNextEvent();
139 std::shared_ptr<WorkflowExecutionEvent> waitForNextEvent(
double timeout);
140 virtual void processEventStandardJobCompletion(std::shared_ptr<StandardJobCompletedEvent>);
142 virtual void processEventStandardJobFailure(std::shared_ptr<StandardJobFailedEvent>);
144 virtual void processEventPilotJobStart(std::shared_ptr<PilotJobStartedEvent>);
146 virtual void processEventPilotJobExpiration(std::shared_ptr<PilotJobExpiredEvent>);
148 virtual void processEventFileCopyCompletion(std::shared_ptr<FileCopyCompletedEvent>);
150 virtual void processEventFileCopyFailure(std::shared_ptr<FileCopyFailedEvent>);
152 virtual void processEventTimer(std::shared_ptr<TimerEvent>);
164 friend class DataMovementManager;
165 friend class JobManager;
172 std::set<std::shared_ptr<ComputeService>> compute_services;
174 std::set<std::shared_ptr<StorageService>> storage_services;
176 std::set<std::shared_ptr<NetworkProximityService>> network_proximity_services;
178 std::shared_ptr<FileRegistryService> file_registry_service;
181 std::shared_ptr<StandardJobScheduler> standard_job_scheduler;
183 std::shared_ptr<PilotJobScheduler> pilot_job_scheduler;
186 std::vector<std::unique_ptr<DynamicOptimization>> dynamic_optimizations;
188 std::vector<std::unique_ptr<StaticOptimization>> static_optimizations;
195 virtual int main() = 0;
202 #endif //WRENCH_WMS_H