|
|
@@ -1,8 +1,11 @@
|
|
|
package com.fdkankan.modeling.constants;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.dingtalk.DingTalkSendUtils;
|
|
|
import com.fdkankan.modeling.entity.MqEcs;
|
|
|
import com.fdkankan.modeling.service.IMqEcsService;
|
|
|
+import com.taobao.api.ApiException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
@@ -17,6 +20,10 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.security.InvalidKeyException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -43,6 +50,9 @@ public class SysConstants implements ApplicationContextAware {
|
|
|
public static final String SCENE_BUILDING = SYSTEM_PREFIX+":scene:building:num:";
|
|
|
public static final String SCENE_MESSAGE_BUILDING = SYSTEM_PREFIX+":scene:building:message:";
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DingTalkSendUtils dingTalkSendUtils;
|
|
|
+
|
|
|
public static ExecutorService executorService = Executors.newFixedThreadPool(1);
|
|
|
|
|
|
@Value("${hostName.filePath:/opt/hosts/hosts.txt}")
|
|
|
@@ -100,10 +110,23 @@ public class SysConstants implements ApplicationContextAware {
|
|
|
SysConstants.isResidenceService = false;
|
|
|
}
|
|
|
if(mqEcs == null){
|
|
|
+
|
|
|
+ String checkFilePath = "/mnt/dont_delete/nas_check.txt";
|
|
|
+
|
|
|
List<MqEcs> list = mqEcsService.getNotUse();
|
|
|
mqEcs = list.get(0);
|
|
|
mqEcs.setEcsName(SysConstants.hostName);
|
|
|
mqEcs.setUpdateTime(null);
|
|
|
+ if(!FileUtil.exist(checkFilePath)){
|
|
|
+ //发送钉钉通知,没有挂上nas,需要通知运维处理
|
|
|
+ try {
|
|
|
+ dingTalkSendUtils.sendActioncardMsgToDingRobot("弹性伸缩启动失败,实例:" + SysConstants.hostName + "失败原因:nas挂载失败@马瑞", "弹性伸缩启动失败");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发送钉钉消息失败,弹性伸缩启动失败");
|
|
|
+ }
|
|
|
+ //修改mq推送记录为异常状态,调度服务会快速启动一台新的
|
|
|
+ mqEcs.setStatus(2);
|
|
|
+ }
|
|
|
mqEcsService.updateById(mqEcs);
|
|
|
}
|
|
|
return mqEcs.getQueueName();
|