#include <mcache.h>
Inheritance diagram for MediaPage:


Public Types | |
| enum | { FETCHLOCK = 1, XMITLOCK = 2 } |
Public Member Functions | |
| MediaPage (const char *n, int s, double mt, double et, double a, int l) | |
| virtual | ~MediaPage () |
| virtual WebPageType | type () const |
| virtual void | print_info (char *buf) |
| int | num_layer () const |
| HitCount * | get_hit_count (int layer) |
| void | hit_layer (int layer) |
| int | layer_size (int layer) |
| void | add_segment (int layer, const MediaSegment &s) |
| int | evict_tail_segment (int layer, int size) |
| void | add_layer (int layer) |
| char * | print_layer (int layer) |
| MediaSegmentList | is_available (int layer, const MediaSegment &s) |
| MediaSegment | next_available (int layer, const MediaSegment &s) |
| MediaSegment | next_overlap (int layer, const MediaSegment &s) |
| void | lock () |
| void | unlock () |
| int | is_locked () |
| void | tlock () |
| void | tunlock () |
| int | is_tlocked () |
| int | is_complete () |
| void | set_complete () |
| void | create () |
| int | realsize () const |
| void | name (char *buf) |
| double & | mtime () |
| double & | etime () |
| double & | age () |
| HttpApp * | server () |
| void | validate (double mtime) |
| void | invalidate (double mtime) |
| int | is_valid () const |
| int | is_header_valid () const |
| void | set_valid_hdr () |
| void | set_uncacheable () |
| int | is_uncacheable () |
| void | set_unread () |
| void | set_read () |
| int | is_unread () |
| int | is_server_down () |
| void | server_down () |
| int & | counter () |
| int | count_inval (int a, int th) |
| int | count_request (int b, int th) |
| void | set_mpush (double time) |
| void | clear_mpush () |
| int | is_mpush () |
| double | mpush_time () |
| int | size () const |
| int & | id () |
Static Public Member Functions | |
| void | split_name (const char *name, PageID &id) |
| void | print_name (char *name, PageID &id) |
Static Public Attributes | |
| int | PUSHALL_ = 0 |
Protected Member Functions | |
| void | set_complete_layer (int layer) |
| int | is_complete_layer (int layer) |
| void | set_page_state (int state) |
| void | clear_page_state (int state) |
| void | set_page_action (int action) |
| void | clear_page_action (int action) |
Protected Attributes | |
| MediaSegmentList | layer_ [MAX_LAYER] |
| int | flags_ [MAX_LAYER] |
| HitCount * | hc_ [MAX_LAYER] |
| int | num_layer_ |
| int | locked_ |
| int | realsize_ |
| HttpApp * | server_ |
| double | age_ |
| double | mtime_ |
| double | etime_ |
| int | status_ |
| int | counter_ |
| double | mpushTime_ |
| int | size_ |
| int | id_ |
|
|
Definition at line 148 of file mcache.h.
|
|
||||||||||||||||||||||||||||
|
Definition at line 38 of file mcache.cc. References flags_, hc_, and num_layer_.
00039 : 00040 ClientPage(n, s, mt, et, a), num_layer_(l), locked_(0), realsize_(0) 00041 { 00042 for (int i = 0; i < num_layer_; i++) { 00043 hc_[i] = new HitCount(this, i); 00044 flags_[i] = 0; 00045 } 00046 } |
|
|
Definition at line 48 of file mcache.cc. References MediaSegmentList::destroy(), hc_, layer_, and num_layer_.
00049 {
00050 int i;
00051 for (i = 0; i < num_layer_; i++) {
00052 // Delete hit count list
00053 // These hit count records should have already been removed
00054 // from the cache's hit count list.
00055 assert((hc_[i]->prev() == NULL) && (hc_[i]->next() == NULL));
00056 delete hc_[i];
00057 // Delete media segment list
00058 layer_[i].destroy();
00059 }
00060 }
|
Here is the call graph for this function:

