Commit 85baf3f0 by 房斌

1找到了报zk关闭问题 2 去掉多余日志 3url改为生产得url

parent 496a4e03
...@@ -3,7 +3,8 @@ package com.secoo.mall.gracefulshutdown.component; ...@@ -3,7 +3,8 @@ package com.secoo.mall.gracefulshutdown.component;
public class ConfigConstant { public class ConfigConstant {
// public static String EXWARN="http://172.17.76.196:6080/gracefulshutdown/gracefulSave"; // public static String EXWARN="http://172.17.76.196:6080/gracefulshutdown/gracefulSave";
public static String EXWARN="http://test-exwarn.secoo.com/gracefulshutdown/gracefulSave"; // public static String EXWARN="http://test-exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static String EXWARN="http://exwarn.secoo.com/gracefulshutdown/gracefulSave";
public static final int CONNECT_TIMEOUT = 1000;//连接超时时间 public static final int CONNECT_TIMEOUT = 1000;//连接超时时间
public static final int SOCKET_TIMEOUT = 5000;//等待数据超时时间 public static final int SOCKET_TIMEOUT = 5000;//等待数据超时时间
......
...@@ -42,7 +42,6 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener< ...@@ -42,7 +42,6 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
//容器初始化后执行 //容器初始化后执行
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
logger.info("dddddddddddddduuuuuuuuuuuuuuuuubbbbbbbbbbbboooooooooooolllllllllllme!!!!");
if (DubboShutdownHook.getDubboShutdownHook() != null) { if (DubboShutdownHook.getDubboShutdownHook() != null) {
//hock卸载 //hock卸载
DubboShutdownHook.getDubboShutdownHook().unregister(); DubboShutdownHook.getDubboShutdownHook().unregister();
...@@ -55,56 +54,9 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener< ...@@ -55,56 +54,9 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
} }
public void test() {
ExecutorDetails result = new ExecutorDetails();
result.setCode(0);
List<ExecutorDetail> details = new ArrayList<ExecutorDetail>();
result.setT(details);
String ip = NetUtils.getIpByHost(NetUtils.getLocalAddress().getHostName());
String name = ApplicationModel.getApplication();
result.setIp(ip);
result.setName(name);
logger.info("gracefulshutdown execute:name:" + name + " ip:" + ip + " time:" + DateUtil.getDateTime());
try {
Map<String, StopService> map = context.getBeansOfType(StopService.class);
if (map != null && map.size() > 0) {
Set<StopService> ts = new TreeSet<StopService>();
for (StopService service : map.values()) {
if (!(service instanceof TomcatShutDownHook)) {
ts.add(service);
}
}
//按定义顺序执行
Iterator<StopService> it = ts.iterator();
while (it.hasNext()) {
StopService service = (StopService) it.next();
ExecutorDetail one = (ExecutorDetail) service.stop();
if (one != null) {
details.add(one);
if (one.getCode() != 0) {
result.setCode(-1);
}
}
}
}
} catch (Exception e) {
LoggerUtil.error("matrix.gracefulshutdown.error", e);
}
try {
dubboUpdata.upData(result);
} catch (Exception e) {
LoggerUtil.error("matrix.gracefulshutdown update .error data:" + JSON.toJSONString(result), e);
}
logger.info("gracefulshutdown execute end :name:" + name + " ip:" + ip + " time:" + DateUtil.getDateTime());
}
@Override @Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("222222222222222 dubbo stop");
ExecutorDetails result = new ExecutorDetails(); ExecutorDetails result = new ExecutorDetails();
result.setCode(0); result.setCode(0);
List<ExecutorDetail> details = new ArrayList<ExecutorDetail>(); List<ExecutorDetail> details = new ArrayList<ExecutorDetail>();
......
...@@ -27,7 +27,7 @@ public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> { ...@@ -27,7 +27,7 @@ public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> {
nvps.add(new BasicNameValuePair("gracefulresult", result)); nvps.add(new BasicNameValuePair("gracefulresult", result));
HttpClientUtils.setHttpParam(ConfigConstant.CONNECT_TIMEOUT,ConfigConstant.SOCKET_TIMEOUT,ConfigConstant.REQUEST_TIMEOUT); HttpClientUtils.setHttpParam(ConfigConstant.CONNECT_TIMEOUT,ConfigConstant.SOCKET_TIMEOUT,ConfigConstant.REQUEST_TIMEOUT);
httpPost.setEntity(new UrlEncodedFormEntity(nvps)); httpPost.setEntity(new UrlEncodedFormEntity(nvps));
logger.info("test in http start"); // logger.info("test in http start");
String back= HttpClientUtils.asynchronousPost(httpPost); String back= HttpClientUtils.asynchronousPost(httpPost);
return true; return true;
}catch (Exception e){ }catch (Exception e){
......
...@@ -34,7 +34,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli ...@@ -34,7 +34,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext; this.context = applicationContext;
logger.info("11111111111111111111 tomcat set Application");
} }
public TomcatShutDownHook getTomcatShutDownHook() { public TomcatShutDownHook getTomcatShutDownHook() {
return tomcatShutDownHook; return tomcatShutDownHook;
...@@ -51,7 +50,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli ...@@ -51,7 +50,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override @Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("11111111111111111111 tomcat stop");
tomcatShutDownHook.stop(); tomcatShutDownHook.stop();
} }
} }
...@@ -74,17 +74,13 @@ public class DubboCustomerShutDownHook extends AbstractShutDown implements Obser ...@@ -74,17 +74,13 @@ public class DubboCustomerShutDownHook extends AbstractShutDown implements Obser
while (iterator.hasNext()) { while (iterator.hasNext()) {
Registry r = iterator.next(); Registry r = iterator.next();
zookperRegster = (ZookeeperRegistry) r; zookperRegster = (ZookeeperRegistry) r;
logger.info(" DubboCustomerShutDownHook ip:{},name :{}, zookperRegstered ,:{}",ip,name,zookperRegster.getRegistered().toString()+StringUtil.line()); // logger.info(" DubboCustomerShutDownHook ip:{},name :{}, zookperRegstered ,:{}",ip,name,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();
logger.info(" DubboCustomerShutDownHook ip:{},name :{},zookperRegstered urls :{}",ip,name,((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null")+StringUtil.line()); // logger.info(" DubboCustomerShutDownHook ip:{},name :{},zookperRegstered urls :{}",ip,name,((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) {
if(value!=null&&StringUtil.isNotEmpty(value.getParameter(Constants.CATEGORY_KEY))&&value.getParameter(Constants.CATEGORY_KEY).equals(Constants.PROVIDERS_CONSUMERS)){
logger.info("matrix gracefulshutdown delete before service:{},category:{}",value.getServiceKey(),value.getParameter(Constants.CATEGORY_KEY)); //消费者不用处理,走默认优雅停机就可以
continue;
}
checks.add(value); checks.add(value);
try { try {
logger.info("provider url executer ip:{},name :{} unregister before:{} time:{}" , ip,name,value.getServiceInterface() , new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()) +StringUtil.line()); logger.info("provider url executer ip:{},name :{} unregister before:{} time:{}" , ip,name,value.getServiceInterface() , new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()) +StringUtil.line());
......
...@@ -157,10 +157,10 @@ public class RegistryServerSync extends Observable implements InitializingBean, ...@@ -157,10 +157,10 @@ public class RegistryServerSync extends Observable implements InitializingBean,
while (iterator.hasNext()) { while (iterator.hasNext()) {
Registry r = iterator.next(); Registry r = iterator.next();
zookperRegster = (ZookeeperRegistry) r; zookperRegster = (ZookeeperRegistry) r;
logger.info("RegistryServerSync r-------------->"+zookperRegster.getRegistered().toString()); // logger.info("RegistryServerSync r-------------->"+zookperRegster.getRegistered().toString());
if (zookperRegster.getRegistered() != null && zookperRegster.getRegistered().size() > 0) { if (zookperRegster.getRegistered() != null && zookperRegster.getRegistered().size() > 0) {
urls = zookperRegster.getRegistered(); urls = zookperRegster.getRegistered();
logger.info("RegistryServerSync urls-------------->"+((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null")); // logger.info("RegistryServerSync urls-------------->"+((urls!=null&&urls.size()>0)?JSON.toJSONString(urls):"url si null"));
if (urls != null && urls.size() > 0) { if (urls != null && urls.size() > 0) {
subscribedUrl = new ArrayList<URL>(); subscribedUrl = new ArrayList<URL>();
for(URL value: urls){ for(URL value: urls){
......
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