#include <pagepool.h>
Inheritance diagram for ClientPagePool:


Public Member Functions | |
| ClientPagePool () | |
| virtual | ~ClientPagePool () |
| virtual ClientPage * | enter_page (int argc, const char *const *argv) |
| virtual ClientPage * | enter_metadata (int argc, const char *const *argv) |
| virtual ClientPage * | enter_page (const char *name, int size, double mt, double et, double age) |
| virtual ClientPage * | enter_metadata (const char *name, int size, double mt, double et, double age) |
| virtual int | remove_page (const char *name) |
| void | invalidate_server (int server_id) |
| ClientPage * | get_page (const char *name) |
| int | get_mtime (const char *name, double &mt) |
| int | set_mtime (const char *name, double mt) |
| int | exist_page (const char *name) |
| int | get_size (const char *name, int &size) |
| int | get_age (const char *name, double &age) |
| int | get_etime (const char *name, double &et) |
| int | set_etime (const char *name, double et) |
| int | get_pageinfo (const char *name, char *buf) |
| virtual int | command (int argc, const char *const *argv) |
| int | num_pages () const |
| int | num_pages () const |
Protected Member Functions | |
| int | add_page (ClientPage *pg) |
| TclObject * | lookup_obj (const char *name) |
| TclObject * | lookup_obj (const char *name) |
Protected Attributes | |
| Tcl_HashTable * | namemap_ |
| int | num_pages_ |
| double | start_time_ |
| double | end_time_ |
| int | duration_ |
|
|
Definition at line 609 of file pagepool.cc. References namemap_.
00610 {
00611 namemap_ = new Tcl_HashTable;
00612 Tcl_InitHashTable(namemap_, 2);
00613 }
|
|
|
Definition at line 615 of file pagepool.cc. References namemap_.
|
|
|
Definition at line 738 of file pagepool.cc. References ClientPage::counter(), HTTP_MAXURLLEN, ClientPage::is_mpush(), ClientPage::mpush_time(), ClientPage::name(), namemap_, PagePool::num_pages_, ClientPage::set_mpush(), ClientPage::split_name(), and t1. Referenced by enter_page(), and MClientPagePool::enter_page().
00739 {
00740 if (pg == NULL)
00741 return -1;
00742
00743 char buf[HTTP_MAXURLLEN];
00744 pg->name(buf);
00745
00746 PageID t1;
00747 void* t2[2];
00748 ClientPage::split_name(buf, t1);
00749 t2[0] = (void *)t1.s_;
00750 t2[1] = (void *)t1.id_;
00751
00752 int newEntry = 1;
00753 Tcl_HashEntry *he = Tcl_CreateHashEntry(namemap_,
00754 (const char *)t2,
00755 &newEntry);
00756 if (he == NULL)
00757 return -1;
00758
00759 // XXX If cache replacement algorithm is added, should change
00760 // cache size here!!
00761 if (newEntry) {
00762 Tcl_SetHashValue(he, (ClientData)pg);
00763 num_pages_++;
00764 } else {
00765 // Replace the old one
00766 ClientPage *q = (ClientPage *)Tcl_GetHashValue(he);
00767 // XXX must copy the counter value
00768 pg->counter() = q->counter();
00769 // XXX must copy the mpush values
00770 if (q->is_mpush())
00771 pg->set_mpush(q->mpush_time());
00772 Tcl_SetHashValue(he, (ClientData)pg);
00773 delete q;
00774 }
00775 return 0;
00776 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from PagePool. Reimplemented in MClientPagePool. Definition at line 624 of file pagepool.cc. References PagePool::command(), namemap_, PagePool::num_pages_, and t1. Referenced by MClientPagePool::command().
00625 {
00626 Tcl& tcl = Tcl::instance();
00627 if (argc == 2) {
00628 if (strcmp(argv[1], "list-pages") == 0) {
00629 Tcl_HashEntry *he;
00630 Tcl_HashSearch hs;
00631 char *buf = new char[num_pages_*20];
00632 char *p = buf;
00633 for (he = Tcl_FirstHashEntry(namemap_, &hs);
00634 he != NULL;
00635 he = Tcl_NextHashEntry(&hs)) {
00636 int* t2 = (int*)Tcl_GetHashKey(namemap_, he);
00637 PageID t1(t2);
00638 #ifdef NEED_SUNOS_PROTOS
00639 sprintf(p, "%s:%-d ", t1.s_->name(),t1.id_);
00640 p += strlen(p);
00641 #else
00642 p += sprintf(p,"%s:%-d ",t1.s_->name(),t1.id_);
00643 #endif
00644 }
00645 tcl.resultf("%s", buf);
00646 delete []buf;
00647 return TCL_OK;
00648 }
00649 }
00650 return PagePool::command(argc, argv);
00651 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 729 of file pagepool.cc. References enter_page(), and ClientPage::set_valid_hdr().
00731 {
00732 ClientPage *pg = enter_page(name, size, mt, et, age);
00733 if (pg != NULL)
00734 pg->set_valid_hdr();
00735 return pg;
00736 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 721 of file pagepool.cc. References enter_page(), and ClientPage::set_valid_hdr(). Referenced by HttpPercInvalCache::command().
00722 {
00723 ClientPage *pg = enter_page(argc, argv);
00724 if (pg != NULL)
00725 pg->set_valid_hdr();
00726 return pg;
00727 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 708 of file pagepool.cc. References add_page().
00710 {
00711 ClientPage* pg = new ClientPage(name, size, mt, et, age);
00712 if (add_page(pg) < 0) {
00713 delete pg;
00714 return NULL;
00715 }
00716 return pg;
00717 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in MClientPagePool. Definition at line 676 of file pagepool.cc. References add_page(), Scheduler::clock(), Scheduler::instance(), and ClientPage::set_uncacheable(). Referenced by MediaServer::command(), HttpApp::command(), enter_metadata(), and HttpMInvalCache::recv_upd().
00677 {
00678 double mt = -1, et, age = -1, noc = 0;
00679 int size = -1;
00680 for (int i = 3; i < argc; i+=2) {
00681 if (strcmp(argv[i], "modtime") == 0)
00682 mt = strtod(argv[i+1], NULL);
00683 else if (strcmp(argv[i], "size") == 0)
00684 size = atoi(argv[i+1]);
00685 else if (strcmp(argv[i], "age") == 0)
00686 age = strtod(argv[i+1], NULL);
00687 else if (strcmp(argv[i], "noc") == 0)
00688 // non-cacheable flag
00689 noc = 1;
00690 }
00691 // XXX allow mod time < 0 and age < 0!!
00692 if (size < 0) {
00693 fprintf(stderr, "PagePool %s: wrong information for page %s\n",
00694 name_, argv[2]);
00695 return NULL;
00696 }
00697 et = Scheduler::instance().clock();
00698 ClientPage* pg = new ClientPage(argv[2], size, mt, et, age);
00699 if (add_page(pg) < 0) {
00700 delete pg;
00701 return NULL;
00702 }
00703 if (noc)
00704 pg->set_uncacheable();
00705 return pg;
00706 }
|
Here is the call graph for this function:

|
|
Definition at line 316 of file pagepool.h. References get_page(). Referenced by HttpApp::command().
00316 { return (get_page(name) != NULL); }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 844 of file pagepool.cc. References ClientPage::age(), and get_page(). Referenced by HttpApp::command().
00845 {
00846 ClientPage *pg = (ClientPage *)get_page(name);
00847 if (pg == NULL)
00848 return -1;
00849 age = pg->age();
00850 return 0;
00851 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 826 of file pagepool.cc. References ClientPage::etime(), and get_page(). Referenced by HttpApp::command().
00827 {
00828 ClientPage *pg = (ClientPage *)get_page(name);
00829 if (pg == NULL)
00830 return -1;
00831 et = pg->etime();
00832 return 0;
00833 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 808 of file pagepool.cc. References get_page(), and ClientPage::mtime(). Referenced by HttpApp::command().
00809 {
00810 ClientPage *pg = (ClientPage *)get_page(name);
00811 if (pg == NULL)
00812 return -1;
00813 mt = pg->mtime();
00814 return 0;
00815 }
|
Here is the call graph for this function:

|
|
Definition at line 653 of file pagepool.cc. References namemap_, ClientPage::split_name(), and t1. Referenced by MClientPagePool::add_segment(), MediaServer::command(), MediaClient::command(), MediaCache::command(), HttpPercInvalCache::command(), HttpMInvalCache::command(), HttpYucInvalServer::command(), HttpApp::command(), exist_page(), MClientPagePool::fill_page(), MClientPagePool::force_remove(), get_age(), MediaCache::get_data(), get_etime(), get_mtime(), MediaServer::get_next_segment(), get_pageinfo(), get_size(), MClientPagePool::hc_update(), HttpMInvalCache::process_inv(), HttpMInvalCache::recv_upd(), MClientPagePool::remove_page(), set_etime(), and set_mtime().
00654 {
00655 PageID t1;
00656 void* t2[2];
00657 ClientPage::split_name(name, t1);
00658 t2[0] = (void *)t1.s_;
00659 t2[1] = (void *)t1.id_;
00660
00661 Tcl_HashEntry *he = Tcl_FindHashEntry(namemap_, (const char *)t2);
00662 if (he == NULL)
00663 return NULL;
00664 return (ClientPage *)Tcl_GetHashValue(he);
00665 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 667 of file pagepool.cc. References get_page(), and ClientPage::print_info(). Referenced by HttpApp::command().
00668 {
00669 ClientPage *pg = get_page(name);
00670 if (pg == NULL)
00671 return -1;
00672 pg->print_info(buf);
00673 return 0;
00674 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 835 of file pagepool.cc. References get_page(), and Page::size(). Referenced by HttpApp::command().
00836 {
00837 ClientPage *pg = (ClientPage *)get_page(name);
00838 if (pg == NULL)
00839 return -1;
00840 size = pg->size();
00841 return 0;
00842 }
|
Here is the call graph for this function:

|
|
Definition at line 853 of file pagepool.cc. References HttpApp::id(), namemap_, ClientPage::server(), and ClientPage::server_down(). Referenced by HttpMInvalCache::invalidate_server(), and HttpMInvalCache::recv_leave().
00854 {
00855 Tcl_HashEntry *he;
00856 Tcl_HashSearch hs;
00857 ClientPage *pg;
00858 int i;
00859
00860 for (i = 0, he = Tcl_FirstHashEntry(namemap_, &hs);
00861 he != NULL;
00862 he = Tcl_NextHashEntry(&hs), i++) {
00863 pg = (ClientPage *) Tcl_GetHashValue(he);
00864 if (pg->server()->id() == sid)
00865 pg->server_down();
00866 }
00867 }
|
Here is the call graph for this function:

|
|
Definition at line 242 of file pagepool.h.
00242 {
00243 TclObject* obj = Tcl::instance().lookup(name);
00244 if (obj == NULL)
00245 fprintf(stderr, "Bad object name %s\n", name);
00246 return obj;
00247 }
|
|
|
Definition at line 30 of file persconn.h. Referenced by WebTrafPool::command(), EmpWebTrafPool::command(), EmpFtpTrafPool::command(), WebTrafPool::lookup_rv(), EmpWebTrafPool::lookup_rv(), EmpFtpTrafPool::lookup_rv(), WebTrafPool::picksink(), EmpWebTrafPool::picksink(), EmpFtpTrafPool::picksink(), WebTrafPool::picktcp(), EmpWebTrafPool::picktcp(), and EmpFtpTrafPool::picktcp().
00030 {
00031 TclObject* obj = Tcl::instance().lookup(name);
00032 if (obj == NULL)
00033 fprintf(stderr, "Bad object name %s\n", name);
00034 return obj;
00035 }
|
|
|
Definition at line 233 of file pagepool.h. References PagePool::num_pages_.
00233 { return num_pages_; }
|
|
|
Definition at line 21 of file persconn.h. References PagePool::num_pages_.
00021 { return num_pages_; }
|
|
|
Reimplemented in MClientPagePool. Definition at line 778 of file pagepool.cc. References namemap_, PagePool::num_pages_, ClientPage::split_name(), and t1. Referenced by MClientPagePool::force_remove(), and MClientPagePool::remove_page().
00779 {
00780 PageID t1;
00781 void* t2[2];
00782 ClientPage::split_name(name, t1);
00783 t2[0] = (void *)t1.s_;
00784 t2[1] = (void *)t1.id_;
00785
00786 // Find out which client we are seeking
00787 Tcl_HashEntry *he = Tcl_FindHashEntry(namemap_, (const char *)t2);
00788 if (he == NULL)
00789 return -1;
00790 ClientPage *pg = (ClientPage *)Tcl_GetHashValue(he);
00791 Tcl_DeleteHashEntry(he);
00792 delete pg;
00793 num_pages_--;
00794 // XXX If cache replacement algorithm is added, should change
00795 // cache size here!!
00796 return 0;
00797 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 817 of file pagepool.cc. References ClientPage::etime(), and get_page(). Referenced by HttpApp::command().
00818 {
00819 ClientPage *pg = (ClientPage *)get_page(name);
00820 if (pg == NULL)
00821 return -1;
00822 pg->etime() = et;
00823 return 0;
00824 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 799 of file pagepool.cc. References get_page(), and ClientPage::mtime(). Referenced by HttpApp::command().
00800 {
00801 ClientPage *pg = (ClientPage *)get_page(name);
00802 if (pg == NULL)
00803 return -1;
00804 pg->mtime() = mt;
00805 return 0;
00806 }
|
Here is the call graph for this function:

|
|
Definition at line 239 of file pagepool.h. Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), ProxyTracePagePool::find_info(), and MediaPagePool::MediaPagePool(). |
|
|
Definition at line 238 of file pagepool.h. Referenced by TracePagePool::change_time(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), TracePagePool::load_page(), and PagePool::PagePool(). |
|
|
Definition at line 328 of file pagepool.h. Referenced by add_page(), ClientPagePool(), command(), get_page(), invalidate_server(), remove_page(), and ~ClientPagePool(). |
|
|
|
Definition at line 237 of file pagepool.h. Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), TracePagePool::load_page(), ProxyTracePagePool::load_req(), and PagePool::PagePool(). |
1.3.3