19 #ifndef PAGESPEED_KERNEL_CACHE_PURGE_CONTEXT_H_
20 #define PAGESPEED_KERNEL_CACHE_PURGE_CONTEXT_H_
33 namespace net_instaweb {
39 class NamedLockManager;
67 static const char kContentions[];
68 static const char kFileParseFailures[];
69 static const char kFileStats[];
70 static const char kFileWriteFailures[];
71 static const char kFileWrites[];
72 static const char kPurgeIndex[];
73 static const char kPurgePollTimestampMs[];
74 static const char kStatCalls[];
79 int max_bytes_in_cache,
97 request_batching_delay_ms_ = delay_ms;
108 void AddPurgeUrl(StringPiece url, int64 timestamp_ms,
109 PurgeCallback* callback);
118 PurgeCallback* callback);
139 friend class PurgeContextTest;
141 typedef std::vector<PurgeCallback*> PurgeCallbackVector;
146 void UpdateCachePurgeFile();
155 void ReadPurgeFile(
PurgeSet* purges_from_file);
156 void ReadFileAndCallCallbackIfChanged(
bool needs_update);
182 PurgeCallbackVector* return_callbacks,
189 void HandleWriteFailure(
int failures,
190 PurgeCallbackVector* callbacks,
192 bool* lock_and_update);
200 bool Verify(
const GoogleString& expected_purge_file_contents);
204 GoogleString LockName()
const {
return StrCat(filename_,
"-lock"); }
209 void WaitForTimerAndGrabLock();
214 void GrabLockAndUpdate();
219 void CancelCachePurgeFile();
226 bool ParseAndValidateTimestamp(StringPiece time_string, int64 now_ms,
227 int64* timestamp_ms);
230 scoped_ptr<NamedLock> interprocess_lock_;
231 FileSystem* file_system_;
234 Statistics* statistics_;
235 scoped_ptr<AbstractMutex> mutex_;
236 CopyOnWrite<PurgeSet> purge_set_;
237 PurgeSet pending_purges_;
238 PurgeCallbackVector pending_callbacks_;
239 int64 local_purge_index_;
240 int num_consecutive_failures_;
241 bool waiting_for_interprocess_lock_;
245 int max_bytes_in_cache_;
247 int64 request_batching_delay_ms_;
249 Variable* cancellations_;
250 Variable* contentions_;
251 Variable* file_parse_failures_;
252 Variable* file_stats_;
253 Variable* file_write_failures_;
254 Variable* file_writes_;
255 Variable* purge_index_;
256 scoped_ptr<UpDownCounter> purge_poll_timestamp_ms_;
258 Scheduler* scheduler_;
259 MessageHandler* message_handler_;
261 scoped_ptr<PurgeSetCallback> update_callback_;
void set_request_batching_delay_ms(int64 delay_ms)
Definition: purge_context.h:96
Definition: callback.h:167
Definition: named_lock_manager.h:82
void SetUpdateCallback(PurgeSetCallback *cb)
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
static const int64 kSecondMs
Definition: timer.h:34
void AddPurgeUrl(StringPiece url, int64 timestamp_ms, PurgeCallback *callback)
Definition: purge_set.h:44
static const char kCancellations[]
Variable names.
Definition: purge_context.h:66
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: file_system.h:76
static const int kCheckCacheIntervalMs
Definition: purge_context.h:63
Definition: thread_system.h:40
Definition: message_handler.h:39
void SetCachePurgeGlobalTimestampMs(int64 timestamp_ms, PurgeCallback *callback)
Definition: scheduler.h:47
Definition: purge_context.h:54
void set_enable_purge(bool x)
Definition: purge_context.h:136
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
Definition: callback.h:44