| | |
| | | package com.yeshi.fanli.controller;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
|
| | | import com.yeshi.fanli.service.inter.common.DataMonitorService;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | /**
|
| | | * 监控
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("monitor")
|
| | | public class MonitorController {
|
| | |
|
| | | @Resource
|
| | | private DataMonitorService dataMonitorService;
|
| | |
|
| | | /**
|
| | | * 10分钟外没爬单就判断为异常
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getTaoBaoOrderParseState")
|
| | | public void getTaoBaoOrderParseState(HttpServletResponse response, PrintWriter out) {
|
| | | Date date = dataMonitorService.getLatestParseTaoBaoOrderSuccessTime();
|
| | | // 10分钟做判断
|
| | | if (date != null && (Math.abs(date.getTime() - System.currentTimeMillis())) < 1000 * 60 * 10) {
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | return;
|
| | | } else {
|
| | | try {
|
| | | response.sendError(666, "订单爬取疑似有问题");
|
| | | return;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.yeshi.fanli.util.RedisKeyEnum; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import com.yeshi.fanli.service.inter.common.DataMonitorService; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.NetWorkUtil; |
| | | |
| | | /** |
| | | * 监控 |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | @Controller |
| | | @RequestMapping("monitor") |
| | | public class MonitorController { |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private DataMonitorService dataMonitorService; |
| | | |
| | | /** |
| | | * 10分钟外没爬单就判断为异常 |
| | | * |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getTaoBaoOrderParseState") |
| | | public void getTaoBaoOrderParseState(HttpServletResponse response, PrintWriter out) { |
| | | Date date = dataMonitorService.getLatestParseTaoBaoOrderSuccessTime(); |
| | | // 10分钟做判断 |
| | | if (date != null && (Math.abs(date.getTime() - System.currentTimeMillis())) < 1000 * 60 * 10) { |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | return; |
| | | } else { |
| | | try { |
| | | response.sendError(666, "订单爬取疑似有问题"); |
| | | return; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * zookeeper服务 |
| | | */ |
| | | @RequestMapping("zookeeper") |
| | | public void zookeeper(HttpServletResponse response, PrintWriter out) { |
| | | if (NetWorkUtil.isHostConnectable("134.175.68.214", 2181, 2000)) { |
| | | out.print("200"); |
| | | } else { |
| | | try { |
| | | response.sendError(666, "异常"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 商品服务 |
| | | */ |
| | | @RequestMapping("dubboGoodsService") |
| | | public void dubboGoodsService(HttpServletResponse response, PrintWriter out) { |
| | | if (NetWorkUtil.isHostConnectable("134.175.68.214", 20882, 2000)) { |
| | | out.print("200"); |
| | | } else { |
| | | try { |
| | | response.sendError(666, "异常"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 订单爬取是否正常 |
| | | * @param platform |
| | | * @return |
| | | */ |
| | | private boolean isParseOrderNormal(String platform) { |
| | | String st = redisManager.getCommonString(RedisKeyEnum.monitor.getKey() + platform); |
| | | if (StringUtil.isNullOrEmpty(st)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单解析是否正常 |
| | | * @param sourceType |
| | | * @param response |
| | | * @param out |
| | | */ |
| | | @RequestMapping("orderParse") |
| | | public void orderParse(int sourceType, HttpServletResponse response, PrintWriter out) { |
| | | if (isParseOrderNormal(sourceType+"")) { |
| | | out.print("200"); |
| | | } else { |
| | | try { |
| | | response.sendError(666, "异常"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |