Page Speed Optimization Libraries  1.9.32.2
 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 NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
18 #define NET_INSTAWEB_SYSTEM_PUBLIC_SYSTEM_SERVER_CONTEXT_H_
19 
21 
22 #include "net/instaweb/http/public/request_context.h"
24 #include "pagespeed/kernel/base/basictypes.h"
25 #include "pagespeed/kernel/base/scoped_ptr.h"
26 #include "pagespeed/kernel/base/string.h"
27 #include "pagespeed/kernel/base/string_util.h"
28 #include "pagespeed/kernel/util/copy_on_write.h"
29 
30 namespace net_instaweb {
31 
32 class AbstractMutex;
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 class Writer;
52 
55  public:
62 
64  StringPiece hostname, int port);
65  virtual ~SystemServerContext();
66 
67  void SetCachePath(SystemCachePath* cache_path);
68 
77  void FlushCacheIfNecessary();
78 
79  SystemRewriteOptions* global_system_rewrite_options();
80  GoogleString hostname_identifier() { return hostname_identifier_; }
81 
84  void UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set);
85 
87  virtual void PostInitHook();
88 
89  static void InitStats(Statistics* statistics);
90 
92  virtual void ChildInit(SystemRewriteDriverFactory* factory);
93 
97  void CreateLocalStatistics(Statistics* global_statistics,
99 
102  bool initialized() const { return initialized_; }
103 
115  virtual void ApplySessionFetchers(const RequestContextPtr& req,
116  RewriteDriver* driver);
117 
120  void AddHtmlRewriteTimeUs(int64 rewrite_time_us);
121 
122  SystemCachePath* cache_path() { return cache_path_; }
123 
129 
132  virtual const SystemRewriteOptions* SpdyGlobalConfig() const;
133 
136  void ConsoleHandler(const SystemRewriteOptions& options,
137  AdminSite::AdminSource source,
138  const QueryParams& query_params, AsyncFetch* fetch);
139 
141  void MessageHistoryHandler(const RewriteOptions& options,
142  AdminSite::AdminSource source,
143  AsyncFetch* fetch);
144 
146  void StatisticsGraphsHandler(Writer* writer);
147 
151  void AdminPage(bool is_global, const GoogleUrl& stripped_gurl,
152  const QueryParams& query_params, const RewriteOptions* options,
153  AsyncFetch* fetch);
154 
160  void StatisticsPage(bool is_global, const QueryParams& query_params,
161  const RewriteOptions* options,
162  AsyncFetch* fetch);
163 
164  AdminSite* admin_site() { return admin_site_.get(); }
165 
166  protected:
179  virtual bool UpdateCacheFlushTimestampMs(int64 timestamp_ms);
180 
182  virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr& request,
183  RewriteDriver* driver) {}
184 
186  void ConsoleJsonHandler(const QueryParams& params, AsyncFetch* fetch);
187 
199  void StatisticsHandler(const RewriteOptions& options, bool is_global_request,
200  AdminSite::AdminSource source, AsyncFetch* fetch);
201 
204 
207 
210  void PrintCaches(bool is_global, AdminSite::AdminSource source,
211  const GoogleUrl& stripped_gurl,
212  const QueryParams& query_params,
213  const RewriteOptions* options,
214  AsyncFetch* fetch);
215 
217  void PrintHistograms(bool is_global_request,
218  AdminSite::AdminSource source,
219  AsyncFetch* fetch);
220 
221  Variable* statistics_404_count();
222 
223  private:
233  void CheckLegacyGlobalCacheFlushFile();
234 
235  scoped_ptr<AdminSite> admin_site_;
236 
237  bool initialized_;
238  bool use_per_vhost_statistics_;
239 
243  scoped_ptr<AbstractMutex> cache_flush_mutex_;
244  int64 last_cache_flush_check_sec_;
245 
246  Variable* cache_flush_count_;
247  UpDownCounter* cache_flush_timestamp_ms_;
248 
249  Histogram* html_rewrite_time_us_histogram_;
250 
252  scoped_ptr<Statistics> split_statistics_;
253 
255  SharedMemStatistics* local_statistics_;
256 
258  scoped_ptr<RewriteStats> local_rewrite_stats_;
259  scoped_ptr<UrlAsyncFetcherStats> stats_fetcher_;
260 
264  GoogleString hostname_identifier_;
265 
266  SystemCaches* system_caches_;
267 
268  SystemCachePath* cache_path_;
269 
270  DISALLOW_COPY_AND_ASSIGN(SystemServerContext);
271 };
272 
273 }
274 
275 #endif
virtual void MaybeApplySpdySessionFetcher(const RequestContextPtr &request, RewriteDriver *driver)
Hook for implementations to support fetching directly from the spdy module.
Definition: system_server_context.h:182
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 const SystemRewriteOptions * SpdyGlobalConfig() const
virtual void CollapseConfigOverlaysAndComputeSignatures()
void ConsoleJsonHandler(const QueryParams &params, AsyncFetch *fetch)
Returns JSON used by the PageSpeed Console JavaScript.
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:54
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:31
void CreateLocalStatistics(Statistics *global_statistics, SystemRewriteDriverFactory *factory)
void PrintSpdyConfig(AdminSite::AdminSource source, AsyncFetch *fetch)
Print details fo the SPDY configuration.
void PrintCaches(bool is_global, AdminSite::AdminSource source, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
Definition: async_fetch.h:53
bool initialized() const
Definition: system_server_context.h:102
Definition: system_caches.h:59
Definition: rewrite_driver.h:98
void StatisticsGraphsHandler(Writer *writer)
Deprecated handler for graphs in the PSOL console.
Definition: server_context.h:101
A server context with features specific to a PSOL port on a unix system.
Definition: system_server_context.h:54
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
const GoogleString & hostname() const
Returns the current server hostname.
Definition: server_context.h:587
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)
Definition: rewrite_options.h:83
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)
void PrintNormalConfig(AdminSite::AdminSource source, AsyncFetch *fetch)
Print details fo the non-SPDY configuration.
Definition: rewrite_driver_factory.h:73