DelayTagged.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 77 Delay Pools */
10 
11 #include "squid.h"
12 
13 #if USE_DELAY_POOLS
14 #include "comm/Connection.h"
15 #include "DelayTagged.h"
16 #include "NullDelayId.h"
17 #include "Store.h"
18 
20 {
22 }
23 
25 
27 {
29  buckets.destroy(DelayTaggedFree);
30 }
31 
33 
34 int
36 {
37  /* for rate limiting, case insensitive */
38  return left->tag.caseCmp(right->tag);
39 }
40 
41 void
43 {}
44 
48  void operator() (DelayTaggedBucket::Pointer const &current) {
49  current->stats(sentry);
50  }
51 };
52 
53 void
55 {
56  spec.stats (sentry, "Per Tag");
57 
58  if (spec.restore_bps == -1)
59  return;
60 
61  storeAppendPrintf(sentry, "\t\tCurrent: ");
62 
63  if (buckets.empty()) {
64  storeAppendPrintf (sentry, "Not used yet.\n\n");
65  return;
66  }
67 
68  DelayTaggedStatsVisitor visitor(sentry);
69  buckets.visit(visitor);
70  storeAppendPrintf(sentry, "\n\n");
71 }
72 
73 void
75 {
76  spec.dump(entry);
77 }
78 
80  DelayTaggedUpdater (DelaySpec &_spec, int _incr):spec(_spec),incr(_incr) {};
81 
83  int incr;
84 };
85 
86 void
88 {
90  /* This doesn't change the value of the DelayTaggedBucket, so is safe */
91  const_cast<DelayTaggedBucket *>(current.getRaw())->theBucket.update(t->spec, t->incr);
92 }
93 
97  void operator() (DelayTaggedBucket::Pointer const &current) {
98  const_cast<DelayTaggedBucket *>(current.getRaw())->theBucket.update(updater->spec, updater->incr);
99  }
100 };
101 
102 void
104 {
105  DelayTaggedUpdater updater(spec, incr);
106  DelayTaggedUpdateVisitor visitor(&updater);
107  buckets.visit(visitor);
108  kickReads();
109 }
110 
111 void
113 {
114  spec.parse();
115 }
116 
118 
120 {
121  if (!details.tag.size())
122  return new NullDelayId;
123 
124  return new Id(this, details.tag);
125 }
126 
128 {
129  debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket");
130 }
131 
133 {
134  debugs(77, 3, "DelayTaggedBucket::~DelayTaggedBucket");
135 }
136 
137 void
139 {
141  theBucket.stats(entry);
142 }
143 
144 DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, String &aTag) : theTagged(aDelayTagged)
145 {
146  theBucket = new DelayTaggedBucket(aTag);
147  DelayTaggedBucket::Pointer const *existing = theTagged->buckets.find(theBucket, DelayTaggedCmp);
148 
149  if (existing) {
150  theBucket = *existing;
151  return;
152  }
153 
155  theTagged->buckets.insert (theBucket, DelayTaggedCmp);
156 }
157 
159 {
160  debugs(77, 3, "DelayTagged::Id::~Id");
161 }
162 
163 int
165 {
166  return theBucket->theBucket.bytesWanted(min,max);
167 }
168 
169 void
171 {
172  theBucket->theBucket.bytesIn(qty);
173 }
174 
175 void
177 {
178  theTagged->delayRead(aRead);
179 }
180 
181 #endif
182 
#define SQUIDSTRINGPH
Definition: SquidString.h:20
void operator()(DelayTaggedBucket::Pointer const &current)
Definition: DelayTagged.cc:97
#define SQUIDSTRINGPRINT(s)
Definition: SquidString.h:21
int caseCmp(char const *) const
Definition: String.cc:299
virtual void stats(StoreEntry *sentry)
Definition: DelayTagged.cc:54
Splay< DelayTaggedBucket::Pointer > buckets
Definition: DelayTagged.h:77
virtual void parse()
Definition: DelayTagged.cc:112
virtual int bytesWanted(int min, int max) const
Definition: DelayTagged.cc:164
DelayTaggedUpdateVisitor(DelayTaggedUpdater *u)
Definition: DelayTagged.cc:96
DelayTaggedStatsVisitor(StoreEntry *se)
Definition: DelayTagged.cc:47
static void deregisterForUpdates(Updateable *)
Definition: delay_pools.cc:515
static Splay< DelayTaggedBucket::Pointer >::SPLAYCMP DelayTaggedCmp
Definition: DelayTagged.cc:32
Definition: splay.h:56
void parse()
Definition: DelaySpec.cc:42
size_type size() const
Definition: SquidString.h:71
A const & max(A const &lhs, A const &rhs)
DelayTaggedUpdater(DelaySpec &_spec, int _incr)
Definition: DelayTagged.cc:80
virtual void dump(StoreEntry *entry) const
Definition: DelayTagged.cc:74
virtual ~DelayTagged()
Definition: DelayTagged.cc:26
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
int restore_bps
Definition: DelaySpec.h:23
Id(RefCount< DelayTagged >, String &)
Definition: DelayTagged.cc:144
void stats(StoreEntry *sentry, char const *) const
Definition: DelaySpec.cc:23
static Splay< DelayTaggedBucket::Pointer >::SPLAYFREE DelayTaggedFree
Definition: DelayTagged.cc:24
virtual void delayRead(DeferredRead const &)
Definition: DelayTagged.cc:176
void init(DelaySpec const &)
Definition: DelayBucket.cc:47
DelayTaggedUpdater * updater
Definition: DelayTagged.cc:95
DelayTaggedBucket::Pointer theBucket
Definition: DelayTagged.h:71
DelayTaggedBucket(String &aTag)
Definition: DelayTagged.cc:127
void stats(StoreEntry *) const
Definition: DelayBucket.cc:20
virtual void bytesIn(int qty)
Definition: DelayTagged.cc:170
void dump(StoreEntry *) const
Definition: DelaySpec.cc:36
void stats(StoreEntry *) const
Definition: DelayTagged.cc:138
virtual void update(int incr)
Definition: DelayTagged.cc:103
DelaySpec spec
Definition: DelayTagged.h:76
virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &)
Definition: DelayTagged.cc:119
friend class Id
Definition: DelayTagged.h:74
RefCount< DelayTagged > theTagged
Definition: DelayTagged.h:70
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:904
void DelayTaggedUpdateWalkee(DelayTaggedBucket::Pointer const &current, void *state)
Definition: DelayTagged.cc:87
C * getRaw() const
Definition: RefCount.h:74
void operator()(DelayTaggedBucket::Pointer const &current)
Definition: DelayTagged.cc:48
A const & min(A const &lhs, A const &rhs)
DelayBucket theBucket
Definition: DelayTagged.h:34
static void registerForUpdates(Updateable *)
Definition: delay_pools.cc:508

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors