Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dubbo_proxy: Implement the routing of Dubbo requests #5973

Merged
merged 23 commits into from
Mar 14, 2019

Conversation

gengleilei
Copy link
Contributor

Description: Implement the routing of Dubbo requests
Risk Level: low
Testing: unit test
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue] #3998
[Optional Deprecated:]

this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy

@gengleilei gengleilei requested a review from lizan as a code owner February 15, 2019 06:58
@lizan lizan requested a review from zyfjeff February 15, 2019 07:05
ENVOY_LOG(debug, "err {}", what());

switch (type_) {
case AppExceptionType::ClientTimeout:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace AppExceptionType to ResponseStatus?

Obviously, there is not much difference between the AppExceptionType and the ResponseStatus here except for the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

deps = [
":deserializer_interface",
":hessian_deserializer_impl_lib",
":hessian_utils_lib",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

hdrs = ["app_exception.h"],
deps = [
":deserializer_interface",
":hessian_deserializer_impl_lib",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

AppException(AppExceptionType::ServerError,
fmt::format("dubbo upstream request: too many connections to '{}'",
upstream_host_->address()->asString())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry,it should use false here,we should not shut down downstream connection because of one upstream request error.

AppException(AppExceptionType::ServerError,
fmt::format("dubbo upstream request: connection failure '{}'",
upstream_host_->address()->asString())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -68,16 +68,21 @@ typedef std::unique_ptr<ResponseMessageImpl> ResponseMessageImplPtr;

class DubboProtocolImpl : public Protocol {
public:
DubboProtocolImpl(ProtocolCallbacks& callbacks) : callbacks_(callbacks) {}
DubboProtocolImpl() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

void HessianDeserializerImpl::serializeRpcResult(Buffer::Instance& output_buffer,
const std::string& content, RpcResponseType type) {
uint8_t response_type_code = static_cast<uint8_t>(type);
uint8_t base_code = 0x90;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what meaning? add comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding for type has been moved to HessianUtils::writeInt.

// we've already handled any possible downstream response.
parent_.callbacks_->resetDownstreamConnection();
break;
case Tcp::ConnectionPool::PoolFailureReason::RemoteConnectionFailure:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the connection is closed remotely, how should the current ActiveMessage be destructed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If RemoteConnectionFailure mistakes before not yet received the response, will be called sendLocalReply, this function will close the downstream connection, will trigger a ConnectionManager: :onEvent function call, will eventually trigger ActiveMessage: :onReset function calls.
If you have received a response, it will call resetDownstreamConnection, will eventually trigger ActiveMessage: : onReset function calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will close the Downstream connection? why do you close?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a resetStream interface that notified downstream module to release the current stream when the upstream connection was closed,downstream connection will not be closed.


void Router::UpstreamRequest::resetStream() {
if (conn_pool_handle_) {
conn_pool_handle_->cancel(Tcp::ConnectionPool::CancelPolicy::Default);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT(!conn_data_)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resetStream may be called before a connection is established, such as when onDestroy calls resetStream after a connection fails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If conn_pool_handle_ is not nullptr, the connection has not been established, so conn_data_ must be nullptr, do not know if I understand correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, but resetStream does not know when it is called, and the connection may not have been established or may have already been established, so you cannot use ASSERT to force check conn_data_ or conn_pool_handle_ in this function.

Copy link
Member

@zyfjeff zyfjeff Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is conn_pool_handle_ and conn_data_ back nullptr at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

conn_pool_handle_->cancel(Tcp::ConnectionPool::CancelPolicy::Default);
}

if (conn_data_ != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT(! conn_pool_handle_)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conn_pool_handle_ is the processing that the connection pool provides to the upper layer while the connection is being established, and is set to nullptr once the connection is established, the resetStream call may be made after the connection is established

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

void Router::UpstreamRequest::resetStream() {
if (conn_pool_handle_) {
conn_pool_handle_->cancel(Tcp::ConnectionPool::CancelPolicy::Default);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conn_pool_handle_ = nullptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (end_stream) {
// Response is incomplete, but no more data is coming.
ENVOY_STREAM_LOG(debug, "dubbo router: response underflow", *callbacks_);
upstream_request_->onResponseComplete();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this onResponseComplete called here, is the response not completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although upstreamData still needs more data, end_stream has been flagged for new data to arrive and the connection has been disconnected, so in the case of upstream_request_, the request has been completed, and both success and failure are forms of completion

@zyfjeff
Copy link
Member

zyfjeff commented Feb 18, 2019

/ wait

// we've already handled any possible downstream response.
parent_.callbacks_->resetDownstreamConnection();
break;
case Tcp::ConnectionPool::PoolFailureReason::RemoteConnectionFailure:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will close the Downstream connection? why do you close?

@@ -516,6 +558,12 @@ std::string HessianUtils::readByte(Buffer::Instance& buffer) {
return result;
}

void HessianUtils::writeString(Buffer::Instance& buffer, const std::string& str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace const std::string& str to const absl::string_view& ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

void doWriteString(Buffer::Instance& instance, absl::string_view str_view) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const absl::string_view&?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return;
} else if (status == DubboFilters::UpstreamResponseStatus::Reset) {
ENVOY_STREAM_LOG(debug, "dubbo router: upstream reset", *callbacks_);
upstream_request_->resetStream();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't onResponseComplete called here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset merely resets the upstream connection and does not indicate that the request has been completed.

@zyfjeff
Copy link
Member

zyfjeff commented Feb 18, 2019

/ wait

callbacks_->sendLocalReply(AppException(ResponseStatus::ServiceNotFound,
fmt::format("dubbo router: no route for interface '{}'",
metadata->service_name())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

callbacks_->sendLocalReply(
AppException(ResponseStatus::ServerError, fmt::format("dubbo router: unknown cluster '{}'",
route_entry_->clusterName())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

AppException(ResponseStatus::ServerError,
fmt::format("dubbo router: maintenance mode for cluster '{}'",
route_entry_->clusterName())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

AppException(
ResponseStatus::ServerError,
fmt::format("dubbo router: no healthy upstream for '{}'", route_entry_->clusterName())),
true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

":protocol_interface",
"//include/envoy/buffer:buffer_interface",
"//source/common/buffer:buffer_lib",
"//source/common/common:byte_order_lib",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#include "extensions/filters/network/dubbo_proxy/app_exception.h"

#include "common/buffer/buffer_impl.h"
#include "common/common/byte_order.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


#include "common/buffer/buffer_impl.h"
#include "common/common/byte_order.h"
#include "common/common/hex.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


// Serialized response content.
absl::string_view str_view(content);
HessianUtils::writeString(output_buffer, str_view);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HessianUtils::writeString(output_buffer, content)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

hdrs = ["config.h"],
deps = [
":router_lib",
":router_matcher",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route_matcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace router_matcher to route_matcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router_matcher dependency has been removed and the router_matcher library name renamed to route_matcher.

if (upstream_request_->metadata_->message_type() == MessageType::Oneway) {
// No response expected
upstream_request_->onResponseComplete();
cleanup();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove ActiveMessage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the request is one_way, the current stream is released after the Filter ends the callback, and there is no need to call the resetStream function.

Network::FilterStatus Router::transportEnd() {
ASSERT(upstream_request_);

upstream_request_->encodeData(upstream_request_buffer_, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the end_stream equal to true here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is legacy code, I've deleted the end_stream parameter.

}
}

void Router::UpstreamRequest::encodeData(Buffer::Instance& data, bool end_stream) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of this end_stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is legacy code, I've deleted the end_stream parameter.

@zyfjeff
Copy link
Member

zyfjeff commented Feb 20, 2019

/ wait


context->header_size_ = DubboProtocolImpl::MessageSize;
context->body_size_ = body_size;
context->is_heartbeat_ = is_event;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the logic for heartbeat message processing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heartbeat processing logic is in the Decoder and ConnectionManager, which is not included in this submission.

#include "extensions/filters/network/dubbo_proxy/hessian_deserializer_impl.h"
#include "extensions/filters/network/dubbo_proxy/metadata.h"

#include "test/extensions/filters/network/dubbo_proxy/mocks.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#include "test/extensions/filters/network/dubbo_proxy/mocks.h"
#include "test/test_common/test_base.h"

#include "gmock/gmock.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// For oneway requests, we should not attempt a response. Reset the downstream to signal
// an error.
ENVOY_LOG(debug, "dubbo upstream request: the request is oneway, reset downstream connection");
parent_.callbacks_->resetDownstreamConnection();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to close the connection here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change it to resetStream to end the current stream instead of closing the connection.

// Mimic an upstream reset.
onUpstreamHostSelected(host);
onResetStream(reason);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to continue to call the next filter callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the continue decoding logic.

@zyfjeff
Copy link
Member

zyfjeff commented Feb 21, 2019

/ wait

Network::FilterStatus Router::transportEnd() {
ASSERT(upstream_request_);

upstream_request_->encodeData(upstream_request_buffer_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the connection failure scenario comes here, you should not call the encodeData method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transportEnd interface is not called if the connection fails. assuming that the encodeData function is called, there is a corresponding judgment here. (if (!conn_data_)).

}

void Router::UpstreamRequest::encodeData(Buffer::Instance& data) {
if (!conn_data_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the case that conn_data_ will be nullptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, before connection ready, the filter's callback interface transportEnd has been called, thus triggering encodeData function call. At this time, conn_data_ is nullptr.

ENVOY_LOG(debug, "dubbo upstream request: start sending data to the server {}",
upstream_host_->address()->asString());

if (buffered_request_body_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of buffered_request_body_?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to cache the transfer data when the connection is not ready and the Filter's callback interface is complete.

@zyfjeff
Copy link
Member

zyfjeff commented Feb 21, 2019

/ wait

@zyfjeff
Copy link
Member

zyfjeff commented Feb 21, 2019

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)
🔨 rebuilding ci/circleci: clang_tidy (failed build)
🔨 rebuilding ci/circleci: release (failed build)
🔨 rebuilding ci/circleci: asan (failed build)
🔨 rebuilding ci/circleci: tsan (failed build)
🔨 rebuilding ci/circleci: coverage (failed build)
🔨 rebuilding ci/circleci: compile_time_options (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)
🔨 rebuilding ci/circleci: clang_tidy (failed build)
🔨 rebuilding ci/circleci: release (failed build)
🔨 rebuilding ci/circleci: asan (failed build)
🔨 rebuilding ci/circleci: tsan (failed build)
🔨 rebuilding ci/circleci: coverage (failed build)
🔨 rebuilding ci/circleci: compile_time_options (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)
🔨 rebuilding ci/circleci: clang_tidy (failed build)
🔨 rebuilding ci/circleci: release (failed build)
🔨 rebuilding ci/circleci: asan (failed build)
🔨 rebuilding ci/circleci: tsan (failed build)
🔨 rebuilding ci/circleci: coverage (failed build)
🔨 rebuilding ci/circleci: compile_time_options (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

This reverts commit d9eb2c1.

Signed-off-by: leilei.gll <[email protected]>
Signed-off-by: leilei.gll <[email protected]>
@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)
🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

// Serialized response content.
serialized_size += HessianUtils::writeString(output_buffer, content);

ASSERT(output_buffer.length() - origin_length == serialized_size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(output_buffer.length() - origin_length)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


void Router::UpstreamRequest::onPoolFailure(Tcp::ConnectionPool::PoolFailureReason reason,
Upstream::HostDescriptionConstSharedPtr host) {
ENVOY_LOG(warn, "dubbo upstream request: connection failure '{}'", host->address()->asString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If PoolFailureReason is Overflow, then host is equal to nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (reason == Tcp::ConnectionPool::PoolFailureReason::Timeout ||
reason == Tcp::ConnectionPool::PoolFailureReason::LocalConnectionFailure ||
reason == Tcp::ConnectionPool::PoolFailureReason::RemoteConnectionFailure) {
parent_.callbacks_->continueDecoding();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other PoolFailureReason do not require continueDecoding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not needed, if the reason for failure is equal to overflow, the newConnection call will return nullptr, UpstreamRequest: :start call will return to Continue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (reason != Tcp::ConnectionPool::PoolFailureReason::Overflow) {
   parent_.callbacks_->continueDecoding();
}

better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I wrote it like this at first, but later I changed it because I thought it would be easier to understand.

parent_.callbacks_->sendLocalReply(
AppException(ResponseStatus::ServerError,
fmt::format("dubbo upstream request: too many connections to '{}'",
upstream_host_->address()->asString())),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream_host_ == nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zyfjeff
Copy link
Member

zyfjeff commented Mar 6, 2019

@lizan Looking great, let's take a look.

Signed-off-by: leilei.gll <[email protected]>
@lizan lizan self-assigned this Mar 8, 2019
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly C++ stuff, @zyfjeff did you check the coverage?

: EnvoyException(what), status_(status),
response_type_(RpcResponseType::ResponseWithException) {}

AppException::AppException(const AppException& ex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed to be defined explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i have modified it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant you can just use default, no?
https://en.cppreference.com/w/cpp/language/copy_constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i misunderstood, i have modified it to: AppException(const AppException& ex) = default.

@@ -60,6 +51,8 @@ RpcResultPtr HessianDeserializerImpl::deserializeRpcResult(Buffer::Instance& buf
result = std::make_unique<RpcResultImpl>(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this two line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -68,16 +68,21 @@ typedef std::unique_ptr<ResponseMessageImpl> ResponseMessageImplPtr;

class DubboProtocolImpl : public Protocol {
public:
DubboProtocolImpl(ProtocolCallbacks& callbacks) : callbacks_(callbacks) {}
DubboProtocolImpl() = default;
DubboProtocolImpl(ProtocolCallbacks* callbacks) : callbacks_(callbacks) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ASSERT(size == (str_max_length + values.size()));

size_t child_size = doWriteString(
instance, absl::string_view(str_view.data() + str_max_length, length - str_max_length));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_view.substr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

if (length < two_octet_max_lenth) {
uint8_t code = length / 256; // 0x30 + length / 0x100 must less than 0x34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: >> 8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if (length < two_octet_max_lenth) {
uint8_t code = length / 256; // 0x30 + length / 0x100 must less than 0x34
uint8_t remain = length % 256;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: & 0xff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -35,6 +35,9 @@ class HessianUtils {
static void readNull(Buffer::Instance& buffer);
static std::chrono::milliseconds readDate(Buffer::Instance& buffer);
static std::string readByte(Buffer::Instance& buffer);

static size_t writeString(Buffer::Instance& buffer, const absl::string_view& str);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass string_view by value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

DubboFilters::FilterFactoryCb RouterFilterConfig::createFilterFactoryFromProtoTyped(
const envoy::config::filter::dubbo::router::v2alpha1::Router& proto_config,
const std::string& stat_prefix, Server::Configuration::FactoryContext& context) {
UNREFERENCED_PARAMETER(proto_config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just make parameter unnamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@lizan lizan added the waiting label Mar 8, 2019
@zyfjeff
Copy link
Member

zyfjeff commented Mar 8, 2019

@lizan Sorry the coverage forget didn't check the header file
@gengleilei Please improve some coverage of header files

Signed-off-by: leilei.gll <[email protected]>
@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #5973 (comment) was created by @gengleilei.

see: more, trace.

@gengleilei
Copy link
Contributor Author

@zyfjeff I've improved.

@gengleilei
Copy link
Contributor Author

@lizan Is there any other code review opinion ?

: EnvoyException(what), status_(status),
response_type_(RpcResponseType::ResponseWithException) {}

AppException::AppException(const AppException& ex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant you can just use default, no?
https://en.cppreference.com/w/cpp/language/copy_constructor

}
}

size_t doWriteString(Buffer::Instance& instance, const absl::string_view& str_view) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: string_view by value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modified it to: size_t doWriteString(Buffer::Instance& instance, absl::string_view str_view).

@@ -516,6 +564,16 @@ std::string HessianUtils::readByte(Buffer::Instance& buffer) {
return result;
}

size_t HessianUtils::writeString(Buffer::Instance& buffer, const absl::string_view str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modified it to: size_t writeString(Buffer::Instance& buffer, absl::string_view str).

@lizan lizan merged commit 768fde9 into envoyproxy:master Mar 14, 2019
spenceral added a commit to spenceral/envoy that referenced this pull request Mar 20, 2019
* master: (59 commits)
  http fault: add response rate limit injection (envoyproxy#6267)
  xds: introduce initial_fetch_timeout option to limit initialization time (envoyproxy#6048)
  test: fix cpuset-threads tests (envoyproxy#6278)
  server: add an API for registering for notifications for server instance life… (envoyproxy#6254)
  remove remains of TestBase (envoyproxy#6286)
  dubbo_proxy: Implement the routing of Dubbo requests (envoyproxy#5973)
  Revert "stats: add new BoolIndicator stat type (envoyproxy#5813)" (envoyproxy#6280)
  runtime: codifying runtime guarded features (envoyproxy#6134)
  mysql_filter: fix integration test flakes (envoyproxy#6272)
  tls: update BoringSSL to debed9a4 (3683). (envoyproxy#6273)
  rewrite buffer implementation to eliminate evbuffer dependency (envoyproxy#5441)
  Remove the dependency from TimeSystem to libevent by using the Event::Scheduler abstraction as a delegate. (envoyproxy#6240)
  fuzz: fix use of literal in default initialization. (envoyproxy#6268)
  http: add HCM functionality required for rate limiting (envoyproxy#6242)
  Disable mysql_integration_test until it is deflaked. (envoyproxy#6250)
  test: use ipv6_only IPv6 addresses in custom cluster integration tests. (envoyproxy#6260)
  tracing: If parent span is propagated with empty string, it causes th… (envoyproxy#6263)
  upstream: fix oss-fuzz issue envoyproxy#11095. (envoyproxy#6220)
  Wire up panic mode subset to receive updates (envoyproxy#6221)
  docs: clarify xds docs with warming information (envoyproxy#6236)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants