You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/01 01:07:00 UTC

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

    [ 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<ProducerProvider> 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:
users@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)