Authored by qinchao

测试环境停止检测

1 package com.ui.cloud.task; 1 package com.ui.cloud.task;
2 2
3 import com.ui.model.BaseResponse; 3 import com.ui.model.BaseResponse;
  4 +import org.apache.commons.lang.StringUtils;
4 import org.slf4j.Logger; 5 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory; 6 import org.slf4j.LoggerFactory;
6 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.beans.factory.annotation.Value;
7 import org.springframework.scheduling.annotation.EnableScheduling; 9 import org.springframework.scheduling.annotation.EnableScheduling;
8 import org.springframework.scheduling.annotation.Scheduled; 10 import org.springframework.scheduling.annotation.Scheduled;
9 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
@@ -17,6 +19,10 @@ import org.springframework.stereotype.Component; @@ -17,6 +19,10 @@ import org.springframework.stereotype.Component;
17 public class FetchAutoScalingTask { 19 public class FetchAutoScalingTask {
18 private Logger logger = LoggerFactory.getLogger(getClass()); 20 private Logger logger = LoggerFactory.getLogger(getClass());
19 21
  22 + //当前环境
  23 + @Value("${system.envi}")
  24 + private String env;
  25 +
20 @Autowired 26 @Autowired
21 private AutoScalingLoader autoScalingLoader; 27 private AutoScalingLoader autoScalingLoader;
22 28
@@ -40,6 +46,9 @@ public class FetchAutoScalingTask { @@ -40,6 +46,9 @@ public class FetchAutoScalingTask {
40 */ 46 */
41 @Scheduled(cron = "15/30 * * * * ?") 47 @Scheduled(cron = "15/30 * * * * ?")
42 public void qcloudFetchAutoScaling() { 48 public void qcloudFetchAutoScaling() {
  49 + if(StringUtils.equals("test",env)){
  50 + return ;
  51 + }
43 BaseResponse groups=autoScalingLoader.remoteLoadAutoScalingGroup(2); 52 BaseResponse groups=autoScalingLoader.remoteLoadAutoScalingGroup(2);
44 if(groups==null){ 53 if(groups==null){
45 logger.error("FetchAutoScalingTask qcloudFetchAutoScaling result is null"); 54 logger.error("FetchAutoScalingTask qcloudFetchAutoScaling result is null");
  1 +system.envi=product
1 monitor.service.url=http://monitor-service-master:8080/monitor 2 monitor.service.url=http://monitor-service-master:8080/monitor
2 job.run.log.limit=10 3 job.run.log.limit=10
3 web.context=monitor-ui 4 web.context=monitor-ui
  1 +system.envi=test
1 monitor.service.url=http://127.0.0.1:8880/monitor 2 monitor.service.url=http://127.0.0.1:8880/monitor
2 zkAddress=192.168.102.45:2181 3 zkAddress=192.168.102.45:2181
3 job.run.log.limit=10 4 job.run.log.limit=10