PeerSelectState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 #ifndef SQUID_PEERSELECTSTATE_H
10 #define SQUID_PEERSELECTSTATE_H
11 
12 #include "AccessLogEntry.h"
13 #include "acl/Checklist.h"
14 #include "base/CbcPointer.h"
15 #include "comm/forward.h"
16 #include "hier_code.h"
17 #include "ip/Address.h"
18 #include "ipcache.h"
19 #include "mem/forward.h"
20 #include "PingData.h"
21 #include "typedefs.h" /* for IRCB */
22 
23 class ErrorState;
24 class HtcpReplyData;
25 class HttpRequest;
26 class icp_common_t;
27 class StoreEntry;
28 
29 void peerSelectInit(void);
30 
33 {
34 public:
35  virtual ~PeerSelectionInitiator() = default;
36 
38  virtual void noteDestination(Comm::ConnectionPointer path) = 0;
39 
43  virtual void noteDestinationsEnd(ErrorState *error) = 0;
44 
46  bool subscribed = false;
47 
48  /* protected: */
53 };
54 
55 class FwdServer;
56 
60 {
62 
63 public:
65  virtual ~PeerSelector() override;
66 
67  /* Dns::IpReceiver API */
68  virtual void noteIp(const Ip::Address &ip) override;
69  virtual void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override;
70  virtual void noteLookup(const Dns::LookupDetails &details) override;
71 
72  // Produce a URL for display identifying the transaction we are
73  // trying to locate a peer for.
74  const SBuf url() const;
75 
77  PeerSelectionInitiator *interestedInitiator();
78 
80  bool wantsMoreDestinations() const;
81 
83  void handlePath(const Comm::ConnectionPointer &path, FwdServer &fs);
84 
86  void selectMore();
87 
91 
92  void *peerCountMcastPeerXXX = nullptr;
93 
95 
96 protected:
97  bool selectionAborted();
98 
99  void handlePingTimeout();
100  void handleIcpReply(CachePeer*, const peer_t, icp_common_t *header);
101  void handleIcpParentMiss(CachePeer*, icp_common_t*);
102 #if USE_HTCP
103  void handleHtcpParentMiss(CachePeer*, HtcpReplyData*);
104  void handleHtcpReply(CachePeer*, const peer_t, HtcpReplyData*);
105 #endif
106 
107  int checkNetdbDirect();
108  void checkAlwaysDirectDone(const Acl::Answer answer);
109  void checkNeverDirectDone(const Acl::Answer answer);
110 
111  void selectSomeNeighbor();
112  void selectSomeNeighborReplies();
113  void selectSomeDirect();
114  void selectSomeParent();
115  void selectAllParents();
116  void selectPinned();
117 
118  void addSelection(CachePeer*, const hier_code);
119 
120  void resolveSelected();
121 
126 
127 private:
130  int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
131  size_t foundPaths = 0;
133 
135 
136  /*
137  * Why are these Ip::Address instead of CachePeer *? Because a
138  * CachePeer structure can become invalid during the CachePeer selection
139  * phase, specifically after a reconfigure. Thus we need to lookup
140  * the CachePeer * based on the address when we are finally ready to
141  * reference the CachePeer structure.
142  */
143 
145 
147  /*
148  * ->hit can be CachePeer* because it should only be
149  * accessed during the thread when it is set
150  */
154 
156  Initiator initiator_;
157 
159 };
160 
161 #endif /* SQUID_PEERSELECTSTATE_H */
162 
HttpRequest * request
an interface for receiving IP::Addresses from nbgethostbyname()
Definition: ipcache.h:194
ErrorState * lastError
ping_data ping
Definition: SBuf.h:86
void ACLCB(Acl::Answer, void *)
ACL checklist callback.
Definition: Checklist.h:19
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void error(char *format,...)
ACLChecklist * acl_checklist
FwdServer * servers
a linked list of (unresolved) selected peers
encapsulates DNS lookup results
Definition: LookupDetails.h:20
static EVH HandlePingTimeout
static ACLCB CheckNeverDirectDone
Interface for those who need a list of peers to forward a request to.
const InstanceId< PeerSelector > id
unique identification in worker log
Ip::Address closest_parent_miss
static IRCB HandlePingReply
StoreEntry * entry
void EVH(void *)
Definition: event.h:19
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
Acl::Answer never_direct
virtual void noteDestination(Comm::ConnectionPointer path)=0
called when a new unique destination has been found
CachePeer * hit
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22
void peerSelectInit(void)
Definition: peer_select.cc:775
Initiator initiator_
recipient of the destinations we select; use interestedInitiator() to access
AccessLogEntry::Pointer al
info for the future access.log entry
hier_code
Definition: hier_code.h:12
virtual void noteDestinationsEnd(ErrorState *error)=0
Acl::Answer always_direct
Ip::Address first_parent_miss
peer_t
Definition: enums.h:27
#define CBDATA_CHILD(type)
Definition: cbdata.h:307
CbcPointer< PeerSelectionInitiator > Initiator
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
Definition: peer_select.cc:193
static ACLCB CheckAlwaysDirectDone
virtual ~PeerSelectionInitiator()=default

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors