Merge branch 'v2.0.3_dev' of http://git.komect.net/DDOSAQ/phoenix_ddos_handle into v2.0.3_dev

This commit is contained in:
HuangXin 2020-11-26 18:34:41 +08:00
commit 92ebf33ea0
8 changed files with 49 additions and 49 deletions

View File

@ -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);

View File

@ -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, "鹏信设备返回错误"),
; ;
/** /**

View File

@ -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();
} }

View File

@ -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();
} }
} }

View File

@ -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();
} }

View File

@ -21,8 +21,6 @@ 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;
/** /**
@ -437,14 +435,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
MulReturnType<ErrorCode, String> ret; MulReturnType<ErrorCode, String> ret;
// 重试错误次数过多 // 重试错误次数过多
if (deviceTask.getErrRetry() >= DisposeConfigValue.CALL_ERROR_RETRY_TIMES) { if (deviceTask.getErrRetry() > DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
return; return;
} }
// 设置任务状态为启动中 // 设置任务状态为启动中
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 +467,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 +476,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 任务出错不在重试当做失败任务处理 // 任务出错不在重试当做失败任务处理
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
disposeTask.getFlowDirection(), 0L); disposeTask.getFlowDirection(), 0L);
// 设置设备任务状态为启动处置任务失败
// 设置该任务为启动失败
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW);
//任务出错设备任务状态为启动处置任务失败
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
(long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue()); (long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue());
// 记录任务出错重试次数
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask); log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
} }
} }
@ -499,9 +499,10 @@ 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(), if (deviceTask.getErrRetry() > DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 2) {
(long) PengXinTaskStatus.TASK_UNBLOCKING.getValue()); return;
}
// 停止处置任务 // 停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
@ -513,18 +514,19 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED); deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED);
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 * 2) {
// 设置设备任务状态为解封失败
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
(long) PengXinTaskStatus.TASK_UNBLOCKED_FAILED.getValue());
// 记录任务出错重试次数 // 记录任务出错重试次数
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1); deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
// 设置任务状态为处置中待下次重试停止
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED);
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(), deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
(long) PengXinTaskStatus.TASK_UNBLOCKED_FAILED.getValue()); // 设置该任务为停止失败
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED);
log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask); log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
} }
} }
@ -796,15 +798,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 +822,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());
} }

View File

@ -48,6 +48,10 @@ public enum PengXinTaskStatus implements BaseEnum {
* The Task unblocking. * The Task unblocking.
*/ */
TASK_UNBLOCKING(9, "解封中"), TASK_UNBLOCKING(9, "解封中"),
/**
* The Task unknown.
*/
TASK_UNKNOWN(-1, "未知状态"),
; ;
/** /**

View File

@ -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">
@ -140,9 +140,6 @@
WHERE WHERE
dd.deviceType = 2 dd.deviceType = 2
AND AND
dt.devStatus != 8 AND dt.devStatus != 7 dt.devStatus != 2 AND dt.devStatus != 3 AND dt.devStatus != 6
AND
dt.id >= #{startId}
LIMIT 100
</select> </select>
</mapper> </mapper>