diff --git a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java index 29577d18..a86c66d5 100644 --- a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java @@ -179,18 +179,18 @@ public class PengXinAbilityImpl implements DisposeAbility { if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) { 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) { 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 { int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus(); if (errCode != ErrorCode.ERR_OK.getCode()) { 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); @@ -252,13 +252,13 @@ public class PengXinAbilityImpl implements DisposeAbility { if (rspInfo.getMsgContent().getItems().size() == 0) { 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 { int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus(); if (errCode != ErrorCode.ERR_OK.getCode()) { 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); diff --git a/src/main/java/com/dispose/common/ErrorCode.java b/src/main/java/com/dispose/common/ErrorCode.java index 4928dda4..4880b744 100644 --- a/src/main/java/com/dispose/common/ErrorCode.java +++ b/src/main/java/com/dispose/common/ErrorCode.java @@ -235,7 +235,11 @@ public enum ErrorCode { /** * The Err huawei error. */ - ERR_HUAWEI_ERROR(34, "华为设备返回错误"), + ERR_HUAWEI_ERROR(116, "华为设备返回错误"), + /** + * The Err pengxin error. + */ + ERR_PENGXIN_ERROR(117, "鹏信设备返回错误"), ; /** diff --git a/src/main/java/com/dispose/manager/DeviceTaskManager.java b/src/main/java/com/dispose/manager/DeviceTaskManager.java index 9f313ad2..1e9f555b 100644 --- a/src/main/java/com/dispose/manager/DeviceTaskManager.java +++ b/src/main/java/com/dispose/manager/DeviceTaskManager.java @@ -137,10 +137,9 @@ public interface DeviceTaskManager { DeviceTask getTaskById(Long id); /** - * Gets peng xin task by id. + * Gets peng xin task. * - * @param startId the start id - * @return the peng xin task by id + * @return the peng xin task */ - List getPengXinTaskById(Long startId); + List getPengXinTask(); } diff --git a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java index 1615e20f..608040c6 100644 --- a/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/DeviceTaskManagerImpl.java @@ -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. */ @Override - public List getPengXinTaskById(Long startId){ - return deviceTaskMapper.getPengXinTask(startId); + public List getPengXinTask(){ + return deviceTaskMapper.getPengXinTask(); } } diff --git a/src/main/java/com/dispose/mapper/DeviceTaskMapper.java b/src/main/java/com/dispose/mapper/DeviceTaskMapper.java index 7e1cec48..35602485 100644 --- a/src/main/java/com/dispose/mapper/DeviceTaskMapper.java +++ b/src/main/java/com/dispose/mapper/DeviceTaskMapper.java @@ -158,8 +158,7 @@ public interface DeviceTaskMapper { /** * Gets PengXin device task info. * - * @param startId the start id * @return PengXin device task info */ - List getPengXinTask(Long startId); + List getPengXinTask(); } diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index b929ec4a..67b12001 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -14,15 +14,12 @@ import com.dispose.pojo.po.AbilityInfo; import com.dispose.pojo.po.MulReturnType; import com.dispose.service.DeviceTaskManagerService; import com.dispose.service.DisposeAbilityRouterService; -import com.pengxin.dispose.common.PengXinTaskStatus; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.ConcurrentHashMap; /** @@ -443,8 +440,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { // 设置任务状态为启动中 deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING); - // 设置设备任务状态为启动中 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), (long) PengXinTaskStatus.TASK_STARTING.getValue()); // 设置启动任务攻击类型状态 deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI, deviceTask.getTaskAttackType()); @@ -471,9 +466,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { // 设置该任务为新任务,待下次重试启动 deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW); - // 设置设备任务状态为启动处置任务失败 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), - (long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue()); + // 记录任务出错重试次数 deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); log.error("PENGXIN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(), @@ -482,9 +475,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { // 任务出错,不在重试,当做失败任务处理 deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); - // 设置设备任务状态为启动处置任务失败 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), - (long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue()); + 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) { MulReturnType ret; - // 设置设备任务状态为解封中 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), - (long) PengXinTaskStatus.TASK_UNBLOCKING.getValue()); - // 停止处置任务 ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, deviceTask.getExternId()); @@ -514,17 +501,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); } 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); log.error("PENGXIN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(), ret.getSecondParam(), deviceTask); } else { - // 设置设备任务状态为解封失败 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), - (long) PengXinTaskStatus.TASK_UNBLOCKED_FAILED.getValue()); log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask); } } @@ -796,15 +777,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { * Device task status schedule. */ public void deviceTaskStatusSchedule() { - List taskList = new ArrayList<>(); - //处置任务设备类型为鹏信设备,任务状态不再变更 - for (Long i = 1L; deviceTaskManager.getPengXinTaskById(i).size() != 0; i = taskList.get(taskList.size() - 1).getId() + 1) { - log.debug("startId:{}", i); - taskList.addAll(deviceTaskManager.getPengXinTaskById(i)); - } - - for (DeviceTask v : taskList) { + for (DeviceTask v : deviceTaskManager.getPengXinTask()) { // 获取设备 AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(v.getDeviceId()); @@ -827,6 +801,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { MulReturnType ret = ai.getDb().taskStatus(v.getExternId()); if (ret.getFirstParam() == ErrorCode.ERR_OK) { + log.debug("id:{}, before devStatus:{}, after devStatus:{}", v.getId(), + v.getDevStatus(), ret.getSecondParam()); deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getId(), ret.getSecondParam()); } diff --git a/src/main/resources/mappers/DeviceTask.xml b/src/main/resources/mappers/DeviceTask.xml index 04c4c88b..b161b379 100644 --- a/src/main/resources/mappers/DeviceTask.xml +++ b/src/main/resources/mappers/DeviceTask.xml @@ -29,15 +29,15 @@ VALUES (#{task.taskId}, #{task.deviceId}, #{task.taskAttackType}, - ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, 0) + ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, -1) - INSERT IGNORE INTO device_task(taskId, deviceId, taskAttackType, status) + INSERT IGNORE INTO device_task(taskId, deviceId, taskAttackType, status, devStatus) VALUES (#{taskId}, #{deviceId}, #{taskAttackType}, - ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}) + ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}, -1) \ No newline at end of file