parent
9234d1a1c5
commit
118ebc1528
|
@ -14,7 +14,7 @@ import javax.annotation.Nullable;
|
|||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeAbility {
|
||||
public interface DisposeAbility<T> {
|
||||
|
||||
/**
|
||||
* Init device env.
|
||||
|
@ -35,22 +35,7 @@ public interface DisposeAbility {
|
|||
* @param duration the duration
|
||||
* @return the mul return type
|
||||
*/
|
||||
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long duration);
|
||||
|
||||
/**
|
||||
* Run dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param duration the duration
|
||||
* @return the mul return type
|
||||
*/
|
||||
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
T runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable DDoSAttackType attackType,
|
||||
@Nullable Long duration);
|
||||
|
@ -65,23 +50,7 @@ public interface DisposeAbility {
|
|||
* @param taskId the task id
|
||||
* @return the mul return type
|
||||
*/
|
||||
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long taskId);
|
||||
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param taskId the task id
|
||||
* @return the mul return type
|
||||
*/
|
||||
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||
T stopDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable DDoSAttackType attackType,
|
||||
@Nullable Long taskId);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.dispose.ability.impl;
|
||||
|
||||
import com.dispose.ability.DeviceDisposeAbility;
|
||||
import com.dispose.ability.DisposeAbility;
|
||||
import com.dispose.ability.DisposeTaskCallback;
|
||||
import com.dispose.common.DDoSAttackType;
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.DpTechAttackType;
|
||||
|
@ -22,14 +24,10 @@ import org.apache.wss4j.dom.WSConstants;
|
|||
import org.apache.wss4j.dom.handler.WSHandlerConstants;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.xml.ws.BindingProvider;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Dp tech ability.
|
||||
|
@ -38,7 +36,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DpTechAbilityImpl implements DisposeAbility {
|
||||
public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
||||
/**
|
||||
* The Clean type port.
|
||||
*/
|
||||
|
@ -96,62 +94,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long duration) {
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
try {
|
||||
log.info("++++Begging DPTech Start Cleanup Task: {}", ip);
|
||||
|
||||
// 查找需要处置的流量方向集合
|
||||
List<NetflowDirection> dirList = Arrays.stream(NetflowDirection.values())
|
||||
.filter(d -> nfDirection == null || nfDirection.length == 0 || Arrays.asList(nfDirection).contains(d))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查找需要处理的攻击类型集合
|
||||
List<DpTechAttackType> typeList = Arrays.stream(DDoSAttackType.values())
|
||||
.filter(t -> attackType == null || attackType.length == 0 || Arrays.asList(attackType).contains(t))
|
||||
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
||||
cleanTypePort.startAbnormalTaskForUMC(ip, t.getValue(), d.getValue()))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
log.error("DPTech run dispose: {}, {}, error:{}", ip, t.getValue(),
|
||||
ex.getMessage());
|
||||
} else {
|
||||
log.debug("Cleanup: {} --> {}:{}", d, t.getDescription(), t.getValue());
|
||||
if (v.getResultRetVal() != ErrorCode.ERR_OK.getCode()) {
|
||||
log.error("DPTech run dispose {} error: {}", ip, v.getResultInfo());
|
||||
}
|
||||
}
|
||||
})));
|
||||
log.info("----Finish DPTech Start Cleanup Task: {}", ip);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error("----Error DPTech Start Cleanup Task: {}", ip);
|
||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
||||
}
|
||||
|
||||
return new MulReturnType<>(err, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param duration the duration
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
||||
NetflowDirection nfDirection,
|
||||
DDoSAttackType attackType,
|
||||
Long duration) {
|
||||
|
@ -173,62 +116,9 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
log.error("----Exception Error DPTech Start Cleanup Task: {}", ip);
|
||||
}
|
||||
|
||||
return new MulReturnType<>(err, null);
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
*
|
||||
* @param ipAddr the ip addr
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param taskId the task id
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> stopDispose(String ipAddr, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long taskId) {
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
try {
|
||||
log.info("++++Begging DPTech Stop Cleanup Task: {}", ipAddr);
|
||||
|
||||
// 查找需要处置的流量方向集合
|
||||
List<NetflowDirection> dirList = Arrays.stream(NetflowDirection.values())
|
||||
.filter(d -> nfDirection == null || nfDirection.length == 0 || Arrays.asList(nfDirection).contains(d))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查找需要处理的攻击类型集合
|
||||
List<DpTechAttackType> typeList = Arrays.stream(DDoSAttackType.values())
|
||||
.filter(t -> attackType == null || attackType.length == 0 || Arrays.asList(attackType).contains(t))
|
||||
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
||||
cleanTypePort.stopAbnormalTaskForUMC(ipAddr, t.getValue(), d.getValue()))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
log.error("DPTech stop dispose: {}, {}, error:{}", ipAddr, t.getValue(), ex.getMessage());
|
||||
} else {
|
||||
log.debug("Stop Cleanup: {} --> {}:{}", d, t.getDescription(), t.getValue());
|
||||
if (v.getResultRetVal() != ErrorCode.ERR_OK.getCode()) {
|
||||
log.error("DPTech stop dispose {} error: {}", ipAddr, v.getResultInfo());
|
||||
}
|
||||
}
|
||||
})));
|
||||
log.info("----Finish DPTech Stop Cleanup Task: {}", ipAddr);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error("----Error DPTech Stop Cleanup Task: {}", ipAddr);
|
||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
||||
}
|
||||
|
||||
return new MulReturnType<>(err, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
|
@ -241,7 +131,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip,
|
||||
public ErrorCode stopDispose(String ip,
|
||||
DisposeCapacityType capType,
|
||||
NetflowDirection nfDirection,
|
||||
DDoSAttackType attackType,
|
||||
|
@ -265,7 +155,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
log.error("----Exception Error DPTech Stop Cleanup Task: {}", ip);
|
||||
}
|
||||
|
||||
return new MulReturnType<>(err, null);
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -318,4 +208,52 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
||||
return DpTechAttackType.formDdosAttackTypeMaks(ddosAttackTypeMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Device dispose exec error code.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @param capType the cap type
|
||||
* @param ipAddr the ip addr
|
||||
* @param args the args
|
||||
* @return the error code
|
||||
*/
|
||||
@Override
|
||||
public ErrorCode deviceDisposeExec(DisposeTaskCallback callback, DisposeCapacityType capType, String ipAddr,
|
||||
Object... args) {
|
||||
CompletableFuture.supplyAsync(() -> runDispose(ipAddr, capType, (NetflowDirection) args[0],
|
||||
(DDoSAttackType) args[1], null))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION);
|
||||
} else {
|
||||
callback.upgradeStatusCallback(v);
|
||||
}
|
||||
});
|
||||
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device dispose stop error code.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @param capType the cap type
|
||||
* @param args the args
|
||||
* @return the error code
|
||||
*/
|
||||
@Override
|
||||
public ErrorCode deviceDisposeStop(DisposeTaskCallback callback, DisposeCapacityType capType, Object... args) {
|
||||
CompletableFuture.supplyAsync(() -> stopDispose((String) args[0], capType, (NetflowDirection) args[1],
|
||||
(DDoSAttackType) args[2], null))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION);
|
||||
} else {
|
||||
callback.upgradeStatusCallback(v);
|
||||
}
|
||||
});
|
||||
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ import javax.annotation.Nullable;
|
|||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<MulReturnType<ErrorCode, Long>> {
|
||||
public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode, Long>>,
|
||||
DeviceDisposeAbility<MulReturnType<ErrorCode, Long>> {
|
||||
|
||||
/**
|
||||
* The constant DISPOSE_PLATFORM_NAME.
|
||||
|
@ -51,27 +52,6 @@ public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<M
|
|||
this.urlRootPath = urlPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param duration the duration
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long duration) {
|
||||
return runDispose(ip, capType,
|
||||
NetflowDirection.DIRECTION_BI,
|
||||
DDoSAttackType.ALL_ATTACKS,
|
||||
duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dispose mul return type.
|
||||
*
|
||||
|
@ -111,27 +91,6 @@ public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<M
|
|||
return new MulReturnType<>(ErrorCode.ERR_OK, (long) resp.getCleanTaskId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param taskId the task id
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long taskId) {
|
||||
return stopDispose(ip, capType,
|
||||
NetflowDirection.DIRECTION_BI,
|
||||
DDoSAttackType.ALL_ATTACKS,
|
||||
taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
*
|
||||
|
|
|
@ -17,7 +17,7 @@ import javax.annotation.Nullable;
|
|||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<ErrorCode> {
|
||||
public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
||||
/**
|
||||
* Init device env.
|
||||
*
|
||||
|
@ -41,28 +41,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
|||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long duration) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param duration the duration
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable DDoSAttackType attackType, @Nullable Long duration) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,28 +58,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
|||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection[] nfDirection,
|
||||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long taskId) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop dispose mul return type.
|
||||
*
|
||||
* @param ip the ip
|
||||
* @param capType the cap type
|
||||
* @param nfDirection the nf direction
|
||||
* @param attackType the attack type
|
||||
* @param taskId the task id
|
||||
* @return the mul return type
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||
public ErrorCode stopDispose(String ip, DisposeCapacityType capType,
|
||||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable DDoSAttackType attackType, @Nullable Long taskId) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +122,7 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
|||
capType,
|
||||
null,
|
||||
DDoSAttackType.ALL_ATTACKS,
|
||||
null).getFirstParam();
|
||||
null);
|
||||
|
||||
callback.upgradeStatusCallback(ret);
|
||||
|
||||
|
@ -178,7 +142,7 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
|||
capType,
|
||||
null,
|
||||
DDoSAttackType.ALL_ATTACKS,
|
||||
null).getFirstParam();
|
||||
null);
|
||||
|
||||
callback.upgradeStatusCallback(ret);
|
||||
|
||||
|
|
|
@ -66,4 +66,13 @@ public interface DeviceTaskManager {
|
|||
* @return the task err retry times
|
||||
*/
|
||||
boolean setTaskErrRetryTimes(Long id, Integer rTimes);
|
||||
|
||||
/**
|
||||
* Sets task extern id.
|
||||
*
|
||||
* @param id the id
|
||||
* @param externId the extern id
|
||||
* @return the task extern id
|
||||
*/
|
||||
boolean setTaskExternId(Long id, Long externId);
|
||||
}
|
||||
|
|
|
@ -115,8 +115,27 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|||
return ret == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets task err retry times.
|
||||
*
|
||||
* @param id the id
|
||||
* @param rTimes the r times
|
||||
* @return the task err retry times
|
||||
*/
|
||||
@Override
|
||||
public boolean setTaskErrRetryTimes(Long id, Integer rTimes) {
|
||||
return deviceTaskMapper.changeErrRetry(id, rTimes) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets task extern id.
|
||||
*
|
||||
* @param id the id
|
||||
* @param externId the extern id
|
||||
* @return the task extern id
|
||||
*/
|
||||
@Override
|
||||
public boolean setTaskExternId(Long id, Long externId) {
|
||||
return deviceTaskMapper.changeExternId(id, externId) == 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,4 +121,14 @@ public interface DeviceTaskMapper {
|
|||
*/
|
||||
int changeErrRetry(@Param("id") Long id,
|
||||
@Param("errRetry") Integer errRetry);
|
||||
|
||||
/**
|
||||
* Change extern id int.
|
||||
*
|
||||
* @param id the id
|
||||
* @param externId the extern id
|
||||
* @return the int
|
||||
*/
|
||||
int changeExternId(@Param("id") Long id,
|
||||
@Param("externId") Long externId);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.dispose.manager.DeviceTaskManager;
|
|||
import com.dispose.manager.DisposeTaskManager;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.AbilityInfo;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DeviceTaskManagerService;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -91,8 +92,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
@Async("deviceTaskExecutor")
|
||||
@Scheduled(fixedDelay = 1000)
|
||||
public void deviceTaskRunnerSchedule() {
|
||||
deviceTaskManager.getNewDisposeDeviceTaskInfo()
|
||||
.forEach(v -> {
|
||||
deviceTaskManager.getNewDisposeDeviceTaskInfo().forEach(v -> {
|
||||
DisposeTask task = disposeTaskManager.getDisposeTaskById(v.getTaskId());
|
||||
assert task != null;
|
||||
log.info("Run task {}", task);
|
||||
|
@ -110,7 +110,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
||||
v.getTaskAttackType());
|
||||
// 调用设备处置能力
|
||||
((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec(
|
||||
MulReturnType<ErrorCode, Long> ret = ((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec(
|
||||
errorCode -> {
|
||||
// 启动处置任务成功
|
||||
if (errorCode == ErrorCode.ERR_OK) {
|
||||
|
@ -139,6 +139,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
task.getDisposeCapacity(),
|
||||
task.getDisposeIp(),
|
||||
(long) Helper.getTimestampDiffNow(task.getPlanEndTime()));
|
||||
|
||||
// 启动任务成功,保存浩瀚任务ID到数据库
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
deviceTaskManager.setTaskExternId(v.getId(), ret.getSecondParam());
|
||||
}
|
||||
break;
|
||||
|
||||
case VIRTUAL_DISPOSE:
|
||||
|
@ -174,24 +179,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
log.error("Unknown dispose device type: {}", ai.getDev());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// if (task != null) {
|
||||
//
|
||||
// CompletableFuture.supplyAsync(() ->
|
||||
// disposeAbilityRouterService
|
||||
// .getAbilityDevice(task.getDeviceId())
|
||||
// .getDb()
|
||||
// .runDispose(task.getDisposeIp(),
|
||||
// task.getDisposeCapacity(),
|
||||
// task.getFlowDirection(),
|
||||
// null,
|
||||
// (long)Helper.getTimestampDiffNow(task.getPlanEndTime())))
|
||||
// .whenComplete((k, ex) -> {
|
||||
//
|
||||
// });
|
||||
// }
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,4 +106,10 @@
|
|||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="changeExternId">
|
||||
UPDATE device_task
|
||||
SET externId = #{externId}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -2,7 +2,13 @@ package com.dispose.test.dptech;
|
|||
|
||||
import com.dispose.ability.DisposeAbility;
|
||||
import com.dispose.ability.impl.DpTechAbilityImpl;
|
||||
import com.dispose.common.*;
|
||||
import com.dispose.common.DDoSAttackType;
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.DisposeDeviceType;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.HttpType;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
|
@ -49,11 +55,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t1_runDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
DisposeAbility<ErrorCode> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.15")
|
||||
|
@ -82,10 +84,10 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
// 初始化设备
|
||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
ErrorCode ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,11 +96,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t2_stopDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
DisposeAbility<ErrorCode> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.15")
|
||||
|
@ -128,10 +126,10 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
ErrorCode ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +138,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t3_getAbilityDeviceFirewareTest() {
|
||||
DisposeAbility db;
|
||||
DisposeAbility<ErrorCode> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.15")
|
||||
|
|
|
@ -2,7 +2,11 @@ package com.dispose.test.haohan;
|
|||
|
||||
import com.dispose.ability.DisposeAbility;
|
||||
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
||||
import com.dispose.common.*;
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.DisposeDeviceType;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.HttpType;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
|
@ -49,11 +53,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t1_runDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.88")
|
||||
|
@ -82,8 +82,9 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
|||
// 初始化设备
|
||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5",
|
||||
DisposeCapacityType.CLEANUP,
|
||||
null, null, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
|
@ -94,11 +95,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t2_stopDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.88")
|
||||
|
@ -128,8 +125,9 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
|||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5",
|
||||
DisposeCapacityType.CLEANUP,
|
||||
null, null, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void t3_getAbilityDeviceFirewareTest() {
|
||||
DisposeAbility db;
|
||||
DisposeAbility<? extends MulReturnType<ErrorCode, Long>> db;
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.88")
|
||||
|
|
Loading…
Reference in New Issue