|
|
Definition at line 116 of file mcache.h. References num_layer_.
00116 {
00117 assert((layer >= 0) && (layer < num_layer_));
00118 num_layer_ = (num_layer_ < layer) ? layer : num_layer_;
00119 }
|
|
||||||||||||
|
Definition at line 83 of file mcache.cc. References MediaSegmentList::add(), MediaSegment::datasize(), MediaSegment::is_last(), layer_, MAX_LAYER, realsize_, and set_complete_layer(). Referenced by MClientPagePool::add_segment(), and create().
|
Here is the call graph for this function:

|
|
Definition at line 108 of file pagepool.h. References ClientPage::age_. Referenced by HttpUpdateData::PageRec::copy(), ClientPagePool::get_age(), and ClientPage::print_info().
00108 { return age_; }
|
|
|
Definition at line 197 of file pagepool.h. References ClientPage::clear_page_action(), and HTTP_MANDATORY_PUSH. Referenced by HttpMInvalCache::command(), HttpYucInvalServer::command(), and HttpMInvalCache::recv_upd().
00197 { clear_page_action(HTTP_MANDATORY_PUSH); }
|
Here is the call graph for this function:

|
|
Definition at line 215 of file pagepool.h. References ClientPage::status_. Referenced by ClientPage::clear_mpush().
|
|
|
Definition at line 209 of file pagepool.h. References ClientPage::status_. Referenced by ClientPage::invalidate(), ClientPage::server_down(), ClientPage::set_read(), ClientPage::set_valid_hdr(), and ClientPage::validate().
|
|
||||||||||||
|
Definition at line 174 of file pagepool.h. References ClientPage::counter_, and ClientPage::PUSHALL_. Referenced by HttpYucInvalServer::command(), HttpMInvalCache::process_inv(), and HttpMInvalCache::recv_upd().
|
|
||||||||||||
|
Definition at line 184 of file pagepool.h. References ClientPage::counter_, and ClientPage::PUSHALL_. Referenced by HttpMInvalCache::command(), and HttpYucInvalServer::command().
|
|
|
Definition at line 170 of file pagepool.h. References ClientPage::counter_, and ClientPage::PUSHALL_. Referenced by ClientPagePool::add_page(), HttpMInvalCache::command(), HttpYucInvalServer::command(), HttpMInvalCache::process_inv(), and HttpMInvalCache::recv_upd().
|
|
|
Definition at line 70 of file mcache.cc. References add_segment(), MediaSegmentList::destroy(), layer_, MAX_LAYER, num_layer_, realsize_, set_complete_layer(), and Page::size_. Referenced by MClientPagePool::fill_page().
00071 {
00072 assert((num_layer_ >= 0) && (num_layer_ < MAX_LAYER));
00073 int i, sz = size_ / num_layer_;
00074 for (i = 0; i < num_layer_; i++) {
00075 // Delete whatever that was there.
00076 layer_[i].destroy();
00077 add_segment(i, MediaSegment(0, sz));
00078 set_complete_layer(i);
00079 }
00080 realsize_ = size_;
00081 }
|
Here is the call graph for this function:

|
|
Definition at line 107 of file pagepool.h. References ClientPage::etime_. Referenced by ClientPagePool::get_etime(), ClientPage::print_info(), and ClientPagePool::set_etime().
00107 { return etime_; }
|
|
||||||||||||
|
Definition at line 109 of file mcache.cc. References MediaSegmentList::evict_tail(), is_locked(), is_tlocked(), layer_, MAX_LAYER, ClientPage::name(), and realsize_. Referenced by MClientPagePool::repl_finegrain().
00110 {
00111 if (is_locked() || is_tlocked())
00112 return 0;
00113
00114 assert((layer >= 0) && (layer < MAX_LAYER));
00115 //#ifdef MCACHE_DEBUG
00116 #if 0
00117 char buf[20];
00118 name(buf);
00119 fprintf(stderr, "Page %s evicted layer %d: ", buf, layer);
00120 #endif
00121 int sz = layer_[layer].evict_tail(size);
00122 realsize_ -= sz;
00123 //#ifdef MCACHE_DEBUG
00124 #if 0
00125 fprintf(stderr, "\n");
00126 #endif
00127 return sz;
00128 }
|
Here is the call graph for this function:

