OCT
REM: 1.增加错误码 2.修改鹏信设备执行任务失败错误码 3.修改鹏信设备启动、停止处置任务 4.修改定时更新设备处置状态
This commit is contained in:
parent
1d157e2d54
commit
37bd4aacb6
|
@ -179,18 +179,18 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
|
|
||||||
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
log.error("----Error PengXin start clean {} server return error", disposeObject);
|
log.error("----Error PengXin start clean {} server return error", disposeObject);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
log.error("----Error PengXin start clean {} server return nothing", disposeObject);
|
log.error("----Error PengXin start clean {} server return nothing", disposeObject);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
} else {
|
} else {
|
||||||
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
||||||
|
|
||||||
if (errCode != ErrorCode.ERR_OK.getCode()) {
|
if (errCode != ErrorCode.ERR_OK.getCode()) {
|
||||||
log.error("----Error PengXin start clean {} server return error: {}", disposeObject, errCode);
|
log.error("----Error PengXin start clean {} server return error: {}", disposeObject, errCode);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("----Finish PengXin Start Cleanup Task: {}", disposeObject);
|
log.debug("----Finish PengXin Start Cleanup Task: {}", disposeObject);
|
||||||
|
@ -252,13 +252,13 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
log.error("----Error PengXin stop clean {} server return nothing", disposeObject);
|
log.error("----Error PengXin stop clean {} server return nothing", disposeObject);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
} else {
|
} else {
|
||||||
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
||||||
|
|
||||||
if (errCode != ErrorCode.ERR_OK.getCode()) {
|
if (errCode != ErrorCode.ERR_OK.getCode()) {
|
||||||
log.error("----Error PengXin stop clean {} server return error: {}", disposeObject, errCode);
|
log.error("----Error PengXin stop clean {} server return error: {}", disposeObject, errCode);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_HAOHAN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("----Finish PengXin Stop Cleanup Task: {}", taskId);
|
log.debug("----Finish PengXin Stop Cleanup Task: {}", taskId);
|
||||||
|
|
|
@ -235,7 +235,11 @@ public enum ErrorCode {
|
||||||
/**
|
/**
|
||||||
* The Err huawei error.
|
* The Err huawei error.
|
||||||
*/
|
*/
|
||||||
ERR_HUAWEI_ERROR(34, "华为设备返回错误"),
|
ERR_HUAWEI_ERROR(116, "华为设备返回错误"),
|
||||||
|
/**
|
||||||
|
* The Err pengxin error.
|
||||||
|
*/
|
||||||
|
ERR_PENGXIN_ERROR(117, "鹏信设备返回错误"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -137,10 +137,9 @@ public interface DeviceTaskManager {
|
||||||
DeviceTask getTaskById(Long id);
|
DeviceTask getTaskById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets peng xin task by id.
|
* Gets peng xin task.
|
||||||
*
|
*
|
||||||
* @param startId the start id
|
* @return the peng xin task
|
||||||
* @return the peng xin task by id
|
|
||||||
*/
|
*/
|
||||||
List<DeviceTask> getPengXinTaskById(Long startId);
|
List<DeviceTask> getPengXinTask();
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,12 +297,12 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets PengXin device task info by startId.
|
* Gets PengXin device task info.
|
||||||
*
|
*
|
||||||
* @return the minId task info.
|
* @return the minId task info.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceTask> getPengXinTaskById(Long startId){
|
public List<DeviceTask> getPengXinTask(){
|
||||||
return deviceTaskMapper.getPengXinTask(startId);
|
return deviceTaskMapper.getPengXinTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,8 +158,7 @@ public interface DeviceTaskMapper {
|
||||||
/**
|
/**
|
||||||
* Gets PengXin device task info.
|
* Gets PengXin device task info.
|
||||||
*
|
*
|
||||||
* @param startId the start id
|
|
||||||
* @return PengXin device task info
|
* @return PengXin device task info
|
||||||
*/
|
*/
|
||||||
List<DeviceTask> getPengXinTask(Long startId);
|
List<DeviceTask> getPengXinTask();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,12 @@ import com.dispose.pojo.po.AbilityInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.service.DeviceTaskManagerService;
|
import com.dispose.service.DeviceTaskManagerService;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
import com.pengxin.dispose.common.PengXinTaskStatus;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -443,8 +440,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
|
|
||||||
// 设置任务状态为启动中
|
// 设置任务状态为启动中
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||||
// 设置设备任务状态为启动中
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), (long) PengXinTaskStatus.TASK_STARTING.getValue());
|
|
||||||
// 设置启动任务攻击类型状态
|
// 设置启动任务攻击类型状态
|
||||||
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
||||||
deviceTask.getTaskAttackType());
|
deviceTask.getTaskAttackType());
|
||||||
|
@ -471,9 +466,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||||
// 设置该任务为新任务,待下次重试启动
|
// 设置该任务为新任务,待下次重试启动
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW);
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW);
|
||||||
// 设置设备任务状态为启动处置任务失败
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
|
||||||
(long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue());
|
|
||||||
// 记录任务出错重试次数
|
// 记录任务出错重试次数
|
||||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||||
log.error("PENGXIN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
|
log.error("PENGXIN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||||
|
@ -482,9 +475,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
// 任务出错,不在重试,当做失败任务处理
|
// 任务出错,不在重试,当做失败任务处理
|
||||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||||
disposeTask.getFlowDirection(), 0L);
|
disposeTask.getFlowDirection(), 0L);
|
||||||
// 设置设备任务状态为启动处置任务失败
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
|
||||||
(long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue());
|
|
||||||
log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,10 +490,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
private void pengXinDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
|
private void pengXinDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
|
||||||
MulReturnType<ErrorCode, Long> ret;
|
MulReturnType<ErrorCode, Long> ret;
|
||||||
|
|
||||||
// 设置设备任务状态为解封中
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
|
||||||
(long) PengXinTaskStatus.TASK_UNBLOCKING.getValue());
|
|
||||||
|
|
||||||
// 停止处置任务
|
// 停止处置任务
|
||||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
|
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
|
||||||
deviceTask.getExternId());
|
deviceTask.getExternId());
|
||||||
|
@ -514,17 +501,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
||||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L);
|
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L);
|
||||||
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||||
// 设置设备任务状态为解封失败
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
|
||||||
(long) PengXinTaskStatus.TASK_UNBLOCKED_FAILED.getValue());
|
|
||||||
// 记录任务出错重试次数
|
// 记录任务出错重试次数
|
||||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||||
log.error("PENGXIN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
|
log.error("PENGXIN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||||
ret.getSecondParam(), deviceTask);
|
ret.getSecondParam(), deviceTask);
|
||||||
} else {
|
} else {
|
||||||
// 设置设备任务状态为解封失败
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
|
||||||
(long) PengXinTaskStatus.TASK_UNBLOCKED_FAILED.getValue());
|
|
||||||
log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
|
log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,15 +777,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
* Device task status schedule.
|
* Device task status schedule.
|
||||||
*/
|
*/
|
||||||
public void deviceTaskStatusSchedule() {
|
public void deviceTaskStatusSchedule() {
|
||||||
List<DeviceTask> taskList = new ArrayList<>();
|
|
||||||
|
|
||||||
//处置任务设备类型为鹏信设备,任务状态不再变更
|
//处置任务设备类型为鹏信设备,任务状态不再变更
|
||||||
for (Long i = 1L; deviceTaskManager.getPengXinTaskById(i).size() != 0; i = taskList.get(taskList.size() - 1).getId() + 1) {
|
for (DeviceTask v : deviceTaskManager.getPengXinTask()) {
|
||||||
log.debug("startId:{}", i);
|
|
||||||
taskList.addAll(deviceTaskManager.getPengXinTaskById(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DeviceTask v : taskList) {
|
|
||||||
// 获取设备
|
// 获取设备
|
||||||
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(v.getDeviceId());
|
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(v.getDeviceId());
|
||||||
|
|
||||||
|
@ -827,6 +801,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
MulReturnType<ErrorCode, Long> ret = ai.getDb().taskStatus(v.getExternId());
|
MulReturnType<ErrorCode, Long> ret = ai.getDb().taskStatus(v.getExternId());
|
||||||
|
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
log.debug("id:{}, before devStatus:{}, after devStatus:{}", v.getId(),
|
||||||
|
v.getDevStatus(), ret.getSecondParam());
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getId(),
|
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getId(),
|
||||||
ret.getSecondParam());
|
ret.getSecondParam());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,15 +29,15 @@
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="taskLists" item="task" separator=",">
|
<foreach collection="taskLists" item="task" separator=",">
|
||||||
(#{task.taskId}, #{task.deviceId}, #{task.taskAttackType},
|
(#{task.taskId}, #{task.deviceId}, #{task.taskAttackType},
|
||||||
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, 0)
|
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, -1)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="addNewTaskInfo" useGeneratedKeys="true" keyProperty="id"
|
<insert id="addNewTaskInfo" useGeneratedKeys="true" keyProperty="id"
|
||||||
parameterType="com.dispose.pojo.entity.DeviceTask">
|
parameterType="com.dispose.pojo.entity.DeviceTask">
|
||||||
INSERT IGNORE INTO device_task(taskId, deviceId, taskAttackType, status)
|
INSERT IGNORE INTO device_task(taskId, deviceId, taskAttackType, status, devStatus)
|
||||||
VALUES (#{taskId}, #{deviceId}, #{taskAttackType},
|
VALUES (#{taskId}, #{deviceId}, #{taskAttackType},
|
||||||
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()})
|
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, -1)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="getTaskInfoById" resultMap="device_task">
|
<select id="getTaskInfoById" resultMap="device_task">
|
||||||
|
@ -136,9 +136,6 @@
|
||||||
WHERE
|
WHERE
|
||||||
dd.deviceType = 2
|
dd.deviceType = 2
|
||||||
AND
|
AND
|
||||||
dt.devStatus != 8 AND dt.devStatus != 7
|
dt.devStatus != 8 AND dt.devStatus != 7 AND dt.devStatus != -1
|
||||||
AND
|
|
||||||
dt.id >= #{startId}
|
|
||||||
LIMIT 100
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue