Page Speed Optimization Libraries  1.2.24.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions
net_instaweb::ApacheRewriteDriverFactory Class Reference

Creates an Apache RewriteDriver. More...

#include "apache_rewrite_driver_factory.h"

Inheritance diagram for net_instaweb::ApacheRewriteDriverFactory:
net_instaweb::RewriteDriverFactory

List of all members.

Public Member Functions

 ApacheRewriteDriverFactory (server_rec *server, const StringPiece &version)
virtual HasherNewHasher ()
UrlPollableAsyncFetcherSubResourceFetcher ()
GoogleString hostname_identifier ()
AbstractSharedMemshared_mem_runtime () const
SharedMemRefererStatisticsshared_mem_referer_statistics () const
ApacheMessageHandlerapache_message_handler ()
bool is_root_process () const
void RootInit ()
void ChildInit ()
void DumpRefererStatistics (Writer *writer)
SlowWorkerslow_worker ()
StatisticsMakeGlobalSharedMemStatistics (bool logging, int64 logging_interval_ms, const GoogleString &logging_file)
SharedMemStatisticsAllocateAndInitSharedMemStatistics (const StringPiece &name, const bool logging, const int64 logging_interval_ms, const GoogleString &logging_file)
 Creates and ::Initializes a shared memory statistics object.
ApacheServerContextMakeApacheServerContext (server_rec *server)
void set_fetch_with_gzip (bool x)
bool fetch_with_gzip () const
void set_track_original_content_length (bool x)
bool track_original_content_length () const
void set_num_rewrite_threads (int x)
int num_rewrite_threads () const
void set_num_expensive_rewrite_threads (int x)
int num_expensive_rewrite_threads () const
void set_message_buffer_size (int x)
void list_outstanding_urls_on_error (bool x)
bool use_per_vhost_statistics () const
void set_use_per_vhost_statistics (bool x)
bool enable_property_cache () const
void set_enable_property_cache (bool x)
bool inherit_vhost_config () const
 If true, virtual hosts should inherit global configuration.
void set_inherit_vhost_config (bool x)
bool disable_loopback_routing () const
void set_disable_loopback_routing (bool x)
bool install_crash_handler () const
void set_install_crash_handler (bool x)
ApacheCacheGetCache (ApacheConfig *config)
AprMemCacheNewAprMemCache (const GoogleString &spec)
 Create a new AprMemCache from the given hostname[:port] specification.
CacheInterfaceGetMemcached (ApacheConfig *config, CacheInterface *l2_cache)
CacheInterfaceGetFilesystemMetadataCache (ApacheConfig *config)
void StopAsyncGets ()
UrlAsyncFetcherGetFetcher (ApacheConfig *config)
SerfUrlAsyncFetcherGetSerfFetcher (ApacheConfig *config)
bool PoolDestroyed (ApacheServerContext *rm)
virtual RewriteOptionsNewRewriteOptions ()
virtual RewriteOptionsNewRewriteOptionsForQuery ()
void PrintMemCacheStats (GoogleString *out)
 Print out details of all the connections to memcached servers.
void ApplySessionFetchers (ApacheServerContext *manager, RewriteDriver *driver, request_rec *req)

Static Public Member Functions

static void InitStats (Statistics *statistics)
static void Initialize ()
 Initializes static variables. Initialize/Terminate calls must be paired.
static void Terminate ()
static bool TreatRequestAsSpdy (request_rec *req)

Static Public Attributes

static const char kMemcached []
static const char kStaticJavaScriptPrefix []

Protected Member Functions

virtual UrlFetcherDefaultUrlFetcher ()
virtual UrlAsyncFetcherDefaultAsyncUrlFetcher ()
virtual void StopCacheActivity ()
virtual MessageHandlerDefaultHtmlParseMessageHandler ()
 Provide defaults.
virtual MessageHandlerDefaultMessageHandler ()
virtual FileSystemDefaultFileSystem ()
virtual TimerDefaultTimer ()
virtual void SetupCaches (ServerContext *resource_manager)
virtual NamedLockManagerDefaultLockManager ()
virtual QueuedWorkerPoolCreateWorkerPool (WorkerPoolName name)
virtual bool ShouldWriteResourcesToFileSystem ()
void ParentOrChildInit ()
void SharedCircularBufferInit (bool is_root)
void SharedMemRefererStatisticsInit (bool is_root)
virtual void ShutDown ()
virtual void InitStaticJavascriptManager (StaticJavascriptManager *static_js_manager)
 Initializes the StaticJavascriptManager.

Detailed Description

Creates an Apache RewriteDriver.


Member Function Documentation

Give access to apache_message_handler_ for the cases we need to use ApacheMessageHandler rather than MessageHandler. e.g. Use ApacheMessageHandler::Dump() This is a better choice than cast from MessageHandler.

If needed, sets session fetchers on the driver to do the following: a) Adds custom headers when configured in RewriteOptions. b) Route requests directly to this very server when they are not configured to be external. c) Route requests to mod_spdy's slave connection code if configured to.

