#include <webserver.h>
Inheritance diagram for WebServer:


Public Types | |
| enum | TimerStatus { TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING } |
Public Member Functions | |
| WebServer (WebTrafPool *) | |
| void | set_node (Node *) |
| Node * | get_node () |
| int | get_nid () |
| void | set_rate (double) |
| void | set_mode (int) |
| void | set_queue_limit (int) |
| double | job_arrival (int, Node *, Agent *, Agent *, int, void *) |
| void | sched (double delay) |
| void | resched (double delay) |
| void | cancel () |
| void | force_cancel () |
| int | status () |
Protected Member Functions | |
| virtual void | handle (Event *) |
Protected Attributes | |
| int | status_ |
| Event | event_ |
Private Member Functions | |
| virtual void | expire (Event *e) |
| double | job_departure () |
| void | schedule_next_job () |
Private Attributes | |
| WebTrafPool * | web_pool_ |
| Node * | node |
| double | rate_ |
| int | mode_ |
| job_s * | head |
| job_s * | tail |
| int | queue_size_ |
| int | queue_limit_ |
| int | busy_ |
|
|
Definition at line 66 of file timer-handler.h.
00066 { TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING };
|
|
|
Definition at line 34 of file webserver.cc. References busy_, head, queue_limit_, queue_size_, set_mode(), set_rate(), tail, and web_pool_.
00034 {
00035 web_pool_ = webpool;
00036
00037 // clean busy flag
00038 busy_ = 0;
00039
00040 // Initialize function flag:
00041 // 0: there's no server processing delay
00042 // 1: server processing delay from FCFS scheduling policy
00043 // 2: server processing delay from STF scheduling policy
00044 set_mode(0);
00045
00046 // Initialize server processing raste
00047 set_rate(1);
00048
00049 // initialize the job queue
00050 head = tail = NULL;
00051 queue_size_ = 0;
00052 queue_limit_ = 0;
00053
00054 //cancel();
00055 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Implements TimerHandler. Definition at line 191 of file webserver.cc. References job_departure().
00191 {
00192 job_departure();
00193 }
|
Here is the call graph for this function:

|
|
Definition at line 60 of file timer-handler.h. References TimerHandler::_cancel(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING. Referenced by TcpAgent::cancel_rtx_timer(), TcpSessionAgent::cancel_rtx_timer(), TcpFsAgent::cancel_rtx_timer(), AbsTcpAgent::cancel_timer(), TcpAgent::cancel_timers(), TcpSessionAgent::cancel_timers(), FullTcpAgent::cancel_timers(), TcpFsAgent::cancel_timers(), SinkAgent::command(), UnslottedAlohaMac::end_of_contention(), GAFAgent::processDiscoveryMsg(), RTPAgent::rate_change(), TfrcAgent::stop(), RTPAgent::stop(), and SinkAgent::stop().
00060 { // cancel!
00061 if (status_ == TIMER_PENDING) {
00062 _cancel();
00063 status_ = TIMER_IDLE;
00064 }
00065 }
|
Here is the call graph for this function:

|
|
Definition at line 74 of file webserver.cc. References node, and Node::nodeid(). Referenced by WebTrafPool::command(), and WebTrafPool::find_server().
|
Here is the call graph for this function:

|
|
Definition at line 83 of file webserver.cc. References node. Referenced by WebTrafPool::pickdst(), and LogWebTrafPool::pickdst().
00083 {
00084 return(node);
00085 }
|
|
|
Implements Handler. Reimplemented in EmpFtpTrafSession, EmpWebPage, EmpWebTrafSession, HBTimer, WebPage, and WebTrafSession. Definition at line 69 of file timer-handler.cc. References abort(), TimerHandler::expire(), TimerHandler::status_, TimerHandler::TIMER_HANDLING, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING. Referenced by WebTrafSession::handle(), WebPage::handle(), HBTimer::handle(), EmpWebTrafSession::handle(), EmpWebPage::handle(), and EmpFtpTrafSession::handle().
00070 {
00071 if (status_ != TIMER_PENDING) // sanity check
00072 abort();
00073 status_ = TIMER_HANDLING;
00074 expire(e);
00075 // if it wasn't rescheduled, it's done
00076 if (status_ == TIMER_HANDLING)
00077 status_ = TIMER_IDLE;
00078 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Definition at line 87 of file webserver.cc. References busy_, job_s::clnt, job_s::data, head, WebTrafPool::launchResp(), mode_, job_s::next, node, job_s::obj_id, queue_limit_, queue_size_, schedule_next_job(), job_s::size, job_s::snk, tail, job_s::tcp, and web_pool_. Referenced by WebTrafPool::command().
00087 {
00088 // There's no server processing delay
00089 if (! mode_) {
00090 web_pool_->launchResp(obj_id, node, clnt, tcp, snk, size, data);
00091
00092 return 1;
00093 }
00094
00095 //printf("%d %d\n", queue_limit_, queue_size_);
00096 if (!queue_limit_ || queue_size_ < queue_limit_) {
00097 // Insert the new job to the job queue
00098 job_s *new_job = new(job_s);
00099 new_job->obj_id = obj_id;
00100 new_job->clnt = clnt;
00101 new_job->tcp = tcp;
00102 new_job->snk = snk;
00103 new_job->size = size;
00104 new_job->data = data;
00105 new_job->next = NULL;
00106
00107 // always insert the new job to the tail.
00108 if (tail)
00109 tail->next = new_job;
00110 else
00111 head = new_job;
00112 tail = new_job;
00113
00114 queue_size_++;
00115 } else {
00116 // drop the incoming job
00117 //printf("server drop job\n");
00118 return 0;
00119 }
00120
00121 // Schedule the dequeue time when there's no job being processed
00122 if (!busy_)
00123 schedule_next_job();
00124
00125 return 1;
00126 }
|
Here is the call graph for this function:

|
|
Definition at line 129 of file webserver.cc. References job_s::clnt, job_s::data, head, WebTrafPool::launchResp(), job_s::next, node, job_s::obj_id, queue_size_, schedule_next_job(), job_s::size, job_s::snk, tail, job_s::tcp, and web_pool_. Referenced by expire().
00129 {
00130 if (head) {
00131 web_pool_->launchResp(head->obj_id, node, head->clnt, head->tcp, head->snk, head->size, head->data);
00132
00133 // delete the first job
00134 job_s *p = head;
00135 if (head->next)
00136 head = head->next;
00137 else
00138 head = tail = NULL;
00139
00140 delete(p);
00141 queue_size_--;
00142 }
00143
00144 // Schedule next job
00145 schedule_next_job();
00146 return 0;
00147 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Definition at line 149 of file webserver.cc. References busy_, job_s::clnt, job_s::data, head, mode_, job_s::next, job_s::obj_id, rate_, TimerHandler::resched(), job_s::size, and STF_DELAY. Referenced by job_arrival(), and job_departure().
00149 {
00150 job_s *p, *q;
00151
00152 if (head) {
00153 // do shortest task first scheduling
00154 if (mode_ == STF_DELAY) {
00155 // find the shortest task
00156 p = q = head;
00157 while (q) {
00158 if (p->size > q->size)
00159 p = q;
00160
00161 q = q->next;
00162 }
00163
00164 // exchange the queue head with the shortest job
00165 int obj_id = p->obj_id;
00166 Node *clnt = p->clnt;
00167 int size = p->size;
00168 void *data = p->data;
00169
00170 p->obj_id = head->obj_id;
00171 p->clnt = head->clnt;
00172 p->size = head->size;
00173 p->data = head->data;
00174
00175 head->obj_id = obj_id;
00176 head->clnt = clnt;
00177 head->size = size;
00178 head->data = data;
00179 }
00180
00181 // Schedule the processing timer
00182 double delay_ = head->size / rate_;
00183 resched(delay_);
00184 busy_ = 1;
00185 // printf("%d, %f, %f\n", head->size, rate_, delay_);
00186 } else
00187 busy_ = 0;
00188 }
|
Here is the call graph for this function:

|
|
Definition at line 63 of file webserver.cc. References mode_. Referenced by WebTrafPool::command(), and WebServer().
00063 {
00064 mode_ = s_mode;
00065 }
|
|
|
Definition at line 79 of file webserver.cc. References node. Referenced by WebTrafPool::command().
00079 {
00080 node = n;
00081 }
|
|
|
Definition at line 68 of file webserver.cc. References queue_limit_. Referenced by WebTrafPool::command().
00068 {
00069 queue_limit_ = limit;
00070 }
|
|
|
Definition at line 58 of file webserver.cc. References rate_. Referenced by WebTrafPool::command(), and WebServer().
00058 {
00059 rate_ = s_rate;
00060 }
|
|
|
|
Definition at line 103 of file webserver.h. Referenced by job_arrival(), schedule_next_job(), and WebServer(). |
|
|
Definition at line 75 of file timer-handler.h. Referenced by TimerHandler::_cancel(), TimerHandler::_sched(), WebPage::start(), and EmpWebPage::start(). |
|
|
Definition at line 94 of file webserver.h. Referenced by job_arrival(), job_departure(), schedule_next_job(), and WebServer(). |
|
|
Definition at line 91 of file webserver.h. Referenced by job_arrival(), schedule_next_job(), and set_mode(). |
|
|
Definition at line 82 of file webserver.h. Referenced by get_nid(), get_node(), job_arrival(), job_departure(), and set_node(). |
|
|
Definition at line 96 of file webserver.h. Referenced by job_arrival(), set_queue_limit(), and WebServer(). |
|
|
Definition at line 95 of file webserver.h. Referenced by job_arrival(), job_departure(), and WebServer(). |
|
|
Definition at line 85 of file webserver.h. Referenced by schedule_next_job(), and set_rate(). |
|
|
|
Definition at line 94 of file webserver.h. Referenced by job_arrival(), job_departure(), and WebServer(). |
|
|
Definition at line 79 of file webserver.h. Referenced by job_arrival(), job_departure(), and WebServer(). |
1.3.3