17 #ifndef PAGESPEED_SYSTEM_SYSTEM_REWRITE_OPTIONS_H_
18 #define PAGESPEED_SYSTEM_SYSTEM_REWRITE_OPTIONS_H_
23 #include "net/instaweb/rewriter/static_asset_config.pb.h"
34 namespace net_instaweb {
42 typedef std::set<StaticAssetEnum::StaticAsset> StaticAssetSet;
44 static const char kCentralControllerPort[];
45 static const char kPopularityContestMaxInFlight[];
46 static const char kPopularityContestMaxQueueSize[];
47 static const char kStaticAssetCDN[];
48 static const char kRedisServer[];
49 static const char kRedisReconnectionDelayMs[];
50 static const char kRedisTimeoutUs[];
51 static const char kRedisDatabaseIndex[];
53 static constexpr
int kMemcachedDefaultPort = 11211;
54 static constexpr
int kRedisDefaultPort = 6379;
56 static void Initialize();
57 static void Terminate();
67 StringPiece name, StringPiece arg1, StringPiece arg2,
72 int64 file_cache_clean_interval_ms()
const {
73 return file_cache_clean_interval_ms_.value();
75 bool has_file_cache_clean_interval_ms()
const {
76 return file_cache_clean_interval_ms_.was_set();
78 void set_file_cache_clean_interval_ms(int64 x) {
81 int64 file_cache_clean_size_kb()
const {
82 return file_cache_clean_size_kb_.value();
84 bool has_file_cache_clean_size_kb()
const {
85 return file_cache_clean_size_kb_.was_set();
87 void set_file_cache_clean_size_kb(int64 x) {
90 int64 file_cache_clean_inode_limit()
const {
91 return file_cache_clean_inode_limit_.value();
93 bool has_file_cache_clean_inode_limit()
const {
94 return file_cache_clean_inode_limit_.was_set();
96 void set_file_cache_clean_inode_limit(int64 x) {
99 int64 lru_cache_byte_limit()
const {
100 return lru_cache_byte_limit_.value();
102 void set_lru_cache_byte_limit(int64 x) {
105 int64 lru_cache_kb_per_process()
const {
106 return lru_cache_kb_per_process_.value();
108 void set_lru_cache_kb_per_process(int64 x) {
111 bool use_shared_mem_locking()
const {
112 return use_shared_mem_locking_.value();
114 void set_use_shared_mem_locking(
bool x) {
117 bool compress_metadata_cache()
const {
118 return compress_metadata_cache_.value();
120 void set_compress_metadata_cache(
bool x) {
123 bool statistics_enabled()
const {
124 return statistics_enabled_.value();
126 void set_statistics_enabled(
bool x) {
129 bool statistics_logging_enabled()
const {
130 return statistics_logging_enabled_.value();
132 void set_statistics_logging_enabled(
bool x) {
135 int64 statistics_logging_max_file_size_kb()
const {
136 return statistics_logging_max_file_size_kb_.value();
138 const GoogleString& statistics_logging_charts_css()
const {
139 return statistics_logging_charts_css_.value();
141 const GoogleString& statistics_logging_charts_js()
const {
142 return statistics_logging_charts_js_.value();
144 int64 statistics_logging_interval_ms()
const {
145 return statistics_logging_interval_ms_.value();
147 void set_statistics_logging_interval_ms(int64 x) {
148 set_option(x, &statistics_logging_interval_ms_);
151 return file_cache_path_.value();
156 const GoogleString& log_dir()
const {
return log_dir_.value(); }
159 return memcached_servers_.value();
164 int memcached_threads()
const {
165 return memcached_threads_.value();
167 void set_memcached_threads(
int x) {
170 int memcached_timeout_us()
const {
171 return memcached_timeout_us_.value();
173 bool has_memcached_timeout_us()
const {
174 return memcached_timeout_us_.was_set();
176 void set_memcached_timeout_us(
int x) {
180 return redis_server_.value();
185 int64 redis_reconnection_delay_ms()
const {
186 return redis_reconnection_delay_ms_.value();
188 int64 redis_timeout_us()
const {
189 return redis_timeout_us_.value();
191 int redis_database_index()
const {
192 return redis_database_index_.value();
194 bool has_redis_database_index()
const {
195 return redis_database_index_.was_set();
197 int64 slow_file_latency_threshold_us()
const {
198 return slow_file_latency_threshold_us_.value();
200 bool has_slow_file_latency_threshold_us()
const {
201 return slow_file_latency_threshold_us_.was_set();
203 void set_slow_file_latency_threshold_us(int64 x) {
204 set_option(x, &slow_file_latency_threshold_us_);
207 return fetcher_proxy_.value();
214 return controller_port_.value();
216 int popularity_contest_max_inflight_requests()
const {
217 return popularity_contest_max_inflight_requests_.value();
219 int popularity_contest_max_queue_size()
const {
220 return popularity_contest_max_queue_size_.value();
225 set_option(num_seconds, &cache_flush_poll_interval_sec_);
227 int64 cache_flush_poll_interval_sec()
const {
228 return cache_flush_poll_interval_sec_.value();
230 void set_cache_flush_filename(
const StringPiece& sp) {
231 set_option(sp.as_string(), &cache_flush_filename_);
234 return cache_flush_filename_.value();
238 return https_options_.value();
241 return ssl_cert_directory_.value();
244 return ssl_cert_file_.value();
247 int64 slurp_flush_limit()
const {
248 return slurp_flush_limit_.value();
250 void set_slurp_flush_limit(int64 x) {
253 bool slurp_read_only()
const {
254 return slurp_read_only_.value();
256 void set_slurp_read_only(
bool x) {
259 bool rate_limit_background_fetches()
const {
260 return rate_limit_background_fetches_.value();
263 return slurp_directory_.value();
268 bool disable_loopback_routing()
const {
269 return disable_loopback_routing_.value();
271 bool fetch_with_gzip()
const {
272 return fetch_with_gzip_.value();
274 int64 ipro_max_response_bytes()
const {
275 return ipro_max_response_bytes_.value();
277 int64 ipro_max_concurrent_recordings()
const {
278 return ipro_max_concurrent_recordings_.value();
280 int64 default_shared_memory_cache_kb()
const {
281 return default_shared_memory_cache_kb_.value();
283 void set_default_shared_memory_cache_kb(int64 x) {
284 set_option(x, &default_shared_memory_cache_kb_);
286 int shm_metadata_cache_checkpoint_interval_sec()
const {
287 return shm_metadata_cache_checkpoint_interval_sec_.value();
292 const GoogleString& purge_method()
const {
return purge_method_.value(); }
294 bool AllowDomain(
const GoogleUrl& url,
295 const FastWildcardGroup& wildcard_group)
const;
300 return AllowDomain(url, *statistics_domains_);
302 bool GlobalStatisticsAccessAllowed(
const GoogleUrl& url)
const {
303 return AllowDomain(url, *global_statistics_domains_);
305 bool MessagesAccessAllowed(
const GoogleUrl& url)
const {
306 return AllowDomain(url, *messages_domains_);
308 bool ConsoleAccessAllowed(
const GoogleUrl& url)
const {
309 return AllowDomain(url, *console_domains_);
311 bool AdminAccessAllowed(
const GoogleUrl& url)
const {
312 return AllowDomain(url, *admin_domains_);
314 bool GlobalAdminAccessAllowed(
const GoogleUrl& url)
const {
315 return AllowDomain(url, *global_admin_domains_);
322 return test_proxy_.value();
324 void set_test_proxy(
bool x) {
332 return static_assets_to_cdn_.was_set();
337 return static_assets_to_cdn_.asset_set();
342 return static_assets_to_cdn_.value();
355 return test_proxy_slurp_.value();
360 return !slurp_directory().empty();
363 bool slurping_enabled_read_only()
const {
367 virtual SystemRewriteOptions*
Clone()
const;
368 virtual SystemRewriteOptions*
NewOptions()
const;
373 const RewriteOptions* instance);
374 static SystemRewriteOptions*
DynamicCast(RewriteOptions* instance);
380 void set_description(
const StringPiece& x) { x.CopyToString(&description_); }
385 class HttpsOptions :
public Option<GoogleString> {
387 virtual bool SetFromString(StringPiece value_string,
391 class StaticAssetCDNOptions :
public OptionTemplateBase<GoogleString> {
393 virtual bool SetFromString(StringPiece value_string,
398 virtual void Merge(
const OptionBase* src);
401 const StaticAssetSet& asset_set()
const {
402 return *static_assets_to_cdn_.get();
407 CopyOnWrite<StaticAssetSet> static_assets_to_cdn_;
410 template<
typename Spec,
int default_port>
411 class ExternalServersOption :
public OptionTemplateBase<Spec> {
413 bool SetFromString(StringPiece value_string,
415 return this->mutable_value().SetFromString(value_string, default_port,
419 return this->value().ToString();
422 return hasher->Hash(ToString());
426 class ControllerPortOption :
public Option<GoogleString> {
428 bool SetFromString(StringPiece value_string,
434 static Properties* system_properties_;
438 template<
class OptionClass>
439 static void AddSystemProperty(
typename OptionClass::ValueType default_value,
440 OptionClass SystemRewriteOptions::*offset,
442 StringPiece option_name,
444 bool safe_to_print) {
446 safe_to_print, system_properties_);
449 template<
class OptionClass>
450 static void AddSystemProperty(
typename OptionClass::ValueType default_value,
451 OptionClass SystemRewriteOptions::*offset,
453 StringPiece option_name,
456 bool safe_to_print) {
457 AddProperty(default_value, offset,
id, option_name, scope, help,
458 safe_to_print, system_properties_);
461 static void AddProperties();
466 Option<GoogleString> fetcher_proxy_;
467 Option<GoogleString> file_cache_path_;
468 Option<GoogleString> log_dir_;
470 ExternalServersOption<ExternalClusterSpec, kMemcachedDefaultPort>
472 ExternalServersOption<ExternalServerSpec, kRedisDefaultPort> redis_server_;
473 Option<GoogleString> statistics_logging_charts_css_;
474 Option<GoogleString> statistics_logging_charts_js_;
475 Option<GoogleString> cache_flush_filename_;
476 Option<GoogleString> ssl_cert_directory_;
477 Option<GoogleString> ssl_cert_file_;
478 HttpsOptions https_options_;
480 Option<GoogleString> slurp_directory_;
481 Option<GoogleString> test_proxy_slurp_;
483 Option<bool> statistics_enabled_;
484 Option<bool> statistics_logging_enabled_;
485 Option<bool> use_shared_mem_locking_;
486 Option<bool> compress_metadata_cache_;
488 Option<bool> slurp_read_only_;
489 Option<bool> test_proxy_;
490 Option<bool> rate_limit_background_fetches_;
494 Option<bool> disable_loopback_routing_;
499 Option<bool> fetch_with_gzip_;
501 ControllerPortOption controller_port_;
502 Option<int> popularity_contest_max_inflight_requests_;
503 Option<int> popularity_contest_max_queue_size_;
505 Option<int> memcached_threads_;
506 Option<int> memcached_timeout_us_;
507 Option<int64> redis_reconnection_delay_ms_;
508 Option<int64> redis_timeout_us_;
509 Option<int> redis_database_index_;
511 Option<int64> slow_file_latency_threshold_us_;
512 Option<int64> file_cache_clean_inode_limit_;
513 Option<int64> file_cache_clean_interval_ms_;
514 Option<int64> file_cache_clean_size_kb_;
515 Option<int64> lru_cache_byte_limit_;
516 Option<int64> lru_cache_kb_per_process_;
517 Option<int64> statistics_logging_interval_ms_;
520 Option<int64> cache_flush_poll_interval_sec_;
521 Option<int64> statistics_logging_max_file_size_kb_;
522 Option<int64> slurp_flush_limit_;
523 Option<int64> ipro_max_response_bytes_;
524 Option<int64> ipro_max_concurrent_recordings_;
525 Option<int64> default_shared_memory_cache_kb_;
526 Option<int> shm_metadata_cache_checkpoint_interval_sec_;
527 Option<GoogleString> purge_method_;
529 StaticAssetCDNOptions static_assets_to_cdn_;
531 CopyOnWrite<FastWildcardGroup> statistics_domains_;
532 CopyOnWrite<FastWildcardGroup> global_statistics_domains_;
533 CopyOnWrite<FastWildcardGroup> messages_domains_;
534 CopyOnWrite<FastWildcardGroup> console_domains_;
535 CopyOnWrite<FastWildcardGroup> admin_domains_;
536 CopyOnWrite<FastWildcardGroup> global_admin_domains_;
class GoogleUrl
Definition: google_url.h:58
static const SystemRewriteOptions * DynamicCast(const RewriteOptions *instance)
void FillInStaticAssetCDNConf(StaticAssetConfig *out_conf) const
Fills in an options proto based on the CDN settings passed above.
static void AddProperty(typename OptionClass::ValueType default_value, OptionClass RewriteOptionsSubclass::*offset, const char *id, StringPiece option_name, OptionScope scope, const char *help_text, bool safe_to_print, Properties *properties)
Adds a new Property to 'properties' (the last argument).
Definition: rewrite_options.h:3167
void set_cache_flush_poll_interval_sec(int64 num_seconds)
Cache flushing configuration.
Definition: system_rewrite_options.h:224
Definition: external_server_spec.h:27
GoogleString test_proxy_slurp() const
Definition: system_rewrite_options.h:354
StringPiece description() const
Definition: system_rewrite_options.h:379
bool slurping_enabled() const
Helper functions.
Definition: system_rewrite_options.h:359
Definition: system_rewrite_options.h:40
OptionScope
Definition: rewrite_options.h:629
virtual GoogleString SubclassSignatureLockHeld()
void set_option(const T &new_value, OptionTemplateBase< T > *option)
Definition: rewrite_options.h:3219
virtual SystemRewriteOptions * NewOptions() const
Make an empty options object of the same type as this.
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
const StaticAssetSet & static_assets_to_cdn() const
Particular assets to serve of an external URL.
Definition: system_rewrite_options.h:336
bool has_static_assets_to_cdn() const
Definition: system_rewrite_options.h:331
bool StatisticsAccessAllowed(const GoogleUrl &url) const
Definition: system_rewrite_options.h:299
const Hasher * hasher() const
Returns the hasher used for signatures and URLs to purge.
Definition: rewrite_options.h:3021
Definition: rewrite_options.h:633
Definition: thread_system.h:40
OptionSettingResult
Used for return value of SetOptionFromName.
Definition: rewrite_options.h:813
Definition: message_handler.h:39
Definition: external_server_spec.h:44
const GoogleString & static_assets_cdn_base() const
Base URL to serve them from.
Definition: system_rewrite_options.h:341
virtual SystemRewriteOptions * Clone() const
Definition: rewrite_options.h:84
virtual void Merge(const RewriteOptions &src)
bool test_proxy() const
Definition: system_rewrite_options.h:321