You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by os...@apache.org on 2014/08/12 15:08:19 UTC
git commit: ats_speed: upgrade from 1.7.30.4 to 1.8.31.4
Repository: trafficserver
Updated Branches:
refs/heads/oschaaf-pagespeed-1.8.31.4 [created] 7bb2070eb
ats_speed: upgrade from 1.7.30.4 to 1.8.31.4
Work in progress.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7bb2070e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7bb2070e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7bb2070e
Branch: refs/heads/oschaaf-pagespeed-1.8.31.4
Commit: 7bb2070eba7159bf57ca8691a257274b3fee6002
Parents: 8324816
Author: Otto van der Schaaf <os...@we-amp.com>
Authored: Tue Aug 12 05:09:45 2014 +0200
Committer: Otto van der Schaaf <os...@we-amp.com>
Committed: Tue Aug 12 05:09:45 2014 +0200
----------------------------------------------------------------------
plugins/experimental/ats_speed/Makefile | 13 +--
.../ats_speed/ats_beacon_intercept.cc | 2 +
.../experimental/ats_speed/ats_demo_filter.cc | 90 --------------------
.../experimental/ats_speed/ats_demo_filter.h | 65 --------------
.../ats_speed/ats_process_context.cc | 6 +-
.../ats_speed/ats_process_context.h | 3 +-
.../ats_speed/ats_resource_intercept.cc | 35 ++------
.../ats_speed/ats_rewrite_driver_factory.cc | 16 +++-
.../ats_speed/ats_rewrite_driver_factory.h | 5 +-
.../ats_speed/ats_rewrite_options.cc | 1 -
plugins/experimental/ats_speed/ats_speed.cc | 14 ++-
11 files changed, 45 insertions(+), 205 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/Makefile
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/Makefile b/plugins/experimental/ats_speed/Makefile
index f76c334..7498b2b 100644
--- a/plugins/experimental/ats_speed/Makefile
+++ b/plugins/experimental/ats_speed/Makefile
@@ -52,19 +52,20 @@ INC =-I$(MOD_PAGESPEED_DIR)\
-I$(MOD_PAGESPEED_DIR)out/$(BUILDTYPE)/obj/gen\
-I$(MOD_PAGESPEED_DIR)out/$(BUILDTYPE)/obj/gen/protoc_out/instaweb
-PSOL_LIBS = $(PAGESPEED_OUT)pagespeed_automatic.a $(PAGESPEED_OUT)libserf.a $(PAGESPEED_OUT)libaprutil.a $(PAGESPEED_OUT)libapr.a
+PSOL_LIBS = $(PAGESPEED_OUT)pagespeed_automatic.a
+#PSOL_LIBS = $(PAGESPEED_OUT)pagespeed_automatic.a $(PAGESPEED_OUT)libserf.a $(PAGESPEED_OUT)libaprutil.a $(PAGESPEED_OUT)libapr.a
%.so: psol %.cc
# https://github.com/pagespeed/ngx_pagespeed/issues/433: it would be nice to have -Wall -Werror, only suppressing when needed.
- g++ $(INC) -shared -o ats_speed.so -g -pipe -O3 -fpic $(MOD_PAGESPEED_DIR)/out/$(BUILDTYPE)/obj/gen/data2c_out/instaweb/net/instaweb/apache/install/mod_pagespeed_example/*.cc $(MOD_PAGESPEED_DIR)/net/instaweb/system/*.cc *.cc -lstdc++ -lstdc++ -lpthread $(PSOL_LIBS) -lrt
+ g++ $(INC) -shared -o ats_speed.so -g -pipe -O3 -fpic *.cc -lstdc++ -lstdc++ -lpthread $(PSOL_LIBS) -lrt
all: psol gzip/gzip.so ats_speed.so
-1.7.30.4.tar.gz:
- wget --no-check-certificate https://dl.google.com/dl/page-speed/psol/1.7.30.4.tar.gz
+1.8.31.4.tar.gz:
+ wget --no-check-certificate https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
-psol/: 1.7.30.4.tar.gz
- tar -xzvf 1.7.30.4.tar.gz
+psol/: 1.8.31.4.tar.gz
+ tar -xzvf 1.8.31.4.tar.gz
gzip/gzip.so:
cd gzip && make
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_beacon_intercept.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_beacon_intercept.cc b/plugins/experimental/ats_speed/ats_beacon_intercept.cc
index fc96933..9b14244 100644
--- a/plugins/experimental/ats_speed/ats_beacon_intercept.cc
+++ b/plugins/experimental/ats_speed/ats_beacon_intercept.cc
@@ -249,6 +249,8 @@ processRequest(InterceptCtx *cont_data) {
SystemRequestContext* system_request_context =
new SystemRequestContext(server_context->thread_system()->NewMutex(),
server_context->timer(),
+ // TODO(oschaaf): determine these for real.
+ "www.foo.com",
80,
"127.0.0.1");
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_demo_filter.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_demo_filter.cc b/plugins/experimental/ats_speed/ats_demo_filter.cc
deleted file mode 100644
index 2fc3c32..0000000
--- a/plugins/experimental/ats_speed/ats_demo_filter.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include "net/instaweb/rewriter/public/add_head_filter.h"
-#include "net/instaweb/htmlparse/public/html_parse.h"
-#include "net/instaweb/htmlparse/public/html_element.h"
-#include <string>
-
-#include <ts/ts.h>
-#include "ats_demo_filter.h"
-
-namespace net_instaweb {
- const char* AtsDemoFilter::kPoweredByHtml =
- "<div id=\"weamp_poweredby\" style=\"bottom:0; height:30px; left:0; width:100%;\">"
- "<div style=\"line-height:30px; margin:0 auto; width:100%; text-align:center; \">"
- "<a target=\"_blank\" title=\"Google PageSpeed optimization demo brought to you by We-Amp\" href=\"http://www.we-amp.com/\">Google PageSpeed optimization demo by We-Amp</a>"
- "</div>"
- "</div>";
-
-
-
-AtsDemoFilter::AtsDemoFilter(HtmlParse* parser, bool banner) :
- parser_(parser),
- banner_(banner)
-{
-}
-
-void AtsDemoFilter::StartElement(HtmlElement* element) {
- if (banner_ && element->keyword() == HtmlName::kBody) {
- HtmlNode* el = parser_->NewCharactersNode(NULL, AtsDemoFilter::kPoweredByHtml);
- parser_->InsertNodeBeforeCurrent(el);
- }
-
- if (element->keyword() == HtmlName::kA || element->keyword() == HtmlName::kBase
- || element->keyword() == HtmlName::kForm|| element->keyword() == HtmlName::kImg
- || element->keyword() == HtmlName::kLink || element->keyword() == HtmlName::kScript) {
- HtmlElement::AttributeList* attributes = element->mutable_attributes();
- for (HtmlElement::AttributeIterator i(attributes->begin());
- i != attributes->end(); ++i) {
-
- HtmlElement::Attribute& attribute = *i;
- if (attribute.keyword() == HtmlName::kAction || attribute.keyword() == HtmlName::kHref
- || attribute.keyword() == HtmlName::kSrc) {
- const char * attribute_value = NULL;
- if ( attribute.DecodedValueOrNull() != NULL ) {
- attribute_value = attribute.DecodedValueOrNull();
- } else {
- attribute_value = attribute.escaped_value();
- }
-
- if ( attribute_value != NULL) {
- GoogleUrl url( attribute_value );
- if (url.IsWebValid()) {
- if (url.Host() == from_domain_) {
- StringPiece scheme = url.Scheme();
- StringPiece host = to_domain_.c_str();
- StringPiece pathAndQuery = url.PathAndLeaf();
- GoogleString rewritten = StrCat(scheme,"://", host, pathAndQuery);
- attribute.SetValue(rewritten.c_str());
- break;
- }
- }
- }
- }
- }
- }
-}
-
-
-} // namespace net_instaweb
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_demo_filter.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_demo_filter.h b/plugins/experimental/ats_speed/ats_demo_filter.h
deleted file mode 100644
index 2b813b2..0000000
--- a/plugins/experimental/ats_speed/ats_demo_filter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#ifndef ATS_DEMO_FILTER_H_
-#define ATS_DEMO_FILTER_H_
-
-#include "base/basictypes.h"
-#include "base/string_piece.h"
-#include "net/instaweb/htmlparse/public/empty_html_filter.h"
-#include "net/instaweb/util/public/atom.h"
-#include "net/instaweb/htmlparse/public/html_parse.h"
-#include "net/instaweb/htmlparse/public/html_element.h"
-#include <string>
-
-using base::StringPiece;
-
-namespace net_instaweb {
-
-
-
- class AtsDemoFilter : public EmptyHtmlFilter {
- public:
- static const char* kPoweredByHtml;
-
- explicit AtsDemoFilter(HtmlParse* parser, bool banner);
- virtual void StartElement(HtmlElement* element);
- virtual const char* Name() const { return "AtsDemo"; }
- // TODO: move to constructor
- void set_domains(const StringPiece& to_domain, const StringPiece& from_domain)
- {
- to_domain.CopyToString(&to_domain_);
- from_domain.CopyToString(&from_domain_);
- }
-
- private:
- std::string to_domain_;
- std::string from_domain_;
- HtmlParse* parser_;
- bool banner_;
- DISALLOW_COPY_AND_ASSIGN(AtsDemoFilter);
- };
-
-} // namespace net_instaweb
-
-#endif // ATS_DEMO_FILTER_H_
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_process_context.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_process_context.cc b/plugins/experimental/ats_speed/ats_process_context.cc
index 9a131dc..f3ca481 100644
--- a/plugins/experimental/ats_speed/ats_process_context.cc
+++ b/plugins/experimental/ats_speed/ats_process_context.cc
@@ -35,10 +35,12 @@
namespace net_instaweb {
-AtsProcessContext::AtsProcessContext() {
+ AtsProcessContext::AtsProcessContext() : ProcessContext() {
AtsThreadSystem* ts = new AtsThreadSystem();
message_handler_.reset(new AtsMessageHandler(ts->NewMutex()));
- driver_factory_.reset(new AtsRewriteDriverFactory(ts));
+ driver_factory_.reset(
+ new AtsRewriteDriverFactory(
+ *this, ts, ""/*hostname, not used*/, -1/*port, not used*/));
server_context_ = driver_factory()->MakeAtsServerContext();
AtsRewriteOptions* root_options_ = (AtsRewriteOptions*)driver_factory_->default_options();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_process_context.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_process_context.h b/plugins/experimental/ats_speed/ats_process_context.h
index 95dfbff..aa344b2 100644
--- a/plugins/experimental/ats_speed/ats_process_context.h
+++ b/plugins/experimental/ats_speed/ats_process_context.h
@@ -27,6 +27,7 @@
#include "net/instaweb/util/public/google_message_handler.h"
#include "net/instaweb/util/public/message_handler.h"
#include "net/instaweb/util/public/scoped_ptr.h"
+#include "net/instaweb/rewriter/public/process_context.h"
namespace net_instaweb {
@@ -34,7 +35,7 @@ class AtsRewriteDriverFactory;
class ProxyFetchFactory;
class AtsServerContext;
-class AtsProcessContext {
+class AtsProcessContext : ProcessContext {
public:
explicit AtsProcessContext();
virtual ~AtsProcessContext();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_resource_intercept.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_resource_intercept.cc b/plugins/experimental/ats_speed/ats_resource_intercept.cc
index 5d96867..0afeae5 100644
--- a/plugins/experimental/ats_speed/ats_resource_intercept.cc
+++ b/plugins/experimental/ats_speed/ats_resource_intercept.cc
@@ -40,7 +40,7 @@
#include "net/instaweb/system/public/system_request_context.h"
#include "net/instaweb/util/public/string_writer.h"
-#include "net/instaweb/system/public/handlers.h"
+
using namespace net_instaweb;
@@ -145,6 +145,7 @@ resource_intercept(TSCont cont, TSEvent event, void *edata)
SystemRequestContext* system_request_context =
new SystemRequestContext(server_context->thread_system()->NewMutex(),
server_context->timer(),
+ "www.foo.com",// TODO(oschaaf): compute these
80,
"127.0.0.1");
@@ -278,36 +279,14 @@ read_cache_header_callback(TSCont cont, TSEvent event, void *edata)
const char* error_message = NULL;
StringPiece request_uri_path = ctx->gurl->PathAndLeaf();
- if (ctx->gurl->PathSansQuery() == "/robots.txt") {
+ if (false && ctx->gurl->PathSansQuery() == "/robots.txt") {
content_type = kContentTypeText;
writer.Write("User-agent: *\n", server_context->message_handler());
writer.Write("Disallow: /\n", server_context->message_handler());
- } else if (ctx->gurl->PathSansQuery() == "/pagespeed_message") {
- // TODO(oschaaf)... let's wait for a bit with this one.
- } else if (ctx->gurl->PathSansQuery() == "/pagespeed_statistics" || ctx->gurl->PathSansQuery() == "/pagespeed_global_statistics") {
- error_message = StatisticsHandler(
- factory,
- server_context,
- NULL, // No SPDY-specific config in ats_pagespeed.
- !factory->use_per_vhost_statistics() || StringCaseStartsWith(
- request_uri_path, "/pagespeed_global_statistics"),
- StringPiece(ctx->gurl->Query().as_string().c_str()),
- &content_type,
- &writer,
- server_context->message_handler());
- } else if (ctx->gurl->PathSansLeaf() == "/ats_speed_static/") {
- StringPiece file_contents;
- if (server_context->static_asset_manager()->GetAsset(
- request_uri_path.substr(
- strlen("/ats_speed_static/")),
- &file_contents, &content_type, &cache_control)) {
- file_contents.CopyToString(&output);
- } else {
- error_message = "Static asset not found";
- }
- } else if (ctx->gurl->PathSansQuery() == "/pagespeed_console") {
- ConsoleHandler(server_context, server_context->config(), &writer, server_context->message_handler());
- } else {
+ }
+
+ // TODO(oschaaf): /pagespeed_admin handling
+ else {
// Optimized resource are highly cacheable (1 year expiry)
// TODO(oschaaf): configuration
TSHttpTxnRespCacheableSet(txn, 1);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_rewrite_driver_factory.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_rewrite_driver_factory.cc b/plugins/experimental/ats_speed/ats_rewrite_driver_factory.cc
index 1c8ffb1..cf73ed3 100644
--- a/plugins/experimental/ats_speed/ats_rewrite_driver_factory.cc
+++ b/plugins/experimental/ats_speed/ats_rewrite_driver_factory.cc
@@ -60,9 +60,13 @@
namespace net_instaweb {
- AtsRewriteDriverFactory::AtsRewriteDriverFactory(AtsThreadSystem* thread_system)
- // TODO(oschaaf): fix hostname/port (?)
- : SystemRewriteDriverFactory(thread_system, new PthreadSharedMem(), StringPiece("foohost"), 8080)
+ AtsRewriteDriverFactory::AtsRewriteDriverFactory(
+ const ProcessContext& process_context,
+ AtsThreadSystem* thread_system,
+ StringPiece hostname, int port)
+ : SystemRewriteDriverFactory(process_context,
+ thread_system, NULL /*default shared mem runtime*/,
+ "" /*hostname, not used*/, -1/*port, not used*/)
, ats_message_handler_(new AtsMessageHandler(thread_system->NewMutex()))
, ats_html_parse_message_handler_(new AtsMessageHandler(thread_system->NewMutex()))
, use_per_vhost_statistics_(false)
@@ -145,6 +149,12 @@ namespace net_instaweb {
return options;
}
+ ServerContext* AtsRewriteDriverFactory::NewDecodingServerContext() {
+ ServerContext* sc = new AtsServerContext(this);
+ InitStubDecodingServerContext(sc);
+ return sc;
+ }
+
void AtsRewriteDriverFactory::InitStats(Statistics* statistics) {
// Init standard PSOL stats.
SystemRewriteDriverFactory::InitStats(statistics);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_rewrite_driver_factory.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_rewrite_driver_factory.h b/plugins/experimental/ats_speed/ats_rewrite_driver_factory.h
index 9aa5405..de18a28 100644
--- a/plugins/experimental/ats_speed/ats_rewrite_driver_factory.h
+++ b/plugins/experimental/ats_speed/ats_rewrite_driver_factory.h
@@ -52,7 +52,9 @@ namespace net_instaweb {
class AtsRewriteDriverFactory : public SystemRewriteDriverFactory {
public:
- explicit AtsRewriteDriverFactory(AtsThreadSystem* thread_system);
+ explicit AtsRewriteDriverFactory(const ProcessContext& process_context,
+ AtsThreadSystem* thread_system,
+ StringPiece hostname, int port);
virtual ~AtsRewriteDriverFactory();
virtual Hasher* NewHasher();
@@ -62,6 +64,7 @@ class AtsRewriteDriverFactory : public SystemRewriteDriverFactory {
virtual Timer* DefaultTimer();
virtual NamedLockManager* DefaultLockManager();
virtual RewriteOptions* NewRewriteOptions();
+ virtual ServerContext* NewDecodingServerContext();
virtual bool UseBeaconResultsInFilters() const {
return true;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_rewrite_options.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_rewrite_options.cc b/plugins/experimental/ats_speed/ats_rewrite_options.cc
index 97a72ab..172db83 100644
--- a/plugins/experimental/ats_speed/ats_rewrite_options.cc
+++ b/plugins/experimental/ats_speed/ats_rewrite_options.cc
@@ -52,7 +52,6 @@ void AtsRewriteOptions::Init() {
DCHECK(ats_properties_ != NULL)
<< "Call AtsRewriteOptions::Initialize() before construction";
InitializeOptions(ats_properties_);
- statistics_handler_path_.set_default("/pagespeed_global_statistics");
}
void AtsRewriteOptions::AddProperties() {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7bb2070e/plugins/experimental/ats_speed/ats_speed.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_speed/ats_speed.cc b/plugins/experimental/ats_speed/ats_speed.cc
index da67ca7..8fcef55 100644
--- a/plugins/experimental/ats_speed/ats_speed.cc
+++ b/plugins/experimental/ats_speed/ats_speed.cc
@@ -42,7 +42,6 @@
#include "ats_speed.h"
#include "ats_config.h"
-#include "ats_demo_filter.h"
#include "ats_header_utils.h"
#include "ats_rewrite_options.h"
#include "ats_log_message_handler.h"
@@ -70,8 +69,8 @@
#include "net/instaweb/rewriter/public/process_context.h"
#include "net/instaweb/rewriter/public/resource_fetch.h"
#include "net/instaweb/rewriter/public/rewrite_driver.h"
+#include "net/instaweb/rewriter/public/rewrite_query.h"
#include "net/instaweb/rewriter/public/static_asset_manager.h"
-#include "net/instaweb/system/public/handlers.h"
#include "net/instaweb/public/global_constants.h"
#include "net/instaweb/public/version.h"
#include "net/instaweb/util/public/google_message_handler.h"
@@ -196,11 +195,9 @@ RewriteOptions* ps_determine_request_options(
// make cache key consistent for both lookup and storing in cache.
//
// Sets option from request headers and url.
- ServerContext::OptionsBoolPair query_options_success =
- server_context->GetQueryOptions(url, request_headers,
- response_headers);
- bool get_query_options_success = query_options_success.second;
- if (!get_query_options_success) {
+ RewriteQuery rewrite_query;
+ if (!server_context->GetQueryOptions(url, request_headers,
+ response_headers, &rewrite_query)) {
// Failed to parse query params or request headers. Treat this as if there
// were no query params given.
TSError("ps_route rerquest: parsing headers or query params failed.");
@@ -209,7 +206,7 @@ RewriteOptions* ps_determine_request_options(
// Will be NULL if there aren't any options set with query params or in
// headers.
- return query_options_success.first;
+ return rewrite_query.ReleaseOptions();
}
bool ps_determine_options(ServerContext* server_context,
@@ -456,6 +453,7 @@ ats_transform_init(TSCont contp, TransformCtx * ctx)
SystemRequestContext* system_request_context =
new SystemRequestContext(server_context->thread_system()->NewMutex(),
server_context->timer(),
+ "www.foo.com",
80,
"127.0.0.1");