Commit 161fa2bd by 房斌

breakbug 加监听日志

parent 5293c91d
...@@ -199,8 +199,10 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not ...@@ -199,8 +199,10 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not
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());
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"));
if (urls != null && urls.size() > 0) { if (urls != null && urls.size() > 0) {
for(URL value: urls){ for(URL value: urls){
try { try {
...@@ -211,9 +213,9 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not ...@@ -211,9 +213,9 @@ public class RegistryServerSync implements InitializingBean, DisposableBean, Not
} }
} }
} }
break;
} }
break;
} }
} }
......
package com.secoo.mall.dubbo.service.impl; 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.core.bean.gracefulshowtdownBean.ExecutorDetail;
import com.secoo.mall.common.util.date.DateUtil; import com.secoo.mall.common.util.date.DateUtil;
import com.secoo.mall.common.util.log.LoggerUtil; import com.secoo.mall.common.util.log.LoggerUtil;
...@@ -39,7 +40,7 @@ public class DubboCustomerDownHock extends AbstractStop { ...@@ -39,7 +40,7 @@ public class DubboCustomerDownHock extends AbstractStop {
public ExecutorDetail stop() { public ExecutorDetail stop() {
ExecutorDetail detail = new ExecutorDetail(); ExecutorDetail detail = new ExecutorDetail();
detail.setBeginTime(DateUtil.getDateTime()); detail.setBeginTime(DateUtil.getDateTime());
detail.setServiceName("dubboDownHock1001"); detail.setServiceName("dubboDownHock1005");
List<String> str = new ArrayList<String>(); List<String> str = new ArrayList<String>();
detail.setDetail(str); detail.setDetail(str);
detail.setCode(0); detail.setCode(0);
...@@ -56,8 +57,10 @@ public class DubboCustomerDownHock extends AbstractStop { ...@@ -56,8 +57,10 @@ public class DubboCustomerDownHock extends AbstractStop {
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());
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"));
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) {
...@@ -76,9 +79,10 @@ public class DubboCustomerDownHock extends AbstractStop { ...@@ -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()); str.add("warn:matrix-monitor no dubbo registered for delete ip " + ip + " name :" +name+ StringUtil.line());
detail.setCode(-1); detail.setCode(-1);
} }
break;
} }
break;
} }
} }
//step3 check检查 //step3 check检查
...@@ -107,6 +111,7 @@ public class DubboCustomerDownHock extends AbstractStop { ...@@ -107,6 +111,7 @@ public class DubboCustomerDownHock extends AbstractStop {
} }
} }
}else{ }else{
detail.setCode(-1);
str.add("warn:matrix-monitor no urls check ip:" + ip + " name :"+name + StringUtil.line()); 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()); logger.info("warn:matrix-monitor no urls check ip:" + ip + " name :"+name + StringUtil.line());
} }
......
...@@ -76,44 +76,44 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen ...@@ -76,44 +76,44 @@ public class GracefullyShoutDown implements CommandLineRunner, ApplicationListen
//test-------------------------------------> begin //test-------------------------------------> begin
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>();
result.setT(details); // result.setT(details);
String ip = NetUtils.getIpByHost(NetUtils.getLocalAddress().getHostName()); // String ip = NetUtils.getIpByHost(NetUtils.getLocalAddress().getHostName());
String name = ApplicationModel.getApplication(); // String name = ApplicationModel.getApplication();
result.setIp(ip); // result.setIp(ip);
result.setName(name); // 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-------------------------------------> //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