1 #ifndef SQUID_ADAPT_HISTORY_H
2 #define SQUID_ADAPT_HISTORY_H
4 #include "adaptation/DynamicGroupCfg.h"
6 #include "HttpHeader.h"
8 #include "SquidString.h"
13 /// collects information about adaptations related to a master transaction
14 class History
: public RefCountable
17 typedef RefCount
<Adaptation::History
> Pointer
;
21 /// record the start of a xact, return xact history ID
22 int recordXactStart(const String
&serviceId
, const timeval
&when
, bool retrying
);
24 /// record the end of a xact identified by its history ID
25 void recordXactFinish(int hid
);
27 /// dump individual xaction times to a string
28 void allLogString(const char *serviceId
, String
&buf
);
30 /// dump xaction times, merging retried and retry times together
31 void sumLogString(const char *serviceId
, String
&buf
);
33 /// sets or resets a cross-transactional database record
34 void updateXxRecord(const char *name
, const String
&value
);
36 /// returns true and fills the record fields iff there is a db record
37 bool getXxRecord(String
&name
, String
&value
) const;
39 /// sets or resets next services for the Adaptation::Iterator to notice
40 void updateNextServices(const String
&services
);
42 /// returns true, fills the value, and resets iff next services were set
43 bool extractNextServices(String
&value
);
45 /// store the last meta header fields received from the adaptation service
46 void recordMeta(const HttpHeader
*lm
);
49 /// Last received meta header (REQMOD or RESPMOD, whichever comes last).
51 /// All REQMOD and RESPMOD meta headers merged. Last field wins conflicts.
54 /// sets future services for the Adaptation::AccessCheck to notice
55 void setFutureServices(const DynamicGroupCfg
&services
);
57 /// returns true, fills the value, and resets iff future services were set
58 bool extractFutureServices(DynamicGroupCfg
&services
);
61 /// single Xaction stats (i.e., a historical record entry)
65 Entry(const String
&serviceId
, const timeval
&when
);
66 Entry(); // required by Vector<>
68 void stop(); ///< updates stats on transaction end
69 int rptm(); ///< returns response time [msec], calculates it if needed
71 String service
; ///< adaptation service ID
72 timeval start
; ///< when the xaction was started
75 int theRptm
; ///< calculated and cached response time value in msec
78 bool retried
; ///< whether the xaction was replaced by another
81 typedef Vector
<Entry
> Entries
;
82 Entries theEntries
; ///< historical record, in the order of xact starts
84 // theXx* will become a map<string,string>, but we only support one record
85 String theXxName
; ///< name part of the cross-transactional database record
86 String theXxValue
; ///< value part of the cross-xactional database record
88 String theNextServices
; ///< services Adaptation::Iterator must use next
89 DynamicGroupCfg theFutureServices
; ///< services AccessCheck must use
92 } // namespace Adaptation