|
|
Definition at line 99 of file mcache.h. References hc_, and num_layer_. Referenced by MClientPagePool::add_segment(), MClientPagePool::force_remove(), MClientPagePool::hc_update(), and MClientPagePool::repl_atomic().
00099 {
00100 assert((layer >= 0) && (layer < num_layer_));
00101 return hc_[layer];
00102 }
|
|
|
Definition at line 103 of file mcache.h. References hc_, layer_, num_layer_, Page::size_, and HitCount::update(). Referenced by MClientPagePool::hc_update().
|
Here is the call graph for this function:

|
|
Definition at line 38 of file pagepool.h. References Page::id_. Referenced by TracePagePool::add_page(), ClientPage::name(), and ServerPage::ServerPage().
00038 { return id_; }
|
|
|
Definition at line 120 of file pagepool.h. References ClientPage::clear_page_state(), HTTP_VALID_HEADER, HTTP_VALID_PAGE, and ClientPage::mtime_. Referenced by HttpMInvalCache::process_inv().
00120 {
00121 if (mtime_ >= mtime)
00122 return;
00123 clear_page_state(HTTP_VALID_PAGE);
00124 clear_page_state(HTTP_VALID_HEADER);
00125 mtime_ = mtime;
00126 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 124 of file mcache.h. References MediaSegmentList::check_holes(), layer_, and MAX_LAYER. Referenced by MediaCache::get_data().
00124 {
00125 assert((layer >= 0) && (layer < MAX_LAYER));
00126 return layer_[layer].check_holes(s);
00127 }
|
Here is the call graph for this function:

|
|
Definition at line 92 of file mcache.cc. References is_complete_layer(), layer_, MediaSegmentList::length(), and num_layer_.
00093 {
00094 // Consider a page finished when all NON-EMPTY layers are
00095 // marked as "completed"
00096 for (int i = 0; i < num_layer_; i++)
00097 if (!is_complete_layer(i) && (layer_[i].length() > 0))
00098 return 0;
00099 return 1;
00100 }
|
Here is the call graph for this function:

|
|
Definition at line 173 of file mcache.h. References flags_. Referenced by is_complete().
00173 {
00174 return flags_[layer] == 1;
00175 }
|
|
|
Definition at line 130 of file pagepool.h. References HTTP_VALID_HEADER, HTTP_VALID_PAGE, and ClientPage::status_. Referenced by HttpPercInvalCache::command(), and HttpPercInvalCache::recv_inv_filter().
00130 {
00131 return ((status_ & HTTP_VALID_PAGE) ||
00132 (status_ & HTTP_VALID_HEADER));
00133 }
|
|
|
Definition at line 153 of file mcache.h. References FETCHLOCK, and locked_. Referenced by evict_tail_segment(), MediaCache::get_data(), MClientPagePool::repl_atomic(), and MClientPagePool::repl_finegrain().
|
|
|
Definition at line 198 of file pagepool.h. References HTTP_MANDATORY_PUSH, and ClientPage::status_. Referenced by ClientPagePool::add_page(), HttpYucInvalServer::command(), and HttpMInvalCache::recv_upd().
00198 { return status_ & HTTP_MANDATORY_PUSH; }
|
|
|
Definition at line 158 of file pagepool.h. References HTTP_SERVER_DOWN, and ClientPage::status_.
00158 { return (status_ & HTTP_SERVER_DOWN); }
|
|
|
Definition at line 157 of file mcache.h. References locked_, and XMITLOCK. Referenced by evict_tail_segment(), MClientPagePool::repl_atomic(), and MClientPagePool::repl_finegrain().
|
|
|
Definition at line 144 of file pagepool.h. References HTTP_UNCACHEABLE, and ClientPage::status_. Referenced by ClientPage::print_info().
00144 {
00145 return (status_ & HTTP_UNCACHEABLE);
00146 }
|
|
|
Definition at line 156 of file pagepool.h. References HTTP_UNREAD_PAGE, and ClientPage::status_. Referenced by HttpMInvalCache::command().
00156 { return (status_ & HTTP_UNREAD_PAGE); }
|
|
|
Definition at line 127 of file pagepool.h. References HTTP_VALID_PAGE, and ClientPage::status_. Referenced by HttpApp::command(), and HttpMInvalCache::recv_inv_filter().
00127 {
00128 return (status_ & HTTP_VALID_PAGE);
00129 }
|
|
|
Definition at line 109 of file mcache.h. References layer_, MediaSegmentList::length(), and num_layer_. Referenced by MClientPagePool::add_segment(), MediaServer::get_next_segment(), and MClientPagePool::repl_finegrain().
|
Here is the call graph for this function:

|
|
Definition at line 151 of file mcache.h. References FETCHLOCK, and locked_. Referenced by MClientPagePool::fill_page().
|
|
|
Definition at line 199 of file pagepool.h. References ClientPage::mpushTime_. Referenced by ClientPagePool::add_page(), HttpYucInvalServer::command(), and HttpMInvalCache::recv_upd().
00199 { return mpushTime_; }
|
|
|
Definition at line 106 of file pagepool.h. References ClientPage::mtime_. Referenced by HttpUpdateData::PageRec::copy(), ClientPagePool::get_mtime(), ClientPage::print_info(), HttpMInvalCache::process_inv(), HttpPercInvalCache::recv_inv_filter(), HttpMInvalCache::recv_inv_filter(), HttpMInvalCache::recv_upd(), and ClientPagePool::set_mtime().
00106 { return mtime_; }
|
|
|
Definition at line 100 of file pagepool.cc. References Page::id(), and ClientPage::server_. Referenced by ClientPagePool::add_page(), MClientPagePool::cache_replace(), HttpUpdateData::PageRec::copy(), evict_tail_segment(), HitCountList::print(), MClientPagePool::repl_atomic(), and MClientPagePool::repl_finegrain().
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 132 of file mcache.h. References MediaSegmentList::get_nextseg(), layer_, and MAX_LAYER.
00132 {
00133 assert((layer >= 0) && (layer < MAX_LAYER));
00134 return layer_[layer].get_nextseg(s);
00135 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 136 of file mcache.h. References MediaSegment::end(), MediaSegmentList::get_nextseg(), MediaSegment::is_last(), layer_, MAX_LAYER, MediaSegment::set_last(), and MediaSegment::start(). Referenced by MediaCache::get_data(), and MediaServer::get_next_segment().
00136 {
00137 assert((layer >= 0) && (layer < MAX_LAYER));
00138 MediaSegment s1 = layer_[layer].get_nextseg(s);
00139 if ((s1.end() <= s.start()) || (s1.start() >= s.end())) {
00140 MediaSegment s;
00141 if (s1.is_last())
00142 s.set_last();
00143 return s;
00144 } else
00145 return s1;
00146 }
|
Here is the call graph for this function:

|
|
Definition at line 97 of file mcache.h. References num_layer_. Referenced by MClientPagePool::add_segment(), MediaClient::command(), MediaCache::command(), HttpApp::command(), MClientPagePool::force_remove(), MediaServer::get_next_segment(), and MClientPagePool::repl_atomic().
00097 { return num_layer_; }
|
|
|
Reimplemented from ClientPage. Definition at line 62 of file mcache.cc. References num_layer_, and ClientPage::print_info().
00063 {
00064 ClientPage::print_info(buf);
00065 buf += strlen(buf);
00066 sprintf(buf, " pgtype MEDIA layer %d", num_layer_);
00067 }
|
Here is the call graph for this function:

|
|
Definition at line 120 of file mcache.h. References MediaSegmentList::dump2buf(), layer_, and num_layer_. Referenced by MediaClient::command(), and MediaCache::command().
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 72 of file pagepool.cc. References PageID::id_, and PageID::s_.
|
|
|
Definition at line 167 of file mcache.h. References realsize_. Referenced by MClientPagePool::fill_page(), MClientPagePool::force_remove(), MClientPagePool::repl_atomic(), and MClientPagePool::repl_finegrain().
00167 { return realsize_; }
|
|
|
Definition at line 109 of file pagepool.h. References ClientPage::server_. Referenced by ClientPagePool::invalidate_server(), and HttpMInvalCache::process_inv().
00109 { return server_; }
|
|
|
Definition at line 159 of file pagepool.h. References ClientPage::clear_page_state(), HTTP_SERVER_DOWN, HTTP_VALID_HEADER, HTTP_VALID_PAGE, and ClientPage::set_page_state(). Referenced by ClientPagePool::invalidate_server().
00159 {
00160 // Set page as invalid
00161 // Don't change mtime, only change page status
00162 clear_page_state(HTTP_VALID_PAGE);
00163 clear_page_state(HTTP_VALID_HEADER);
00164 set_page_state(HTTP_SERVER_DOWN);
00165 }
|
Here is the call graph for this function:

|
|
Definition at line 102 of file mcache.cc. References num_layer_, and set_complete_layer().
00103 {
00104 for (int i = 0; i < num_layer_; i++)
00105 set_complete_layer(i);
00106 }
|
Here is the call graph for this function:

|
|
Definition at line 170 of file mcache.h. References flags_. Referenced by add_segment(), create(), and set_complete().
00170 {
00171 flags_[layer] = 1;
00172 }
|
|
|
Definition at line 194 of file pagepool.h. References HTTP_MANDATORY_PUSH, ClientPage::mpushTime_, and ClientPage::set_page_action(). Referenced by ClientPagePool::add_page(), HttpMInvalCache::command(), and HttpYucInvalServer::command().
00194 {
00195 set_page_action(HTTP_MANDATORY_PUSH), mpushTime_ = time;
00196 }
|
Here is the call graph for this function:

|
|
Definition at line 212 of file pagepool.h. References ClientPage::status_. Referenced by ClientPage::set_mpush().
00212 {
00213 status_ |= action;
00214 }
|
|
|
Definition at line 206 of file pagepool.h. References ClientPage::status_. Referenced by ClientPage::server_down(), ClientPage::set_uncacheable(), ClientPage::set_unread(), ClientPage::set_valid_hdr(), and ClientPage::validate().
00206 {
00207 status_ |= state;
00208 }
|
|
|
Definition at line 153 of file pagepool.h. References ClientPage::clear_page_state(), and HTTP_UNREAD_PAGE. Referenced by HttpMInvalCache::command().
00153 {
00154 clear_page_state(HTTP_UNREAD_PAGE);
00155 }
|
Here is the call graph for this function:

|
|
Definition at line 141 of file pagepool.h. References HTTP_UNCACHEABLE, and ClientPage::set_page_state(). Referenced by ClientPagePool::enter_page(), and MClientPagePool::enter_page().
00141 {
00142 set_page_state(HTTP_UNCACHEABLE);
00143 }
|
Here is the call graph for this function:

|
|
Definition at line 150 of file pagepool.h. References HTTP_UNREAD_PAGE, and ClientPage::set_page_state(). Referenced by HttpMInvalCache::command(), and HttpMInvalCache::recv_upd().
00150 {
00151 set_page_state(HTTP_UNREAD_PAGE);
00152 }
|
Here is the call graph for this function:

|
|
Definition at line 134 of file pagepool.h. References ClientPage::clear_page_state(), HTTP_SERVER_DOWN, HTTP_VALID_HEADER, HTTP_VALID_PAGE, and ClientPage::set_page_state(). Referenced by ClientPagePool::enter_metadata().
00134 {
00135 // XXX page invalid, but only header valid
00136 clear_page_state(HTTP_SERVER_DOWN);
00137 clear_page_state(HTTP_VALID_PAGE);
00138 set_page_state(HTTP_VALID_HEADER);
00139 }
|
Here is the call graph for this function:

|
|
Definition at line 37 of file pagepool.h. References Page::size_. Referenced by HttpUpdateData::add(), HttpUpdateData::PageRec::copy(), MClientPagePool::fill_page(), MClientPagePool::force_remove(), ClientPagePool::get_size(), Page::Page(), ClientPage::print_info(), and MClientPagePool::remove_page().
00037 { return size_; }
|
|
||||||||||||
|
Definition at line 77 of file pagepool.cc. References abort(), PageID::id_, and PageID::s_. Referenced by ClientPagePool::add_page(), CompMathPagePool::command(), ClientPagePool::get_page(), MediaServer::get_piq(), and ClientPagePool::remove_page().
00078 {
00079 char *buf = new char[strlen(name)+1];
00080 strcpy(buf, name);
00081 char *tmp = strtok(buf, ":");
00082 id.s_ = (HttpApp*)TclObject::lookup(tmp);
00083 if (id.s_ == NULL) {
00084 fprintf(stderr, "Non-exitent server name for page %s\n", name);
00085 abort();
00086 }
00087 tmp = strtok(NULL, ":");
00088 id.id_ = atol(tmp);
00089 delete []buf;
00090 }
|
Here is the call graph for this function:

|
|
Definition at line 155 of file mcache.h. References locked_, and XMITLOCK. Referenced by MediaCache::command().
|
|
|
Definition at line 156 of file mcache.h. References locked_, and XMITLOCK. Referenced by MediaCache::command().
|
|
|
Reimplemented from ClientPage. Definition at line 95 of file mcache.h. References MEDIA, and WebPageType. Referenced by MediaCache::command(), and HttpApp::command().
00095 { return MEDIA; }
|
|
|
Definition at line 152 of file mcache.h. References FETCHLOCK, and locked_. Referenced by MediaCache::command(), and MClientPagePool::fill_page().
|
|
|
Definition at line 112 of file pagepool.h. References abort(), ClientPage::clear_page_state(), HTTP_SERVER_DOWN, HTTP_VALID_PAGE, ClientPage::mtime_, and ClientPage::set_page_state().
00112 {
00113 if (mtime_ >= mtime)
00114 abort(); // This shouldn't happen!
00115 // Clear server down bit
00116 clear_page_state(HTTP_SERVER_DOWN);
00117 set_page_state(HTTP_VALID_PAGE);
00118 mtime_ = mtime;
00119 }
|
Here is the call graph for this function:

|
|
Definition at line 220 of file pagepool.h. Referenced by ClientPage::age(). |
|
|
Definition at line 224 of file pagepool.h. Referenced by ClientPage::count_inval(), ClientPage::count_request(), and ClientPage::counter(). |
|
|
Definition at line 222 of file pagepool.h. Referenced by ClientPage::etime(). |
|
|
Definition at line 178 of file mcache.h. Referenced by is_complete_layer(), MediaPage(), and set_complete_layer(). |
|
|
Definition at line 179 of file mcache.h. Referenced by get_hit_count(), hit_layer(), MediaPage(), and ~MediaPage(). |
|
|
Definition at line 43 of file pagepool.h. Referenced by ClientPage::ClientPage(), Page::id(), and ServerPage::ServerPage(). |
|
|
Definition at line 177 of file mcache.h. Referenced by add_segment(), create(), evict_tail_segment(), hit_layer(), is_available(), is_complete(), layer_size(), next_available(), next_overlap(), print_layer(), and ~MediaPage(). |
|
|
Definition at line 181 of file mcache.h. Referenced by is_locked(), is_tlocked(), lock(), tlock(), tunlock(), and unlock(). |
|
|
Definition at line 225 of file pagepool.h. Referenced by ClientPage::mpush_time(), and ClientPage::set_mpush(). |
|
|
Definition at line 221 of file pagepool.h. Referenced by ClientPage::invalidate(), ClientPage::mtime(), and ClientPage::validate(). |
|
|
Definition at line 180 of file mcache.h. Referenced by add_layer(), create(), get_hit_count(), hit_layer(), is_complete(), layer_size(), MediaPage(), num_layer(), print_info(), print_layer(), set_complete(), and ~MediaPage(). |
|
|
Definition at line 43 of file pagepool.cc. Referenced by PagePool::command(), ClientPage::count_inval(), ClientPage::count_request(), and ClientPage::counter(). |
|
|
Definition at line 182 of file mcache.h. Referenced by add_segment(), create(), evict_tail_segment(), and realsize(). |
|
|
Definition at line 219 of file pagepool.h. Referenced by ClientPage::ClientPage(), ClientPage::name(), and ClientPage::server(). |
|
|
Definition at line 42 of file pagepool.h. Referenced by create(), hit_layer(), Page::Page(), ServerPage::size(), and Page::size(). |
|
1.3.3