Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
#include <sched.h>
#endif

using namespace facebook::velox;

namespace facebook::presto {
namespace {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
#include "presto_cpp/main/http/tests/HttpTestBase.h"

using namespace facebook::presto;
using namespace facebook::velox;

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
folly::Init init{&argc, &argv};
Expand Down
57 changes: 31 additions & 26 deletions presto-native-execution/presto_cpp/main/http/tests/HttpTestBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

namespace fs = boost::filesystem;

using namespace facebook::presto;
using namespace facebook::velox;
using namespace facebook::velox::memory;

std::string getCertsPath(const std::string& fileName) {
std::string currentPath = fs::current_path().c_str();
if (boost::algorithm::ends_with(currentPath, "fbcode")) {
Expand Down Expand Up @@ -65,7 +61,8 @@ inline folly::SSLContextPtr makeSslContext() {

class HttpServerWrapper {
public:
explicit HttpServerWrapper(std::unique_ptr<http::HttpServer> server)
explicit HttpServerWrapper(
std::unique_ptr<facebook::presto::http::HttpServer> server)
: server_(std::move(server)) {}

~HttpServerWrapper() {
Expand Down Expand Up @@ -100,7 +97,7 @@ class HttpServerWrapper {
}

private:
std::unique_ptr<http::HttpServer> server_;
std::unique_ptr<facebook::presto::http::HttpServer> server_;
std::unique_ptr<std::thread> serverThread_;
folly::Promise<folly::SocketAddress> promise_;
std::vector<std::unique_ptr<proxygen::RequestHandlerFactory>> filters_ = {};
Expand Down Expand Up @@ -136,15 +133,19 @@ void ping(
proxygen::HTTPMessage* /*message*/,
std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
proxygen::ResponseBuilder(downstream).status(http::kHttpOk, "").sendWithEOM();
proxygen::ResponseBuilder(downstream)
.status(facebook::presto::http::kHttpOk, "")
.sendWithEOM();
}

void blackhole(
proxygen::HTTPMessage* /*message*/,
std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {}

std::string bodyAsString(http::HttpResponse& response, MemoryPool* pool) {
std::string bodyAsString(
facebook::presto::http::HttpResponse& response,
facebook::velox::memory::MemoryPool* pool) {
EXPECT_FALSE(response.hasError());
std::ostringstream oss;
auto iobufs = response.consumeBody();
Expand All @@ -170,15 +171,15 @@ void echo(
proxygen::ResponseHandler* downstream) {
if (body.empty()) {
proxygen::ResponseBuilder(downstream)
.status(http::kHttpOk, "")
.status(facebook::presto::http::kHttpOk, "")
.body(folly::IOBuf::wrapBuffer(
message->getURL().c_str(), message->getURL().size()))
.sendWithEOM();
return;
}

proxygen::ResponseBuilder(downstream)
.status(http::kHttpOk, "")
.status(facebook::presto::http::kHttpOk, "")
.header(proxygen::HTTP_HEADER_CONTENT_TYPE, "text/plain")
.body(toString(body))
.sendWithEOM();
Expand All @@ -196,14 +197,14 @@ class HttpClientFactory {
eventBaseThread_->join();
}

std::shared_ptr<http::HttpClient> newClient(
std::shared_ptr<facebook::presto::http::HttpClient> newClient(
const folly::SocketAddress& address,
const std::chrono::milliseconds& transactionTimeout,
const std::chrono::milliseconds& connectTimeout,
bool useHttps,
std::shared_ptr<MemoryPool> pool,
std::shared_ptr<facebook::velox::memory::MemoryPool> pool,
std::function<void(int)>&& reportOnBodyStatsFunc = nullptr) {
return std::make_shared<http::HttpClient>(
return std::make_shared<facebook::presto::http::HttpClient>(
eventBase_.get(),
nullptr,
proxygen::Endpoint(
Expand All @@ -221,32 +222,33 @@ class HttpClientFactory {
std::unique_ptr<std::thread> eventBaseThread_;
};

folly::SemiFuture<std::unique_ptr<http::HttpResponse>> sendGet(
http::HttpClient* client,
folly::SemiFuture<std::unique_ptr<facebook::presto::http::HttpResponse>>
sendGet(
facebook::presto::http::HttpClient* client,
const std::string& url,
const uint64_t sendDelay = 0,
const std::string body = "") {
return http::RequestBuilder()
return facebook::presto::http::RequestBuilder()
.method(proxygen::HTTPMethod::GET)
.url(url)
.send(client, body, sendDelay);
}

static std::unique_ptr<http::HttpServer> getHttpServer(
static std::unique_ptr<facebook::presto::http::HttpServer> getHttpServer(
bool useHttps,
const std::shared_ptr<folly::IOThreadPoolExecutor>& httpIOExecutor) {
if (useHttps) {
const std::string certPath = getCertsPath("test_cert1.pem");
const std::string keyPath = getCertsPath("test_key1.pem");
const std::string ciphers = "AES128-SHA,AES128-SHA256,AES256-GCM-SHA384";
auto httpsConfig = std::make_unique<http::HttpsConfig>(
auto httpsConfig = std::make_unique<facebook::presto::http::HttpsConfig>(
folly::SocketAddress("127.0.0.1", 0), certPath, keyPath, ciphers);
return std::make_unique<http::HttpServer>(
return std::make_unique<facebook::presto::http::HttpServer>(
httpIOExecutor, nullptr, std::move(httpsConfig));
} else {
return std::make_unique<http::HttpServer>(
return std::make_unique<facebook::presto::http::HttpServer>(
httpIOExecutor,
std::make_unique<http::HttpConfig>(
std::make_unique<facebook::presto::http::HttpConfig>(
folly::SocketAddress("127.0.0.1", 0)),
nullptr);
}
Expand All @@ -268,17 +270,18 @@ struct AsyncMsgRequestState {
std::function<void()> customFunc;
};

http::EndpointRequestHandlerFactory asyncMsg(
facebook::presto::http::EndpointRequestHandlerFactory asyncMsg(
std::shared_ptr<AsyncMsgRequestState> request) {
return [request](
proxygen::HTTPMessage* /* message */,
const std::vector<std::string>& /* args */) {
return new http::CallbackRequestHandler(
return new facebook::presto::http::CallbackRequestHandler(
[request](
proxygen::HTTPMessage* /*message*/,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream,
std::shared_ptr<http::CallbackRequestHandlerState> handlerState) {
std::shared_ptr<facebook::presto::http::CallbackRequestHandlerState>
handlerState) {
auto [promise, future] = folly::makePromiseContract<std::string>();
auto eventBase = folly::EventBaseManager::get()->getEventBase();
auto maxWaitMillis = request->maxWaitMillis;
Expand All @@ -297,7 +300,7 @@ http::EndpointRequestHandlerFactory asyncMsg(
if (!handlerState->requestExpired()) {
request->requestStatus = kStatusValid;
proxygen::ResponseBuilder(downstream)
.status(http::kHttpOk, "")
.status(facebook::presto::http::kHttpOk, "")
.header(proxygen::HTTP_HEADER_CONTENT_TYPE, "text/plain")
.body(msg)
.sendWithEOM();
Expand All @@ -311,7 +314,9 @@ http::EndpointRequestHandlerFactory asyncMsg(
if (!handlerState->requestExpired()) {
request->requestStatus = kStatusValid;
proxygen::ResponseBuilder(downstream)
.status(http::kHttpInternalServerError, "")
.status(
facebook::presto::http::kHttpInternalServerError,
"")
.header(
proxygen::HTTP_HEADER_CONTENT_TYPE, "text/plain")
.body(e.what())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "presto_cpp/main/common/Configs.h"
#include "presto_cpp/main/operators/BroadcastExchangeSource.h"

using namespace facebook::velox;

namespace facebook::presto::operators {

namespace {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "velox/vector/ComplexVector.h"
#include "velox/vector/VectorStream.h"

using namespace facebook::velox;

namespace facebook::presto::operators {

/// Struct for single broadcast file info.]
Expand Down Expand Up @@ -48,7 +46,7 @@ class BroadcastFileWriter {
virtual ~BroadcastFileWriter() = default;

/// Write to file.
void collect(const RowVectorPtr& input);
void collect(const velox::RowVectorPtr& input);

/// Flush the data.
void noMoreData();
Expand Down Expand Up @@ -110,8 +108,8 @@ class BroadcastFactory {
virtual ~BroadcastFactory() = default;

std::unique_ptr<BroadcastFileWriter> createWriter(
memory::MemoryPool* pool,
const RowTypePtr& inputType);
velox::memory::MemoryPool* pool,
const velox::RowTypePtr& inputType);

std::shared_ptr<BroadcastFileReader> createReader(
const std::unique_ptr<BroadcastFileInfo> fileInfo,
Expand Down