Page Speed Optimization Libraries
1.2.24.1
|
Creates an Apache RewriteDriver. More...
#include "apache_rewrite_driver_factory.h"
Public Member Functions | |
ApacheRewriteDriverFactory (server_rec *server, const StringPiece &version) | |
virtual Hasher * | NewHasher () |
UrlPollableAsyncFetcher * | SubResourceFetcher () |
GoogleString | hostname_identifier () |
AbstractSharedMem * | shared_mem_runtime () const |
SharedMemRefererStatistics * | shared_mem_referer_statistics () const |
ApacheMessageHandler * | apache_message_handler () |
bool | is_root_process () const |
void | RootInit () |
void | ChildInit () |
void | DumpRefererStatistics (Writer *writer) |
SlowWorker * | slow_worker () |
Statistics * | MakeGlobalSharedMemStatistics (bool logging, int64 logging_interval_ms, const GoogleString &logging_file) |
SharedMemStatistics * | AllocateAndInitSharedMemStatistics (const StringPiece &name, const bool logging, const int64 logging_interval_ms, const GoogleString &logging_file) |
Creates and ::Initializes a shared memory statistics object. | |
ApacheServerContext * | MakeApacheServerContext (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) |
ApacheCache * | GetCache (ApacheConfig *config) |
AprMemCache * | NewAprMemCache (const GoogleString &spec) |
Create a new AprMemCache from the given hostname[:port] specification. | |
CacheInterface * | GetMemcached (ApacheConfig *config, CacheInterface *l2_cache) |
CacheInterface * | GetFilesystemMetadataCache (ApacheConfig *config) |
void | StopAsyncGets () |
UrlAsyncFetcher * | GetFetcher (ApacheConfig *config) |
SerfUrlAsyncFetcher * | GetSerfFetcher (ApacheConfig *config) |
bool | PoolDestroyed (ApacheServerContext *rm) |
virtual RewriteOptions * | NewRewriteOptions () |
virtual RewriteOptions * | NewRewriteOptionsForQuery () |
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 UrlFetcher * | DefaultUrlFetcher () |
virtual UrlAsyncFetcher * | DefaultAsyncUrlFetcher () |
virtual void | StopCacheActivity () |
virtual MessageHandler * | DefaultHtmlParseMessageHandler () |
Provide defaults. | |
virtual MessageHandler * | DefaultMessageHandler () |
virtual FileSystem * | DefaultFileSystem () |
virtual Timer * | DefaultTimer () |
virtual void | SetupCaches (ServerContext *resource_manager) |
virtual NamedLockManager * | DefaultLockManager () |
virtual QueuedWorkerPool * | CreateWorkerPool (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. |
Creates an Apache RewriteDriver.
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.
void net_instaweb::ApacheRewriteDriverFactory::ApplySessionFetchers | ( | ApacheServerContext * | manager, |
RewriteDriver * | driver, | ||
request_rec * | req | ||
) |
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.
virtual QueuedWorkerPool* net_instaweb::ApacheRewriteDriverFactory::CreateWorkerPool | ( | WorkerPoolName | name | ) | [protected, virtual] |
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.
virtual NamedLockManager* net_instaweb::ApacheRewriteDriverFactory::DefaultLockManager | ( | ) | [protected, virtual] |
They may also supply a custom lock manager. The default implementation will use the file system.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual UrlFetcher* net_instaweb::ApacheRewriteDriverFactory::DefaultUrlFetcher | ( | ) | [protected, virtual] |
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).
CacheInterface* net_instaweb::ApacheRewriteDriverFactory::GetFilesystemMetadataCache | ( | ApacheConfig * | config | ) |
Returns the filesystem metadata cache for the given config's specification (if it has one). NULL is returned if no cache is specified.
CacheInterface* net_instaweb::ApacheRewriteDriverFactory::GetMemcached | ( | ApacheConfig * | config, |
CacheInterface * | l2_cache | ||
) |
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.
SerfUrlAsyncFetcher* net_instaweb::ApacheRewriteDriverFactory::GetSerfFetcher | ( | ApacheConfig * | config | ) |
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.
bool net_instaweb::ApacheRewriteDriverFactory::is_root_process | ( | ) | const [inline] |
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.
void net_instaweb::ApacheRewriteDriverFactory::list_outstanding_urls_on_error | ( | bool | x | ) | [inline] |
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.
virtual RewriteOptions* net_instaweb::ApacheRewriteDriverFactory::NewRewriteOptions | ( | ) | [virtual] |
Create a new RewriteOptions. In this implementation it will be an ApacheConfig.
Reimplemented from net_instaweb::RewriteDriverFactory.
virtual RewriteOptions* net_instaweb::ApacheRewriteDriverFactory::NewRewriteOptionsForQuery | ( | ) | [virtual] |
As above, but set a name on the ApacheConfig noting that it came from a query.
Reimplemented from net_instaweb::RewriteDriverFactory.
void net_instaweb::ApacheRewriteDriverFactory::ParentOrChildInit | ( | ) | [protected] |
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.
void net_instaweb::ApacheRewriteDriverFactory::set_fetch_with_gzip | ( | bool | x | ) | [inline] |
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.
void net_instaweb::ApacheRewriteDriverFactory::set_track_original_content_length | ( | bool | x | ) | [inline] |
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.
void net_instaweb::ApacheRewriteDriverFactory::SharedCircularBufferInit | ( | bool | is_root | ) | [protected] |
Initialize SharedCircularBuffer and pass it to ApacheMessageHandler and ApacheHtmlParseMessageHandler. is_root is true if this is invoked from root (ie. parent) process.
void net_instaweb::ApacheRewriteDriverFactory::SharedMemRefererStatisticsInit | ( | bool | is_root | ) | [protected] |
Initialize shared_mem_referer_statistics_; is_root should be true if this is invoked from the root (i.e. parent) process
virtual bool net_instaweb::ApacheRewriteDriverFactory::ShouldWriteResourcesToFileSystem | ( | ) | [inline, protected, virtual] |
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.