2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_HTTPHIERARCHYLOGENTRY_H
10 #define SQUID_HTTPHIERARCHYLOGENTRY_H
12 #include "comm/Connection.h"
14 #include "hier_code.h"
15 #include "http/StatusCode.h"
20 /// Maintains peer selection details and peer I/O stats.
21 /// Here, "peer" is an origin server or CachePeer.
22 class HierarchyLogEntry
28 /// Start recording new origin server or cache peer connection details.
29 /// Call this when trying to connect to a peer.
30 void resetPeerNotes(const Comm::ConnectionPointer
&server
, const char *requestedHost
);
32 /// Account for a TCP peer read. Maintains peer response time stats (%<pt).
33 /// Call this after each successful peer socket read(2).
36 /// Account for a TCP peer write. Maintains peer response time stats (%<pt).
37 /// Call this after each peer socket write(2), including failed ones.
40 /// Start recording total time spent communicating with peers
41 void startPeerClock();
43 * Record total time spent communicating with peers
44 * \param force whether to overwrite old recorded value if any
46 void stopPeerClock(const bool force
);
48 /// Estimates response generation and sending delay at the last peer.
49 /// \returns whether the estimate (stored in `responseTime`) is available.
50 bool peerResponseTime(struct timeval
&responseTime
);
52 /// Estimates the total time spent communicating with peers.
53 /// \returns whether the estimate (stored in `responseTime`) is available.
54 bool totalResponseTime(struct timeval
&responseTime
);
58 char host
[SQUIDHOSTNAMELEN
];
60 char cd_host
[SQUIDHOSTNAMELEN
]; /* the host of selected by cd peer */
61 lookup_t cd_lookup
; /* cd prediction: none, miss, hit */
62 int n_choices
; /* #peers we selected from (cd only) */
63 int n_ichoices
; /* #peers with known rtt we selected from (cd only) */
65 struct timeval peer_select_start
;
67 struct timeval store_complete_stop
;
69 Http::StatusCode peer_reply_status
; ///< last HTTP status code received
70 Comm::ConnectionPointer tcpServer
; ///< TCP/IP level details of the last peer/server connection
71 int64_t bodyBytesRead
; ///< number of body bytes received from the next hop or -1
74 void clearPeerNotes();
76 timeval firstConnStart_
; ///< first connection use among all peers
77 struct timeval peer_last_read_
; ///< time of the last read from the last peer
78 struct timeval peer_last_write_
; ///< time of the last write to the last peer
79 struct timeval totalResponseTime_
; ///< cumulative for all peers
82 #endif /* SQUID_HTTPHIERARCHYLOGENTRY_H */