-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
|
||
|
@@ -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 { | ||
|
@@ -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(); | ||
} catch (Throwable stop) { | ||
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to stop qos server: ", stop); | ||
} | ||
if (isServer) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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 whenqosCheck=true
is met, is this expected?There was a problem hiding this comment.
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.