#include <http.h>
Inheritance diagram for HttpMInvalCache:


|
|
Definition at line 675 of file http.cc. References Ca_, Cb_, enable_upd_, hb_interval_, hb_timer_, HTTP_HBINTERVAL, nbr_, push_high_bound_, push_low_bound_, push_thresh_, HBTimer::set_interval(), and sstate_.
00675 : 00676 hb_timer_(this, HTTP_HBINTERVAL), 00677 inv_sender_(0), num_sender_(0), size_sender_(0), 00678 invlist_(0), num_inv_(0), inv_parent_(NULL), 00679 upd_sender_(NULL), num_updater_(0), size_updater_(0) 00680 { 00681 bind("hb_interval_", &hb_interval_); 00682 bind("enable_upd_", &enable_upd_); // If we allow push 00683 bind("Ca_", &Ca_); 00684 bind("Cb_", &Cb_); 00685 bind("push_thresh_", &push_thresh_); 00686 bind("push_high_bound_", &push_high_bound_); 00687 bind("push_low_bound_", &push_low_bound_); 00688 00689 hb_timer_.set_interval(hb_interval_); 00690 Tcl_InitHashTable(&sstate_, TCL_ONE_WORD_KEYS); 00691 Tcl_InitHashTable(&nbr_, TCL_ONE_WORD_KEYS); 00692 } |
Here is the call graph for this function:

|
|
Definition at line 694 of file http.cc. References inv_sender_, nbr_, num_sender_, and sstate_.
00695 {
00696 if (num_sender_ > 0)
00697 delete []inv_sender_;
00698 Tcl_DeleteHashTable(&sstate_);
00699 Tcl_DeleteHashTable(&nbr_);
00700 }
|
|
|
Definition at line 657 of file http.cc. References CacheRepository_, HttpApp::id(), and NumCache_. Referenced by command().
00658 {
00659 if (CacheRepository_ == NULL) {
00660 CacheRepository_ = new HttpMInvalCache* [c->id() + 1];
00661 CacheRepository_[c->id()] = c;
00662 NumCache_ = c->id();
00663 } else if (NumCache_ < c->id()) {
00664 HttpMInvalCache** p = new HttpMInvalCache* [c->id()+1];
00665 memcpy(p, CacheRepository_,
00666 (c->id()+1)*sizeof(HttpMInvalCache*));
00667 delete[]CacheRepository_;
00668 CacheRepository_ = p;
00669 NumCache_ = c->id();
00670 p[c->id()] = c;
00671 } else
00672 CacheRepository_[c->id()] = c;
00673 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 69 of file http.cc. References client, and HttpApp::tpa_. Referenced by HttpApp::command().
00070 {
00071 int newEntry = 1;
00072 Tcl_HashEntry *he = Tcl_CreateHashEntry(tpa_,
00073 (const char *)client->id(),
00074 &newEntry);
00075 if (he == NULL)
00076 return -1;
00077 if (newEntry)
00078 Tcl_SetHashValue(he, (ClientData)agt);
00079 return 0;
00080 }
|
|
||||||||||||
|
Definition at line 1239 of file http.cc. References InvalidationRec::detach(), get_invrec(), InvalidationRec::insert(), invlist_, InvalidationRec::mtime(), and num_inv_. Referenced by recv_upd().
01240 {
01241 InvalidationRec *p = get_invrec(name);
01242 if ((p != NULL) && (p->mtime() < mtime)) {
01243 p->detach();
01244 delete p;
01245 p = NULL;
01246 num_inv_--;
01247 }
01248 if (p == NULL) {
01249 p = new InvalidationRec(name, mtime);
01250 p->insert(&invlist_);
01251 num_inv_++;
01252 }
01253 }
|
Here is the call graph for this function:

|
|
Definition at line 1045 of file http.cc. References Scheduler::clock(), hb_interval_, HTTP_HBEXPIRE_COUNT, HttpApp::id(), Scheduler::instance(), and nbr_. Referenced by command(), and recv_heartbeat().
01046 {
01047 int newEntry = 1;
01048 Tcl_HashEntry *he =
01049 Tcl_CreateHashEntry(&nbr_, (const char *)cache->id(),
01050 &newEntry);
01051 if (he == NULL)
01052 return;
01053 // If this cache already exists, don't do anything
01054 if (!newEntry)
01055 return;
01056
01057 // Start a timer for the neighbor
01058 LivenessTimer *timer =
01059 new LivenessTimer(this,HTTP_HBEXPIRE_COUNT*hb_interval_,
01060 cache->id());
01061
01062 double time = Scheduler::instance().clock();
01063 NeighborCache *c = new NeighborCache(cache, time, timer);
01064 Tcl_SetHashValue(he, (ClientData)c);
01065 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1017 of file http.cc. References sstate_. Referenced by check_sstate().
01018 {
01019 int newEntry = 1;
01020 Tcl_HashEntry *he =
01021 Tcl_CreateHashEntry(&sstate_, (const char *)sid, &newEntry);
01022 if (he == NULL)
01023 return;
01024 if (newEntry)
01025 Tcl_SetHashValue(he, (ClientData)sst);
01026 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 974 of file http.cc. References abort(), NeighborCache::add_server(), add_sstate(), HttpApp::id_, Scheduler::instance(), HttpMInvalCache::SState::is_down(), lookup_nbr(), lookup_sstate(), NeighborCache::server_up(), and HttpMInvalCache::SState::up(). Referenced by command(), and process_inv().
00975 {
00976 if ((sid == cid) && (cid == id_))
00977 // How come?
00978 return;
00979 SState *sst = lookup_sstate(sid);
00980 NeighborCache *c = lookup_nbr(cid);
00981 if (sst == NULL) {
00982 if (c == NULL) {
00983 fprintf(stderr,
00984 "%g: cache %d: No neighbor cache for received invalidation from %d via %d\n",
00985 Scheduler::instance().clock(), id_, sid, cid);
00986 abort();
00987 }
00988 #ifdef WEBCACHE_DEBUG
00989 fprintf(stderr,
00990 "%g: cache %d: registered server %d via cache %d\n",
00991 Scheduler::instance().clock(), id_, sid, cid);
00992 #endif
00993 sst = new SState(c);
00994 add_sstate(sid, sst);
00995 c->add_server(sid);
00996 } else if (sst->is_down()) {
00997 sst->up();
00998 if (cid != id_) {
00999 if (c == NULL) {
01000 fprintf(stderr,
01001 "[%g]: Cache %d has an invalid neighbor cache %d\n",
01002 Scheduler::instance().clock(), id_, cid);
01003 abort();
01004 }
01005 c->server_up(sid);
01006 }
01007 #ifdef WEBCACHE_DEBUG
01008 fprintf(stderr,
01009 "[%g] Cache %d reconnected to server %d via cache %d\n",
01010 Scheduler::instance().clock(), id_,
01011 sid, cid);
01012 #endif
01013 Tcl::instance().evalf("%s mark-rejoin", name_);
01014 }
01015 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from HttpApp. Reimplemented in HttpPercInvalCache. Definition at line 702 of file http.cc. References add_cache(), add_nbr(), Agent::attachApp(), NeighborCache::cache(), HttpMInvalCache::SState::cache(), Cb_, check_sstate(), ClientPage::clear_mpush(), HttpApp::command(), ClientPage::count_request(), ClientPage::counter(), ClientPagePool::get_page(), hb_timer_, HttpApp::id(), HttpApp::id_, Scheduler::instance(), inv_parent_, inv_sender_, ClientPage::is_unread(), HttpApp::log(), lookup_nbr(), lookup_sstate(), num_sender_, num_updater_, HttpApp::pool_, push_high_bound_, HttpUpdateData::rec_age(), HttpUpdateData::rec_mtime(), HttpHbData::rec_mtime(), HttpUpdateData::rec_page(), HttpHbData::rec_pg(), HttpUpdateData::rec_size(), recv_heartbeat(), recv_inv(), recv_upd(), HBTimer::sched(), send_upd(), ClientPage::set_mpush(), HttpUpdateData::set_pgsize(), ClientPage::set_read(), ClientPage::set_unread(), size_sender_, size_updater_, TimerHandler::status(), TIMER_IDLE, and upd_sender_. Referenced by HttpPercInvalCache::command().
00703 {
00704 Tcl& tcl = Tcl::instance();
00705 if (argc < 2)
00706 return HttpInvalCache::command(argc, argv);
00707
00708 switch (argv[1][0]) {
00709 case 'a':
00710 if ((strcmp(argv[1], "add-inval-listener") == 0) ||
00711 (strcmp(argv[1], "add-upd-listener") == 0)) {
00712 HttpInvalAgent *tmp =
00713 (HttpInvalAgent *)TclObject::lookup(argv[2]);
00714 tmp->attachApp((Application *)this);
00715 return TCL_OK;
00716 } else if (strcmp(argv[1], "add-inval-sender") == 0) {
00717 HttpInvalAgent *tmp =
00718 (HttpInvalAgent *)TclObject::lookup(argv[2]);
00719 if (tmp == NULL) {
00720 tcl.resultf("Non-existent agent %s", argv[2]);
00721 return TCL_ERROR;
00722 }
00723 if (num_sender_ == size_sender_) {
00724 HttpInvalAgent **tt =
00725 new HttpInvalAgent*[size_sender_+5];
00726 memcpy(tt, inv_sender_,
00727 sizeof(HttpInvalAgent*)*size_sender_);
00728 delete []inv_sender_;
00729 size_sender_ += 5;
00730 inv_sender_ = tt;
00731 }
00732 inv_sender_[num_sender_++] = tmp;
00733 return TCL_OK;
00734 } else if (strcmp(argv[1], "add-to-map") == 0) {
00735 add_cache(this);
00736 return TCL_OK;
00737 } else if (strcmp(argv[1], "add-upd-sender") == 0) {
00738 HttpInvalAgent *tmp =
00739 (HttpInvalAgent *)TclObject::lookup(argv[2]);
00740 if (tmp == NULL) {
00741 tcl.resultf("Non-existent agent %s", argv[2]);
00742 return TCL_ERROR;
00743 }
00744 if (num_updater_ == size_updater_) {
00745 HttpInvalAgent **tt =
00746 new HttpInvalAgent*[size_updater_+5];
00747 memcpy(tt, upd_sender_,
00748 sizeof(HttpInvalAgent*)*size_updater_);
00749 delete []upd_sender_;
00750 size_updater_ += 5;
00751 upd_sender_ = tt;
00752 }
00753 upd_sender_[num_updater_++] = tmp;
00754 return TCL_OK;
00755 }
00756 break;
00757
00758 case 'c':
00759 if (strcmp(argv[1], "count-request") == 0) {
00760 ClientPage *pg =
00761 (ClientPage *)pool_->get_page(argv[2]);
00762 if (pg == NULL) {
00763 tcl.resultf("%d count-request: No page %s",
00764 id_, argv[2]);
00765 return TCL_ERROR;
00766 }
00767 pg->count_request(Cb_, push_high_bound_);
00768 log("E NTF p %s v %d\n", argv[2], pg->counter());
00769 return TCL_OK;
00770 } else if (strcmp(argv[1], "check-sstate") == 0) {
00771 /*
00772 * <cache> check-sstate <sid> <cid>
00773 * If server is re-connected, reinstate it
00774 */
00775 int sid = atoi(argv[2]);
00776 int cid = atoi(argv[3]);
00777 check_sstate(sid, cid);
00778 return TCL_OK;
00779 }
00780 break;
00781
00782 case 'i':
00783 // XXX We don't need a "is-pushable" for cache!
00784 if (strcmp(argv[1], "is-unread") == 0) {
00785 ClientPage *pg =
00786 (ClientPage *)pool_->get_page(argv[2]);
00787 if (pg == NULL) {
00788 tcl.resultf("%d is-unread: No page %s",
00789 id_, argv[2]);
00790 return TCL_ERROR;
00791 }
00792 tcl.resultf("%d", pg->is_unread());
00793 return TCL_OK;
00794 }
00795 break;
00796
00797 case 'j':
00798 if (strcmp(argv[1], "join") == 0) {
00799 /*
00800 * <cache> join <server_id> <cache>
00801 *
00802 * <server> join via <cache>. If they are the same,
00803 * it means we are the primary cache for <server>.
00804 */
00805 int sid = atoi(argv[2]);
00806 HttpMInvalCache *cache =
00807 (HttpMInvalCache*)TclObject::lookup(argv[3]);
00808 if (cache == NULL) {
00809 tcl.add_errorf("Non-existent cache %s", argv[3]);
00810 return TCL_ERROR;
00811 }
00812 // Add neighbor cache if necessary
00813 NeighborCache *c = lookup_nbr(cache->id());
00814 if (c == NULL)
00815 add_nbr(cache);
00816 // Establish server invalidation contract
00817 check_sstate(sid, cache->id());
00818 return TCL_OK;
00819 }
00820 break;
00821
00822 case 'p':
00823 if (strcmp(argv[1], "parent-cache") == 0) {
00824 /*
00825 * <cache> parent-cache <web_server_id>
00826 * Return the parent cache of <web_server_id> in the
00827 * virtual distribution tree.
00828 */
00829 int sid = atoi(argv[2]);
00830 SState *sst = lookup_sstate(sid);
00831 if (sst == NULL)
00832 tcl.result("");
00833 else {
00834 // Bad hack... :(
00835 NeighborCache *c = lookup_nbr(sst->cache()->cache()->id());
00836 tcl.resultf("%s", c->cache()->name());
00837 }
00838 return TCL_OK;
00839 } else if (strcmp(argv[1], "push-children") == 0) {
00840 // Multicast the pushed page to all children
00841 ClientPage *pg =
00842 (ClientPage *)pool_->get_page(argv[2]);
00843 if (pg == NULL) {
00844 tcl.resultf("%d is-valid: No page %s",
00845 id_, argv[2]);
00846 return TCL_ERROR;
00847 }
00848 send_upd(pg);
00849 return TCL_OK;
00850 }
00851 break;
00852
00853 case 'r':
00854 if (strcmp(argv[1], "recv-inv") == 0) {
00855 /*
00856 * <cache> recv-inv <pageid> <modtime>
00857 * This should be called only by a web server,
00858 * therefore we do not check the validity of the
00859 * invalidation
00860 */
00861 // Pack it into a HttpHbData, and process it
00862 HttpHbData *d = new HttpHbData(id_, 1);
00863 strcpy(d->rec_pg(0), argv[2]);
00864 d->rec_mtime(0) = strtod(argv[3], NULL);
00865 //int old_inv = num_inv_;
00866 tcl.resultf("%d", recv_inv(d));
00867 delete d;
00868 return TCL_OK;
00869 } else if (strcmp(argv[1], "recv-push") == 0) {
00870 /*
00871 * <cache> recv-push <pageid> args
00872 */
00873 HttpUpdateData *d = new HttpUpdateData(id_, 1);
00874 strcpy(d->rec_page(0), argv[2]);
00875 for (int i = 3; i < argc; i+=2) {
00876 if (strcmp(argv[i], "modtime") == 0)
00877 d->rec_mtime(0) = strtod(argv[i+1], NULL);
00878 else if (strcmp(argv[i], "size") == 0) {
00879 d->rec_size(0) = atoi(argv[i+1]);
00880 // XXX need to set total update page size
00881 d->set_pgsize(d->rec_size(0));
00882 } else if (strcmp(argv[i], "age") == 0)
00883 d->rec_age(0) = strtod(argv[i+1], NULL);
00884 }
00885 tcl.resultf("%d", recv_upd(d));
00886 delete d;
00887 return TCL_OK;
00888 } else if (strcmp(argv[1], "register-server") == 0) {
00889 /*
00890 * <self> register-server <cache_id> <server_id>
00891 * We get a GET response about a page from <server>,
00892 * which we hear from <cache>
00893 */
00894 int cid = atoi(argv[2]);
00895 int sid = atoi(argv[3]);
00896 // Assuming we've already known the cache
00897 check_sstate(sid, cid);
00898 return TCL_OK;
00899 }
00900 break;
00901
00902 case 's':
00903 if (strcmp(argv[1], "start-hbtimer") == 0) {
00904 if (hb_timer_.status() == TIMER_IDLE)
00905 hb_timer_.sched();
00906 return TCL_OK;
00907 } else if (strcmp(argv[1], "server-hb") == 0) {
00908 int id = atoi(argv[2]);
00909 recv_heartbeat(id);
00910 return TCL_OK;
00911 } else if (strcmp(argv[1], "set-pinv-agent") == 0) {
00912 inv_parent_ =
00913 (HttpUInvalAgent*)TclObject::lookup(argv[2]);
00914 return TCL_OK;
00915 } else if (strcmp(argv[1], "set-parent") == 0) {
00916 HttpMInvalCache *c =
00917 (HttpMInvalCache*)TclObject::lookup(argv[2]);
00918 if (c == NULL) {
00919 tcl.add_errorf("Non-existent cache %s", argv[2]);
00920 return TCL_ERROR;
00921 }
00922 // Add parent cache into known cache list
00923 add_nbr(c);
00924 return TCL_OK;
00925 } else if (strcmp(argv[1], "set-unread") == 0) {
00926 ClientPage *pg =
00927 (ClientPage *)pool_->get_page(argv[2]);
00928 if (pg == NULL) {
00929 tcl.resultf("%d is-valid: No page %s",
00930 id_, argv[2]);
00931 return TCL_ERROR;
00932 }
00933 pg->set_unread();
00934 return TCL_OK;
00935 } else if (strcmp(argv[1], "set-read") == 0) {
00936 ClientPage *pg =
00937 (ClientPage *)pool_->get_page(argv[2]);
00938 if (pg == NULL) {
00939 tcl.resultf("%d is-valid: No page %s",
00940 id_, argv[2]);
00941 return TCL_ERROR;
00942 }
00943 pg->set_read();
00944 return TCL_OK;
00945 } else if (strcmp(argv[1], "set-mandatory-push") == 0) {
00946 ClientPage *pg =
00947 (ClientPage *)pool_->get_page(argv[2]);
00948 if (pg == NULL) {
00949 tcl.resultf("%d is-valid: No page %s",
00950 id_, argv[2]);
00951 return TCL_ERROR;
00952 }
00953 pg->set_mpush(Scheduler::instance().clock());
00954 return TCL_OK;
00955 } else if (strcmp(argv[1], "stop-mpush") == 0) {
00956 ClientPage *pg =
00957 (ClientPage *)pool_->get_page(argv[2]);
00958 if (pg == NULL) {
00959 tcl.resultf("%d is-valid: No page %s",
00960 id_, argv[2]);
00961 return TCL_ERROR;
00962 }
00963 pg->clear_mpush();
00964 return TCL_OK;
00965 }
00966 break;
00967
00968 default:
00969 break;
00970 }
00971 return HttpInvalCache::command(argc, argv);
00972 }
|
Here is the call graph for this function:

|
|
Definition at line 82 of file http.cc. References client, and HttpApp::tpa_. Referenced by HttpApp::command().
|
|
||||||||||||
|
Reimplemented from Process. Reimplemented in MediaCache, and MediaServer. Definition at line 47 of file http.h. References abort(). Referenced by MediaCache::get_data().
00047 {
00048 // Do not support it
00049 abort();
00050 return NULL;
00051 }
|
Here is the call graph for this function:

|
|
Definition at line 1255 of file http.cc. References invlist_, InvalidationRec::next(), and InvalidationRec::pg(). Referenced by add_inv(), and process_inv().
01256 {
01257 // XXX What should we do if we already have an
01258 // invalidation record of this page in our
01259 // invlist_? --> We should replace it with the new one
01260 InvalidationRec *r = invlist_;
01261 for (r = invlist_; r != NULL; r = r->next())
01262 if (strcmp(name, r->pg()) == 0)
01263 return r;
01264 return NULL;
01265 }
|
Here is the call graph for this function:

|
|
Definition at line 1114 of file http.cc. References NeighborCache::down(), HttpApp::id_, Scheduler::instance(), NeighborCache::invalidate(), lookup_nbr(), NeighborCache::num(), NeighborCache::pack_leave(), and send_leave(). Referenced by LivenessTimer::expire().
01115 {
01116 #ifdef WEBCACHE_DEBUG
01117 fprintf(stderr, "[%g] Cache %d disconnected from cache %d\n",
01118 Scheduler::instance().clock(), id_, cid);
01119 #endif
01120 Tcl::instance().evalf("%s mark-leave", name_);
01121
01122 NeighborCache *c = lookup_nbr(cid);
01123 if (c == NULL) {
01124 fprintf(stderr, "%s: An unknown neighbor cache %d failed.\n",
01125 name_, cid);
01126 }
01127 // Mark the cache down
01128 c->down();
01129 // Invalidate entries of all servers related to that cache
01130 // XXX We don't have an iterator for all servers in NeighborCache!
01131 c->invalidate(this);
01132
01133 // Send leave message to all children
01134 HttpLeaveData* data = new HttpLeaveData(id_, c->num());
01135 c->pack_leave(*data);
01136 send_leave(data);
01137 }
|
Here is the call graph for this function:

|
|
Definition at line 44 of file http.h. References HttpApp::id_. Referenced by add_cache(), add_nbr(), command(), MediaServer::get_piq(), ClientPagePool::invalidate_server(), and process_inv().
00044 { return id_; }
|
|
|
Definition at line 1104 of file http.cc. References HttpMInvalCache::SState::down(), ClientPagePool::invalidate_server(), HttpMInvalCache::SState::is_down(), lookup_sstate(), and HttpApp::pool_. Referenced by NeighborCache::invalidate().
01105 {
01106 SState *sst = lookup_sstate(sid);
01107 if (sst->is_down())
01108 // If this server is already marked down, return
01109 return;
01110 sst->down();
01111 pool_->invalidate_server(sid);
01112 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 356 of file http.cc. References HttpApp::id_, Scheduler::instance(), HttpApp::log_, BaseTrace::round(), and TIME_FORMAT. Referenced by MediaClient::command(), MediaCache::command(), command(), HttpYucInvalServer::command(), MediaClient::process_data(), MediaCache::process_data(), process_inv(), and recv_upd().
00357 {
00358 // Don't do anything if we don't have a log file.
00359 if (log_ == 0)
00360 return;
00361
00362 char buf[10240], *p;
00363 sprintf(buf, TIME_FORMAT" i %d ",
00364 BaseTrace::round(Scheduler::instance().clock()), id_);
00365 p = &(buf[strlen(buf)]);
00366 va_list ap;
00367 va_start(ap, fmt);
00368 vsprintf(p, fmt, ap);
00369 Tcl_Write(log_, buf, strlen(buf));
00370 }
|
Here is the call graph for this function:

|
|
Definition at line 92 of file http.cc. References client, and HttpApp::tpa_. Referenced by HttpApp::command().
|
|
|
Definition at line 1036 of file http.cc. References nbr_. Referenced by check_sstate(), command(), handle_node_failure(), recv_heartbeat(), and recv_leave().
01037 {
01038 Tcl_HashEntry *he = Tcl_FindHashEntry(&nbr_, (const char *)id);
01039 if (he == NULL)
01040 return NULL;
01041 return (NeighborCache *)Tcl_GetHashValue(he);
01042 }
|
|
|
Definition at line 1028 of file http.cc. References sstate_. Referenced by check_sstate(), command(), invalidate_server(), process_inv(), and recv_leave().
01029 {
01030 Tcl_HashEntry *he = Tcl_FindHashEntry(&sstate_, (const char *)sid);
01031 if (he == NULL)
01032 return NULL;
01033 return (SState *)Tcl_GetHashValue(he);
01034 }
|
|
|
Definition at line 214 of file http.h. References CacheRepository_. Referenced by recv_heartbeat().
00214 {
00215 return CacheRepository_[id];
00216 }
|
|
|
Definition at line 1267 of file http.cc. References HttpHbData::add(), InvalidationRec::dec_scount(), InvalidationRec::detach(), HttpApp::id_, invlist_, InvalidationRec::next(), and num_inv_. Referenced by send_heartbeat().
01268 {
01269 HttpHbData *data = new HttpHbData(id_, num_inv_);
01270 InvalidationRec *p = invlist_, *q;
01271 int i = 0;
01272 while (p != NULL) {
01273 data->add(i++, p);
01274 // Clearing up invalidation sending list
01275 if (!p->dec_scount()) {
01276 // Each invalidation is sent to its children
01277 // for at most HTTP_HBEXPIRE times. After that
01278 // the invalidation record is removed from
01279 // the list
01280 q = p;
01281 p = p->next();
01282 q->detach();
01283 delete q;
01284 num_inv_--;
01285 } else
01286 p = p->next();
01287 }
01288 return data;
01289 }
|
Here is the call graph for this function:

|
|
Definition at line 1456 of file http.cc. References HttpUpdateData::add(), and HttpApp::id_. Referenced by send_upd().
01457 {
01458 HttpUpdateData *data = new HttpUpdateData(id_, 1);
01459 data->add(0, page);
01460 return data;
01461 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from HttpApp. Definition at line 1208 of file http.cc. References HTTP_INVALIDATION, HTTP_LEAVE, HTTP_UPDATE, HttpData::id(), HttpApp::process_data(), recv_heartbeat(), recv_inv(), recv_leave(), recv_upd(), and AppData::type().
01209 {
01210 if (data == NULL)
01211 return;
01212
01213 switch (data->type()) {
01214 case HTTP_INVALIDATION: {
01215 // Update timer for the source of the heartbeat
01216 HttpHbData *inv = (HttpHbData*)data;
01217 recv_heartbeat(inv->id());
01218 recv_inv(inv);
01219 break;
01220 }
01221 case HTTP_UPDATE: {
01222 // Replace all updated pages
01223 HttpUpdateData *pg = (HttpUpdateData*)data;
01224 recv_upd(pg);
01225 break;
01226 }
01227 // JOIN messages are sent via TCP and direct TCL callback.
01228 case HTTP_LEAVE: {
01229 HttpLeaveData *l = (HttpLeaveData*)data;
01230 recv_leave(l);
01231 break;
01232 }
01233 default:
01234 HttpApp::process_data(size, data);
01235 return;
01236 }
01237 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1311 of file http.cc. References abort(), Ca_, NeighborCache::cache(), HttpMInvalCache::SState::cache(), check_sstate(), ClientPage::count_inval(), ClientPage::counter(), InvalidationRec::detach(), get_invrec(), ClientPagePool::get_page(), HTTP_INVALCACHE_FILTERED, HttpApp::id(), InvalidationRec::insert(), ClientPage::invalidate(), invlist_, HttpApp::log(), lookup_sstate(), InvalidationRec::mtime(), ClientPage::mtime(), InvalidationRec::next(), num_inv_, InvalidationRec::pg(), HttpApp::pool_, push_low_bound_, recv_inv_filter(), and ClientPage::server(). Referenced by recv_inv().
01312 {
01313 InvalidationRec *p = ivlist, *q, *r;
01314 //int upd = 0;
01315 while (p != NULL) {
01316 ClientPage* pg = (ClientPage *)pool_->get_page(p->pg());
01317
01318 // XXX Establish server states. Server states only gets
01319 // established when we have a page (no matter if we have its
01320 // content), and we have got an invalidation for the page.
01321 // Then we know we've got an invalidation contract for the
01322 // page.
01323 if (pg != NULL) {
01324 check_sstate(pg->server()->id(), cache);
01325 // Count this invalidation no matter whether we're
01326 // going to drop it. But if we doesn't get it
01327 // from our virtual parent, don't count it
01328 SState *sst = lookup_sstate(pg->server()->id());
01329 if (sst == NULL) {
01330 // How come we doesn't know the server???
01331 fprintf(stderr,
01332 "%s %d: couldn't find the server.\n",
01333 __FILE__, __LINE__);
01334 abort();
01335 }
01336 if ((sst->cache()->cache()->id() == cache) &&
01337 (pg->mtime() > p->mtime())) {
01338 // Don't count repeated invalidations.
01339 pg->count_inval(Ca_, push_low_bound_);
01340 log("E NTF p %s v %d\n",p->pg(),pg->counter());
01341 }
01342 }
01343
01344 // Hook for filters of derived classes
01345 if (recv_inv_filter(pg, p) == HTTP_INVALCACHE_FILTERED) {
01346 // If we do not have the page, or we have (or know
01347 // about) a newer page, ignore this invalidation
01348 // record and keep going.
01349 //
01350 // If we have this version of the page, and it's
01351 // already invalid, ignore this extra invalidation
01352 q = p;
01353 p = p->next();
01354 q->detach();
01355 delete q;
01356 } else {
01357 // Otherwise we invalidate our page and setup a
01358 // invalidation sending record for the page
01359 pg->invalidate(p->mtime());
01360 // Delete existing record for that page if any
01361 q = get_invrec(p->pg());
01362 if ((q != NULL) && (q->mtime() < p->mtime())) {
01363 q->detach();
01364 delete q;
01365 q = NULL;
01366 num_inv_--;
01367 }
01368 r = p;
01369 p = p->next();
01370 r->detach();
01371 // Insert it if necessary
01372 if (q == NULL) {
01373 r->insert(&invlist_);
01374 num_inv_++;
01375 // XXX
01376 Tcl::instance().evalf("%s mark-invalid",name_);
01377 log("E GINV p %s m %.17g\n", r->pg(), r->mtime());
01378 } else
01379 delete r;
01380 }
01381 }
01382 }
|
Here is the call graph for this function:

|
|
Definition at line 1070 of file http.cc. References add_nbr(), Scheduler::clock(), HttpApp::id_, Scheduler::instance(), NeighborCache::is_down(), lookup_nbr(), map_cache(), NeighborCache::reset_timer(), and NeighborCache::up(). Referenced by command(), and process_data().
01071 {
01072 // Receive time of the heartbeat
01073 double time = Scheduler::instance().clock();
01074
01075 NeighborCache *c = lookup_nbr(id);
01076 if (c == NULL) {
01077 // XXX
01078 // The only possible place for this to happen is in the TLC
01079 // group, where no JOIN could ever reach. Moreover,
01080 // we don't even have an entry for that cache yet, so here
01081 // we add that cache into our entry, and later on we'll add
01082 // corresponding servers there.
01083 if (id == id_)
01084 return;
01085 add_nbr(map_cache(id));
01086 #ifdef WEBCACHE_DEBUG
01087 fprintf(stderr, "TLC %d discovered TLC %d\n", id_, id);
01088 #endif
01089 return;
01090 } else if (c->is_down()) {
01091 // Neighbor cache recovers. Don't do anything special and
01092 // let invalid entries recover themselves
01093 c->up();
01094 #ifdef WEBCACHE_DEBUG
01095 fprintf(stderr, "[%g] Cache %d reconnected to cache %d\n",
01096 Scheduler::instance().clock(), id_, id);
01097 #endif
01098 Tcl::instance().evalf("%s mark-rejoin", name_);
01099 } else
01100 // Update heartbeat time
01101 c->reset_timer(time);
01102 }
|
Here is the call graph for this function:

|
|
Definition at line 1291 of file http.cc. References HttpHbData::extract(), HttpData::id(), HttpHbData::num_inv(), num_inv_, and process_inv(). Referenced by command(), and process_data().
01292 {
01293 if (data->num_inv() == 0)
01294 return 0;
01295
01296 InvalidationRec *head;
01297 data->extract(head);
01298 int old_inv = num_inv_;
01299 process_inv(data->num_inv(), head, data->id());
01300 //log("E GINV z %d\n", data->size());
01301 if (old_inv < num_inv_)
01302 // This invalidation is valid
01303 return 1;
01304 else
01305 return 0;
01306 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in HttpPercInvalCache. Definition at line 159 of file http.h. References HTTP_INVALCACHE_FILTERED, HTTP_INVALCACHE_UNFILTERED, ClientPage::is_valid(), InvalidationRec::mtime(), and ClientPage::mtime(). Referenced by process_inv().
00159 {
00160 return ((pg == NULL) || (pg->mtime() >= p->mtime()) ||
00161 !pg->is_valid()) ?
00162 HTTP_INVALCACHE_FILTERED : HTTP_INVALCACHE_UNFILTERED;
00163 }
|
Here is the call graph for this function:

|
|
Definition at line 1139 of file http.cc. References HttpLeaveData::add(), HttpMInvalCache::SState::cache(), HttpMInvalCache::SState::down(), HttpData::id(), HttpApp::id_, Scheduler::instance(), ClientPagePool::invalidate_server(), HttpMInvalCache::SState::is_down(), lookup_nbr(), lookup_sstate(), HttpLeaveData::num(), HttpApp::pool_, HttpLeaveData::rec_id(), and send_leave(). Referenced by process_data().
01140 {
01141 #ifdef WEBCACHE_DEBUG
01142 fprintf(stderr, "[%g] Cache %d gets a LEAVE from cache %d\n",
01143 Scheduler::instance().clock(), id_, d->id());
01144 #endif
01145
01146 if (d->num() == 0) {
01147 fprintf(stderr,
01148 "%s (%g) gets a leave from cache without server!\n",
01149 name_, Scheduler::instance().clock());
01150 return;
01151 }
01152
01153 SState *sst;
01154 HttpLeaveData* data = new HttpLeaveData(id_, d->num());
01155 NeighborCache *c = lookup_nbr(d->id());
01156 int i, j;
01157 for (i = 0, j = 0; i < d->num(); i++) {
01158 sst = lookup_sstate(d->rec_id(i));
01159
01160 // If we haven't heard of that server, which means we don't
01161 // have any page of that server, ignore the leave message.
01162 if (sst == NULL)
01163 continue;
01164 // If it's already marked down, don't bother again.
01165 if (sst->is_down())
01166 continue;
01167 // If we hear a LEAVE about a server from one of
01168 // our child in the virtual distribution tree
01169 // of the server, ignore it.
01170 if (c != sst->cache())
01171 continue;
01172
01173 // We have the page, and we hold inval contract. Invalidate
01174 // the page and inform our children of it.
01175 sst->down();
01176 data->add(j++, d->rec_id(i));
01177 pool_->invalidate_server(d->rec_id(i));
01178 Tcl::instance().evalf("%s mark-leave", name_);
01179 }
01180 // Delete it if it's not sent out
01181 if (j > 0)
01182 send_leave(data);
01183 delete data;
01184 }
|
Here is the call graph for this function:

|
|
Definition at line 1402 of file http.cc. References abort(), add_inv(), Ca_, ClientPage::clear_mpush(), Scheduler::clock(), ClientPage::count_inval(), ClientPage::counter(), enable_upd_, ClientPagePool::enter_page(), ClientPagePool::get_page(), hb_interval_, HTTP_HBEXPIRE_COUNT, HttpApp::id_, Scheduler::instance(), ClientPage::is_mpush(), HttpApp::log(), ClientPage::mpush_time(), ClientPage::mtime(), HttpUpdateData::num(), HttpUpdateData::pgsize(), HttpApp::pool_, push_low_bound_, push_thresh_, HttpUpdateData::rec_age(), HttpUpdateData::rec_mtime(), HttpUpdateData::rec_page(), HttpUpdateData::rec_size(), and ClientPage::set_unread(). Referenced by command(), and process_data().
01403 {
01404 if (d->num() != 1) {
01405 fprintf(stderr,
01406 "%d gets an update which contain !=1 pages.\n", id_);
01407 abort();
01408 }
01409
01410 ClientPage *pg = pool_->get_page(d->rec_page(0));
01411 if (pg != NULL)
01412 if (pg->mtime() >= d->rec_mtime(0)) {
01413 // If we've already had this version, or a newer
01414 // version, ignore this old push
01415 // fprintf(stderr, "[%g] %d gets an old push\n",
01416 // Scheduler::instance().clock(), id_);
01417 // log("E OLD m %g p %g\n", d->rec_mtime(0), pg->mtime());
01418 return 0;
01419 } else {
01420 // Our old page is invalidated by this new push,
01421 // set up invalidation records for our children
01422 add_inv(d->rec_page(0), d->rec_mtime(0));
01423 pg->count_inval(Ca_, push_low_bound_);
01424 log("E NTF p %s v %d\n", d->rec_page(0),pg->counter());
01425 }
01426
01427 // Add the new page into our pool
01428 ClientPage *q = pool_->enter_page(d->rec_page(0), d->rec_size(0),
01429 d->rec_mtime(0),
01430 Scheduler::instance().clock(),
01431 d->rec_age(0));
01432 // By default the page is valid and read. Set it as unread
01433 q->set_unread();
01434
01435 log("E GUPD m %.17g z %d\n", d->rec_mtime(0), d->pgsize());
01436 Tcl::instance().evalf("%s mark-valid", name_);
01437
01438 // XXX If the page was previously marked as MandatoryPush, then
01439 // we need to check if it's timed out
01440 if (q->is_mpush() && (Scheduler::instance().clock() - q->mpush_time()
01441 > HTTP_HBEXPIRE_COUNT*hb_interval_)) {
01442 // If mandatory push timer expires, stop push
01443 q->clear_mpush();
01444 Tcl::instance().evalf("%s cancel-mpush-refresh %s",
01445 name_, d->rec_page(0));
01446 }
01447
01448 if (enable_upd_ && (q->counter() >= push_thresh_) || q->is_mpush())
01449 // XXX Continue pushing if we either select to push, or
01450 // were instructed to do so.
01451 return 1;
01452 else
01453 return 0;
01454 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 106 of file ns-process.h. References Process::process_data(), and Process::target_. Referenced by TcpApp::process_data(), and MediaApp::process_data().
00106 {
00107 if (target_)
00108 target_->process_data(size, data);
00109 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1384 of file http.cc. References AppData::copy(), inv_parent_, inv_sender_, num_sender_, HttpInvalAgent::send(), and HttpUInvalAgent::send(). Referenced by send_heartbeat(), and send_leave().
01385 {
01386 if (inv_parent_ != NULL)
01387 inv_parent_->send(size, data->copy());
01388 for (int i = 0; i < num_sender_; i++)
01389 inv_sender_[i]->send(size, data->copy());
01390 }
|
Here is the call graph for this function:

|
|
Definition at line 1392 of file http.cc. References HttpHbData::cost(), inv_parent_, num_sender_, pack_heartbeat(), and send_hb_helper(). Referenced by timeout().
01393 {
01394 if ((num_sender_ == 0) && (inv_parent_ == NULL))
01395 return;
01396
01397 HttpHbData* d = pack_heartbeat();
01398 send_hb_helper(d->cost(), d);
01399 delete d;
01400 }
|
Here is the call graph for this function:

|
|
Definition at line 1186 of file http.cc. References HttpLeaveData::cost(), and send_hb_helper(). Referenced by handle_node_failure(), and recv_leave().
01187 {
01188 send_hb_helper(d->cost(), d);
01189 }
|
Here is the call graph for this function:

|
|
Definition at line 1469 of file http.cc. References enable_upd_, num_updater_, pack_upd(), HttpUpdateData::pgsize(), and send_upd_helper(). Referenced by command().
01470 {
01471 if ((num_updater_ == 0) || !enable_upd_)
01472 return;
01473
01474 HttpUpdateData* d = pack_upd(page);
01475 send_upd_helper(d->pgsize(), d);
01476 delete d;
01477 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1463 of file http.cc. References AppData::copy(), num_updater_, HttpInvalAgent::send(), and upd_sender_. Referenced by send_upd().
01464 {
01465 for (int i = 0; i < num_updater_; i++)
01466 upd_sender_[i]->send(pgsize, data->copy());
01467 }
|
Here is the call graph for this function:

|
|
Definition at line 58 of file http.h. References HttpApp::pool_.
00058 { pool_ = pp; }
|
|
|
Definition at line 97 of file ns-process.h. References Process::target_. Referenced by QA::check_availability(), Process::command(), HttpApp::command(), MediaApp::get_data(), QA::output(), and TcpApp::process_data().
00097 { return target_; }
|
|
|
Definition at line 1191 of file http.cc. References HTTP_INVALIDATION, HTTP_UPDATE, and send_heartbeat(). Referenced by HBTimer::expire(), and PushTimer::expire().
01192 {
01193 switch (reason) {
01194 case HTTP_INVALIDATION:
01195 // Send an invalidation message
01196 send_heartbeat();
01197 break;
01198 case HTTP_UPDATE:
01199 // XXX do nothing. May put client selective joining update
01200 // group here.
01201 break;
01202 default:
01203 fprintf(stderr, "%s: Unknown reason %d", name_, reason);
01204 break;
01205 }
01206 }
|
Here is the call graph for this function:

|
|
Definition at line 197 of file http.h. Referenced by HttpMInvalCache(), process_inv(), and recv_upd(). |
|
|
Definition at line 654 of file http.cc. Referenced by add_cache(), and map_cache(). |
|
|
Definition at line 197 of file http.h. Referenced by command(), and HttpMInvalCache(). |
|
|
Definition at line 196 of file http.h. Referenced by HttpMInvalCache(), recv_upd(), and send_upd(). |
|
|
Definition at line 195 of file http.h. Referenced by add_nbr(), HttpMInvalCache(), and recv_upd(). |
|
|
Definition at line 146 of file http.h. Referenced by command(), and HttpMInvalCache(). |
|
|
Definition at line 61 of file http.h. Referenced by check_sstate(), MediaServer::command(), MediaCache::command(), HttpPercInvalCache::command(), command(), HttpYucInvalServer::command(), HttpApp::command(), handle_node_failure(), HttpApp::HttpApp(), HttpApp::id(), HttpApp::log(), pack_heartbeat(), HttpYucInvalServer::pack_heartbeat(), pack_upd(), recv_heartbeat(), recv_leave(), and recv_upd(). |
|
|
Definition at line 189 of file http.h. Referenced by command(), send_hb_helper(), and send_heartbeat(). |
|
|
Definition at line 147 of file http.h. Referenced by command(), send_hb_helper(), and ~HttpMInvalCache(). |
|
|
Definition at line 150 of file http.h. Referenced by add_inv(), get_invrec(), pack_heartbeat(), and process_inv(). |
|
|
Definition at line 63 of file http.h. Referenced by HttpApp::command(), and HttpApp::log(). |
|
|
Definition at line 185 of file http.h. Referenced by add_nbr(), HttpMInvalCache(), lookup_nbr(), and ~HttpMInvalCache(). |
|
|
Definition at line 151 of file http.h. Referenced by add_inv(), pack_heartbeat(), process_inv(), and recv_inv(). |
|
|
Definition at line 148 of file http.h. Referenced by command(), send_hb_helper(), send_heartbeat(), and ~HttpMInvalCache(). |
|
|
Definition at line 201 of file http.h. Referenced by command(), send_upd(), and send_upd_helper(). |
|
|
Definition at line 655 of file http.cc. Referenced by add_cache(). |
|
|
Definition at line 62 of file http.h. Referenced by MediaServer::command(), HttpPercInvalCache::command(), command(), HttpYucInvalServer::command(), HttpApp::command(), MediaCache::get_data(), MediaServer::get_next_segment(), invalidate_server(), MediaClient::mpool(), MediaCache::mpool(), process_inv(), recv_leave(), recv_upd(), and HttpApp::set_pagepool(). |
|
|
Definition at line 198 of file http.h. Referenced by command(), and HttpMInvalCache(). |
|
|
Definition at line 198 of file http.h. Referenced by HttpMInvalCache(), process_inv(), and recv_upd(). |
|
|
Definition at line 197 of file http.h. Referenced by HttpMInvalCache(), and recv_upd(). |
|
|
Definition at line 149 of file http.h. Referenced by command(). |
|
|
Definition at line 202 of file http.h. Referenced by command(). |
|
|
Definition at line 178 of file http.h. Referenced by add_sstate(), HttpMInvalCache(), lookup_sstate(), and ~HttpMInvalCache(). |
|
|
Definition at line 113 of file ns-process.h. Referenced by HttpUInvalAgent::command(), Process::Process(), HttpUInvalAgent::process_data(), Process::send_data(), and Process::target(). |
|
|
Definition at line 60 of file http.h. Referenced by HttpApp::add_cnc(), HttpApp::delete_cnc(), HttpApp::HttpApp(), HttpApp::lookup_cnc(), and HttpApp::~HttpApp(). |
|
|
Definition at line 200 of file http.h. Referenced by command(), and send_upd_helper(). |
1.3.3