Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
net_instaweb::SystemServerContext Class Reference

A server context with features specific to a PSOL port on a unix system. More...

#include "system_server_context.h"

Inheritance diagram for net_instaweb::SystemServerContext:
net_instaweb::ServerContext net_instaweb::ApacheServerContext

Public Member Functions

 SystemServerContext (RewriteDriverFactory *factory, StringPiece hostname, int port)
 
void SetCachePath (SystemCachePath *cache_path)
 
void FlushCacheIfNecessary ()
 
SystemRewriteOptionsglobal_system_rewrite_options ()
 
GoogleString hostname_identifier ()
 
void UpdateCachePurgeSet (const CopyOnWrite< PurgeSet > &purge_set)
 
virtual void PostInitHook ()
 Initialize this SystemServerContext to set up its admin site.
 
virtual void ChildInit (SystemRewriteDriverFactory *factory)
 Called by SystemRewriteDriverFactory::ChildInit. See documentation there.
 
void CreateLocalStatistics (Statistics *global_statistics, SystemRewriteDriverFactory *factory)
 
bool initialized () const
 
virtual void ApplySessionFetchers (const RequestContextPtr &req, RewriteDriver *driver)
 
void AddHtmlRewriteTimeUs (int64 rewrite_time_us)
 
SystemCachePathcache_path ()
 
virtual void CollapseConfigOverlaysAndComputeSignatures ()
 
void ConsoleHandler (const SystemRewriteOptions &options, AdminSite::AdminSource source, const QueryParams &query_params, AsyncFetch *fetch)
 
void MessageHistoryHandler (const RewriteOptions &options, AdminSite::AdminSource source, AsyncFetch *fetch)
 Displays recent Info/Warning/Error messages.
 
void StatisticsGraphsHandler (Writer *writer)
 Deprecated handler for graphs in the PSOL console.
 
