You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/08/28 12:02:17 UTC
[GitHub] chickenlj closed pull request #2370: [Dubbo-1814][Baiji-Team1]Add:
xml attributes for graceful-shutdown timeout #1814
chickenlj closed pull request #2370: [Dubbo-1814][Baiji-Team1]Add: xml attributes for graceful-shutdown timeout #1814
URL: https://github.com/apache/incubator-dubbo/pull/2370
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConfigUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConfigUtils.java
index f112ec2576..7284843af3 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConfigUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConfigUtils.java
@@ -32,7 +32,8 @@
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
+import org.apache.dubbo.config.ApplicationConfig;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ConfigUtils {
private static final Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
@@ -307,7 +308,43 @@ public static int getPid() {
@SuppressWarnings("deprecation")
public static int getServerShutdownTimeout() {
int timeout = Constants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
- String value = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY);
+
+ String path = System.getProperty(Constants.DUBBO_PROPERTIES_KEY);
+ if (path == null || path.length() == 0) {
+ path = System.getenv(Constants.DUBBO_PROPERTIES_KEY);
+ if (path == null || path.length() == 0) {
+ path = Constants.DEFAULT_DUBBO_PROPERTIES;
+ }
+ }
+
+ ClassPathXmlApplicationContext context =
+ new ClassPathXmlApplicationContext(path + "/application.xml");
+
+ context.start();
+ ApplicationConfig application = (ApplicationConfig) context.getBean("application");
+ String value = application.getShutdownWaitKey();
+ if (value != null && value.length() > 0) {
+ try {
+ timeout = Integer.parseInt(value);
+ } catch (Exception e) {
+ // ignore
+ }
+ } else {
+ value = application.getShutdownWaitSecondsKey();
+ if (value != null && value.length() > 0) {
+ try {
+ timeout = Integer.parseInt(value) * 1000;
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ if (value != null && value.length() > 0) {
+ return timeout;
+ }
+
+ value = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY);
if (value != null && value.length() > 0) {
try {
timeout = Integer.parseInt(value);
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
index 86d40012dc..9da853967b 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
@@ -83,6 +83,10 @@
// customized parameters
private Map<String, String> parameters;
+ // graceful-shutdown timeout
+ private String shutdownWaitKey;
+ private String shutdownWaitSecondsKey;
+
public ApplicationConfig() {
}
@@ -254,4 +258,21 @@ public void setParameters(Map<String, String> parameters) {
checkParameterName(parameters);
this.parameters = parameters;
}
+
+ @Parameter(key = Constants.SHUTDOWN_WAIT_KEY)
+ public String getShutdownWaitKey() {
+ return shutdownWaitKey;
+ }
+
+ public void setShutdownWaitKey(String shutdownWaitKey) {
+ this.shutdownWaitKey = shutdownWaitKey;
+ }
+ @Parameter(key = Constants.SHUTDOWN_WAIT_SECONDS_KEY)
+ public String getShutdownWaitSecondsKey() {
+ return shutdownWaitSecondsKey;
+ }
+
+ public void setShutdownWaitSecondsKey(String shutdownWaitSecondsKey) {
+ this.shutdownWaitSecondsKey = shutdownWaitSecondsKey;
+ }
}
\ No newline at end of file
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org