diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index 775bd9bf..c5fa9287 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -119,90 +119,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED); } - /** - * Hao han device task run. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void haoHanDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 重试错误次数过多 - if (deviceTask.getErrRetry() >= DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - return; - } - - // 设置任务状态为启动中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING); - // 设置启动任务攻击类型状态 - deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI, - deviceTask.getTaskAttackType()); - - ret = ai.getDb() - .runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(), - disposeTask.getDisposeCapacity(), null, - null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60)); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - // 设置攻击类型任务启动结果 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), - disposeTask.getFlowDirection(), deviceTask.getTaskAttackType()); - // 更改处置任务状态为处置中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED); - - // 记录浩瀚设备返回的任务ID - deviceTaskManager.setTaskExternId(deviceTask.getId(), ret.getSecondParam()); - - log.info("HAOHAN_PLATFORM setup task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - - // 重置错误尝试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 设置该任务为新任务,待下次重试启动 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW); - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - // 任务出错,不在重试,当做失败任务处理 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), - disposeTask.getFlowDirection(), 0L); - log.error("HAOHAN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask); - } - } - - /** - * Hao han device task stop. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void haoHanDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 停止处置任务 - ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, - deviceTask.getExternId()); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - log.info("HAOHAN_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - // 设置任务状态为结束 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED); - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("HAOHAN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - log.error("HAOHAN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask); - } - } /** * Dp tech device task run. @@ -424,195 +340,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { } } - /** - * Peng xin device task run. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void pengXinDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 重试错误次数过多 - if (deviceTask.getErrRetry() > DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - return; - } - - // 设置任务状态为启动中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING); - // 设置启动任务攻击类型状态 - deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI, - deviceTask.getTaskAttackType()); - - ret = ai.getDb() - .runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(), - disposeTask.getDisposeCapacity(), null, - null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60)); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - // 设置攻击类型任务启动结果 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), - disposeTask.getFlowDirection(), deviceTask.getTaskAttackType()); - // 更改处置任务状态为处置中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED); - - // 记录鹏信设备返回的任务ID - deviceTaskManager.setTaskExternId(deviceTask.getId(), ret.getSecondParam()); - - log.info("PENGXIN_PLATFORM setup task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - - // 重置错误尝试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 设置该任务为新任务,待下次重试启动 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW); - - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("PENGXIN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - // 任务出错,不在重试,当做失败任务处理 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); - - // 设置该任务为启动失败 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), - DisposeTaskStatus.TASK_START_FAILED); - - //任务出错,设备任务状态为启动处置任务失败 - deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), - (long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue()); - - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - - log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask); - } - } - - /** - * Peng xin device task stop. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void pengXinDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 重试错误次数过多 - if (deviceTask.getErrRetry() > DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - return; - } - - // 停止处置任务 - ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, - deviceTask.getExternId()); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - log.info("PENGXIN_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - // 设置任务状态为结束 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED); - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("PENGXIN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - // 设置该任务为停止失败 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STOP_FAILED); - - log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask); - } - } - - /** - * Hua wei device task run. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void huaWeiDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 重试错误次数过多 - if (deviceTask.getErrRetry() >= DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - return; - } - - // 设置任务状态为启动中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING); - // 设置启动任务攻击类型状态 - deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI, - deviceTask.getTaskAttackType()); - - ret = ai.getDb() - .runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(), - disposeTask.getDisposeCapacity(), null, - null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60)); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - // 设置攻击类型任务启动结果 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), - disposeTask.getFlowDirection(), deviceTask.getTaskAttackType()); - // 更改处置任务状态为处置中 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED); - - log.info("HUAWEI_PLATFORM setup task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - - // 重置错误尝试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 设置该任务为新任务,待下次重试启动 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW); - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("HUAWEI_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - // 任务出错,不在重试,当做失败任务处理 - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), - disposeTask.getFlowDirection(), 0L); - log.error("HUAWEI_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask); - } - } - - /** - * Hua wei device task stop. - * - * @param ai the ai - * @param deviceTask the device task - * @param disposeTask the dispose task - */ - private void huaWeiDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) { - MulReturnType ret; - - // 停止处置任务 - ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, - deviceTask.getExternId()); - - if (ret.getFirstParam() == ErrorCode.ERR_OK) { - log.info("HUAWEI_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam()); - // 设置任务状态为结束 - deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED); - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); - deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L); - } else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { - // 记录任务出错重试次数 - deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); - log.error("HUAWEI_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(), - ret.getSecondParam(), deviceTask); - } else { - log.error("HUAWEI_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask); - } - } - /** * Restful device task run. *