void AdminPage (bool is_global, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
 
void StatisticsPage (bool is_global, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
 
AdminSiteadmin_site ()
 
- Public Member Functions inherited from net_instaweb::ServerContext
 ServerContext (RewriteDriverFactory *factory)
 
void SetDefaultLongCacheHeaders (const ContentType *content_type, StringPiece charset, StringPiece cache_control_suffix, ResponseHeaders *header) const
 
void set_filename_prefix (const StringPiece &file_prefix)
 
void set_statistics (Statistics *x)
 
void set_rewrite_stats (RewriteStats *x)
 
void set_lock_manager (NamedLockManager *x)
 
void set_enable_property_cache (bool enabled)
 
void set_message_handler (MessageHandler *x)
 
StringPiece filename_prefix () const
 
Statisticsstatistics () const
 
NamedLockManagerlock_manager () const
 
RewriteDriverFactoryfactory () const
 
ThreadSynchronizerthread_synchronizer ()
 
ExperimentMatcherexperiment_matcher ()
 
void ApplyInputCacheControl (const ResourceVector &inputs, ResponseHeaders *headers)
 
bool IsPagespeedResource (const GoogleUrl &url) const
 Is this URL a ref to a Pagespeed resource?
 
const RewriteFilterFindFilterForDecoding (const StringPiece &id) const
 
bool DecodeUrlGivenOptions (const GoogleUrl &url, const RewriteOptions *options, const UrlNamer *url_namer, StringVector *decoded_urls) const
 See RewriteDriver::DecodeUrl.
 
void ComputeSignature (RewriteOptions *rewrite_options) const
 
Hasherhasher () const
 
const Hasherlock_hasher () const
 
const Hashercontents_hasher () const
 
FileSystemfile_system ()
 
void set_file_system (FileSystem *fs)
 
UrlNamerurl_namer () const
 
void set_url_namer (UrlNamer *n)
 
RewriteOptionsManagerrewrite_options_manager () const
 
SHA1Signaturesignature () const
 
void SetRewriteOptionsManager (RewriteOptionsManager *rom)
 Takes ownership of RewriteOptionsManager.
 
StaticAssetManagerstatic_asset_manager () const
 
void set_static_asset_manager (StaticAssetManager *manager)
 
Schedulerscheduler () const
 
void set_scheduler (Scheduler *s)
 
bool has_default_system_fetcher () const
 
UrlAsyncFetcherDefaultSystemFetcher ()
 
virtual CacheUrlAsyncFetcherCreateCustomCacheFetcher (const RewriteOptions *options, const GoogleString &fragment, CacheUrlAsyncFetcher::AsyncOpHooks *hooks, UrlAsyncFetcher *fetcher)
 
Timertimer () const
 
void set_timer (Timer *timer)
 Note: doesn't take ownership.
 
HTTPCachehttp_cache () const
 
void set_http_cache (HTTPCache *x)
 
void MakePagePropertyCache (PropertyStore *property_store)
 Creates PagePropertyCache object with the provided PropertyStore object.
 
PropertyCachepage_property_cache () const
 
const PropertyCache::Cohortdom_cohort () const
 
void set_dom_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortbeacon_cohort () const
 
void set_beacon_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortdependencies_cohort () const
 
void set_dependencies_cohort (const PropertyCache::Cohort *c)
 
const PropertyCache::Cohortfix_reflow_cohort () const
 
void set_fix_reflow_cohort (const PropertyCache::Cohort *c)
 
CacheInterfacefilesystem_metadata_cache () const
 
void set_filesystem_metadata_cache (CacheInterface *x)
 
CacheInterfacemetadata_cache () const
 
void set_metadata_cache (CacheInterface *x)
 
CriticalImagesFindercritical_images_finder () const
 
void set_critical_images_finder (CriticalImagesFinder *finder)
 
CriticalSelectorFindercritical_selector_finder () const
 
void set_critical_selector_finder (CriticalSelectorFinder *finder)
 
UserAgentMatcheruser_agent_matcher () const
 
void set_user_agent_matcher (UserAgentMatcher *n)
 
SimpleRandomsimple_random ()
 
bool store_outputs_in_file_system ()
 
void set_store_outputs_in_file_system (bool store)
 
RewriteStatsrewrite_stats () const
 
MessageHandlermessage_handler () const
 
NamedLockMakeCreationLock (const GoogleString &name)
 
void TryLockForCreation (NamedLock *creation_lock, Function *callback)
 Attempt to obtain a named lock without blocking. Return true if we do so.
 
void LockForCreation (NamedLock *creation_lock, Sequence *worker, Function *callback)
 
void set_hasher (Hasher *hasher)
 Setters should probably only be used in testing.
 
void set_signature (SHA1Signature *signature)
 
void set_default_system_fetcher (UrlAsyncFetcher *fetcher)
 
bool HandleBeacon (StringPiece body, StringPiece user_agent, const RequestContextPtr &request_context)
 
RewriteOptionsglobal_options ()
 
const RewriteOptionsglobal_options () const
 
void reset_global_options (RewriteOptions *options)
 
RewriteOptionsNewOptions ()
 Makes a new, empty set of RewriteOptions.
 
bool GetQueryOptions (const RequestContextPtr &request_context, const RewriteOptions *domain_options, GoogleUrl *request_url, RequestHeaders *request_headers, ResponseHeaders *response_headers, RewriteQuery *rewrite_query)
 
void GetRemoteOptions (RewriteOptions *remote_options, bool on_startup)
 
RewriteOptionsGetCustomOptions (RequestHeaders *request_headers, RewriteOptions *domain_options, RewriteOptions *query_options)
 
GoogleString GetRewriteOptionsSignatureHash (const RewriteOptions *options)
 
RewriteDriverNewRewriteDriver (const RequestContextPtr &request_ctx)
 
RewriteDriverNewRewriteDriverFromPool (RewriteDriverPool *pool, const RequestContextPtr &request_ctx)
 
RewriteDriverNewUnmanagedRewriteDriver (RewriteDriverPool *pool, RewriteOptions *options, const RequestContextPtr &request_ctx)
 
RewriteDriverNewCustomRewriteDriver (RewriteOptions *custom_options, const RequestContextPtr &request_ctx)
 
void ReleaseRewriteDriver (RewriteDriver *rewrite_driver)
 
ThreadSystemthread_system ()
 
UsageDataReporterusage_data_reporter ()
 
void set_shutting_down ()
 
bool shutting_down () const
 
void ShutDownDrivers (int64 cutoff_time_ms)
 
void MergeNonCachingResponseHeaders (const ResourcePtr &input, const OutputResourcePtr &output)
 
void MergeNonCachingResponseHeaders (const ResponseHeaders &input_headers, ResponseHeaders *output_headers)
 Entry-point with the same functionality, exposed for easier testing.
 
QueuedWorkerPoolhtml_workers ()
 Pool of worker-threads that can be used to handle html-parsing.
 
QueuedWorkerPoolrewrite_workers ()
 Pool of worker-threads that can be used to handle resource rewriting.
 
QueuedWorkerPoollow_priority_rewrite_workers ()
 
size_t num_active_rewrite_drivers ()
 
void InitWorkers ()
 
bool response_headers_finalized () const
 
void set_response_headers_finalized (bool x)
 
RewriteDriverPoolstandard_rewrite_driver_pool ()
 
const GoogleStringhostname () const
 Returns the current server hostname.
 
void set_hostname (const GoogleString &x)
 
void set_central_controller (std::shared_ptr< CentralController > controller)
 
CentralControllercentral_controller ()
 
void AddOriginalContentLengthHeader (const ResourceVector &inputs, ResponseHeaders *headers)
 
virtual bool ProxiesHtml () const =0
 
RequestPropertiesNewRequestProperties ()
 Makes a new RequestProperties.
 
void DeleteCacheOnDestruction (CacheInterface *cache)
 
void set_cache_property_store (CachePropertyStore *p)
 
void set_decoding_driver (RewriteDriver *rd)
 
virtual PropertyStoreCreatePropertyStore (CacheInterface *cache_backend)
 Creates CachePropertyStore object which will be used by PagePropertyCache.
 
const PropertyCache::CohortAddCohort (const GoogleString &cohort_name, PropertyCache *pcache)
 
const PropertyCache::CohortAddCohortWithCache (const GoogleString &cohort_name, CacheInterface *cache, PropertyCache *pcache)
 
const CacheInterfacepcache_cache_backend ()
 
const
pagespeed::js::JsTokenizerPatterns
js_tokenizer_patterns () const
 
void ShowCacheHandler (Format format, StringPiece url, StringPiece ua, bool should_delete, AsyncFetch *fetch, RewriteOptions *options)
 
virtual GoogleString FormatOption (StringPiece option_name, StringPiece args)
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 
- Static Public Member Functions inherited from net_instaweb::ServerContext
static bool IsExcludedAttribute (const char *attribute)
 
static GoogleString ShowCacheForm (StringPiece user_agent)
 

Protected Member Functions

virtual bool UpdateCacheFlushTimestampMs (int64 timestamp_ms)
 
void ConsoleJsonHandler (const QueryParams &params, AsyncFetch *fetch)
 Returns JSON used by the PageSpeed Console JavaScript.
 
void StatisticsHandler (const RewriteOptions &options, bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch)
 
void PrintConfig (AdminSite::AdminSource source, AsyncFetch *fetch)
 Print details for configuration.
 
void PrintCaches (bool is_global, AdminSite::AdminSource source, const GoogleUrl &stripped_gurl, const QueryParams &query_params, const RewriteOptions *options, AsyncFetch *fetch)
 
void PrintHistograms (bool is_global_request, AdminSite::AdminSource source, AsyncFetch *fetch)
 Print histograms showing the dynamics of server activity.
 
Variablestatistics_404_count ()
 
- Protected Member Functions inherited from net_instaweb::ServerContext
void ManageRewriteDriverPool (RewriteDriverPool *pool)
 

Additional Inherited Members

- Public Types inherited from net_instaweb::ServerContext
enum  Format { kFormatAsHtml, kFormatAsJson }
 
typedef std::pair
< RewriteOptions *, bool > 
OptionsBoolPair
 
- Static Public Attributes inherited from net_instaweb::ServerContext
static const int64 kGeneratedMaxAgeMs
 The lifetime for cache-extended generated resources, in milliseconds.
 
static const int64 kCacheTtlForMismatchedContentMs
 Short lifetime for generated resources fetched with mismatching hash.
 
static const char kResourceEtagValue []
 
static const char kCacheKeyResourceNamePrefix []
 

Detailed Description

A server context with features specific to a PSOL port on a unix system.

Constructor & Destructor Documentation

net_instaweb::SystemServerContext::SystemServerContext ( RewriteDriverFactory factory,
StringPiece  hostname,
int  port 
)

Identifies whether the user arrived at an admin page from a /pagespeed_admin handler or a /**_pagespeed_statistics handler. The main difference between these is that the _admin site might in the future grant more privileges than the statistics site did, such as flushing cache. But it also affects the syntax of the links created to sub-pages in the top navigation bar.

Member Function Documentation

void net_instaweb::SystemServerContext::AddHtmlRewriteTimeUs ( int64  rewrite_time_us)

Accumulate in a histogram the amount of time spent rewriting HTML.

Todo:
TODO(sligocki): Remove in favor of RewriteStats::rewrite_latency_histogram.
void net_instaweb::SystemServerContext::AdminPage ( bool  is_global,
const GoogleUrl stripped_gurl,
const QueryParams query_params,
const RewriteOptions options,
AsyncFetch fetch 
)

Handle a request for /pagespeed_admin/**, which is a launching point for all the administrator pages including stats, message-histogram, console, etc.

virtual void net_instaweb::SystemServerContext::ApplySessionFetchers ( const RequestContextPtr req,
RewriteDriver driver 
)
virtual

Normally we just fetch with the default UrlAsyncFetcher, generally serf, but there are some cases where we need to do something more complex:

  • Local requests: requests for resources on this host should go directly to the local IP.
  • Custom fetch headers: before continuing with the fetch we want to add request headers. Session fetchers allow us to make these decisions. Here we may update driver->async_fetcher() to be a special fetcher just for this request.

Reimplemented from net_instaweb::ServerContext.

virtual void net_instaweb::SystemServerContext::CollapseConfigOverlaysAndComputeSignatures ( )
virtual

Hook called after all configuration parsing is done to support implementers like ApacheServerContext that need to collapse configuration inside the config overlays into actual RewriteOptions objects. It will also compute signatures when done, and by default that's the only thing it does.

Reimplemented in net_instaweb::ApacheServerContext.

void net_instaweb::SystemServerContext::ConsoleHandler ( const SystemRewriteOptions options,
AdminSite::AdminSource  source,
const QueryParams query_params,
AsyncFetch fetch 
)

Handler which serves PSOL console. Note: ConsoleHandler always succeeds.

void net_instaweb::SystemServerContext::CreateLocalStatistics ( Statistics global_statistics,
SystemRewriteDriverFactory factory 
)

Initialize this ServerContext to have its own statistics domain. Must be called after global_statistics has been created and had ::InitStats called on it.

void net_instaweb::SystemServerContext::FlushCacheIfNecessary ( )

Implementations should call this method on every request, both for html and resources, to avoid serving stale resources.

Todo:
TODO(jmarantz): allow a URL-based mechanism to flush cache, even if we implement it by simply writing the cache.flush file so other servers can see it. Note that using shared-memory is not a great plan because we need the cache-invalidation to persist across server restart.
bool net_instaweb::SystemServerContext::initialized ( ) const
inline

Whether ChildInit() has been called yet. Exposed so debugging code can verify initialization proceeded properly.

void net_instaweb::SystemServerContext::PrintCaches ( bool  is_global,
AdminSite::AdminSource  source,
const GoogleUrl stripped_gurl,
const QueryParams query_params,
const RewriteOptions options,
AsyncFetch fetch 
)
protected

Print statistics about the caches. In the future this will also be a launching point for examining cache entries and purging them.

void net_instaweb::SystemServerContext::StatisticsHandler ( const RewriteOptions options,
bool  is_global_request,
AdminSite::AdminSource  source,
AsyncFetch fetch 
)
protected

Handler for /mod_pagespeed_statistics and /ngx_pagespeed_statistics, as well as /...pagespeed__global_statistics. If the latter, is_global_request should be true.

void net_instaweb::SystemServerContext::StatisticsPage ( bool  is_global,
const QueryParams query_params,
const RewriteOptions options,
AsyncFetch fetch 
)

Handle a request for the legacy /**_pagespeed_statistics page, which also serves as a launching point for a subset of the admin pages. Because the admin pages are not uniformly sensitive, an existing PageSpeed user might have granted public access to /mod_pagespeed_statistics, but we don't want that to automatically imply access to the server cache.

virtual bool net_instaweb::SystemServerContext::UpdateCacheFlushTimestampMs ( int64  timestamp_ms)
protectedvirtual

Flush the cache by updating the cache flush timestamp in the global options. This will change its signature, which is part of the cache key, and so all previously cached entries will be unreachable.

Returns true if it actually updated the timestamp, false if the existing cache flush timestamp was newer or the same as the one provided.

Subclasses which add additional configurations need to override this method to additionally update the cache flush timestamp in those other configurations.

void net_instaweb::SystemServerContext::UpdateCachePurgeSet ( const CopyOnWrite< PurgeSet > &  purge_set)

Updates the PurgeSet with a new version. This is called when the system picks up (by polling or API) a new version of the cache.purge file.


The documentation for this class was generated from the following file: