GreenCloud Simulator
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ParetoCloudUser Class Reference
Inheritance diagram for ParetoCloudUser:
Inheritance graph
[legend]
Collaboration diagram for ParetoCloudUser:
Collaboration graph
[legend]

Public Member Functions

 ParetoCloudUser ()
 
virtual double next_interval (int &)
 
virtual void timeout ()
 
int on ()
 
int command (int argc, const char *const *argv)
 

Protected Member Functions

void init ()
 

Protected Attributes

double ontime_
 
double offtime_
 
double rate_
 
double interval_
 
double burstlen_
 
double shape_
 
unsigned int rem_
 
double p1_
 
double p2_
 
int on_
 
RNG * rng_
 

Additional Inherited Members

- Private Member Functions inherited from CloudUser
 CloudUser ()
 
virtual ~CloudUser ()
 
CloudTaskcreateTask ()
 
void setRandomized (int i)
 
int process_command (int argc, const char *const *argv)
 
void printTasksStatus ()
 
void postSimulationTestTasks ()
 
void calculateStatistics ()
 
- Private Attributes inherited from CloudUser
int id_
 
double tskmips_
 
double memory_
 
double storage_
 
unsigned int tsksize_
 
double tskmaxduration_
 
int toutputsize_
 
int tintercom_
 
int randomized_
 
double mean_response_time_
 
double sd_response_time_
 
int unfinished_tasks_
 
DataCenterdc_
 
int taskcounter_
 
ExponentialRandomVariable random_tskmips_
 
std::vector< TaskInfo * > tasks_info_
 

Detailed Description

Definition at line 14 of file paretoclouduser.cc.

Constructor & Destructor Documentation

ParetoCloudUser::ParetoCloudUser ( )

Definition at line 83 of file paretoclouduser.cc.

83  : rng_(NULL)
84 {
85  bind_time("burst_time_", &ontime_);
86  bind_time("idle_time_", &offtime_);
87  bind_bw("rate_", &rate_);
88  bind("shape_", &shape_);
89  bind("packetSize_", &size_);
90 }

Member Function Documentation

int ParetoCloudUser::command ( int  argc,
const char *const *  argv 
)

Definition at line 57 of file paretoclouduser.cc.

57  {
58 
59  Tcl& tcl = Tcl::instance();
60  if(argc==3){
61  if (strcmp(argv[1], "use-rng") == 0) {
62  rng_ = (RNG*)TclObject::lookup(argv[2]);
63  if (rng_ == 0) {
64  tcl.resultf("no such RNG %s", argv[2]);
65  return(TCL_ERROR);
66  }
67  return (TCL_OK);
68  }
69  //ADDED CODE
70  else if (strcmp(argv[1], "join-datacenter") == 0) {
71  DataCenter *dc = dynamic_cast<DataCenter*> (TclObject::lookup(argv[2]));
72  if(dc){
73  dc_ = dc;
74  return (TCL_OK);
75  }
76  return (TCL_ERROR);
77  }
78  //ADDED CODE
79  }
80  return Application::command(argc,argv);
81 }
DataCenter * dc_
Definition: clouduser.h:45
void ParetoCloudUser::init ( )
protected

Definition at line 92 of file paretoclouduser.cc.

93 {
94  interval_ = (double)(size_ << 3)/(double)rate_;
96  rem_ = 0;
97  on_ = 0;
98  p1_ = burstlen_ * (shape_ - 1.0)/shape_;
99  p2_ = offtime_ * (shape_ - 1.0)/shape_;
100 }
unsigned int rem_
double ParetoCloudUser::next_interval ( int &  size)
virtual

Definition at line 102 of file paretoclouduser.cc.

103 {
104 
105  double t = interval_;
106 
107  on_ = 1;
108  if (rem_ == 0) {
109  /* compute number of packets in next burst */
110  if(rng_ == 0){
111  rem_ = int(Random::pareto(p1_, shape_) + .5);
112  }
113  else{
114  // Added by Debojyoti Dutta 13th October 2000
115  rem_ = int(rng_->pareto(p1_, shape_) + .5);
116  }
117  /* make sure we got at least 1 */
118  if (rem_ == 0)
119  rem_ = 1;
120  /* start of an idle period, compute idle time */
121  if(rng_ == 0){
122  t += Random::pareto(p2_, shape_);
123  }
124  else{
125  // Added by Debojyoti Dutta 13th October 2000
126  t += rng_->pareto(p2_, shape_);
127  }
128  on_ = 0;
129  }
130  rem_--;
131 
132  size = size_;
133  return(t);
134 
135 }
unsigned int rem_
int ParetoCloudUser::on ( )
inline

Definition at line 19 of file paretoclouduser.cc.

19 { return on_ ; }
void ParetoCloudUser::timeout ( )
virtual

Definition at line 137 of file paretoclouduser.cc.

138 {
139  if (! running_)
140  return;
141 
142  /* send a packet */
143  dc_->receivedTsk(size_, createTask());
144  /* figure out when to send the next one */
145  nextPkttime_ = next_interval(size_);
146  /* schedule it */
147  if (nextPkttime_ > 0)
148  timer_.resched(nextPkttime_);
149  else
150  running_ = 0;
151 }
CloudTask * createTask()
Definition: clouduser.cc:19
virtual void receivedTsk(int tsksize, CloudTask *pTask, const char *flags=0)
Definition: datacenter.cc:161
virtual double next_interval(int &)
DataCenter * dc_
Definition: clouduser.h:45

Member Data Documentation

double ParetoCloudUser::burstlen_
protected

Definition at line 28 of file paretoclouduser.cc.

double ParetoCloudUser::interval_
protected

Definition at line 27 of file paretoclouduser.cc.

double ParetoCloudUser::offtime_
protected

Definition at line 25 of file paretoclouduser.cc.

int ParetoCloudUser::on_
protected

Definition at line 37 of file paretoclouduser.cc.

double ParetoCloudUser::ontime_
protected

Definition at line 24 of file paretoclouduser.cc.

double ParetoCloudUser::p1_
protected

Definition at line 31 of file paretoclouduser.cc.

double ParetoCloudUser::p2_
protected

Definition at line 34 of file paretoclouduser.cc.

double ParetoCloudUser::rate_
protected

Definition at line 26 of file paretoclouduser.cc.

unsigned int ParetoCloudUser::rem_
protected

Definition at line 30 of file paretoclouduser.cc.

RNG* ParetoCloudUser::rng_
protected

Definition at line 40 of file paretoclouduser.cc.

double ParetoCloudUser::shape_
protected

Definition at line 29 of file paretoclouduser.cc.


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