GreenCloud Simulator
datacenter.h
Go to the documentation of this file.
1 #ifndef ns_datacenter_h
2 #define ns_datacenter_h
3 
4 #include "object.h"
5 #include "dchost.h"
6 #include "vm.h"
7 #include "tskagent.h"
8 #include "resourcespec.h"
9 #include "dcresource.h"
10 #include "powermodel/powermodel.h"
11 #include "vmmigration.h"
15 #include "dcscheduler/randdens.h"
16 #include "dcscheduler/bestdens.h"
19 
20 #include <tclcl.h>
21 #include <vector>
22 #include <math.h>
23 #include <iostream>
24 #include <numeric>
25 
26 
27 class DataCenter : public TclObject {
28 public:
29  DataCenter();
30  virtual ~DataCenter();
31  void clear();
32  void addHostPointer(DcHost *newhst);
33  void addVmPointer(VM* newvm);
34  void addHostTaskAgentPointer(TskComAgent *newagnt);
35  void addVmTaskAgentPointer(TskComAgent *newagnt);
38  void addPModelPointer(PowerModel* newPModel);
40  int initiallyConfigureVms();
41  int setScheduler( const char* scheduler_name);
42  void migrateVm(VM* vm, ResourceProvider* target);
43  int configureResource(DcResource* confRes, const char* spec_name); /*Check existence of Resource specification named and adds pointer to it configured resource.*/
44  int configureVirtualResource(DcResource* confRes, const char* spec_name); /*Check existence of Resource specification named and adds pointer to it configured resource.*/
45  void printResourceSpecs();
46 
47  virtual void receivedTsk(int tsksize, CloudTask * pTask, const char* flags = 0);
48  virtual int command(int argc, const char*const* argv);
49 
50 
51  /* Stats */
54  double avgLoad_;
55  double avgLoadMem_;
56  double avgLoadStor_;
57  double avgPower_;
58 
59 protected:
60  vector <ResourceProvider*> host_list;
61  vector <TskComAgent*> host_agent_list;
62  vector <ResourceProvider*> vm_list;
63  vector <TskComAgent*> vm_agent_list;
64  vector <PowerModel*> power_model_list;
65 
67 
68  /* Two dimensional structure: Vector of resource types, that are itself vectors of specification for given type.
69  * this structure contains all resource specifications available in data center.*/
70  vector < ResourceSpec* > resource_specification_list;
71  vector < ResourceSpec* > virt_resource_specification_list;
72 
74  /* Schedulers */
77 
79 
80  /*Round robin should be adapted to the new resource policies. (i.e. add availability checking or data-center level queues for hosts)*/
82  TskComAgent *scheduleRoundRobin(CloudTask *tsk,std::vector<TskComAgent*> agent_list);
85  void computeLoad();
86 
88  void setVmScheduling(bool scheduleOnVms);
89 
90 private:
91  void createNewMigration();
92 };
93 
94 #endif
void addHostTaskAgentPointer(TskComAgent *newagnt)
Definition: datacenter.cc:74
int configureResource(DcResource *confRes, const char *spec_name)
Definition: datacenter.cc:391
TskComAgent * scheduleGreen(CloudTask *tsk)
Definition: datacenter.cc:188
void setVmScheduling(bool scheduleOnVms)
Definition: datacenter.cc:61
int tskFailed_
Definition: datacenter.h:53
double avgPower_
Definition: datacenter.h:57
int configureVirtualResource(DcResource *confRes, const char *spec_name)
Definition: datacenter.cc:410
double avgLoadStor_
Definition: datacenter.h:56
void clear()
Definition: datacenter.cc:40
TskComAgent * scheduleRoundRobin(CloudTask *tsk)
Definition: datacenter.cc:181
vector< TskComAgent * > vm_agent_list
Definition: datacenter.h:63
void addPModelPointer(PowerModel *newPModel)
Definition: datacenter.cc:91
DcHost * newhost_
Definition: datacenter.h:73
void addVmTaskAgentPointer(TskComAgent *newagnt)
Definition: datacenter.cc:80
vector< PowerModel * > power_model_list
Definition: datacenter.h:64
void migrateVm(VM *vm, ResourceProvider *target)
Definition: datacenter.cc:151
void addResourceSpecificationPointer(ResourceSpec *newresspec)
Definition: datacenter.cc:86
vector< ResourceProvider * > host_list
Definition: datacenter.h:60
int numVmTskAgents_
Definition: datacenter.h:76
virtual void receivedTsk(int tsksize, CloudTask *pTask, const char *flags=0)
Definition: datacenter.cc:161
int numHostTskAgents_
Definition: datacenter.h:75
void computeLoad()
Definition: datacenter.cc:348
virtual int command(int argc, const char *const *argv)
Definition: datacenter.cc:221
VmMigration * tmp_migration_
Definition: datacenter.h:78
vector< ResourceProvider * > vm_list
Definition: datacenter.h:62
void addVmPointer(VM *newvm)
Definition: datacenter.cc:70
int initiallyConfigureVms()
Definition: datacenter.cc:101
void createNewMigration()
Definition: datacenter.cc:142
bool scheduleOnVms_
Definition: datacenter.h:87
void addVirtualResourceSpecificationPointer(ResourceSpec *newresspec)
Definition: datacenter.cc:96
Definition: dchost.h:27
vector< ResourceSpec * > virt_resource_specification_list
Definition: datacenter.h:71
vector< ResourceSpec * > resource_specification_list
Definition: datacenter.h:70
DcScheduler * dcScheduler
Definition: datacenter.h:66
double avgLoadMem_
Definition: datacenter.h:55
vector< TskComAgent * > host_agent_list
Definition: datacenter.h:61
virtual ~DataCenter()
Definition: datacenter.cc:35
TskComAgent * scheduleGreenVmOnly(CloudTask *tsk)
Definition: datacenter.cc:208
void addHostPointer(DcHost *newhst)
Definition: datacenter.cc:65
int setScheduler(const char *scheduler_name)
Definition: datacenter.cc:111
double avgLoad_
Definition: datacenter.h:54
int tskSubmitted_
Definition: datacenter.h:52
Definition: vm.h:29
void printResourceSpecs()
Definition: datacenter.cc:382