REM:
1. 增加浩瀚设备异常处理
This commit is contained in:
HuangXin 2020-09-25 14:20:47 +08:00
parent ec838d467e
commit ef440833a8
2 changed files with 76 additions and 48 deletions

View File

@ -65,6 +65,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long duration) {
try {
log.info("++++Begging Haohan Start Cleanup Task: {}", ip);
if (capType != DisposeCapacityType.CLEANUP) {
@ -77,7 +78,8 @@ public class HaoHanAbilityImpl implements DisposeAbility {
duration = -1L;
}
HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip, Math.max(duration.intValue(), 0),
HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip,
Math.max(duration.intValue(), 0),
DISPOSE_PLATFORM_NAME);
if (resp == null) {
@ -92,6 +94,10 @@ public class HaoHanAbilityImpl implements DisposeAbility {
log.debug("----Finish Haohan Start Cleanup Task: {}", ip);
return new MulReturnType<>(ErrorCode.ERR_OK, (long) resp.getCleanTaskId());
} catch (Exception ex) {
log.error("----Exception Haohan Start Cleanup Task: {}, {}, {}", ip, nfDirection, duration);
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
}
}
/**
@ -109,6 +115,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long taskId) {
try {
log.debug("++++Begging Haohan Stop Cleanup Task: {}", taskId);
if (capType != DisposeCapacityType.CLEANUP) {
@ -130,6 +137,10 @@ public class HaoHanAbilityImpl implements DisposeAbility {
log.debug("----Finish Haohan Stop Cleanup Task: {}", taskId);
return new MulReturnType<>(ErrorCode.ERR_OK, null);
} catch (Exception ex) {
log.error("----Exception Haohan Stop Cleanup Task: {}, {}, {}", ip, nfDirection, taskId);
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
}
}
/**
@ -139,8 +150,14 @@ public class HaoHanAbilityImpl implements DisposeAbility {
*/
@Override
public boolean getDeviceLinkStatus() {
try {
// 获取任务信息接口调用成功认为设备心跳正常
return (restfulInterface.getCleanTaskStatus(this.urlRootPath, -1) != null);
} catch (Exception ex) {
log.error(ex.getMessage());
}
return false;
}
/**

View File

@ -2,6 +2,7 @@ package com.dispose.manager.impl;
import com.dispose.common.ErrorCode;
import com.dispose.common.HttpType;
import com.dispose.common.IpAddrType;
import com.dispose.common.ObjectStatus;
import com.dispose.manager.DisposeDeviceManager;
import com.dispose.mapper.DisposeCapacityMapper;
@ -77,7 +78,12 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
// 添加设备能力信息
if (err == ErrorCode.ERR_OK) {
dev.getDevCapacity().forEach(v -> v.setDeviceId(dev.getId()));
dev.getDevCapacity().forEach(v -> {
v.setDeviceId(dev.getId());
if (v.getIpType() == null) {
v.setIpType(IpAddrType.IPV4_IPV6);
}
});
disposeCapacityMapper.addNewDisposeCapacity(dev.getDevCapacity());
}
@ -170,7 +176,12 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
Long devId = tDev.getId();
if (tDev.getDevCapacity().size() != 0) {
tDev.getDevCapacity().forEach(v -> v.setDeviceId(devId));
tDev.getDevCapacity().forEach(v -> {
v.setDeviceId(dev.getId());
if (v.getIpType() == null) {
v.setIpType(IpAddrType.IPV4_IPV6);
}
});
disposeCapacityMapper.addNewDisposeCapacity(tDev.getDevCapacity());
}