REM:
1.增加鹏信设备任务状态码
2.启动、停止处置任务时设置设备任务状态码
This commit is contained in:
chenlinghy 2020-11-25 09:25:35 +08:00
parent 119008860f
commit d42467968a
2 changed files with 112 additions and 1 deletions

View File

@ -14,6 +14,7 @@ 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;
@ -442,6 +443,8 @@ 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());
@ -468,6 +471,9 @@ 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(),
@ -476,6 +482,9 @@ 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);
}
}
@ -490,6 +499,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
private void pengXinDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
MulReturnType<ErrorCode, Long> ret;
// 设置设备任务状态为解封中
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
(long) PengXinTaskStatus.TASK_UNBLOCKING.getValue());
// 停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
deviceTask.getExternId());
@ -501,11 +514,17 @@ 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);
}
}
@ -808,7 +827,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
MulReturnType<ErrorCode, Long> ret = ai.getDb().taskStatus(v.getExternId());
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getExternId(),
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getId(),
ret.getSecondParam());
}
}

View File

@ -0,0 +1,92 @@
package com.pengxin.dispose.common;
import com.dispose.common.BaseEnum;
/**
* The enum Dispose task status.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public enum PengXinTaskStatus implements BaseEnum {
/**
* The Task starting.
*/
TASK_STARTING(0, "启动中"),
/**
* The Task started.
*/
TASK_STARTED(1, "封堵中"),
/**
* The user aborted Task finished .
*/
TASK_FINISHED_USER(2, "用户中止"),
/**
* The Task finished automatically when the scheduled time is reached.
*/
TASK_FINISHED_TIME(3, "已结束"),
/**
* The Task started failed.
*/
TASK_STARTED_FAILED(4, "设备启动处置任务失败"),
/**
* The Task reviewing.
*/
TASK_REVIEWING(5, "待审核"),
/**
* The Task reviewed failed.
*/
TASK_REVIEWED_FAILED(6, "审核失败"),
/**
* The Task unblocked failed.
*/
TASK_UNBLOCKED_FAILED(7, "解封失败"),
/**
* The Task unblocked.
*/
TASK_UNBLOCKED(8, "解封成功"),
/**
* The Task unblocking.
*/
TASK_UNBLOCKING(9, "解封中"),
;
/**
* The Code.
*/
private final Integer code;
/**
* The Readme.
*/
private final String readme;
/**
* Instantiates a new Dispose task status.
*
* @param code the code
* @param readme the readme
*/
PengXinTaskStatus(int code, String readme) {
this.code = code;
this.readme = readme;
}
/**
* Gets value.
*
* @return the value
*/
@Override
public Integer getValue() {
return this.code;
}
/**
* Gets description.
*
* @return the description
*/
@Override
public String getDescription() {
return this.readme;
}
}