morningman commented on a change in pull request #7473: URL: https://github.com/apache/incubator-doris/pull/7473#discussion_r805164341
########## File path: be/src/http/action/stream_load_2pc.cpp ########## @@ -0,0 +1,96 @@ +// 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 "http/action/stream_load_2pc.h" + +#include <rapidjson/prettywriter.h> +#include <rapidjson/stringbuffer.h> + +#include "common/status.h" +#include "http/http_channel.h" +#include "http/http_headers.h" +#include "http/http_request.h" +#include "http/http_status.h" +#include "http/utils.h" +#include "runtime/stream_load/stream_load_context.h" +#include "runtime/stream_load/stream_load_executor.h" +#include "util/json_util.h" + +namespace doris { + +const static std::string HEADER_JSON = "application/json"; + +StreamLoad2PCAction::StreamLoad2PCAction(ExecEnv* exec_env) : _exec_env(exec_env) {} + +void StreamLoad2PCAction::handle(HttpRequest* req) { + Status status = Status::OK(); + std::string status_result; + + if (config::disable_stream_load_2pc) { + status = Status::InternalError("Two phase commit (2PC) for stream load was disabled"); + status_result = to_json(status); + HttpChannel::send_reply(req, HttpStatus::OK, status_result); + return; + } + + StreamLoadContext* ctx = new StreamLoadContext(_exec_env); + ctx->ref(); + req->set_handler_ctx(ctx); + ctx->db = req->param(HTTP_DB_KEY); + std::string req_txn_id = req->header(HTTP_TXN_ID_KEY); + try { + ctx->txn_id = std::stoull(req_txn_id); + } catch (const std::exception& e) { + status = Status::InternalError("convert txn_id [" + req_txn_id + "] failed"); + status_result = to_json(status); + HttpChannel::send_reply(req, HttpStatus::OK, status_result); + return; + } + ctx->txn_operation = req->header(HTTP_TXN_OPERATION_KEY); Review comment: check invalid parameter? ########## File path: gensrc/thrift/FrontendService.thrift ########## @@ -656,6 +656,23 @@ struct TLoadTxnCommitResult { 1: required Status.TStatus status } +struct TLoadTxn2PCRequest { + 1: optional string cluster + 2: required string user Review comment: use `optional` for all fields ########## File path: be/src/common/config.h ########## @@ -353,6 +353,7 @@ CONF_mInt32(stream_load_record_batch_size, "50"); CONF_Int32(stream_load_record_expire_time_secs, "28800"); // time interval to clean expired stream load records CONF_mInt64(clean_stream_load_record_interval_secs, "1800"); +CONF_mBool(disable_stream_load_2pc, "false"); Review comment: I think we can set default value to true. And set it true after we complete the flink connector and everything is ok, -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org