Skip to content

Commit

Permalink
Support check if qos server is started (#12952)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Aug 23, 2023
1 parent f5cc40c commit 2a5b437
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface QosConstants {

String QOS_ENABLE = "qos.enable";

String QOS_CHECK = "qos.check";

String QOS_HOST = "qos.host";

String QOS_PORT = "qos.port";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import static org.apache.dubbo.common.constants.QosConstants.ANONYMOUS_ACCESS_ALLOW_COMMANDS;
import static org.apache.dubbo.common.constants.QosConstants.ANONYMOUS_ACCESS_PERMISSION_LEVEL;
import static org.apache.dubbo.common.constants.QosConstants.ANONYMOUS_ACCESS_PERMISSION_LEVEL_COMPATIBLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_CHECK;
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE_COMPATIBLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
Expand Down Expand Up @@ -146,6 +147,11 @@ public class ApplicationConfig extends AbstractConfig {
*/
private Boolean qosEnable;

/**
* Whether qos should start success or not, will check qosEnable first
*/
private Boolean qosCheck;

/**
* The qos host to listen
*/
Expand Down Expand Up @@ -433,6 +439,15 @@ public void setQosEnable(Boolean qosEnable) {
this.qosEnable = qosEnable;
}

@Parameter(key = QOS_CHECK)
public Boolean getQosCheck() {
return qosCheck;
}

public void setQosCheck(Boolean qosCheck) {
this.qosCheck = qosCheck;
}

@Parameter(key = QOS_HOST)
public String getQosHost() {
return qosHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@
<xsd:documentation><![CDATA[ Whether to enable qos or not. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="qos-check" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation><![CDATA[ Whether qos should start success or not, will check qosEnable first. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="qos-host" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[ The qos host to listen. ]]></xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP_WHITELIST;
import static org.apache.dubbo.common.constants.QosConstants.ANONYMOUS_ACCESS_ALLOW_COMMANDS;
import static org.apache.dubbo.common.constants.QosConstants.ANONYMOUS_ACCESS_PERMISSION_LEVEL;
import static org.apache.dubbo.common.constants.QosConstants.QOS_CHECK;
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
import static org.apache.dubbo.common.constants.QosConstants.QOS_PORT;
Expand Down Expand Up @@ -131,6 +132,10 @@ private void startQosServer(URL url) {

} catch (Throwable throwable) {
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to start qos server: ", throwable);
boolean qosCheck = url.getParameter(QOS_CHECK, false);
if (qosCheck) {
throw new IllegalStateException("Fail to start qos server: " + throwable.getMessage(), throwable);
}
}
}

Expand Down

0 comments on commit 2a5b437

Please sign in to comment.