[opt] system log and almost to release

This commit is contained in:
tjq 2020-06-07 18:39:13 +08:00
parent 010eb92f57
commit c7a105db29
7 changed files with 17 additions and 16 deletions

View File

@ -15,7 +15,6 @@ import com.github.kfcfans.oms.server.common.constans.InstanceType;
import com.github.kfcfans.oms.server.persistence.core.model.InstanceInfoDO; import com.github.kfcfans.oms.server.persistence.core.model.InstanceInfoDO;
import com.github.kfcfans.oms.server.persistence.core.repository.InstanceInfoRepository; import com.github.kfcfans.oms.server.persistence.core.repository.InstanceInfoRepository;
import com.github.kfcfans.oms.server.service.id.IdGenerateService; import com.github.kfcfans.oms.server.service.id.IdGenerateService;
import com.github.kfcfans.oms.server.service.workflow.WorkflowInstanceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -42,8 +41,6 @@ public class InstanceService {
@Resource @Resource
private IdGenerateService idGenerateService; private IdGenerateService idGenerateService;
@Resource @Resource
private WorkflowInstanceService workflowInstanceService;
@Resource
private InstanceInfoRepository instanceInfoRepository; private InstanceInfoRepository instanceInfoRepository;
/** /**
@ -114,12 +111,12 @@ public class InstanceService {
ServerStopInstanceReq req = new ServerStopInstanceReq(instanceId); ServerStopInstanceReq req = new ServerStopInstanceReq(instanceId);
taskTrackerActor.tell(req, null); taskTrackerActor.tell(req, null);
log.info("[InstanceService-{}] update instance log and send request succeed.", instanceId); log.info("[Instance-{}] update instanceInfo and send request succeed.", instanceId);
}catch (IllegalArgumentException ie) { }catch (IllegalArgumentException ie) {
throw ie; throw ie;
}catch (Exception e) { }catch (Exception e) {
log.error("[InstanceService-{}] stopInstance failed.", instanceId, e); log.error("[Instance-{}] stopInstance failed.", instanceId, e);
throw e; throw e;
} }
} }
@ -132,7 +129,7 @@ public class InstanceService {
public InstanceInfoDTO getInstanceInfo(Long instanceId) { public InstanceInfoDTO getInstanceInfo(Long instanceId) {
InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId); InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId);
if (instanceInfoDO == null) { if (instanceInfoDO == null) {
log.warn("[InstanceService] can't find execute log for instanceId: {}.", instanceId); log.warn("[Instance-{}] can't find InstanceInfo by instanceId.", instanceId);
throw new IllegalArgumentException("invalid instanceId: " + instanceId); throw new IllegalArgumentException("invalid instanceId: " + instanceId);
} }
InstanceInfoDTO instanceInfoDTO = new InstanceInfoDTO(); InstanceInfoDTO instanceInfoDTO = new InstanceInfoDTO();
@ -148,7 +145,7 @@ public class InstanceService {
public InstanceStatus getInstanceStatus(Long instanceId) { public InstanceStatus getInstanceStatus(Long instanceId) {
InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId); InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId);
if (instanceInfoDO == null) { if (instanceInfoDO == null) {
log.warn("[InstanceService] can't find execute log for instanceId: {}.", instanceId); log.warn("[Instance-{}] can't find InstanceInfo by instanceId.", instanceId);
throw new IllegalArgumentException("invalid instanceId: " + instanceId); throw new IllegalArgumentException("invalid instanceId: " + instanceId);
} }
return InstanceStatus.of(instanceInfoDO.getStatus()); return InstanceStatus.of(instanceInfoDO.getStatus());
@ -163,7 +160,7 @@ public class InstanceService {
InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId); InstanceInfoDO instanceInfoDO = instanceInfoRepository.findByInstanceId(instanceId);
if (instanceInfoDO == null) { if (instanceInfoDO == null) {
log.warn("[InstanceService] can't find execute log for instanceId: {}.", instanceId); log.warn("[Instance-{}] can't find InstanceInfo by instanceId", instanceId);
throw new IllegalArgumentException("invalid instanceId: " + instanceId); throw new IllegalArgumentException("invalid instanceId: " + instanceId);
} }
@ -190,11 +187,11 @@ public class InstanceService {
instanceDetail.setRunningTimes(instanceInfoDO.getRunningTimes()); instanceDetail.setRunningTimes(instanceInfoDO.getRunningTimes());
return instanceDetail; return instanceDetail;
}else { }else {
log.warn("[InstanceService] ask InstanceStatus from TaskTracker failed, the message is {}.", askResponse.getMessage()); log.warn("[Instance-{}] ask InstanceStatus from TaskTracker failed, the message is {}.", instanceId, askResponse.getMessage());
} }
}catch (Exception e) { }catch (Exception e) {
log.error("[InstanceService] ask InstanceStatus from TaskTracker failed.", e); log.error("[Instance-{}] ask InstanceStatus from TaskTracker failed, exception is {}", instanceId, e.toString());
} }
// 失败则返回基础版信息 // 失败则返回基础版信息

View File

@ -3,6 +3,8 @@ package com.github.kfcfans.oms.server.web;
import com.github.kfcfans.oms.common.OmsException; import com.github.kfcfans.oms.common.OmsException;
import com.github.kfcfans.oms.common.response.ResultDTO; import com.github.kfcfans.oms.common.response.ResultDTO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.messaging.handler.annotation.support.MethodArgumentTypeMismatchException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -24,7 +26,9 @@ public class ControllerExceptionHandler {
// 不是所有异常都需要打印完整堆栈后续可以定义内部的Exception便于判断 // 不是所有异常都需要打印完整堆栈后续可以定义内部的Exception便于判断
if (e instanceof IllegalArgumentException || e instanceof OmsException) { if (e instanceof IllegalArgumentException || e instanceof OmsException) {
log.warn("[ControllerException] http request failed, message is {}.", e.getMessage()); log.warn("[ControllerException] http request failed, message is {}.", e.getMessage());
}else { } else if (e instanceof HttpMessageNotReadableException || e instanceof MethodArgumentTypeMismatchException) {
log.warn("[ControllerException] invalid http request params, exception is {}.", e.getMessage());
} else {
log.error("[ControllerException] http request failed.", e); log.error("[ControllerException] http request failed.", e);
} }
return ResultDTO.failed(e.getMessage()); return ResultDTO.failed(e.getMessage());

View File

@ -85,7 +85,7 @@ public class SystemInfoController {
} }
return ResultDTO.failed(askResponse.getMessage()); return ResultDTO.failed(askResponse.getMessage());
}catch (Exception e) { }catch (Exception e) {
log.error("[SystemInfoController] listWorker for appId:{} failed.", appId, e); log.error("[SystemInfoController] listWorker for appId:{} failed, exception is {}", appId, e.toString());
return ResultDTO.failed("no worker or server available"); return ResultDTO.failed("no worker or server available");
} }
} }

View File

@ -35,7 +35,7 @@
<MaxHistory>7</MaxHistory> <MaxHistory>7</MaxHistory>
</rollingPolicy> </rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - %msg%n</pattern>
<charset>UTF-8</charset> <charset>UTF-8</charset>
</encoder> </encoder>
<append>true</append> <append>true</append>

View File

@ -67,7 +67,7 @@ public class OmsContainerFactory {
deployContainer(deployRequest); deployContainer(deployRequest);
} }
}catch (Exception e) { }catch (Exception e) {
log.error("[OmsContainer-{}] deployed container failed.", containerId, e); log.error("[OmsContainer-{}] deployed container failed, exception is {}", containerId, e.toString());
} }
return CARGO.get(containerId); return CARGO.get(containerId);

View File

@ -61,7 +61,7 @@ public abstract class MapProcessor implements BasicProcessor {
AskResponse respObj = (AskResponse) requestCS.toCompletableFuture().get(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS); AskResponse respObj = (AskResponse) requestCS.toCompletableFuture().get(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
requestSucceed = respObj.isSuccess(); requestSucceed = respObj.isSuccess();
}catch (Exception e) { }catch (Exception e) {
log.warn("[MapProcessor] map failed.", e); log.warn("[MapProcessor] map failed, exception is {}.", e.toString());
} }
if (requestSucceed) { if (requestSucceed) {

View File

@ -226,7 +226,7 @@ public class CommonTaskTracker extends TaskTracker {
try { try {
AskResponse askResponse = (AskResponse) askCS.toCompletableFuture().get(RemoteConstant.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS); AskResponse askResponse = (AskResponse) askCS.toCompletableFuture().get(RemoteConstant.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
serverAccepted = askResponse.isSuccess(); serverAccepted = askResponse.isSuccess();
}catch (Exception e) { }catch (Exception ignore) {
log.warn("[TaskTracker-{}] report finished status failed, result={}.", instanceId, result); log.warn("[TaskTracker-{}] report finished status failed, result={}.", instanceId, result);
} }