23 allServicesSame(allSame)
39 services.push_back(i->key);
51 if (!removedServices.empty()) {
53 for (Store::iterator it = removedServices.begin(); it != removedServices.end(); ++it) {
58 debugs(93,
DBG_IMPORTANT,
"Adaptation group '" <<
id <<
"' contains disabled member(s) after reconfiguration: " << s);
59 removedServices.clear();
63 bool baselineBypass =
false;
64 for (
Pos pos = 0; has(pos); ++pos) {
66 const String &serviceId = services[pos];
68 if (service !=
nullptr) {
75 finalizeMsg(
"Inconsistent service method for", serviceId,
true);
77 finalizeMsg(
"Inconsistent vectoring point for", serviceId,
true);
82 if (allServicesSame) {
83 if (!baselineKey.
size()) {
84 baselineKey = service->
cfg().
key;
86 }
else if (baselineBypass != service->
cfg().
bypass) {
88 ' ' <<
id <<
" may produce surprising results: " <<
89 baselineKey <<
" vs. " << serviceId);
93 finalizeMsg(
"ERROR: Unknown adaptation name", serviceId,
true);
96 debugs(93,7,
"finalized " << kind <<
": " <<
id);
107 for (
Pos p = checkedPos + 1; has(p); ++p) {
109 if (s !=
nullptr && s->
cfg().
key == checkedService->
cfg().
key)
110 finalizeMsg(
"duplicate service name", s->
cfg().
key,
false);
111 else if (s !=
nullptr && s->
cfg().
uri == checkedService->
cfg().
uri)
112 finalizeMsg(
"duplicate service URI", s->
cfg().
uri,
false);
122 const char *pfx =
error ?
"ERROR: " :
"WARNING: ";
123 debugs(93,level, pfx << msg <<
' ' << culprit <<
" in " << kind <<
" '" <<
137 return findService(filter, pos);
143 if (method != filter.
method || point != filter.
point) {
144 debugs(93,5,
id <<
" serves another location");
149 bool foundEssential =
false;
151 for (; has(pos); ++pos) {
152 debugs(93,9,
id <<
" checks service at " << pos);
158 if (!service->
wants(filter))
161 if (service->
up() || !service->
probed()) {
162 debugs(93,9,
id <<
" has matching service at " << pos);
167 debugs(93,9,
id <<
" has bypassable service at " << pos);
171 if (!allServicesSame) {
172 debugs(93,9,
id <<
" has essential service at " << pos);
176 if (!foundEssential) {
177 debugs(93,9,
id <<
" searches for best essential service from " << pos);
178 foundEssential =
true;
183 if (foundEssential) {
184 debugs(93,9,
id <<
" has best essential service at " << essPos);
189 debugs(93,5,
id <<
" has no matching services");
196 return allServicesSame && findService(filter, pos);
202 return !allServicesSame && findService(filter, pos);
231 kind =
"dynamic adaptation chain";
237 point = filter.
point;
249 bool doingCurrent =
true;
250 const char *item =
nullptr;
252 const char *pos =
nullptr;
264 doingCurrent =
false;
281 group(g), pos(0), atEof(!g || !g->has(pos))
298 if (!atEof && !group->findReplacement(filter, ++pos))
306 if (!atEof && !group->findLink(filter, ++pos))
315 return os <<
"[nil]";
317 return os << group->id <<
'[' << pos <<
".." << group->services.size() <<
318 (atEof ?
".]" :
"]");
333 typedef Groups::iterator GI;
int strListGetItem(const String *str, char del, const char **item, int *ilen, const char **pos)
void error(char *format,...)
DynamicServiceGroup configuration to remember future dynamic chains.
Store services
services in the group
void add(const String &item)
updates group id and services
static void Split(const ServiceFilter &filter, const String &ids, DynamicGroupCfg ¤t, DynamicGroupCfg &future)
separates dynamic services matching current location from future ones
DynamicServiceChain(const DynamicGroupCfg &cfg, const ServiceFilter &f)
information used to search for adaptation services
Method method
adaptation direction
VectPoint point
adaptation location
bool wants(const ServiceFilter &filter) const
bool findLink(const ServiceFilter &filter, Pos &pos) const
find next to link after success, starting with pos
ServiceGroup(const String &aKind, bool areAllServicesSame)
void checkUniqueness(const Pos checkedPos) const
checks that the service name or URI is not repeated later in the group
ServicePointer at(const Pos pos) const
void finalizeMsg(const char *msg, const String &culprit, bool error) const
emits a formatted warning or error message at the appropriate dbg level
bool findReplacement(const ServiceFilter &filter, Pos &pos) const
these methods control group iteration; used by ServicePlan
bool findService(const ServiceFilter &filter, Pos &pos) const
ServicePointer replacement(const ServiceFilter &filter)
next to try after failure
bool atEof
cached information for better performance
Pos pos
current service position within the group
std::ostream & print(std::ostream &os) const
ServicePointer next(const ServiceFilter &filter)
next in chain after success
ServiceGroupPointer group
the group we are iterating
ServicePointer current() const
returns nil if the plan is complete
bool wants(const ServiceFilter &filter) const
const ServiceConfig & cfg() const
virtual bool up() const =0
virtual bool probed() const =0
SingleService(const String &aServiceKey)
static char * NextToken()
static void ParseWordList(wordlist **list)
void assign(const char *str, int len)
void cut(size_type newLength)
void append(char const *buf, int len)
#define debugs(SECTION, LEVEL, CONTENT)
std::vector< ServiceGroupPointer > Groups
ServiceGroupPointer FindGroup(const ServiceGroup::Id &id)
ServicePointer FindService(const Service::Id &key)
RefCount< Service > ServicePointer
void wordlistDestroy(wordlist **list)
destroy a wordlist