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 * | MakeSharedMemStatistics () |
ApacheResourceManager * | MakeApacheResourceManager (server_rec *server) |
void | set_fetch_with_gzip (bool x) |
void | set_num_rewrite_threads (int x) |
void | set_num_expensive_rewrite_threads (int x) |
void | set_message_buffer_size (int x) |
void | list_outstanding_urls_on_error (bool x) |
ApacheCache * | GetCache (ApacheConfig *config) |
UrlPollableAsyncFetcher * | GetFetcher (ApacheConfig *config) |
void | AddHtmlRewriteTimeUs (int64 rewrite_time_us) |
Accumulate in a histogram the amount of time spent rewriting HTML. | |
bool | PoolDestroyed (ApacheResourceManager *rm) |
virtual RewriteOptions * | NewRewriteOptions () |
virtual RewriteOptions * | NewRewriteOptionsForQuery () |
Static Public Member Functions | |
static void | Initialize (Statistics *statistics) |
Protected Member Functions | |
virtual UrlFetcher * | DefaultUrlFetcher () |
virtual UrlAsyncFetcher * | DefaultAsyncUrlFetcher () |
virtual MessageHandler * | DefaultHtmlParseMessageHandler () |
Provide defaults. | |
virtual MessageHandler * | DefaultMessageHandler () |
virtual FileSystem * | DefaultFileSystem () |
virtual Timer * | DefaultTimer () |
virtual CacheInterface * | DefaultCacheInterface () |
Note: Returned CacheInterface should be thread-safe. | |
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 () |
Creates an Apache RewriteDriver.
ApacheMessageHandler* net_instaweb::ApacheRewriteDriverFactory::apache_message_handler | ( | ) | [inline] |
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.
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.
ApacheCache* net_instaweb::ApacheRewriteDriverFactory::GetCache | ( | ApacheConfig * | config | ) |
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.
UrlPollableAsyncFetcher* net_instaweb::ApacheRewriteDriverFactory::GetFetcher | ( | ApacheConfig * | config | ) |
Finds a fetcher for the settings in this config, sharing with existing fetchers if possible, otherwise making a new one (and its required thread).
static void net_instaweb::ApacheRewriteDriverFactory::Initialize | ( | 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::MakeSharedMemStatistics | ( | ) |
Build shared-memory statistics. This is invoked only if at least one VirtualHost enables statistics, in which case the shared-mem statistics is used for VirtualHosts.
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()
bool net_instaweb::ApacheRewriteDriverFactory::PoolDestroyed | ( | ApacheResourceManager * | rm | ) |
Notification of apache tearing down a context (vhost or top-level) corresponding to given ApacheResourceManager. 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::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.
UrlPollableAsyncFetcher* net_instaweb::ApacheRewriteDriverFactory::SubResourceFetcher | ( | ) |
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