GreenCloud Simulator
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DcHost Class Reference

#include <dchost.h>

Inheritance diagram for DcHost:
Inheritance graph
[legend]
Collaboration diagram for DcHost:
Collaboration graph
[legend]

Public Member Functions

 DcHost ()
 
virtual ~DcHost ()
 
virtual void print ()
 
virtual void printTasklist ()
 
virtual int command (int argc, const char *const *argv)
 
virtual void updateEnergyAndConsumption ()
 
- Public Member Functions inherited from ResourceProvider
 ResourceProvider ()
 
virtual ~ResourceProvider ()
 
void setTskComSink (TskComSink *tcs)
 
int tryToAllocate (ResourceConsumer *rc)
 
bool releaseAllocation (ResourceConsumer *rc)
 
bool addVM (VM *newVm)
 
bool removeVM (VM *vm)
 
ResourceProvidergetHost ()
 
DcHostgetRootHost ()
 
void recv (ResourceConsumer *rcobj)
 
double getResTypeUtil (res_type type)
 
double getTotalCap (res_type type)
 
int testSchedulingPossibility (CloudTask *tskobj)
 
int trySchedulingTsk (CloudTask *tskobj)
 
void sendTaskOutput (CloudTask *task)
 
void scheduleNextExent (double nextDeadline)
 
TskComAgentgetTskComAgent ()
 

Public Attributes

DcRackrack_
 
PowerModelpowerModel
 
double eConsumed_
 
double eNominalrate_
 
double eCurrentConsumption_
 
int eDNS_enabled_
 
- Public Attributes inherited from ResourceProvider
std::vector< std::vector< DcResource * > > resource_list
 
int id_
 
int ntasks_
 
double currentLoad_
 
double currentLoadMem_
 
double currentLoadStor_
 
double currentLoadNet_
 
int eDVFS_enabled_
 
int tskFailed_
 
TskComAgenttskComAgent
 

Protected Member Functions

void setCurrentConsumption ()
 
void eUpdate ()
 
virtual void addResource (DcResource *res)
 
void setPowerModel (PowerModel *pModel)
 
- Protected Member Functions inherited from ResourceProvider
virtual void handle (Event *event)
 
void updateEvent ()
 
void nextEvent (double delay)
 
double getCurrentLoad ()
 
double updateResTypeUtil (res_type type)
 
double getFreeCap (res_type type)
 
double getFreeCapRecursive (res_type type)
 
double getUsedNet (bool in, bool out)
 
double getUsedNetRecursive (bool in, bool out)
 
void setTskComAgent (TskComAgent *agnt)
 
void setAgent (ProviderOutAgent *agent)
 
TcpAgent * getAgent ()
 
void attachSink (VmMigrationSink *vm_mig_sink)
 
void attachSource (ProviderOutAgent *tcp_agent)
 
void detachSink (VmMigrationSink *vm_mig_sink)
 
void detachSource (ProviderOutAgent *tcp_agent)
 

Protected Attributes

double eLastUpdateTime_
 
- Protected Attributes inherited from ResourceProvider
double resource_utilization [LastResType+1]
 
std::vector< ResourceConsumer * > hosted_vms_
 
std::vector< VmMigrationSink * > vm_migration_sinks_
 
std::vector< ProviderOutAgent * > vm_migration_sources_
 
TskComSinktskComSink_
 
ProviderOutAgentpoagent_
 
ResourceProviderhost
 
bool started_
 
int status_
 
Event event_
 

Additional Inherited Members

- Public Types inherited from ResourceProvider
enum  EventStatus
 
- Static Public Attributes inherited from ResourceProvider
static double uplink_overhead =ResourceProvider::MTU/ResourceProvider::useful_bytes
 
static double MTU =1500.0
 
static double useful_bytes =1460.0
 

Detailed Description

Definition at line 27 of file dchost.h.

Constructor & Destructor Documentation

DcHost::DcHost ( )

Definition at line 16 of file dchost.cc.

17 {
18  bind("id_", &id_);
19  bind("ntasks_", &ntasks_);
20  bind("currentLoad_", &currentLoad_);
21  bind("currentLoadMem_", &currentLoadMem_);
22  bind("currentLoadStor_", &currentLoadStor_);
23  bind("tskFailed_", &tskFailed_);
24 
25  bind("eConsumed_", &eConsumed_); /* total W of energy consumed */
26  bind("eNominalrate_", &eNominalrate_);
27  bind("eCurrentConsumption_", &eCurrentConsumption_); /* current consumption rate */
28 
29  bind("eDVFS_enabled_", &eDVFS_enabled_); /* ON when DVFS is enabled */
30  bind("eDNS_enabled_", &eDNS_enabled_); /* ON when DNS is enabled */
31 
32 }
double eNominalrate_
Definition: dchost.h:40
double eLastUpdateTime_
Definition: dchost.h:57
double eCurrentConsumption_
Definition: dchost.h:41
double eConsumed_
Definition: dchost.h:39
int eDNS_enabled_
Definition: dchost.h:44
DcHost::~DcHost ( )
virtual

Definition at line 34 of file dchost.cc.

35 {
36  delete powerModel;
37 }
PowerModel * powerModel
Definition: dchost.h:34

Member Function Documentation

void DcHost::addResource ( DcResource res)
protectedvirtual

Reimplemented from ResourceProvider.

Definition at line 130 of file dchost.cc.

