1 #ifndef SQUID_ADAPT_HISTORY_H
2 #define SQUID_ADAPT_HISTORY_H
4 #include "adaptation/DynamicGroupCfg.h"
5 #include "base/RefCount.h"
6 #include "base/Vector.h"
7 #include "HttpHeader.h"
9 #include "SquidString.h"
14 /// collects information about adaptations related to a master transaction
15 class History
: public RefCountable
18 typedef RefCount
<Adaptation::History
> Pointer
;
22 /// record the start of a xact, return xact history ID
23 int recordXactStart(const String
&serviceId
, const timeval
&when
, bool retrying
);
25 /// record the end of a xact identified by its history ID
26 void recordXactFinish(int hid
);
28 /// dump individual xaction times to a string
29 void allLogString(const char *serviceId
, String
&buf
);
31 /// dump xaction times, merging retried and retry times together
32 void sumLogString(const char *serviceId
, String
&buf
);
34 /// sets or resets a cross-transactional database record
35 void updateXxRecord(const char *name
, const String
&value
);
37 /// returns true and fills the record fields iff there is a db record
38 bool getXxRecord(String
&name
, String
&value
) const;
40 /// sets or resets next services for the Adaptation::Iterator to notice
41 void updateNextServices(const String
&services
);
43 /// returns true, fills the value, and resets iff next services were set
44 bool extractNextServices(String
&value
);
46 /// store the last meta header fields received from the adaptation service
47 void recordMeta(const HttpHeader
*lm
);
50 /// Last received meta header (REQMOD or RESPMOD, whichever comes last).
52 /// All REQMOD and RESPMOD meta headers merged. Last field wins conflicts.
54 /// key:value pairs set by adaptation_meta, to be added to
55 /// AccessLogEntry::notes when ALE becomes available
56 NotePairs::Pointer metaHeaders
;
58 /// sets future services for the Adaptation::AccessCheck to notice
59 void setFutureServices(const DynamicGroupCfg
&services
);
61 /// returns true, fills the value, and resets iff future services were set
62 bool extractFutureServices(DynamicGroupCfg
&services
);
65 /// single Xaction stats (i.e., a historical record entry)
69 Entry(const String
&serviceId
, const timeval
&when
);
70 Entry(); // required by Vector<>
72 void stop(); ///< updates stats on transaction end
73 int rptm(); ///< returns response time [msec], calculates it if needed
75 String service
; ///< adaptation service ID
76 timeval start
; ///< when the xaction was started
79 int theRptm
; ///< calculated and cached response time value in msec
82 bool retried
; ///< whether the xaction was replaced by another
85 typedef Vector
<Entry
> Entries
;
86 Entries theEntries
; ///< historical record, in the order of xact starts
88 // theXx* will become a map<string,string>, but we only support one record
89 String theXxName
; ///< name part of the cross-transactional database record
90 String theXxValue
; ///< value part of the cross-xactional database record
92 String theNextServices
; ///< services Adaptation::Iterator must use next
93 DynamicGroupCfg theFutureServices
; ///< services AccessCheck must use
96 } // namespace Adaptation