[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-06-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16499661#comment-16499661
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin closed pull request #731: [SCB-617] Graceful shutdown with standalone 
tomcat
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/731
 
 
   

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/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java 
b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
index 365868746..38793cd10 100644
--- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
+++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
@@ -28,6 +28,7 @@
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ApplicationEvent;
 import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextClosedEvent;
 import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.core.Ordered;
@@ -71,6 +72,8 @@ public void onApplicationEvent(ApplicationEvent event) {
   }
 
   SCBEngine.getInstance().init();
+} else if (event instanceof ContextClosedEvent) {
+  SCBEngine.getInstance().destroy();
 }
   }
 }
diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java 
b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
index d30eb3c07..4d2f15702 100644
--- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
+++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
@@ -20,6 +20,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.core.BootListener.BootEvent;
 import org.apache.servicecomb.core.BootListener.EventType;
 import org.apache.servicecomb.core.definition.loader.SchemaListenerManager;
@@ -177,7 +178,7 @@ public synchronized void init() {
 doInit();
 status = SCBStatus.UP;
   } catch (Exception e) {
-uninit();
+destroy();
 status = SCBStatus.FAILED;
 throw new IllegalStateException("ServiceComb init failed.", e);
   }
@@ -217,23 +218,23 @@ private void doInit() throws Exception {
 
 RegistryUtils.run();
 
-Runtime.getRuntime().addShutdownHook(new Thread(this::uninit));
+Runtime.getRuntime().addShutdownHook(new Thread(this::destroy));
   }
 
   /**
* not allow throw any exception
* even some step throw exception, must catch it and go on, otherwise 
shutdown process will be broken.
*/
-  public synchronized void uninit() {
+  public synchronized void destroy() {
 if (SCBStatus.UP.equals(status)) {
   LOGGER.info("ServiceComb is closing now...");
-  doUninit();
+  doDestroy();
   status = SCBStatus.DOWN;
   LOGGER.info("ServiceComb had closed");
 }
   }
 
-  private void doUninit() {
+  private void doDestroy() {
 //Step 1: notify all component stop invoke via BEFORE_CLOSE Event
 safeTriggerEvent(EventType.BEFORE_CLOSE);
 
@@ -256,7 +257,10 @@ private void doUninit() {
 VertxUtils.blockCloseVertxByName("config-center");
 VertxUtils.blockCloseVertxByName("transport");
 
-//Step 6: notify all component do clean works via AFTER_CLOSE Event
+//Step 6: destroy config center source
+ConfigUtil.destroyConfigCenterConfigurationSource();
+
+//Step 7: notify all component do clean works via AFTER_CLOSE Event
 safeTriggerEvent(EventType.AFTER_CLOSE);
   }
 
diff --git 
a/core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
 
b/core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
index 2600ebb53..8ea95dff4 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
@@ -17,10 +17,12 @@
 
 package org.apache.servicecomb.core.executor;
 
+import java.io.Closeable;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -30,7 +32,7 @@
 
 import com.netflix.config.DynamicPropertyFactory;
 
-public class FixedThreadExecutor implements Executor {
+public class FixedThreadExecutor implements Executor, Closeable {
   private static final Logger LOGGER = 
LoggerFa

[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-06-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16499658#comment-16499658
 ] 

ASF GitHub Bot commented on SCB-617:


liubao68 commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192612530
 
 

 ##
 File path: 
dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java
 ##
 @@ -109,13 +109,15 @@
 
   private ConfigCenterConfigurationSourceImpl.UpdateHandler updateHandler;
 
-  private static ClientPoolManager clientMgr;
+  private ClientPoolManager clientMgr;
 
   private boolean isWatching = false;
 
-  private static final ServiceLoader authHeaderProviders =
+  private final ServiceLoader authHeaderProviders =
   ServiceLoader.load(AuthHeaderProvider.class);
 
+  private URIConst uriConst = new URIConst();
 
 Review comment:
   After change, it's more convenient for testing different scenarios. We can 
benefit more :-)


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497439#comment-16497439
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192278176
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##
 @@ -17,39 +17,72 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
 for (ProducerProvider provider : producerProviderList) {
   provider.init();
 }
 
 Microservice microservice = RegistryUtils.getMicroservice();
-MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
 for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
   String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
   microservice.addSchema(schemaMeta.getSchemaId(), content);
 }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+  return;
+}
+
+for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+  if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
 
 Review comment:
   1.ExecutorService is not closeable
   2.if someone want to do this, it's not our duty to invoke close.


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497435#comment-16497435
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192278176
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##
 @@ -17,39 +17,72 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
 for (ProducerProvider provider : producerProviderList) {
   provider.init();
 }
 
 Microservice microservice = RegistryUtils.getMicroservice();
-MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
 for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
   String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
   microservice.addSchema(schemaMeta.getSchemaId(), content);
 }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+  return;
+}
+
+for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+  if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
 
 Review comment:
   1.ExecutorService is not closeable
   2.ExecutorService support shutdown multi times


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497431#comment-16497431
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192278085
 
 

 ##
 File path: 
dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java
 ##
 @@ -109,13 +109,15 @@
 
   private ConfigCenterConfigurationSourceImpl.UpdateHandler updateHandler;
 
-  private static ClientPoolManager clientMgr;
+  private ClientPoolManager clientMgr;
 
   private boolean isWatching = false;
 
-  private static final ServiceLoader authHeaderProviders =
+  private final ServiceLoader authHeaderProviders =
   ServiceLoader.load(AuthHeaderProvider.class);
 
+  private URIConst uriConst = new URIConst();
 
 Review comment:
   not necessary
   only use once here


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497429#comment-16497429
 ] 

ASF GitHub Bot commented on SCB-617:


WillemJiang commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192277913
 
 

 ##
 File path: 
dynamic-config/config-cc/src/main/java/org/apache/servicecomb/config/client/ConfigCenterClient.java
 ##
 @@ -109,13 +109,15 @@
 
   private ConfigCenterConfigurationSourceImpl.UpdateHandler updateHandler;
 
-  private static ClientPoolManager clientMgr;
+  private ClientPoolManager clientMgr;
 
   private boolean isWatching = false;
 
-  private static final ServiceLoader authHeaderProviders =
+  private final ServiceLoader authHeaderProviders =
   ServiceLoader.load(AuthHeaderProvider.class);
 
+  private URIConst uriConst = new URIConst();
 
 Review comment:
   Do we need to create a instance of Constant object here?


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497428#comment-16497428
 ] 

ASF GitHub Bot commented on SCB-617:


WillemJiang commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192277636
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##
 @@ -17,39 +17,72 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
 for (ProducerProvider provider : producerProviderList) {
   provider.init();
 }
 
 Microservice microservice = RegistryUtils.getMicroservice();
-MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
 for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
   String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
   microservice.addSchema(schemaMeta.getSchemaId(), content);
 }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+  return;
+}
+
+for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+  if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
 
 Review comment:
   What if the excecutor is the instand of ExecutorService and Closeable at the 
same time?


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497069#comment-16497069
 ] 

ASF GitHub Bot commented on SCB-617:


coveralls commented on issue #731: [SCB-617] Graceful shutdown with standalone 
tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#issuecomment-392573045
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/17258596/badge)](https://coveralls.io/builds/17258596)
   
   Coverage increased (+0.03%) to 87.55% when pulling 
**dd4e69f3df9757ba51c33faefcbcf0c0a1f1e19e on 
wujimin:graceful-shutdown-with-standalone-tomcat** into 
**fc9c7f40f4d957152a602e68f3be889bf5b8c68f on apache:master**.
   


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16496993#comment-16496993
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192198082
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##
 @@ -17,39 +17,71 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
 for (ProducerProvider provider : producerProviderList) {
   provider.init();
 }
 
 Microservice microservice = RegistryUtils.getMicroservice();
-MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
 for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
   String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
   microservice.addSchema(schemaMeta.getSchemaId(), content);
 }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+  return;
+}
+
+for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+  if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
+((ExecutorService) operationMeta.getExecutor()).shutdown();
+continue;
+  }
+
+  if (Closeable.class.isInstance(operationMeta.getExecutor())) {
+IOUtils.closeQuietly((Closeable) operationMeta.getExecutor());
+continue;
+  }
+
+  LOGGER.warn("do not how to shutdown executor: {}", 
operationMeta.getExecutor().getClass().getName());
 
 Review comment:
   done


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16496992#comment-16496992
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192198050
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
 ##
 @@ -71,6 +72,8 @@ public void onApplicationEvent(ApplicationEvent event) {
   }
 
   SCBEngine.getInstance().init();
+} else if (event instanceof ContextClosedEvent) {
+  SCBEngine.getInstance().uninit();
 
 Review comment:
   done
   changed all uninit to destroy


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-31 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16496994#comment-16496994
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin commented on a change in pull request #731: [SCB-617] Graceful shutdown 
with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r192198103
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
 ##
 @@ -74,4 +76,11 @@ private Executor chooseExecutor(long threadId) {
 int idx = index.getAndIncrement() % executorList.size();
 return executorList.get(idx);
   }
+
+  @Override
+  public void close() {
+for (ExecutorService executorService : executorList) {
+  executorService.shutdown();
+}
+  }
 
 Review comment:
   done


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-30 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16496004#comment-16496004
 ] 

ASF GitHub Bot commented on SCB-617:


WillemJiang commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r191976128
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/executor/FixedThreadExecutor.java
 ##
 @@ -74,4 +76,11 @@ private Executor chooseExecutor(long threadId) {
 int idx = index.getAndIncrement() % executorList.size();
 return executorList.get(idx);
   }
+
+  @Override
+  public void close() {
+for (ExecutorService executorService : executorList) {
+  executorService.shutdown();
+}
+  }
 
 Review comment:
   Do we need to clear the excutorList?


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493189#comment-16493189
 ] 

ASF GitHub Bot commented on SCB-617:


liubao68 commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r191327741
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerProviderManager.java
 ##
 @@ -17,39 +17,71 @@
 
 package org.apache.servicecomb.core.provider.producer;
 
+import java.io.Closeable;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
 
 import javax.inject.Inject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.core.ProducerProvider;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
 import org.apache.servicecomb.core.definition.MicroserviceMetaManager;
+import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.core.definition.SchemaMeta;
 import org.apache.servicecomb.core.definition.SchemaUtils;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProducerProviderManager {
+public class ProducerProviderManager implements BootListener {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProducerProviderManager.class);
+
   @Autowired(required = false)
   private List producerProviderList = 
Collections.emptyList();
 
   @Inject
   private MicroserviceMetaManager microserviceMetaManager;
 
+  private MicroserviceMeta microserviceMeta;
+
   public void init() throws Exception {
 for (ProducerProvider provider : producerProviderList) {
   provider.init();
 }
 
 Microservice microservice = RegistryUtils.getMicroservice();
-MicroserviceMeta microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
+microserviceMeta = 
microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
 for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
   String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
   microservice.addSchema(schemaMeta.getSchemaId(), content);
 }
   }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+if (!EventType.AFTER_CLOSE.equals(event.getEventType())) {
+  return;
+}
+
+for (OperationMeta operationMeta : microserviceMeta.getOperations()) {
+  if (ExecutorService.class.isInstance(operationMeta.getExecutor())) {
+((ExecutorService) operationMeta.getExecutor()).shutdown();
+continue;
+  }
+
+  if (Closeable.class.isInstance(operationMeta.getExecutor())) {
+IOUtils.closeQuietly((Closeable) operationMeta.getExecutor());
+continue;
+  }
+
+  LOGGER.warn("do not how to shutdown executor: {}", 
operationMeta.getExecutor().getClass().getName());
 
 Review comment:
   Executor {} do not support close or shutdown, it may block service shutdown.


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493182#comment-16493182
 ] 

ASF GitHub Bot commented on SCB-617:


liubao68 commented on a change in pull request #731: [SCB-617] Graceful 
shutdown with standalone tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#discussion_r191326701
 
 

 ##
 File path: 
core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
 ##
 @@ -71,6 +72,8 @@ public void onApplicationEvent(ApplicationEvent event) {
   }
 
   SCBEngine.getInstance().init();
+} else if (event instanceof ContextClosedEvent) {
+  SCBEngine.getInstance().uninit();
 
 Review comment:
   I think it's better to use destroy, any ideas?


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16492835#comment-16492835
 ] 

ASF GitHub Bot commented on SCB-617:


coveralls commented on issue #731: [SCB-617] Graceful shutdown with standalone 
tomcat
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/731#issuecomment-392573045
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/17200095/badge)](https://coveralls.io/builds/17200095)
   
   Coverage increased (+0.03%) to 87.552% when pulling 
**8c7a3188384b72729ac198b823fac064f25d5a81 on 
wujimin:graceful-shutdown-with-standalone-tomcat** into 
**6ce5280969d1949fff9cb26c6925a1774a409af8 on apache:master**.
   


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-617) graceful shutdown with standalone tomcat

2018-05-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16492413#comment-16492413
 ] 

ASF GitHub Bot commented on SCB-617:


wujimin opened a new pull request #731: [SCB-617] Graceful shutdown with 
standalone tomcat
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/731
 
 
   


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:
us...@infra.apache.org


> graceful shutdown with standalone tomcat
> 
>
> Key: SCB-617
> URL: https://issues.apache.org/jira/browse/SCB-617
> Project: Apache ServiceComb
>  Issue Type: Bug
>  Components: Java-Chassis
>Reporter: wujimin
>Assignee: wujimin
>Priority: Major
> Fix For: java-chassis-1.0.0-m2
>
>
> standalone tomcat shutdown by receive shutdown command from shutdown port
> after everything prepared, then do real shutdown action, so our shutdown hook 
> will not be invoked.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)