130  {
132  if(res->specification->getPowerModel()!=NULL){
133  powerModel->addComponent(res);
134  }
135 }
ResourceSpec * specification
Definition: dcresource.h:34
virtual void addResource(DcResource *res)
virtual void addComponent(DcResource *component)=0
PowerModel * getPowerModel()
Definition: resourcespec.cc:53
PowerModel * powerModel
Definition: dchost.h:34
int DcHost::command ( int  argc,
const char *const *  argv 
)
virtual

Reimplemented from ResourceProvider.

Definition at line 44 of file dchost.cc.

45 {
46  Tcl& tcl = Tcl::instance();
47 
48  if (argc == 2) {
49  if (strcmp(argv[1], "start") == 0) {
50 
51  /* start counting energy consumed */
53  eLastUpdateTime_ = Scheduler::instance().clock();
54  started_ = true;
55  return (TCL_OK);
56  } else if (strcmp(argv[1], "stop") == 0) {
57  /* update total energy consumed */
59  return (TCL_OK);
60  } else if (strcmp(argv[1], "print") == 0) {
61  /* print general info */
62  print();
63  return (TCL_OK);
64  }
65  } else if (argc == 3) {
66  if (strcmp(argv[1], "set-power-model") == 0) {
67  PowerModel* pModel = (PowerModel*) TclObject::lookup(argv[2]);
68  if (pModel == NULL) {
69  tcl.resultf("no such power model %s", argv[2]);
70  return(TCL_ERROR);
71  }
72  setPowerModel(pModel);
73  return(TCL_OK);
74  }
75  }
76  return (ResourceProvider::command(argc, argv));
77 }
void setPowerModel(PowerModel *pModel)
Definition: dchost.cc:39
virtual void print()
Definition: dchost.cc:79
virtual void updateEnergyAndConsumption()
Definition: dchost.cc:138
double eLastUpdateTime_
Definition: dchost.h:57
void setCurrentConsumption()
Definition: dchost.cc:102
virtual int command(int argc, const char *const *argv)
void DcHost::eUpdate ( )
protected

Definition at line 120 of file dchost.cc.

121 {
122  /* Get time spent since last update */
123  double etime = (Scheduler::instance().clock() - eLastUpdateTime_)/3600; /* time in hours */
124 
125  eConsumed_ += etime * eCurrentConsumption_;
126  eLastUpdateTime_ = Scheduler::instance().clock();
127 
128 }
double eLastUpdateTime_
Definition: dchost.h:57
double eCurrentConsumption_
Definition: dchost.h:41
double eConsumed_
Definition: dchost.h:39
void DcHost::print ( )
virtual

Implements ResourceProvider.

Definition at line 79 of file dchost.cc.

79  {
80  std::cout << "DcHost:\t";
81  std::cout << id_;
82  std::cout << "\n";
83  std::cout << "Resources:\n";
84  std::vector <std::vector<DcResource*> >::iterator iter_out;
85  for(iter_out = resource_list.begin(); iter_out!=resource_list.end() ;iter_out++){
86  std::vector <DcResource*>::iterator iter;
87  for (iter = iter_out->begin(); iter!=iter_out->end(); iter++)
88  {
89  (*iter)->print();
90  }
91  }
92  std::cout << "\n";
93 
94 }
std::vector< std::vector< DcResource * > > resource_list
void DcHost::printTasklist ( )
virtual

Reimplemented from ResourceProvider.

Definition at line 96 of file dchost.cc.

96  {
97  std::vector<CloudTask *>::iterator iter;
98  std::cout <<"Host " <<this->id_ << "\n";
100 }
virtual void printTasklist()
void DcHost::setCurrentConsumption ( )
protected

Definition at line 102 of file dchost.cc.

103 {
104  double * predictors = new double[LastResType+1];
105  bool idle = true;
106  for(int i = Computing; i <= LastResType; i++){
107  predictors[i]=updateResTypeUtil(static_cast<res_type>(i));
108  if(predictors[i]!=0){
109  idle=false;
110  }
111  }
112  if((eDNS_enabled_) && (idle)){
114  } else {
115  eCurrentConsumption_ = powerModel->estimate(4,predictors);
116  }
117  delete[] predictors;
118 }
double updateResTypeUtil(res_type type)
virtual double estimate(int size, double *predictors)=0
double eCurrentConsumption_
Definition: dchost.h:41
PowerModel * powerModel
Definition: dchost.h:34
int eDNS_enabled_
Definition: dchost.h:44
void DcHost::setPowerModel ( PowerModel pModel)
protected

Definition at line 39 of file dchost.cc.

39  {
40  powerModel = pModel;
41 }
PowerModel * powerModel
Definition: dchost.h:34
void DcHost::updateEnergyAndConsumption ( )
virtual

Implements ResourceProvider.

Definition at line 138 of file dchost.cc.

138  {
140  eUpdate();
141 }
void eUpdate()
Definition: dchost.cc:120
void setCurrentConsumption()
Definition: dchost.cc:102

Member Data Documentation

double DcHost::eConsumed_

total W of energy consumed

Definition at line 39 of file dchost.h.

double DcHost::eCurrentConsumption_

current consumption rate

Definition at line 41 of file dchost.h.

int DcHost::eDNS_enabled_

ON when dynamic shutdown is enabled

Definition at line 44 of file dchost.h.

double DcHost::eLastUpdateTime_
protected

Definition at line 57 of file dchost.h.

double DcHost::eNominalrate_

nominal consumption rate at full load at max CPU frequency

Definition at line 40 of file dchost.h.

PowerModel* DcHost::powerModel

Definition at line 34 of file dchost.h.

DcRack* DcHost::rack_

Definition at line 33 of file dchost.h.


The documentation for this class was generated from the following files: