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

Only throws exception when exporting service #13217

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public int getDefaultPort() {

@Override
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
startQosServer(invoker.getUrl());
startQosServer(invoker.getUrl(), true);
return protocol.export(invoker);
}

@Override
public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
startQosServer(url);
startQosServer(url, false);
return protocol.refer(type, url);
}

Expand All @@ -96,7 +96,7 @@ public List<ProtocolServer> getServers() {
return protocol.getServers();
}

private void startQosServer(URL url) throws RpcException {
private void startQosServer(URL url, boolean isServer) throws RpcException {
boolean qosCheck = url.getParameter(QOS_CHECK, false);

try {
Expand Down Expand Up @@ -134,13 +134,18 @@ private void startQosServer(URL url) throws RpcException {

} catch (Throwable throwable) {
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to start qos server: ", throwable);
try {
stopServer();
} catch (Throwable stop) {
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to stop qos server: ", stop);
}

if (qosCheck) {
throw new RpcException(throwable);
try {
// Stop QoS Server to support re-start if Qos-Check is enabled
stopServer();
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes stopServer() only be called when qosCheck=true is met, is this expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. If disable check, we should not retry start in the future.

} catch (Throwable stop) {
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to stop qos server: ", stop);
}
if (isServer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to tell 'export' from 'refer' and only throw exception for 'export', I don't get the intention behind this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

In some scenarios, a reference to Dubbo is created when called. If we fail, this will cause the call to fail.

// Only throws exception when export services
throw new RpcException(throwable);
}
}
}
}
Expand Down
Loading