Subclasses can override this to create an appropriately-sized thread pool for their environment. The default implementation will always make one with a single thread.

Reimplemented from net_instaweb::RewriteDriverFactory.

They may also supply a custom lock manager. The default implementation will use the file system.

Reimplemented from net_instaweb::RewriteDriverFactory.

Implementors of RewriteDriverFactory must supply default definitions for each of these methods, although they may be overridden via set_ methods above.

Implements net_instaweb::RewriteDriverFactory.

Finds a Cache for the file_cache_path in the config. If none exists, creates one, using all the other parameters in the ApacheConfig. Currently, no checking is done that the other parameters (e.g. cache size, cleanup interval, etc.) are consistent.

Finds a fetcher for the settings in this config, sharing with existing fetchers if possible, otherwise making a new one (and its required thread).

Returns the filesystem metadata cache for the given config's specification (if it has one). NULL is returned if no cache is specified.

Makes a memcached-based cache if the configuration contains a memcached server specification. The l2_cache passed in is used to handle puts/gets for huge (>1M) values. NULL is returned if memcached is not specified for this server.

If a non-null CacheInterface* is returned, its ownership is transferred to the caller and must be freed on destruction.

As above, but just gets a Serf fetcher --- not a slurp fetcher or a rate limiting one, etc.

static void net_instaweb::ApacheRewriteDriverFactory::InitStats ( Statistics statistics) [static]

Initializes all the statistics objects created transitively by ApacheRewriteDriverFactory, including apache-specific and platform-independent statistics.

Reimplemented from net_instaweb::RewriteDriverFactory.

For shared memory resources the general setup we follow is to have the first running process (aka the root) create the necessary segments and fill in their shared data structures, while processes created to actually handle requests attach to already existing shared data structures.

During normal server startup[1], RootInit() is called from the Apache hooks in the root process for the first task, and then ChildInit() is called in any child process.

Keep in mind, however, that when fork() is involved a process may effectively see both calls, in which case the 'ChildInit' call would come second and override the previous root status. Both calls are also invoked in the debug single-process mode (httpd -X).

Note that these are not static methods --- they are invoked on every ApacheRewriteDriverFactory instance, which exist for the global configuration as well as all the vhosts.

[1] Besides normal startup, Apache also uses a temporary process to syntax check the config file. That basically looks like a complete normal startup and shutdown to the code.

When Serf gets a system error during polling, to avoid spamming the log we just print the number of outstanding fetch URLs. To debug this it's useful to print the complete set of URLs, in which case this should be turned on.

Statistics* net_instaweb::ApacheRewriteDriverFactory::MakeGlobalSharedMemStatistics ( bool  logging,
int64  logging_interval_ms,
const GoogleString logging_file 
)

Build global shared-memory statistics. This is invoked if at least one server context (global or VirtualHost) enables statistics.

Create a new RewriteOptions. In this implementation it will be an ApacheConfig.

Reimplemented from net_instaweb::RewriteDriverFactory.

As above, but set a name on the ApacheConfig noting that it came from a query.

Reimplemented from net_instaweb::RewriteDriverFactory.

This helper method contains init procedures invoked by both RootInit() and ChildInit()

Notification of apache tearing down a context (vhost or top-level) corresponding to given ApacheServerContext. Returns true if it was the last context.

Makes fetches from PSA to origin-server request accept-encoding:gzip, even when used in a context when we want cleartext. We'll decompress as we read the content if needed.

Tracks the size of resources fetched from origin and populates the X-Original-Content-Length header for resources derived from them.

virtual void net_instaweb::ApacheRewriteDriverFactory::SetupCaches ( ServerContext server_context) [protected, virtual]

Called from InitServerContext, but virtualized separately as it is platform-specific. This method must call on the server context: set_http_cache, set_metadata_cache, set_filesystem_metadata_cache, and MakePropertyCaches.

Implements net_instaweb::RewriteDriverFactory.

Initialize SharedCircularBuffer and pass it to ApacheMessageHandler and ApacheHtmlParseMessageHandler. is_root is true if this is invoked from root (ie. parent) process.

Initialize shared_mem_referer_statistics_; is_root should be true if this is invoked from the root (i.e. parent) process

Disable the Resource Manager's filesystem since we have a write-through http_cache.

virtual void net_instaweb::ApacheRewriteDriverFactory::ShutDown ( ) [protected, virtual]

Release all the resources. It also calls the base class ShutDown to release the base class resources.

Reimplemented from net_instaweb::RewriteDriverFactory.

Stops any further Gets from occuring in the Async cache. This is used to help wind down activity during a shutdown.

Returns the fetcher that will be used by the filters to load any resources they need. This either matches the resource manager's async fetcher or is NULL in case we are configured in a way that all fetches will succeed immediately. Must be called after the fetchers have been computed

static bool net_instaweb::ApacheRewriteDriverFactory::TreatRequestAsSpdy ( request_rec *  req) [static]

Returns true if we should handle request as SPDY. This happens in two cases: 1) It's actually a SPDY request using mod_spdy 2) The header X-PSA-Optimize-For-SPDY is present, with any value.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines