Commit 6b39172b by 房斌

4 hook shutdown 错别字

parent 5b62b80b
...@@ -8,7 +8,7 @@ import com.secoo.mall.common.util.log.LoggerUtil; ...@@ -8,7 +8,7 @@ import com.secoo.mall.common.util.log.LoggerUtil;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail; import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetails; import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetails;
import com.secoo.mall.dubbo.monitor.dubbo.service.RegistryServerSync; import com.secoo.mall.dubbo.monitor.dubbo.service.RegistryServerSync;
import com.secoo.mall.dubbo.service.impl.TomcatConnectShoutDownHock; import com.secoo.mall.dubbo.service.impl.TomcatShutDownHock;
import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.DubboShutdownHook; import org.apache.dubbo.config.DubboShutdownHook;
import org.apache.dubbo.config.spring.extension.SpringExtensionFactory; import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;
...@@ -29,9 +29,9 @@ import java.util.*; ...@@ -29,9 +29,9 @@ import java.util.*;
import static org.springframework.context.support.AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME; import static org.springframework.context.support.AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME;
public class GracefullyShoutDown implements CommandLineRunner, ApplicationListener<ContextClosedEvent>,ApplicationContextAware , Ordered { public class GracefulShutDown implements CommandLineRunner, ApplicationListener<ContextClosedEvent>,ApplicationContextAware , Ordered {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
// TomcatConnectShoutDownHock tomcatConnectShoutDownHock; // TomcatShutDownHock tomcatShutDownHock;
private ApplicationContext context; private ApplicationContext context;
// private ProviderService providerService ; // private ProviderService providerService ;
...@@ -39,13 +39,13 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -39,13 +39,13 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
UpDatas dubboUpdata; UpDatas dubboUpdata;
// public GracefullyShoutDown(TomcatConnectShoutDownHock tomcatConnectShoutDownHock,ProviderService providerService,UpDatas dubboUpdata){ // public GracefulShutDown(TomcatShutDownHock tomcatShutDownHock,ProviderService providerService,UpDatas dubboUpdata){
// this.tomcatConnectShoutDownHock=tomcatConnectShoutDownHock; // this.tomcatShutDownHock=tomcatShutDownHock;
// this.providerService=providerService; // this.providerService=providerService;
// this.dubboUpdata=dubboUpdata; // this.dubboUpdata=dubboUpdata;
// } // }
public GracefullyShoutDown(UpDatas dubboUpdata) { public GracefulShutDown(UpDatas dubboUpdata) {
this.dubboUpdata = dubboUpdata; this.dubboUpdata = dubboUpdata;
} }
...@@ -80,7 +80,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -80,7 +80,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
if (map != null && map.size() > 0) { if (map != null && map.size() > 0) {
Set<StopService> ts = new TreeSet<StopService>(); Set<StopService> ts = new TreeSet<StopService>();
for (StopService service : map.values()) { for (StopService service : map.values()) {
if (!(service instanceof TomcatConnectShoutDownHock)) { if (!(service instanceof TomcatShutDownHock)) {
ts.add(service); ts.add(service);
} }
} }
...@@ -100,7 +100,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -100,7 +100,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
try { try {
dubboUpdata.upData(result); dubboUpdata.upData(result);
} catch (Exception e) { } catch (Exception e) {
LoggerUtil.error("matrix.GracefullyShoutDown update .error data:" + JSON.toJSONString(result), e); LoggerUtil.error("matrix.GracefulShutDown update .error data:" + JSON.toJSONString(result), e);
} }
...@@ -131,7 +131,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -131,7 +131,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
String name = ApplicationModel.getApplication(); String name = ApplicationModel.getApplication();
result.setIp(ip); result.setIp(ip);
result.setName(name); result.setName(name);
logger.info("GracefullyShoutDown execute:name:"+name+" ip:"+ip+" time:"+ DateUtil.getDateTime()); logger.info("GracefulShutDown execute:name:"+name+" ip:"+ip+" time:"+ DateUtil.getDateTime());
try { try {
...@@ -139,7 +139,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -139,7 +139,7 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
if (map != null && map.size() > 0) { if (map != null && map.size() > 0) {
Set<StopService> ts = new TreeSet<StopService>(); Set<StopService> ts = new TreeSet<StopService>();
for (StopService service : map.values()) { for (StopService service : map.values()) {
if(!(service instanceof TomcatGracefullyShutDown)) { if(!(service instanceof TomcatGracefulShutDownEntrance)) {
ts.add(service); ts.add(service);
} }
} }
...@@ -158,14 +158,14 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -158,14 +158,14 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
} }
} catch (Exception e) { } catch (Exception e) {
LoggerUtil.error("matrix.GracefullyShoutDown.error", e); LoggerUtil.error("matrix.GracefulShutDown.error", e);
} }
try { try {
dubboUpdata.upData(result); dubboUpdata.upData(result);
} catch (Exception e) { } catch (Exception e) {
LoggerUtil.error("matrix.GracefullyShoutDown update .error data:" + JSON.toJSONString(result), e); LoggerUtil.error("matrix.GracefulShutDown update .error data:" + JSON.toJSONString(result), e);
} }
logger.info("GracefullyShoutDown execute end :name:"+name+" ip:"+ip+" time:"+ DateUtil.getDateTime()); logger.info("GracefulShutDown execute end :name:"+name+" ip:"+ip+" time:"+ DateUtil.getDateTime());
} }
......
package com.secoo.mall.dubbo.service; package com.secoo.mall.dubbo.service;
import com.secoo.mall.dubbo.service.impl.TomcatConnectShoutDownHock; import com.secoo.mall.dubbo.service.impl.TomcatShutDownHock;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -12,22 +12,22 @@ import org.springframework.context.ApplicationListener; ...@@ -12,22 +12,22 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , ApplicationContextAware, Ordered , ApplicationListener<ContextClosedEvent> { public class TomcatGracefulShutDownEntrance implements TomcatConnectorCustomizer , ApplicationContextAware, Ordered , ApplicationListener<ContextClosedEvent> {
private ApplicationContext context; private ApplicationContext context;
TomcatConnectShoutDownHock tomcatConnectShoutDownHock; TomcatShutDownHock tomcatShutDownHock;
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
public TomcatGracefullyShutDown(TomcatConnectShoutDownHock tomcatConnectShoutDownHock) { public TomcatGracefulShutDownEntrance(TomcatShutDownHock tomcatShutDownHock) {
this.tomcatConnectShoutDownHock = tomcatConnectShoutDownHock; this.tomcatShutDownHock = tomcatShutDownHock;
} }
@Override @Override
public void customize(Connector connector) { public void customize(Connector connector) {
tomcatConnectShoutDownHock.setConnector(connector); tomcatShutDownHock.setConnector(connector);
} }
...@@ -36,12 +36,12 @@ public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , App ...@@ -36,12 +36,12 @@ public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , App
this.context = applicationContext; this.context = applicationContext;
logger.info("11111111111111111111 setContext"); logger.info("11111111111111111111 setContext");
} }
public TomcatConnectShoutDownHock getTomcatConnectShoutDownHock() { public TomcatShutDownHock getTomcatShutDownHock() {
return tomcatConnectShoutDownHock; return tomcatShutDownHock;
} }
public void setTomcatConnectShoutDownHock(TomcatConnectShoutDownHock tomcatConnectShoutDownHock) { public void setTomcatShutDownHock(TomcatShutDownHock tomcatShutDownHock) {
this.tomcatConnectShoutDownHock = tomcatConnectShoutDownHock; this.tomcatShutDownHock = tomcatShutDownHock;
} }
@Override @Override
...@@ -52,6 +52,6 @@ public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , App ...@@ -52,6 +52,6 @@ public class TomcatGracefullyShutDown implements TomcatConnectorCustomizer , App
@Override @Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("11111111111111111111 "); logger.info("11111111111111111111 ");
tomcatConnectShoutDownHock.stop(); tomcatShutDownHock.stop();
} }
} }
...@@ -28,7 +28,7 @@ import java.util.*; ...@@ -28,7 +28,7 @@ import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
public class DubboCustomerDownHock extends AbstractStop implements Observer { public class DubboCustomerShutDownHock extends AbstractStop implements Observer {
private ProviderService providerService; private ProviderService providerService;
RegistryServerSync registryServerSync; RegistryServerSync registryServerSync;
...@@ -41,7 +41,7 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer { ...@@ -41,7 +41,7 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer {
this.registryServerSync = registryServerSync; this.registryServerSync = registryServerSync;
} }
public DubboCustomerDownHock(ProviderService providerService) { public DubboCustomerShutDownHock(ProviderService providerService) {
this.providerService = providerService; this.providerService = providerService;
} }
...@@ -73,10 +73,10 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer { ...@@ -73,10 +73,10 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer {
while (iterator.hasNext()) { while (iterator.hasNext()) {
Registry r = iterator.next(); Registry r = iterator.next();
zookperRegster = (ZookeeperRegistry) r; zookperRegster = (ZookeeperRegistry) r;
str.add(" DubboCustomerDownHock zookperRegstered-------------->"+zookperRegster.getRegistered().toString()+StringUtil.line()); str.add(" DubboCustomerShutDownHock zookperRegstered-------------->"+zookperRegster.getRegistered().toString()+StringUtil.line());
if (zookperRegster.getRegistered() != null && zookperRegster.getRegistered().size() > 0) { if (zookperRegster.getRegistered() != null && zookperRegster.getRegistered().size() > 0) {
urls = zookperRegster.getRegistered(); urls = zookperRegster.getRegistered();
str.add(" DubboCustomerDownHock zookperRegstered urls-------------->"+((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null")+StringUtil.line()); str.add(" DubboCustomerShutDownHock zookperRegstered urls-------------->"+((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null")+StringUtil.line());
if (urls != null && urls.size() > 0) { if (urls != null && urls.size() > 0) {
checks=new ArrayList<URL>(); checks=new ArrayList<URL>();
for (URL value : urls) { for (URL value : urls) {
...@@ -135,7 +135,7 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer { ...@@ -135,7 +135,7 @@ public class DubboCustomerDownHock extends AbstractStop implements Observer {
DubboShutdownHook.getDubboShutdownHook().doDestroy(); DubboShutdownHook.getDubboShutdownHook().doDestroy();
} }
detail.setEndTime(DateUtil.getDateTime()); detail.setEndTime(DateUtil.getDateTime());
logger.info("GracefullyShoutDown dubbo end execute:name:" + name + " ip:" + ip + " time:" + DateUtil.getDateTime()); logger.info("GracefulShutDown dubbo end execute:name:" + name + " ip:" + ip + " time:" + DateUtil.getDateTime());
return detail; return detail;
} }
......
...@@ -12,7 +12,7 @@ import java.util.concurrent.ThreadPoolExecutor; ...@@ -12,7 +12,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
//springboot 容器关闭 //springboot 容器关闭
public class TomcatConnectShoutDownHock extends AbstractStop { public class TomcatShutDownHock extends AbstractStop {
private volatile Connector connector; private volatile Connector connector;
public Connector getConnector() { public Connector getConnector() {
......
...@@ -6,11 +6,11 @@ import com.secoo.mall.dubbo.monitor.config.ConfigCenter; ...@@ -6,11 +6,11 @@ import com.secoo.mall.dubbo.monitor.config.ConfigCenter;
import com.secoo.mall.dubbo.monitor.dubbo.service.ProviderService; import com.secoo.mall.dubbo.monitor.dubbo.service.ProviderService;
import com.secoo.mall.dubbo.monitor.dubbo.service.RegistryServerSync; import com.secoo.mall.dubbo.monitor.dubbo.service.RegistryServerSync;
import com.secoo.mall.dubbo.monitor.dubbo.service.impl.ProviderServiceImpl; import com.secoo.mall.dubbo.monitor.dubbo.service.impl.ProviderServiceImpl;
import com.secoo.mall.dubbo.service.GracefullyShoutDown; import com.secoo.mall.dubbo.service.GracefulShutDown;
import com.secoo.mall.dubbo.service.TomcatGracefullyShutDown; import com.secoo.mall.dubbo.service.TomcatGracefulShutDownEntrance;
import com.secoo.mall.dubbo.service.impl.DubboCustomerDownHock; import com.secoo.mall.dubbo.service.impl.DubboCustomerShutDownHock;
import com.secoo.mall.dubbo.service.DubboUpdata; import com.secoo.mall.dubbo.service.DubboUpdata;
import com.secoo.mall.dubbo.service.impl.TomcatConnectShoutDownHock; import com.secoo.mall.dubbo.service.impl.TomcatShutDownHock;
import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URL;
import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.Registry;
...@@ -51,8 +51,8 @@ public class MatrixGracefulShutDownAutoConfiguration { ...@@ -51,8 +51,8 @@ public class MatrixGracefulShutDownAutoConfiguration {
@Bean @Bean
@ConditionalOnClass({ProviderService.class,RegistryServerSync.class}) @ConditionalOnClass({ProviderService.class,RegistryServerSync.class})
@ConditionalOnExpression("!T(org.springframework.util.StringUtils).isEmpty('${dubbo.registry.address:}')") @ConditionalOnExpression("!T(org.springframework.util.StringUtils).isEmpty('${dubbo.registry.address:}')")
DubboCustomerDownHock createDubboConsumerDownHock(ProviderService providerService, RegistryServerSync registryServerSync) { DubboCustomerShutDownHock createDubboConsumerDownHock(ProviderService providerService, RegistryServerSync registryServerSync) {
DubboCustomerDownHock hock= new DubboCustomerDownHock(providerService); DubboCustomerShutDownHock hock= new DubboCustomerShutDownHock(providerService);
registryServerSync.addObserver(hock); registryServerSync.addObserver(hock);
hock.setRegistryServerSync(registryServerSync); hock.setRegistryServerSync(registryServerSync);
return hock; return hock;
...@@ -77,25 +77,25 @@ public class MatrixGracefulShutDownAutoConfiguration { ...@@ -77,25 +77,25 @@ public class MatrixGracefulShutDownAutoConfiguration {
@Bean @Bean
@ConditionalOnClass(TomcatConnectorCustomizer.class) @ConditionalOnClass(TomcatConnectorCustomizer.class)
TomcatConnectShoutDownHock createServletConnectShoutDownHock() { TomcatShutDownHock createServletConnectShoutDownHock() {
return new TomcatConnectShoutDownHock(); return new TomcatShutDownHock();
} }
@Bean @Bean
@ConditionalOnClass(TomcatConnectShoutDownHock.class) @ConditionalOnClass(TomcatShutDownHock.class)
public TomcatGracefullyShutDown createSpringbootTomcatInit(TomcatConnectShoutDownHock tomcatConnectShoutDownHock){ public TomcatGracefulShutDownEntrance createSpringbootTomcatInit(TomcatShutDownHock tomcatShutDownHock){
return new TomcatGracefullyShutDown(tomcatConnectShoutDownHock); return new TomcatGracefulShutDownEntrance(tomcatShutDownHock);
} }
// @Bean // @Bean
// public GracefullyShoutDown createGraceObject(TomcatConnectShoutDownHock servletConnectShoutDownHock, ProviderService providerService, UpDatas dubboUpdata) { // public GracefulShutDown createGraceObject(TomcatShutDownHock servletConnectShoutDownHock, ProviderService providerService, UpDatas dubboUpdata) {
// return new GracefullyShoutDown( servletConnectShoutDownHock, providerService, dubboUpdata); // return new GracefulShutDown( servletConnectShoutDownHock, providerService, dubboUpdata);
// } // }
@Bean @Bean
@ConditionalOnExpression("!T(org.springframework.util.StringUtils).isEmpty('${dubbo.registry.address:}')") @ConditionalOnExpression("!T(org.springframework.util.StringUtils).isEmpty('${dubbo.registry.address:}')")
public GracefullyShoutDown createGraceObject( UpDatas dubboUpdata) { public GracefulShutDown createGraceObject(UpDatas dubboUpdata) {
return new GracefullyShoutDown(dubboUpdata); return new GracefulShutDown(dubboUpdata);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment