File tree Expand file tree Collapse file tree 5 files changed +27
-6
lines changed
presto-native-execution/presto_cpp/main Expand file tree Collapse file tree 5 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 1919#include < sstream>
2020
2121#include " presto_cpp/main/QueryContextManager.h"
22+ #include " presto_cpp/main/common/Configs.h"
2223#include " presto_cpp/main/common/Counters.h"
2324#include " velox/common/base/Exceptions.h"
2425#include " velox/common/testutil/TestValue.h"
@@ -278,9 +279,11 @@ void PrestoExchangeSource::processDataResponse(
278279 return ;
279280 }
280281 auto * headers = response->headers ();
281- VELOX_CHECK (
282- !headers->getIsChunked (),
283- " Chunked http transferring encoding is not supported." );
282+ if (!SystemConfig::instance ()->exchangeHttp2Enabled ()) {
283+ VELOX_CHECK (
284+ !headers->getIsChunked (),
285+ " Chunked http transferring encoding is not supported." );
286+ }
284287 const uint64_t contentLength =
285288 atol (headers->getHeaders ()
286289 .getSingleOrEmpty (proxygen::HTTP_HEADER_CONTENT_LENGTH)
Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ SystemConfig::SystemConfig() {
232232 NUM_PROP (kLogNumZombieTasks , 20 ),
233233 NUM_PROP (kAnnouncementMaxFrequencyMs , 30'000 ), // 30s
234234 NUM_PROP (kHeartbeatFrequencyMs , 0 ),
235+ BOOL_PROP (kExchangeHttp2Enabled , false ),
235236 STR_PROP (kExchangeMaxErrorDuration , " 3m" ),
236237 STR_PROP (kExchangeRequestTimeout , " 20s" ),
237238 STR_PROP (kExchangeConnectTimeout , " 20s" ),
@@ -832,6 +833,10 @@ uint64_t SystemConfig::heartbeatFrequencyMs() const {
832833 return optionalProperty<uint64_t >(kHeartbeatFrequencyMs ).value ();
833834}
834835
836+ bool SystemConfig::exchangeHttp2Enabled () const {
837+ return optionalProperty<bool >(kExchangeHttp2Enabled ).value ();
838+ }
839+
835840std::chrono::duration<double > SystemConfig::exchangeMaxErrorDuration () const {
836841 return velox::config::toDuration (
837842 optionalProperty (kExchangeMaxErrorDuration ).value ());
Original file line number Diff line number Diff line change @@ -638,6 +638,10 @@ class SystemConfig : public ConfigBase {
638638 static constexpr std::string_view kHeartbeatFrequencyMs {
639639 " heartbeat-frequency-ms" };
640640
641+ // / Whether HTTP/2 should be enabled for exchange HTTP client.
642+ static constexpr std::string_view kExchangeHttp2Enabled {
643+ " exchange.http-client.http2-enabled" };
644+
641645 static constexpr std::string_view kExchangeMaxErrorDuration {
642646 " exchange.max-error-duration" };
643647
@@ -1013,6 +1017,8 @@ class SystemConfig : public ConfigBase {
10131017
10141018 uint64_t heartbeatFrequencyMs () const ;
10151019
1020+ bool exchangeHttp2Enabled () const ;
1021+
10161022 std::chrono::duration<double > exchangeMaxErrorDuration () const ;
10171023
10181024 std::chrono::duration<double > exchangeRequestTimeoutMs () const ;
Original file line number Diff line number Diff line change 1616#include < fmt/format.h>
1717#include < folly/io/Cursor.h>
1818#include < sys/resource.h>
19+ #include " presto_cpp/main/common/Configs.h"
1920#include " velox/common/process/ThreadDebugInfo.h"
2021
2122namespace facebook ::presto::util {
@@ -37,7 +38,11 @@ std::shared_ptr<folly::SSLContext> createSSLContext(
3738 sslContext->loadCertKeyPairFromFiles (
3839 clientCertAndKeyPath.c_str (), clientCertAndKeyPath.c_str ());
3940 sslContext->setCiphersOrThrow (ciphers);
40- sslContext->setAdvertisedNextProtocols ({" http/1.1" });
41+ if (SystemConfig::instance ()->exchangeHttp2Enabled ()) {
42+ sslContext->setAdvertisedNextProtocols ({" h2" , " http/1.1" });
43+ } else {
44+ sslContext->setAdvertisedNextProtocols ({" http/1.1" });
45+ }
4146 return sslContext;
4247 } catch (const std::exception& ex) {
4348 LOG (FATAL) << fmt::format (
Original file line number Diff line number Diff line change 1818#include < proxygen/lib/http/connpool/SessionPool.h>
1919#include < proxygen/lib/http/session/HTTPUpstreamSession.h>
2020#include < velox/common/memory/MemoryPool.h>
21- #include " presto_cpp/main/http/HttpConstants .h"
21+ #include " presto_cpp/main/common/Configs .h"
2222#include " velox/common/base/Exceptions.h"
2323
2424namespace facebook ::presto::http {
@@ -215,7 +215,9 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> {
215215class RequestBuilder {
216216 public:
217217 RequestBuilder () {
218- headers_.setHTTPVersion (1 , 1 );
218+ if (!SystemConfig::instance ()->exchangeHttp2Enabled ()) {
219+ headers_.setHTTPVersion (1 , 1 );
220+ }
219221 }
220222
221223 RequestBuilder& method (proxygen::HTTPMethod method) {
You can’t perform that action at this time.
0 commit comments