Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
system_server_context.h
Go to the documentation of this file.
1 // Copyright 2013 Google Inc.
16 
17 #ifndef PAGESPEED_SYSTEM_SYSTEM_SERVER_CONTEXT_H_
18 #define PAGESPEED_SYSTEM_SYSTEM_SERVER_CONTEXT_H_
19 
20 #include "net/instaweb/http/public/request_context.h"
30 
31 namespace net_instaweb {
32 
33 class AsyncFetch;
34 class GoogleUrl;
35 class Histogram;
36 class QueryParams;
37 class PurgeSet;
38 class RewriteDriver;
39 class RewriteDriverFactory;
40 class RewriteOptions;
41 class RewriteStats;
42 class SharedMemStatistics;
43 class Statistics;
44 class SystemCachePath;
45 class SystemCaches;
46 class SystemRewriteDriverFactory;
47 class SystemRewriteOptions;
48 class UpDownCounter;
49 class UrlAsyncFetcherStats;
50 class Variable;
51 
54  public:
61 
63  StringPiece hostname, int port);
64  virtual ~SystemServerContext();
65 
66  void SetCachePath(SystemCachePath* cache_path);
67 
76  void FlushCacheIfNecessary();
77 
78  SystemRewriteOptions* global_system_rewrite_options();
79  GoogleString hostname_identifier() { return hostname_identifier_; }
80 
83  void UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set);
84 
86  virtual void PostInitHook();
87 
88  static void InitStats(Statistics* statistics);
89 
91  virtual void ChildInit(SystemRewriteDriverFactory* factory);
92 
96  void CreateLocalStatistics(Statistics* global_statistics,
98 
101  bool initialized() const { return initialized_; }
102 
111  virtual void ApplySessionFetchers(const RequestContextPtr& req,
112  RewriteDriver* driver);
113 
116  void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
117 
118  SystemCachePath* cache_path() { return cache_path_; }
119 
125 
128  void ConsoleHandler(const SystemRewriteOptions& options,
129  AdminSite::AdminSource source,
130  const QueryParams& query_params, AsyncFetch* fetch);
131 
133  void MessageHistoryHandler(const RewriteOptions& options,
134  AdminSite::AdminSource source,
135  AsyncFetch* fetch);
136 
138  void StatisticsGraphsHandler(Writer* writer);
139 
143  void AdminPage(bool is_global, const GoogleUrl& stripped_gurl,
144  const QueryParams& query_params, const RewriteOptions* options,
145  AsyncFetch* fetch);
146 
152  void StatisticsPage(bool is_global, const QueryParams& query_params,
153  const RewriteOptions* options,
154  AsyncFetch* fetch);
155 
156  AdminSite* admin_site() { return admin_site_.get(); }
157 
158  protected:
169  virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
170 
172  void ConsoleJsonHandler(const QueryParams& params, AsyncFetch* fetch);
173 
178  void StatisticsHandler(const RewriteOptions& options, bool is_global_request,
179  AdminSite::AdminSource source, AsyncFetch* fetch);
180 
182  void PrintConfig(AdminSite::AdminSource source, AsyncFetch* fetch);
183 
186  void PrintCaches(bool is_global, AdminSite::AdminSource source,
187  const GoogleUrl& stripped_gurl,
188  const QueryParams& query_params,
189  const RewriteOptions* options,
190  AsyncFetch* fetch);
191 
193  void PrintHistograms(bool is_global_request,
194  AdminSite::AdminSource source,
195  AsyncFetch* fetch);
196 
197  Variable* statistics_404_count();
198 
199  private:
209  void CheckLegacyGlobalCacheFlushFile();
210 
211  scoped_ptr<AdminSite> admin_site_;
212 
213  bool initialized_;
214  bool use_per_vhost_statistics_;
215 
219  scoped_ptr<AbstractMutex> cache_flush_mutex_;
220  int64 last_cache_flush_check_sec_;
221 
222  Variable* cache_flush_count_;
223  UpDownCounter* cache_flush_timestamp_ms_;
224 
225  Histogram* html_rewrite_time_us_histogram_;
226 
228  scoped_ptr<Statistics> split_statistics_;
229 
231  SharedMemStatistics* local_statistics_;
232 
234  scoped_ptr<RewriteStats> local_rewrite_stats_;
235  scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
236 
240  GoogleString hostname_identifier_;
241 
242  SystemCaches* system_caches_;
243 
244  SystemCachePath* cache_path_;
245 
246 
247 };
248 
249 }
250 
251 #endif
void UpdateCachePurgeSet(const CopyOnWrite< PurgeSet > &purge_set)
void MessageHistoryHandler(const RewriteOptions &options, AdminSite::AdminSource source, AsyncFetch *fetch)
Displays recent Info/Warning/Error messages.
SystemServerContext(RewriteDriverFactory *factory, StringPiece hostname, int port)
virtual void CollapseConfigOverlaysAndComputeSignatures()
void ConsoleJsonHandler(const QueryParams &params, AsyncFetch *fetch)
Returns JSON used by the PageSpeed Console JavaScript.
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
void AddHtmlRewriteTimeUs(int64 rewrite_time_us)
void AdminPage(bool is_global, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
A server context with features specific to a psol port on a unix system.
Definition: system_rewrite_driver_factory.h:57
void StatisticsPage(bool is_global, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms)
Definition: system_rewrite_options.h:40
void CreateLocalStatistics(Statistics *global_statistics, SystemRewriteDriverFactory *factory)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void PrintCaches(bool is_global, AdminSite::AdminSource source, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
bool initialized() const
Definition: system_server_context.h:101
Definition: rewrite_driver.h:100
void StatisticsGraphsHandler(Writer *writer)
Deprecated handler for graphs in the PSOL console.
Definition: server_context.h:99
A server context with features specific to a PSOL port on a unix system.
Definition: system_server_context.h:53
void PrintHistograms(bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch)
Print histograms showing the dynamics of server activity.
AdminSource
Definition: admin_site.h:52
Definition: copy_on_write.h:34
const GoogleString & hostname() const
Returns the current server hostname.
Definition: server_context.h:554
virtual void PostInitHook()
Initialize this SystemServerContext to set up its admin site.
void ConsoleHandler(const SystemRewriteOptions &options, AdminSite::AdminSource source, const QueryParams &query_params, AsyncFetch *fetch)
virtual void ApplySessionFetchers(const RequestContextPtr &req, RewriteDriver *driver)
void PrintConfig(AdminSite::AdminSource source, AsyncFetch *fetch)
Print details for configuration.
Definition: system_cache_path.h:49
virtual void ChildInit(SystemRewriteDriverFactory *factory)
Called by SystemRewriteDriverFactory::ChildInit. See documentation there.
void StatisticsHandler(const RewriteOptions &options, bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch)
Definition: rewrite_driver_factory.h:70