Commit 85baf3f0 by 房斌

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

parent 496a4e03
......@@ -3,7 +3,8 @@ package com.secoo.mall.gracefulshutdown.component;
public class ConfigConstant {
// 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 SOCKET_TIMEOUT = 5000;//等待数据超时时间
......
......@@ -42,7 +42,6 @@ public class GracefulShutDown implements CommandLineRunner, ApplicationListener<
//容器初始化后执行
@Override
public void run(String... args) throws Exception {
logger.info("dddddddddddddduuuuuuuuuuuuuuuuubbbbbbbbbbbboooooooooooolllllllllllme!!!!");
if (DubboShutdownHook.getDubboShutdownHook() != null) {
//hock卸载
DubboShutdownHook.getDubboShutdownHook().unregister();
......@@ -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
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("222222222222222 dubbo stop");
ExecutorDetails result = new ExecutorDetails();
result.setCode(0);
List<ExecutorDetail> details = new ArrayList<ExecutorDetail>();
......
......@@ -27,7 +27,7 @@ public class ShutDownDataReportAsyncHttp implements UpDatas<ExecutorDetails> {
nvps.add(new BasicNameValuePair("gracefulresult", result));
HttpClientUtils.setHttpParam(ConfigConstant.CONNECT_TIMEOUT,ConfigConstant.SOCKET_TIMEOUT,ConfigConstant.REQUEST_TIMEOUT);
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
logger.info("test in http start");
// logger.info("test in http start");
String back= HttpClientUtils.asynchronousPost(httpPost);
return true;
}catch (Exception e){
......
......@@ -34,7 +34,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
logger.info("11111111111111111111 tomcat set Application");
}
public TomcatShutDownHook getTomcatShutDownHook() {
return tomcatShutDownHook;
......@@ -51,7 +50,6 @@ public class TomcatGracefulShutDown implements TomcatConnectorCustomizer , Appli
@Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("11111111111111111111 tomcat stop");
tomcatShutDownHook.stop();
}
}
......@@ -74,17 +74,13 @@ public class DubboCustomerShutDownHook extends AbstractShutDown implements Obser
while (iterator.hasNext()) {
Registry r = iterator.next();
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) {
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) {
checks=new ArrayList<URL>();
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);
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());
......
......@@ -157,10 +157,10 @@ public class RegistryServerSync extends Observable implements InitializingBean,
while (iterator.hasNext()) {
Registry r = iterator.next();
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) {
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) {
subscribedUrl = new ArrayList<URL>();
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