Commit 161fa2bd by 房斌

breakbug 加监听日志

parent 5293c91d
......@@ -199,8 +199,10 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not
while (iterator.hasNext()) {
Registry r = iterator.next();
zookperRegster = (ZookeeperRegistry) r;
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"));
if (urls != null && urls.size() > 0) {
for(URL value: urls){
try {
......@@ -211,9 +213,9 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not
}
}
}
break;
}
break;
}
}
......
package com.secoo.mall.dubbo.service.impl;
import com.alibaba.fastjson.JSON;
import com.secoo.mall.common.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.common.util.date.DateUtil;
import com.secoo.mall.common.util.log.LoggerUtil;
......@@ -39,7 +40,7 @@ public class DubboCustomerDownHock extends AbstractStop {
public ExecutorDetail stop() {
ExecutorDetail detail = new ExecutorDetail();
detail.setBeginTime(DateUtil.getDateTime());
detail.setServiceName("dubboDownHock1001");
detail.setServiceName("dubboDownHock1005");
List<String> str = new ArrayList<String>();
detail.setDetail(str);
detail.setCode(0);
......@@ -56,8 +57,10 @@ public class DubboCustomerDownHock extends AbstractStop {
while (iterator.hasNext()) {
Registry r = iterator.next();
zookperRegster = (ZookeeperRegistry) r;
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"));
if (urls != null && urls.size() > 0) {
checks=new ArrayList<URL>();
for (URL value : urls) {
......@@ -76,9 +79,10 @@ public class DubboCustomerDownHock extends AbstractStop {
str.add("warn:matrix-monitor no dubbo registered for delete ip " + ip + " name :" +name+ StringUtil.line());
detail.setCode(-1);
}
break;
}
break;
}
}
//step3 check检查
......@@ -107,6 +111,7 @@ public class DubboCustomerDownHock extends AbstractStop {
}
}
}else{
detail.setCode(-1);
str.add("warn:matrix-monitor no urls check ip:" + ip + " name :"+name + StringUtil.line());
logger.info("warn:matrix-monitor no urls check ip:" + ip + " name :"+name + StringUtil.line());
}
......
......@@ -76,44 +76,44 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
//test-------------------------------------> begin
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);
// 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);
////
// try {
// Map<String, StopService> map = this.context.getBeansOfType(StopService.class);
// if (map != null && map.size() > 0) {
// Set<StopService> ts = new TreeSet<StopService>();
// for (StopService service : map.values()) {
// 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.GracefullyShoutDown.error", e);
//// }
//// try {
//// dubboUpdata.upData(result);
//// } catch (Exception e) {
//// LoggerUtil.error("matrix.GracefullyShoutDown update .error data:" + JSON.toJSONString(result), e);
//// }
// }
//
try {
Map<String, StopService> map = this.context.getBeansOfType(StopService.class);
if (map != null && map.size() > 0) {
Set<StopService> ts = new TreeSet<StopService>();
for (StopService service : map.values()) {
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.GracefullyShoutDown.error", e);
}
try {
dubboUpdata.upData(result);
} catch (Exception e) {
LoggerUtil.error("matrix.GracefullyShoutDown update .error data:" + JSON.toJSONString(result), e);
}
//test------------------------------------->
......
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